Permalink
Browse files

Clean up backwards compatibility

  • Loading branch information...
PseudoKnight committed Aug 3, 2018
1 parent 7ab8e52 commit 2c74356a856458410ac0b7c33853dba323a2c58e
Showing with 318 additions and 1,353 deletions.
  1. +2 −0 src/main/java/com/laytonsmith/abstraction/MCServer.java
  2. +0 −5 src/main/java/com/laytonsmith/abstraction/MCTeam.java
  3. +11 −23 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitConvertor.java
  4. +4 −14 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCEntityEquipment.java
  5. +1 −5 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCPlayerInventory.java
  6. +0 −5 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCPotionMeta.java
  7. +4 −17 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCScoreboard.java
  8. +6 −6 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCServer.java
  9. +1 −6 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCShapedRecipe.java
  10. +1 −6 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCShapelessRecipe.java
  11. +1 −6 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCSkullMeta.java
  12. +4 −48 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCTeam.java
  13. +58 −133 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCWorld.java
  14. +3 −12 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCArmorStand.java
  15. +1 −5 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCBoat.java
  16. +4 −22 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCCreeper.java
  17. +10 −28 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCEnderCrystal.java
  18. +1 −5 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCEnderDragon.java
  19. +3 −15 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCEnderSignal.java
  20. +11 −93 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCEntity.java
  21. +1 −15 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCFallingBlock.java
  22. +0 −19 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCGuardian.java
  23. +1 −128 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCHorse.java
  24. +4 −15 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCHumanEntity.java
  25. +8 −54 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCLivingEntity.java
  26. +0 −10 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCLlama.java
  27. +32 −109 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCPlayer.java
  28. +2 −11 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCShulker.java
  29. +0 −20 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCSkeleton.java
  30. +2 −11 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCSnowman.java
  31. +0 −19 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCZombie.java
  32. +6 −21 src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitEntityEvents.java
  33. +2 −7 src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitPlayerEvents.java
  34. +0 −2 src/main/java/com/laytonsmith/abstraction/entities/MCFallingBlock.java
  35. +0 −4 src/main/java/com/laytonsmith/abstraction/entities/MCGuardian.java
  36. +0 −15 src/main/java/com/laytonsmith/abstraction/entities/MCHorse.java
  37. +0 −5 src/main/java/com/laytonsmith/abstraction/entities/MCSkeleton.java
  38. +0 −4 src/main/java/com/laytonsmith/abstraction/entities/MCZombie.java
  39. +1 −50 src/main/java/com/laytonsmith/abstraction/enums/MCEffect.java
  40. +0 −11 src/main/java/com/laytonsmith/abstraction/enums/MCNameTagVisibility.java
  41. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/MCSkeletonType.java
  42. +0 −6 src/main/java/com/laytonsmith/abstraction/enums/MCZombieType.java
  43. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCEnderDragonPhase.java
  44. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCItemFlag.java
  45. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCOption.java
  46. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCOptionStatus.java
  47. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCParrotType.java
  48. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCPatternShape.java
  49. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCRabbitType.java
  50. +0 −10 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCSoundCategory.java
  51. +2 −6 src/main/java/com/laytonsmith/commandhelper/CommandHelperServerListener.java
  52. +27 −48 src/main/java/com/laytonsmith/core/ObjectGenerator.java
  53. +11 −19 src/main/java/com/laytonsmith/core/Static.java
  54. +5 −5 src/main/java/com/laytonsmith/core/events/Driver.java
  55. +1 −3 src/main/java/com/laytonsmith/core/functions/BossBar.java
  56. +32 −112 src/main/java/com/laytonsmith/core/functions/EntityManagement.java
  57. +3 −15 src/main/java/com/laytonsmith/core/functions/InventoryManagement.java
  58. +1 −1 src/main/java/com/laytonsmith/core/functions/ItemMeta.java
  59. +4 −4 src/main/java/com/laytonsmith/core/functions/MobManagement.java
  60. +3 −4 src/main/java/com/laytonsmith/core/functions/PlayerManagement.java
  61. +43 −38 src/main/java/com/laytonsmith/core/functions/Scoreboards.java
  62. +0 −6 src/main/java/com/laytonsmith/core/functions/World.java
  63. +1 −12 src/main/resources/functionDocs/entity_spec
