mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +01:00
Removing NMS dependencies, more future version friendly
This commit is contained in:
parent
aed2ad6687
commit
da807bef5e
@ -20,6 +20,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class CMIItemStack {
|
||||
|
||||
@ -94,7 +95,7 @@ public class CMIItemStack {
|
||||
}
|
||||
|
||||
public short getDurability() {
|
||||
return Jobs.getNms().getDurability(getItemStack());
|
||||
return Util.getDurability(getItemStack());
|
||||
}
|
||||
|
||||
public short getMaxDurability() {
|
||||
|
@ -113,8 +113,6 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
public static final Map<UUID, FastPayment> FASTPAYMENT = new HashMap<>();
|
||||
|
||||
private static NMS nms;
|
||||
|
||||
protected static VersionChecker versionCheckManager;
|
||||
protected static SelectionManager smanager;
|
||||
|
||||
@ -275,10 +273,6 @@ public class Jobs extends JavaPlugin {
|
||||
return gConfigManager;
|
||||
}
|
||||
|
||||
public static NMS getNms() {
|
||||
return nms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link PlayerManager}
|
||||
*/
|
||||
@ -692,22 +686,6 @@ public class Jobs extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
try {
|
||||
Class<?> nmsClass = Class.forName("com.gamingmesh.jobs.nmsUtil." + Version.getCurrent().getShortVersion());
|
||||
if (NMS.class.isAssignableFrom(nmsClass)) {
|
||||
nms = (NMS) nmsClass.getConstructor().newInstance();
|
||||
} else {
|
||||
System.out.println("Something went wrong, please note down version and contact author, version: " + Version.getCurrent().toString());
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Your server version is not compatible with this plugins version! Plugin will be disabled: " + Version.getCurrent().toString());
|
||||
setEnabled(false);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName("net.kyori.adventure.text.Component");
|
||||
org.bukkit.inventory.meta.ItemMeta.class.getDeclaredMethod("displayName");
|
||||
|
@ -1,29 +0,0 @@
|
||||
package com.gamingmesh.jobs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public interface NMS {
|
||||
|
||||
List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event);
|
||||
|
||||
String getRealType(Entity entity);
|
||||
|
||||
ItemStack getItemInMainHand(Player player);
|
||||
|
||||
void setItemInMainHand(Player player, ItemStack item);
|
||||
|
||||
double getMaxHealth(LivingEntity entity);
|
||||
|
||||
short getDurability(ItemStack item);
|
||||
|
||||
void setSkullOwner(SkullMeta meta, OfflinePlayer player);
|
||||
}
|
@ -956,7 +956,7 @@ public class PlayerManager {
|
||||
|
||||
// Check mainhand slot
|
||||
if (Jobs.getGCManager().boostedItemsInMainHand) {
|
||||
jitems.add(getJobsItemByNbt(Jobs.getNms().getItemInMainHand(player)));
|
||||
jitems.add(getJobsItemByNbt(Util.getItemInMainHand(player)));
|
||||
}
|
||||
|
||||
// Check offhand slot
|
||||
|
@ -19,9 +19,10 @@
|
||||
package com.gamingmesh.jobs.actions;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BaseActionInfo;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class EntityActionInfo extends BaseActionInfo {
|
||||
private Entity entity;
|
||||
@ -33,7 +34,7 @@ public class EntityActionInfo extends BaseActionInfo {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Jobs.getNms().getRealType(entity);
|
||||
return Util.getRealType(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,11 +15,13 @@ import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class edititembonus implements Cmd {
|
||||
|
||||
private enum actions {
|
||||
list, add, remove;
|
||||
|
||||
public static actions getByname(String name) {
|
||||
for (actions one : actions.values()) {
|
||||
if (one.name().equalsIgnoreCase(name))
|
||||
@ -68,7 +70,7 @@ public class edititembonus implements Cmd {
|
||||
if (jPlayer == null)
|
||||
return false;
|
||||
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack iih = Util.getItemInMainHand(player);
|
||||
if (iih == null || iih.getType() == Material.AIR)
|
||||
return false;
|
||||
|
||||
@ -77,13 +79,13 @@ public class edititembonus implements Cmd {
|
||||
if (jobitem == null)
|
||||
return false;
|
||||
iih = CMIReflections.setNbt(iih, "JobsItemBoost", jobitem.getNode());
|
||||
Jobs.getNms().setItemInMainHand(player, iih);
|
||||
Util.setItemInMainHand(player, iih);
|
||||
break;
|
||||
case list:
|
||||
break;
|
||||
case remove:
|
||||
iih = Jobs.getReflections().removeNbt(iih, "JobsItemBoost");
|
||||
Jobs.getNms().setItemInMainHand(player, iih);
|
||||
Util.setItemInMainHand(player, iih);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -335,7 +335,7 @@ public class editjobs implements Cmd {
|
||||
String key = args[3];
|
||||
switch (args[3]) {
|
||||
case "hand":
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack item = Util.getItemInMainHand(player);
|
||||
key = item.getType().name() + "-" + item.getData().getData();
|
||||
break;
|
||||
case "offhand":
|
||||
|
@ -318,7 +318,7 @@ public class editquests implements Cmd {
|
||||
String key = args[4];
|
||||
switch (args[4]) {
|
||||
case "hand":
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack item = Util.getItemInMainHand(player);
|
||||
key = item.getType().name() + "-" + item.getData().getData();
|
||||
break;
|
||||
case "offhand":
|
||||
|
@ -16,6 +16,7 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
@ -35,7 +36,7 @@ public class itembonus implements Cmd {
|
||||
if (jPlayer == null)
|
||||
return false;
|
||||
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack iih = Util.getItemInMainHand(player);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class iteminfo implements Cmd {
|
||||
|
||||
@ -24,7 +25,7 @@ public class iteminfo implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand((Player) sender);
|
||||
ItemStack iih = Util.getItemInMainHand((Player) sender);
|
||||
|
||||
if (iih == null || iih.getType() == Material.AIR)
|
||||
return true;
|
||||
|
@ -37,6 +37,7 @@ import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.ShopItem;
|
||||
import com.gamingmesh.jobs.stuff.GiveItem;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ShopManager {
|
||||
@ -192,12 +193,12 @@ public class ShopManager {
|
||||
skullMeta.setLore(lore);
|
||||
|
||||
if (item.isHeadOwner()) {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, jPlayer.getPlayer());
|
||||
Util.setSkullOwner(skullMeta, jPlayer.getPlayer());
|
||||
} else {
|
||||
try {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(UUID.fromString(item.getCustomHead())));
|
||||
Util.setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(UUID.fromString(item.getCustomHead())));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Jobs.getNms().setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(item.getCustomHead()));
|
||||
Util.setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(item.getCustomHead()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsArmorChangeEvent;
|
||||
import com.gamingmesh.jobs.container.JobsArmorChangeEvent.EquipMethod;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
public class JobsListener implements Listener {
|
||||
@ -117,7 +118,7 @@ public class JobsListener implements Listener {
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (Jobs.getNms().getItemInMainHand(player).getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
|
||||
if (Util.getItemInMainHand(player).getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()) || !player.hasPermission("jobs.area.select"))
|
||||
@ -369,7 +370,7 @@ public class JobsListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onLimitedItemInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack iih = Util.getItemInMainHand(player);
|
||||
if (iih.getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip.ownershipFeedback;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.hooks.JobsHook;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -215,7 +216,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ItemStack itemInHand = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack itemInHand = Util.getItemInMainHand(player);
|
||||
if (itemInHand.getType() != Material.BUCKET && itemInHand.getType() != Material.BOWL) {
|
||||
return;
|
||||
}
|
||||
@ -398,7 +399,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
// Protection for block break with silktouch
|
||||
if (Jobs.getGCManager().useSilkTouchProtection) {
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack item = Util.getItemInMainHand(player);
|
||||
|
||||
if (item.getType() != Material.AIR && Jobs.getBpManager().isInBp(block)) {
|
||||
for (Enchantment one : item.getEnchantments().keySet()) {
|
||||
@ -777,7 +778,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
CMIMaterial mat1 = CMIMaterial.get(a),
|
||||
mat2 = CMIMaterial.get(b);
|
||||
return mat1 == mat2 && Jobs.getNms().getDurability(a) == Jobs.getNms().getDurability(b) && Objects.equal(a.getData(), b.getData()) &&
|
||||
return mat1 == mat2 && Util.getDurability(a) == Util.getDurability(b) && Objects.equal(a.getData(), b.getData()) &&
|
||||
Objects.equal(a.getEnchantments(), b.getEnchantments());
|
||||
}
|
||||
|
||||
@ -1149,7 +1150,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
Double damage = damageDealtByPlayers.getIfPresent(lVictimUUID);
|
||||
|
||||
if (damage != null) {
|
||||
double perc = (damage * 100D) / Jobs.getNms().getMaxHealth(lVictim);
|
||||
double perc = (damage * 100D) / Util.getMaxHealth(lVictim);
|
||||
|
||||
damageDealtByPlayers.invalidate(lVictimUUID);
|
||||
|
||||
@ -1331,7 +1332,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
continue;
|
||||
|
||||
Player p = (Player) one;
|
||||
if (!Jobs.getNms().getItemInMainHand(p).getType().toString().equalsIgnoreCase("ARMOR_STAND"))
|
||||
if (!Util.getItemInMainHand(p).getType().toString().equalsIgnoreCase("ARMOR_STAND"))
|
||||
continue;
|
||||
|
||||
double d = p.getLocation().distance(loc);
|
||||
@ -1476,7 +1477,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new ItemActionInfo(Jobs.getNms().getItemInMainHand(player), ActionType.EAT));
|
||||
Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new ItemActionInfo(Util.getItemInMainHand(player), ActionType.EAT));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@ -1557,7 +1558,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
CMIMaterial cmat = CMIMaterial.get(block);
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p);
|
||||
Material hand = Jobs.getNms().getItemInMainHand(p).getType();
|
||||
Material hand = Util.getItemInMainHand(p).getType();
|
||||
|
||||
if (event.useInteractedBlock() != org.bukkit.event.Event.Result.DENY
|
||||
&& event.getAction() == Action.RIGHT_CLICK_BLOCK && jPlayer != null && !p.isSneaking()) {
|
||||
@ -1629,7 +1630,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && hand.getMaxDurability()
|
||||
- Jobs.getNms().getDurability(Jobs.getNms().getItemInMainHand(p)) != hand.getMaxDurability())
|
||||
- Util.getDurability(Util.getItemInMainHand(p)) != hand.getMaxDurability())
|
||||
return;
|
||||
|
||||
// either it's version 1.13+ and we're trying to strip a normal log like oak,
|
||||
@ -1706,13 +1707,13 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (Jobs.getGCManager().payItemDurabilityLoss)
|
||||
return true;
|
||||
|
||||
ItemStack hand = Jobs.getNms().getItemInMainHand(p);
|
||||
ItemStack hand = Util.getItemInMainHand(p);
|
||||
|
||||
java.util.Map<Enchantment, Integer> got = Jobs.getGCManager().whiteListedItems.get(CMIMaterial.get(hand));
|
||||
if (got == null)
|
||||
return false;
|
||||
|
||||
if (Jobs.getNms().getDurability(hand) == 0)
|
||||
if (Util.getDurability(hand) == 0)
|
||||
return true;
|
||||
|
||||
for (Map.Entry<Enchantment, Integer> oneG : got.entrySet()) {
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class PistonProtectionListener implements Listener {
|
||||
|
||||
@ -46,7 +47,7 @@ public class PistonProtectionListener implements Listener {
|
||||
y = dir.getModY(),
|
||||
z = dir.getModZ();
|
||||
|
||||
List<Block> blocks = Jobs.getNms().getPistonRetractBlocks(event);
|
||||
List<Block> blocks = Util.getPistonRetractBlocks(event);
|
||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||
Location oldLoc = blocks.get(i).getLocation();
|
||||
Location newLoc = oldLoc.clone().add(x, y, z);
|
||||
|
@ -1,94 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class v1_10 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
String name = entity.getType().name();
|
||||
switch (entity.getType()) {
|
||||
case GUARDIAN:
|
||||
Guardian g = (Guardian) entity;
|
||||
if (g.isElder())
|
||||
name = "GuardianElder";
|
||||
break;
|
||||
case HORSE:
|
||||
Horse horse = (Horse) entity;
|
||||
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||
name = "HorseZombie";
|
||||
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||
name = "HorseSkeleton";
|
||||
break;
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) entity;
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||
name = "SkeletonWither";
|
||||
if (skeleton.getSkeletonType() == SkeletonType.STRAY)
|
||||
name = "SkeletonStray";
|
||||
break;
|
||||
case ZOMBIE:
|
||||
Zombie zombie = (Zombie) entity;
|
||||
if (zombie.isVillager() && zombie.getVillagerProfession().toString().equals("HUSK"))
|
||||
return "ZombieVillager";
|
||||
if (zombie.getVillagerProfession().toString().equals("HUSK"))
|
||||
return "ZombieHusk";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return item.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class v1_11 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return item.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class v1_12 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return item.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
public class v1_13 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return (short) ((Damageable) item.getItemMeta()).getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwningPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
public class v1_14 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return (short) ((Damageable) item.getItemMeta()).getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwningPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
public class v1_15 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return (short) ((Damageable) item.getItemMeta()).getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwningPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
public class v1_16 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return (short) ((Damageable) item.getItemMeta()).getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwningPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class v1_7 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
blocks.add(event.getBlock());
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
String name = entity.getType().name();
|
||||
switch (entity.getType()) {
|
||||
case HORSE:
|
||||
Horse horse = (Horse) entity;
|
||||
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||
name = "HorseZombie";
|
||||
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||
name = "HorseSkeleton";
|
||||
break;
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) entity;
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||
name = "SkeletonWither";
|
||||
break;
|
||||
case ZOMBIE:
|
||||
Zombie zombie = (Zombie) entity;
|
||||
if (zombie.isVillager())
|
||||
return "ZombieVillager";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return item.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class v1_8 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
String name = entity.getType().name();
|
||||
switch (entity.getType()) {
|
||||
case GUARDIAN:
|
||||
Guardian g = (Guardian) entity;
|
||||
if (g.isElder())
|
||||
name = "GuardianElder";
|
||||
break;
|
||||
case HORSE:
|
||||
Horse horse = (Horse) entity;
|
||||
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||
name = "HorseZombie";
|
||||
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||
name = "HorseSkeleton";
|
||||
break;
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) entity;
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||
name = "SkeletonWither";
|
||||
break;
|
||||
case ZOMBIE:
|
||||
Zombie zombie = (Zombie) entity;
|
||||
if (zombie.isVillager())
|
||||
return "ZombieVillager";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return item.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package com.gamingmesh.jobs.nmsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.gamingmesh.jobs.NMS;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class v1_9 implements NMS {
|
||||
|
||||
@Override
|
||||
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealType(Entity entity) {
|
||||
String name = entity.getType().name();
|
||||
switch (entity.getType()) {
|
||||
case GUARDIAN:
|
||||
Guardian g = (Guardian) entity;
|
||||
if (g.isElder())
|
||||
name = "GuardianElder";
|
||||
break;
|
||||
case HORSE:
|
||||
Horse horse = (Horse) entity;
|
||||
if (horse.getVariant() == Variant.UNDEAD_HORSE)
|
||||
name = "HorseZombie";
|
||||
if (horse.getVariant() == Variant.SKELETON_HORSE)
|
||||
name = "HorseSkeleton";
|
||||
break;
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) entity;
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||
name = "SkeletonWither";
|
||||
break;
|
||||
case ZOMBIE:
|
||||
Zombie zombie = (Zombie) entity;
|
||||
if (zombie.isVillager())
|
||||
return "ZombieVillager";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand(Player player) {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(Player player, ItemStack item) {
|
||||
player.getInventory().setItemInHand(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth(LivingEntity entity) {
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getDurability(ItemStack item) {
|
||||
return item.getDurability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
meta.setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -9,24 +9,33 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.JobsWorld;
|
||||
|
||||
public class Util {
|
||||
@ -37,6 +46,98 @@ public class Util {
|
||||
|
||||
public static final List<UUID> LEAVECONFIRM = new ArrayList<>();
|
||||
|
||||
public static List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_8_R1)) {
|
||||
return new ArrayList<>(event.getBlocks());
|
||||
}
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
blocks.add(event.getBlock());
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public static String getRealType(Entity entity) {
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) {
|
||||
return entity.getType().name();
|
||||
}
|
||||
|
||||
String name = entity.getType().name();
|
||||
switch (entity.getType().toString()) {
|
||||
case "GUARDIAN":
|
||||
org.bukkit.entity.Guardian g = (org.bukkit.entity.Guardian) entity;
|
||||
if (g.isElder())
|
||||
name = "GuardianElder";
|
||||
break;
|
||||
case "HORSE":
|
||||
Horse horse = (Horse) entity;
|
||||
if (horse.getVariant().toString().equals("UNDEAD_HORSE"))
|
||||
name = "HorseZombie";
|
||||
if (horse.getVariant().toString().equals("SKELETON_HORSE"))
|
||||
name = "HorseSkeleton";
|
||||
break;
|
||||
case "SKELETON":
|
||||
Skeleton skeleton = (Skeleton) entity;
|
||||
if (skeleton.getSkeletonType().toString().equals("WITHER"))
|
||||
name = "SkeletonWither";
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_10_R1) && skeleton.getSkeletonType().toString().equals("STRAY"))
|
||||
name = "SkeletonStray";
|
||||
break;
|
||||
case "ZOMBIE":
|
||||
Zombie zombie = (Zombie) entity;
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_10_R1)) {
|
||||
if (zombie.isVillager() && zombie.getVillagerProfession().toString().equals("HUSK"))
|
||||
return "ZombieVillager";
|
||||
if (zombie.getVillagerProfession().toString().equals("HUSK"))
|
||||
return "ZombieHusk";
|
||||
} else {
|
||||
if (zombie.isVillager())
|
||||
return "ZombieVillager";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static double getMaxHealth(LivingEntity entity) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_12_R1)) {
|
||||
return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
}
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
|
||||
public static short getDurability(ItemStack item) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||
return (short) ((Damageable) item.getItemMeta()).getDamage();
|
||||
}
|
||||
return item.getDurability();
|
||||
}
|
||||
|
||||
public static void setSkullOwner(SkullMeta meta, OfflinePlayer player) {
|
||||
if (meta != null && player != null) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||
meta.setOwningPlayer(player);
|
||||
} else {
|
||||
meta.setOwner(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemInMainHand(Player player) {
|
||||
if (Version.isCurrentHigher(Version.v1_8_R3))
|
||||
return player.getInventory().getItemInMainHand();
|
||||
return player.getItemInHand();
|
||||
}
|
||||
|
||||
public static void setItemInMainHand(Player player, ItemStack item) {
|
||||
if (Version.isCurrentHigher(Version.v1_8_R3))
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
else
|
||||
player.setItemInHand(item);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ItemStack getSkull(String skullOwner) {
|
||||
ItemStack item = CMIMaterial.PLAYER_HEAD.newItemStack();
|
||||
@ -45,7 +146,7 @@ public class Util {
|
||||
if (skullOwner.length() == 36) {
|
||||
try {
|
||||
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(skullOwner));
|
||||
Jobs.getNms().setSkullOwner(skullMeta, offPlayer);
|
||||
setSkullOwner(skullMeta, offPlayer);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user