@@ -25,6 +25,8 @@
MCPlayer getPlayer(UUID uuid);
MCEntity getEntity(UUID uuid);
MCWorld getWorld(String name);
List<MCWorld> getWorlds();
@@ -1,6 +1,5 @@
package com.laytonsmith.abstraction;
import com.laytonsmith.abstraction.enums.MCNameTagVisibility;
import com.laytonsmith.abstraction.enums.MCOption;
import com.laytonsmith.abstraction.enums.MCOptionStatus;
@@ -18,8 +17,6 @@
String getName();
MCNameTagVisibility getNameTagVisibility();
MCOptionStatus getOption(MCOption option);
Set<String> getEntries();
@@ -42,8 +39,6 @@
void setDisplayName(String displayName);
void setNameTagVisibility(MCNameTagVisibility visibility);
void setOption(MCOption option, MCOptionStatus status);
void setPrefix(String prefix);
@@ -184,16 +184,10 @@ public Class GetServerEventMixin() {
@Override
public MCEnchantment GetEnchantmentByName(String name) {
Enchantment enchant = Enchantment.getByName(name);
if(enchant != null) {
return new BukkitMCEnchantment(enchant);
}
try {
//If they are looking it up by number, we can support that too
int i = Integer.valueOf(name);
return new BukkitMCEnchantment(Enchantment.getById(i));
} catch (NumberFormatException | NullPointerException e) {
if(enchant == null) {
return null;
}
return new BukkitMCEnchantment(enchant);
}
@Override
@@ -460,15 +454,7 @@ public MCItemMeta GetCorrectMeta(MCItemMeta im) {
radius = 1;
}
Location l = (Location) location.getHandle();
Collection<Entity> near;
try {
near = l.getWorld().getNearbyEntities(l, radius, radius, radius);
} catch (NoSuchMethodError ex) {
// Probably before 1.8.3
Entity tempEntity = l.getWorld().spawnEntity(l, EntityType.ARROW);
near = tempEntity.getNearbyEntities(radius, radius, radius);
tempEntity.remove();
}
Collection<Entity> near = l.getWorld().getNearbyEntities(l, radius, radius, radius);
List<MCEntity> entities = new ArrayList<>();
for(Entity e : near) {
entities.add(BukkitGetCorrectEntity(e));
@@ -477,11 +463,10 @@ public MCItemMeta GetCorrectMeta(MCItemMeta im) {
}
public static MCBlockState BukkitGetCorrectBlockState(BlockState bs) {
MCVersion version = Static.getServer().getMinecraftVersion();
if(version.gte(MCVersion.MC1_11) && bs instanceof ShulkerBox) {
if(bs instanceof ShulkerBox) {
return new BukkitMCShulkerBox((ShulkerBox) bs);
}
if(version.gte(MCVersion.MC1_9) && bs instanceof Banner) {
if(bs instanceof Banner) {
return new BukkitMCBanner((Banner) bs);
}
if(bs instanceof CreatureSpawner) {
@@ -514,12 +499,15 @@ public static MCBlockState BukkitGetCorrectBlockState(BlockState bs) {
public static MCItemMeta BukkitGetCorrectMeta(ItemMeta im) {
MCVersion version = Static.getServer().getMinecraftVersion();
if(version.gte(MCVersion.MC1_11_X) && im instanceof SpawnEggMeta) {
return new BukkitMCSpawnEggMeta((SpawnEggMeta) im);
if(version.lt(MCVersion.MC1_13)) {
return new BukkitMCSpawnEggMeta((SpawnEggMeta) im);
}
return new BukkitMCItemMeta(im);
}
if(version.gte(MCVersion.MC1_8_6) && im instanceof BlockStateMeta) {
if(im instanceof BlockStateMeta) {
return new BukkitMCBlockStateMeta((BlockStateMeta) im);
}
if(version.gte(MCVersion.MC1_8) && im instanceof BannerMeta) {
if(im instanceof BannerMeta) {
return new BukkitMCBannerMeta((BannerMeta) im);
}
if(im instanceof BookMeta) {
@@ -4,8 +4,6 @@
import com.laytonsmith.abstraction.MCEntityEquipment;
import com.laytonsmith.abstraction.MCItemStack;
import com.laytonsmith.abstraction.enums.MCEquipmentSlot;
import com.laytonsmith.abstraction.enums.MCVersion;
import com.laytonsmith.core.Static;
import org.bukkit.inventory.EntityEquipment;
import java.util.EnumMap;
@@ -43,9 +41,7 @@ public MCEntity getHolder() {
slots.put(key, getWeapon());
break;
case OFF_HAND:
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_9)) {
slots.put(key, getItemInOffHand());
}
slots.put(key, getItemInOffHand());
break;
case HELMET:
slots.put(key, getHelmet());
@@ -74,9 +70,7 @@ public void setAllEquipment(Map<MCEquipmentSlot, MCItemStack> slots) {
setWeapon(stack);
break;
case OFF_HAND:
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_9)) {
setItemInOffHand(stack);
}
setItemInOffHand(stack);
break;
case HELMET:
setHelmet(stack);
@@ -103,9 +97,7 @@ public void setAllEquipment(Map<MCEquipmentSlot, MCItemStack> slots) {
slots.put(key, getWeaponDropChance());
break;
case OFF_HAND:
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_9)) {
slots.put(key, getOffHandDropChance());
}
slots.put(key, getOffHandDropChance());
break;
case HELMET:
slots.put(key, getHelmetDropChance());
@@ -134,9 +126,7 @@ public void setAllDropChances(Map<MCEquipmentSlot, Float> slots) {
setWeaponDropChance(chance);
break;
case OFF_HAND:
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_9)) {
setOffHandDropChance(chance);
}
setOffHandDropChance(chance);
break;
case HELMET:
setHelmetDropChance(chance);
@@ -45,11 +45,7 @@ public void setBoots(MCItemStack stack) {
@Override
public void setItemInOffHand(MCItemStack stack) {
try {
this.i.setItemInOffHand(((BukkitMCItemStack) stack).__ItemStack());
} catch (NoSuchMethodError ex) {
// probably before 1.9
}
this.i.setItemInOffHand(((BukkitMCItemStack) stack).__ItemStack());
}
@Override
@@ -71,9 +71,4 @@ public boolean removeCustomEffect(int id) {
return pm.removeCustomEffect(PotionEffectType.getById(id));
}
@Override
public boolean setMainEffect(int id) {
return pm.setMainEffect(PotionEffectType.getById(id));
}
}
@@ -1,14 +1,11 @@
package com.laytonsmith.abstraction.bukkit;
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
import com.laytonsmith.abstraction.MCObjective;
import com.laytonsmith.abstraction.MCScore;
import com.laytonsmith.abstraction.MCScoreboard;
import com.laytonsmith.abstraction.MCTeam;
import com.laytonsmith.abstraction.enums.MCDisplaySlot;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCDisplaySlot;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
@@ -77,21 +74,11 @@ public MCObjective getObjective(String name) {
@Override
public MCTeam getPlayerTeam(String entry) {
try {
Team t = s.getEntryTeam(entry);
if(t == null) {
return null;
}
return new BukkitMCTeam(t);
} catch (NoSuchMethodError ex) {
// Probably 1.8.6 or prior
OfflinePlayer player = Bukkit.getOfflinePlayer(entry);
Object t = ReflectionUtils.invokeMethod(s, "getPlayerTeam", player);
if(t == null) {
return null;
}
return new BukkitMCTeam((Team) t);
Team t = s.getEntryTeam(entry);
if(t == null) {
return null;
}
return new BukkitMCTeam(t);
}
@Override
@@ -185,6 +185,11 @@ public MCPlayer getPlayer(UUID uuid) {
return new BukkitMCPlayer(p);
}
@Override
public MCEntity getEntity(UUID uuid) {
return BukkitConvertor.BukkitGetCorrectEntity(s.getEntity(uuid));
}
@Override
public MCWorld getWorld(String name) {
World w = s.getWorld(name);
@@ -562,11 +567,6 @@ public void resetRecipes() {
@Override
public MCBossBar createBossBar(String title, MCBarColor color, MCBarStyle style) {
try {
return new BukkitMCBossBar(s.createBossBar(title, BarColor.valueOf(color.name()), BarStyle.valueOf(style.name())));
} catch (NoSuchMethodError ex) {
// Probably prior to 1.9
return null;
}
return new BukkitMCBossBar(s.createBossBar(title, BarColor.valueOf(color.name()), BarStyle.valueOf(style.name())));
}
}
@@ -19,12 +19,7 @@ public BukkitMCShapedRecipe(ShapedRecipe recipe) {
@Override
public String getKey() {
try {
return r.getKey().getKey();
} catch (NoSuchMethodError ex) {
// Probably prior to 1.12
return null;
}
return r.getKey().getKey();
}
@Override
@@ -19,12 +19,7 @@ public BukkitMCShapelessRecipe(ShapelessRecipe recipe) {
@Override
public String getKey() {
try {
return r.getKey().getKey();
} catch (NoSuchMethodError ex) {
// Probably prior to 1.12
return null;
}
return r.getKey().getKey();
}
@Override
@@ -42,11 +42,6 @@ public boolean setOwner(String owner) {
@Override
public void setOwningPlayer(MCOfflinePlayer player) {
try {
sm.setOwningPlayer((OfflinePlayer) player.getHandle());
} catch (NoSuchMethodError ex) {
// probably prior to 1.12.2
sm.setOwner(player.getName());
}
sm.setOwningPlayer((OfflinePlayer) player.getHandle());
}
}
@@ -1,16 +1,11 @@
package com.laytonsmith.abstraction.bukkit;
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
import com.laytonsmith.abstraction.MCScoreboard;
import com.laytonsmith.abstraction.MCTeam;
import com.laytonsmith.abstraction.enums.MCNameTagVisibility;
import com.laytonsmith.abstraction.enums.MCOption;
import com.laytonsmith.abstraction.enums.MCOptionStatus;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCOption;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCOptionStatus;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import org.bukkit.scoreboard.Team.OptionStatus;
@@ -27,13 +22,7 @@ public BukkitMCTeam(Team team) {
@Override
public void addEntry(String entry) {
try {
t.addEntry(entry);
} catch (NoSuchMethodError ex) {
// Probably 1.8.5 or prior
OfflinePlayer player = Bukkit.getOfflinePlayer(entry);
ReflectionUtils.invokeMethod(t, "addPlayer", player);
}
t.addEntry(entry);
}
@Override
@@ -56,13 +45,6 @@ public String getName() {
return t.getName();
}
@Override
public MCNameTagVisibility getNameTagVisibility() {
// deprecated in 1.9
NameTagVisibility ntv = t.getNameTagVisibility();
return MCNameTagVisibility.valueOf(ntv.name());
}
@Override
public MCOptionStatus getOption(MCOption option) {
OptionStatus os = t.getOption(BukkitMCOption.getConvertor().getConcreteEnum(option));
@@ -72,16 +54,7 @@ public MCOptionStatus getOption(MCOption option) {
@Override
public Set<String> getEntries() {
Set<String> ret = new HashSet<>();
try {
for(String e : t.getEntries()) {
ret.add(e);
}
} catch (NoSuchMethodError ex) {
// Probably 1.8.5 or prior
for(OfflinePlayer o : (Set<OfflinePlayer>) ReflectionUtils.invokeMethod(t, "getPlayers")) {
ret.add(o.getName());
}
}
ret.addAll(t.getEntries());
return ret;
}
@@ -107,24 +80,12 @@ public String getSuffix() {
@Override
public boolean hasEntry(String entry) {
try {
return t.hasEntry(entry);
} catch (NoSuchMethodError ex) {
// Probably 1.8.5 or prior
OfflinePlayer player = Bukkit.getOfflinePlayer(entry);
return (boolean) ReflectionUtils.invokeMethod(t, "hasPlayer", player);
}
return t.hasEntry(entry);
}
@Override
public boolean removeEntry(String entry) {
try {
return t.removeEntry(entry);
} catch (NoSuchMethodError ex) {
// Probably 1.8.5 or prior
OfflinePlayer player = Bukkit.getOfflinePlayer(entry);
return (boolean) ReflectionUtils.invokeMethod(t, "removePlayer", player);
}
return t.removeEntry(entry);
}
@Override
@@ -142,11 +103,6 @@ public void setDisplayName(String displayName) {
t.setDisplayName(displayName);
}
@Override
public void setNameTagVisibility(MCNameTagVisibility visibility) {
t.setNameTagVisibility(NameTagVisibility.valueOf(visibility.name()));
}
@Override
public void setOption(MCOption option, MCOptionStatus status) {
t.setOption(BukkitMCOption.getConvertor().getConcreteEnum(option), BukkitMCOptionStatus.getConvertor().getConcreteEnum(status));
Oops, something went wrong.

0 comments on commit 2c74356

Please sign in to comment.