mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
Updating for 1.13 version support
This commit is contained in:
parent
a91a041be4
commit
4f1e9c4446
71
src/main/java/com/gamingmesh/jobs/CMILib/CMIEffect.java
Normal file
71
src/main/java/com/gamingmesh/jobs/CMILib/CMIEffect.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package com.gamingmesh.jobs.CMILib;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.CMILib.CMIEffectManager.CMIParticle;
|
||||||
|
|
||||||
|
public class CMIEffect {
|
||||||
|
|
||||||
|
private CMIParticle particle;
|
||||||
|
private Color color = Color.fromBGR(0, 0, 200);
|
||||||
|
private Vector offset = new Vector();
|
||||||
|
private int size = 1;
|
||||||
|
private int amount = 1;
|
||||||
|
private float speed = 0;
|
||||||
|
|
||||||
|
public CMIEffect(CMIParticle particle) {
|
||||||
|
this.particle = particle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIParticle getParticle() {
|
||||||
|
if (particle == null)
|
||||||
|
particle = CMIParticle.COLOURED_DUST;
|
||||||
|
return particle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticle(CMIParticle particle) {
|
||||||
|
this.particle = particle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(Vector offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getSpeed() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpeed(float speed) {
|
||||||
|
this.speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(int size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
433
src/main/java/com/gamingmesh/jobs/CMILib/CMIEffectManager.java
Normal file
433
src/main/java/com/gamingmesh/jobs/CMILib/CMIEffectManager.java
Normal file
@ -0,0 +1,433 @@
|
|||||||
|
package com.gamingmesh.jobs.CMILib;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Effect.Type;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
|
import com.gamingmesh.jobs.stuff.VersionChecker.Version;
|
||||||
|
|
||||||
|
public class CMIEffectManager {
|
||||||
|
|
||||||
|
public enum CMIParticleType {
|
||||||
|
SOUND, VISUAL, PARTICLE, NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CMIParticleDataType {
|
||||||
|
Void, DustOptions, ItemStack, BlockData, MaterialData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CMIParticle {
|
||||||
|
CLICK2("null", 0, CMIParticleType.SOUND, null),
|
||||||
|
CLICK1("null", 1, CMIParticleType.SOUND, null),
|
||||||
|
BOW_FIRE("null", 2, CMIParticleType.SOUND, null),
|
||||||
|
DOOR_TOGGLE("null", 3, CMIParticleType.SOUND, null),
|
||||||
|
IRON_DOOR_TOGGLE("null", 4, CMIParticleType.SOUND, null),
|
||||||
|
TRAPDOOR_TOGGLE("null", 5, CMIParticleType.SOUND, null),
|
||||||
|
IRON_TRAPDOOR_TOGGLE("null", 6, CMIParticleType.SOUND, null),
|
||||||
|
FENCE_GATE_TOGGLE("null", 7, CMIParticleType.SOUND, null),
|
||||||
|
DOOR_CLOSE("null", 8, CMIParticleType.SOUND, null),
|
||||||
|
IRON_DOOR_CLOSE("null", 9, CMIParticleType.SOUND, null),
|
||||||
|
TRAPDOOR_CLOSE("null", 10, CMIParticleType.SOUND, null),
|
||||||
|
IRON_TRAPDOOR_CLOSE("null", 11, CMIParticleType.SOUND, null),
|
||||||
|
FENCE_GATE_CLOSE("null", 12, CMIParticleType.SOUND, null),
|
||||||
|
EXTINGUISH("null", 13, CMIParticleType.SOUND, null),
|
||||||
|
RECORD_PLAY("null", 14, CMIParticleType.SOUND, null),
|
||||||
|
GHAST_SHRIEK("null", 15, CMIParticleType.SOUND, null),
|
||||||
|
GHAST_SHOOT("null", 16, CMIParticleType.SOUND, null),
|
||||||
|
BLAZE_SHOOT("null", 17, CMIParticleType.SOUND, null),
|
||||||
|
ZOMBIE_CHEW_WOODEN_DOOR("null", 18, CMIParticleType.SOUND, null),
|
||||||
|
ZOMBIE_CHEW_IRON_DOOR("null", 19, CMIParticleType.SOUND, null),
|
||||||
|
ZOMBIE_DESTROY_DOOR("null", 20, CMIParticleType.SOUND, null),
|
||||||
|
SMOKE("null", 21, CMIParticleType.VISUAL, null),
|
||||||
|
STEP_SOUND("null", 22, CMIParticleType.SOUND, null),
|
||||||
|
POTION_BREAK("null", 23, CMIParticleType.VISUAL, null),
|
||||||
|
ENDER_SIGNAL("null", 24, CMIParticleType.VISUAL, null),
|
||||||
|
MOBSPAWNER_FLAMES("null", 25, CMIParticleType.VISUAL, null),
|
||||||
|
BREWING_STAND_BREW("null", 26, CMIParticleType.SOUND, null),
|
||||||
|
CHORUS_FLOWER_GROW("null", 27, CMIParticleType.SOUND, null),
|
||||||
|
CHORUS_FLOWER_DEATH("null", 28, CMIParticleType.SOUND, null),
|
||||||
|
PORTAL_TRAVEL("null", 29, CMIParticleType.SOUND, null),
|
||||||
|
ENDEREYE_LAUNCH("null", 30, CMIParticleType.SOUND, null),
|
||||||
|
FIREWORK_SHOOT("null", 31, CMIParticleType.SOUND, null),
|
||||||
|
VILLAGER_PLANT_GROW("null", 32, CMIParticleType.VISUAL, null),
|
||||||
|
DRAGON_BREATH("null", 33, CMIParticleType.VISUAL, null),
|
||||||
|
ANVIL_BREAK("null", 34, CMIParticleType.SOUND, null),
|
||||||
|
ANVIL_USE("null", 35, CMIParticleType.SOUND, null),
|
||||||
|
ANVIL_LAND("null", 36, CMIParticleType.SOUND, null),
|
||||||
|
ENDERDRAGON_SHOOT("null", 37, CMIParticleType.SOUND, null),
|
||||||
|
WITHER_BREAK_BLOCK("null", 38, CMIParticleType.SOUND, null),
|
||||||
|
WITHER_SHOOT("null", 39, CMIParticleType.SOUND, null),
|
||||||
|
ZOMBIE_INFECT("null", 40, CMIParticleType.SOUND, null),
|
||||||
|
ZOMBIE_CONVERTED_VILLAGER("null", 41, CMIParticleType.SOUND, null),
|
||||||
|
BAT_TAKEOFF("null", 42, CMIParticleType.SOUND, null),
|
||||||
|
END_GATEWAY_SPAWN("null", 43, CMIParticleType.VISUAL, null),
|
||||||
|
ENDERDRAGON_GROWL("null", 44, CMIParticleType.SOUND, null),
|
||||||
|
FIREWORKS_SPARK("fireworksSpark", 45, CMIParticleType.PARTICLE, CMIMaterial.FIRE_CHARGE.getMaterial()),
|
||||||
|
CRIT("crit", 46, CMIParticleType.PARTICLE, Material.IRON_SWORD),
|
||||||
|
MAGIC_CRIT("CRIT_MAGIC", 47, CMIParticleType.PARTICLE, Material.POTION),
|
||||||
|
POTION_SWIRL("mobSpell", "SPELL_MOB", 48, CMIParticleType.PARTICLE, Material.BLAZE_ROD),
|
||||||
|
POTION_SWIRL_TRANSPARENT("mobSpellAmbient", "SPELL_MOB_AMBIENT", 49, CMIParticleType.PARTICLE, Material.BLAZE_POWDER),
|
||||||
|
SPELL("spell", 50, CMIParticleType.PARTICLE, Material.MILK_BUCKET),
|
||||||
|
INSTANT_SPELL("instantSpell", "SPELL_INSTANT", 51, CMIParticleType.PARTICLE, Material.GLASS_BOTTLE),
|
||||||
|
WITCH_MAGIC("witchMagic", "SPELL_WITCH", 52, CMIParticleType.PARTICLE, Material.SPIDER_EYE),
|
||||||
|
NOTE("note", 53, CMIParticleType.PARTICLE, Material.NOTE_BLOCK),
|
||||||
|
PORTAL("portal", 54, CMIParticleType.PARTICLE, Material.OBSIDIAN),
|
||||||
|
FLYING_GLYPH("enchantmenttable", 55, CMIParticleType.PARTICLE, CMIMaterial.ENCHANTING_TABLE.getMaterial()),
|
||||||
|
FLAME("flame", 56, CMIParticleType.PARTICLE, CMIMaterial.FIRE_CHARGE.getMaterial()),
|
||||||
|
LAVA_POP("lava", 57, CMIParticleType.PARTICLE, Material.FLINT_AND_STEEL),
|
||||||
|
FOOTSTEP("footstep", 58, CMIParticleType.PARTICLE, Material.IRON_BOOTS),
|
||||||
|
SPLASH("splash", "water splash", 59, CMIParticleType.PARTICLE, Material.STICK),
|
||||||
|
PARTICLE_SMOKE("smoke", "SMOKE_NORMAL", 60, CMIParticleType.PARTICLE, Material.ANVIL),
|
||||||
|
EXPLOSION_HUGE("hugeexplosion", 61, CMIParticleType.PARTICLE, Material.FURNACE),
|
||||||
|
EXPLOSION_LARGE("largeexplode", 62, CMIParticleType.PARTICLE, Material.FURNACE),
|
||||||
|
EXPLOSION("explode", "EXPLOSION_NORMAL", 63, CMIParticleType.PARTICLE, Material.TNT),
|
||||||
|
VOID_FOG("depthsuspend", "SUSPENDED_DEPTH", 64, CMIParticleType.PARTICLE, CMIMaterial.SALMON.getMaterial()),
|
||||||
|
SMALL_SMOKE("townaura", 65, CMIParticleType.PARTICLE, CMIMaterial.MYCELIUM.getMaterial()),
|
||||||
|
CLOUD("cloud", 66, CMIParticleType.PARTICLE, CMIMaterial.COBWEB.getMaterial()),
|
||||||
|
COLOURED_DUST("reddust", "redstone", 67, CMIParticleType.PARTICLE, Material.REDSTONE, CMIParticleDataType.DustOptions),
|
||||||
|
SNOWBALL_BREAK("snowballpoof", "SNOWBALL", 68, CMIParticleType.PARTICLE, CMIMaterial.SNOWBALL.getMaterial()),
|
||||||
|
WATERDRIP("dripWater", "WATER_DROP", 69, CMIParticleType.PARTICLE, Material.WATER_BUCKET),
|
||||||
|
LAVADRIP("dripLava", 70, CMIParticleType.PARTICLE, Material.LAVA_BUCKET),
|
||||||
|
SNOW_SHOVEL("snowshovel", 71, CMIParticleType.PARTICLE, CMIMaterial.DIAMOND_SHOVEL.getMaterial()),
|
||||||
|
SLIME("slime", 72, CMIParticleType.PARTICLE, Material.SLIME_BALL),
|
||||||
|
HEART("heart", 73, CMIParticleType.PARTICLE, CMIMaterial.ROSE_RED.getMaterial()),
|
||||||
|
VILLAGER_THUNDERCLOUD("angryVillager", "VILLAGER_ANGRY", 74, CMIParticleType.PARTICLE, Material.EMERALD),
|
||||||
|
HAPPY_VILLAGER("VILLAGER_HAPPY", 75, CMIParticleType.PARTICLE, Material.BOOK),
|
||||||
|
LARGE_SMOKE("largesmoke", "SMOKE_LARGE", 76, CMIParticleType.PARTICLE, Material.FURNACE),
|
||||||
|
ITEM_BREAK("iconcrack", 77, CMIParticleType.NONE, Material.DIAMOND_BOOTS),
|
||||||
|
// TILE_BREAK("blockcrack", 78, CMIParticleType.PARTICLE, CMIMaterial.MELON.getMaterial(), CMIParticleDataType.MaterialData),
|
||||||
|
// TILE_DUST("blockdust", 79, CMIParticleType.PARTICLE, CMIMaterial.MELON.getMaterial(), CMIParticleDataType.MaterialData),
|
||||||
|
|
||||||
|
// 1.13
|
||||||
|
|
||||||
|
WATER_BUBBLE("WATER_BUBBLE", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
WATER_WAKE("WATER_WAKE", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
SUSPENDED("SUSPENDED", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
BARRIER("BARRIER", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
// ITEM_CRACK("ITEM_CRACK", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.ItemStack),
|
||||||
|
MOB_APPEARANCE("MOB_APPEARANCE", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
END_ROD("END_ROD", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
DAMAGE_INDICATOR("DAMAGE_INDICATOR", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
SWEEP_ATTACK("SWEEP_ATTACK", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
// FALLING_DUST("FALLING_DUST", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.BlockData),
|
||||||
|
TOTEM("TOTEM", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
SPIT("SPIT", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
SQUID_INK("SQUID_INK", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
BUBBLE_POP("BUBBLE_POP", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
CURRENT_DOWN("CURRENT_DOWN", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
BUBBLE_COLUMN_UP("BUBBLE_COLUMN_UP", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
NAUTILUS("NAUTILUS", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void),
|
||||||
|
DOLPHIN("DOLPHIN", -1, CMIParticleType.PARTICLE, Material.STONE, CMIParticleDataType.Void);
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String secondaryName = "";
|
||||||
|
private int id;
|
||||||
|
private CMIParticleType type;
|
||||||
|
private Material icon;
|
||||||
|
private Object particle;
|
||||||
|
private Effect effect;
|
||||||
|
private Object EnumParticle;
|
||||||
|
private int[] extra;
|
||||||
|
private CMIParticleDataType dataType = CMIParticleDataType.Void;
|
||||||
|
|
||||||
|
CMIParticle(String name, int id, CMIParticleType type) {
|
||||||
|
this(name, null, id, type, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
CMIParticle(String name, int id, CMIParticleType type, Material icon) {
|
||||||
|
this(name, null, id, type, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
CMIParticle(String name, String secondaryName, int id, CMIParticleType type, Material icon) {
|
||||||
|
this(name, secondaryName, id, type, icon, CMIParticleDataType.Void);
|
||||||
|
}
|
||||||
|
|
||||||
|
CMIParticle(String name, int id, CMIParticleType type, Material icon, CMIParticleDataType dataType) {
|
||||||
|
this(name, null, id, type, icon, dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
CMIParticle(String name, String secondaryName, int id, CMIParticleType type, Material icon, CMIParticleDataType dataType) {
|
||||||
|
this.name = name;
|
||||||
|
this.secondaryName = secondaryName;
|
||||||
|
this.id = id;
|
||||||
|
this.type = type;
|
||||||
|
this.icon = icon;
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIParticleType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isParticle() {
|
||||||
|
return type == CMIParticleType.PARTICLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isColored() {
|
||||||
|
return this.equals(COLOURED_DUST) || this.equals(NOTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isParticle(Effect effect) {
|
||||||
|
if (effect == null)
|
||||||
|
return false;
|
||||||
|
CMIParticle cmiEffect = getCMIParticle(effect.toString());
|
||||||
|
if (cmiEffect == null)
|
||||||
|
return false;
|
||||||
|
return cmiEffect.isParticle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getSafeIcon(Effect effect) {
|
||||||
|
CMIParticle cmiEffect = getCMIParticle(effect.toString());
|
||||||
|
if (cmiEffect == null)
|
||||||
|
return Material.STONE;
|
||||||
|
return cmiEffect.getIcon() == null ? Material.STONE : cmiEffect.getIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getSafeIcon() {
|
||||||
|
return getIcon() == null ? Material.STONE : getIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CMIParticle getCMIParticle(String name) {
|
||||||
|
CMIParticle cmiEffect = null;
|
||||||
|
if (name == null)
|
||||||
|
return null;
|
||||||
|
name = name.replace("_", "").toLowerCase();
|
||||||
|
for (CMIParticle one : CMIParticle.values()) {
|
||||||
|
if (one.getName() != null && one.getName().equalsIgnoreCase(name)) {
|
||||||
|
cmiEffect = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!one.getSecondaryName().isEmpty() && one.getSecondaryName().replace("_", "").equalsIgnoreCase(name)) {
|
||||||
|
cmiEffect = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (one.name().replace("_", "").equalsIgnoreCase(name)) {
|
||||||
|
cmiEffect = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cmiEffect != null && Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R1) && cmiEffect.getParticle() == null)
|
||||||
|
return null;
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_13_R1) && cmiEffect != null && cmiEffect.getEffect() == null)
|
||||||
|
return null;
|
||||||
|
return cmiEffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static Effect getEffect(String name) {
|
||||||
|
// CMIParticle cmiEffect = getCMIParticle(name);
|
||||||
|
//// Bukkit.getConsoleSender().sendMessage("1 "+name);
|
||||||
|
//// Bukkit.getConsoleSender().sendMessage("2 "+cmiEffect);
|
||||||
|
//
|
||||||
|
// if (cmiEffect != null) {
|
||||||
|
// if (!cmiEffect.getType().equals(CMIParticleType.PARTICLE))
|
||||||
|
// return null;
|
||||||
|
// for (Effect one : Effect.values()) {
|
||||||
|
// if (one.toString().equalsIgnoreCase(cmiEffect.name()))
|
||||||
|
// return one;
|
||||||
|
// if (one.toString().equalsIgnoreCase(cmiEffect.getName()))
|
||||||
|
// return one;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// for (Effect one : Effect.values()) {
|
||||||
|
// if (one.toString().replace("_", "").equalsIgnoreCase(name)) {
|
||||||
|
// try {
|
||||||
|
// if (one.getType() != Type.VISUAL)
|
||||||
|
// return null;
|
||||||
|
// } catch (Exception | NoSuchMethodError e) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// return one;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public Effect getEffect() {
|
||||||
|
if (effect != null)
|
||||||
|
return effect;
|
||||||
|
if (!isParticle())
|
||||||
|
return null;
|
||||||
|
for (Effect one : Effect.values()) {
|
||||||
|
if (one.toString().replace("_", "").equalsIgnoreCase(name().replace("_", ""))) {
|
||||||
|
effect = one;
|
||||||
|
return one;
|
||||||
|
}
|
||||||
|
if (one.toString().replace("_", "").equalsIgnoreCase(getName())) {
|
||||||
|
effect = one;
|
||||||
|
return one;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Effect one : Effect.values()) {
|
||||||
|
if (one.toString().replace("_", "").equalsIgnoreCase(name.replace("_", ""))) {
|
||||||
|
try {
|
||||||
|
if (one.getType() != Type.VISUAL)
|
||||||
|
return null;
|
||||||
|
} catch (Exception | NoSuchMethodError e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
effect = one;
|
||||||
|
return one;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getIcon() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<CMIParticle> getParticleList() {
|
||||||
|
List<CMIParticle> ls = new ArrayList<CMIParticle>();
|
||||||
|
for (CMIParticle one : CMIParticle.values()) {
|
||||||
|
if (!one.isParticle())
|
||||||
|
continue;
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R1) && one.getParticle() == null)
|
||||||
|
continue;
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_13_R1) && one.getEffect() == null)
|
||||||
|
continue;
|
||||||
|
ls.add(one);
|
||||||
|
}
|
||||||
|
return ls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIParticle getNextPartcileEffect() {
|
||||||
|
|
||||||
|
List<CMIParticle> ls = getParticleList();
|
||||||
|
for (int i = 0; i < ls.size(); i++) {
|
||||||
|
CMIParticle next = ls.get(i);
|
||||||
|
if (next == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!next.isParticle())
|
||||||
|
continue;
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R1) && next.getParticle() == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (next.equals(this)) {
|
||||||
|
if (i == ls.size() - 1)
|
||||||
|
return ls.get(0);
|
||||||
|
return ls.get(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIParticle getPrevParticleEffect() {
|
||||||
|
List<CMIParticle> ls = getParticleList();
|
||||||
|
for (int i = 0; i < ls.size(); i++) {
|
||||||
|
CMIParticle next = ls.get(i);
|
||||||
|
|
||||||
|
if (next == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_9_R1) && next.getParticle() == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!next.isParticle())
|
||||||
|
continue;
|
||||||
|
if (next.equals(this)) {
|
||||||
|
if (i == 0)
|
||||||
|
return ls.get(ls.size() - 1);
|
||||||
|
return ls.get(i - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecondaryName() {
|
||||||
|
return secondaryName == null ? "" : secondaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecondaryName(String secondaryName) {
|
||||||
|
this.secondaryName = secondaryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public org.bukkit.Particle getParticle() {
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_8_R3))
|
||||||
|
return null;
|
||||||
|
if (particle == null) {
|
||||||
|
String n = this.toString().replace("_", "").toLowerCase();
|
||||||
|
for (org.bukkit.Particle one : org.bukkit.Particle.values()) {
|
||||||
|
String name = one.toString().toLowerCase().replace("_", "");
|
||||||
|
if (name.equalsIgnoreCase(n)) {
|
||||||
|
particle = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (particle == null) {
|
||||||
|
String n = name().replace("_", "").toLowerCase();
|
||||||
|
for (org.bukkit.Particle one : org.bukkit.Particle.values()) {
|
||||||
|
String name = one.toString().toLowerCase().replace("_", "");
|
||||||
|
if (name.equalsIgnoreCase(n)) {
|
||||||
|
particle = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (particle == null) {
|
||||||
|
String n = getName().replace("_", "").toLowerCase();
|
||||||
|
for (org.bukkit.Particle one : org.bukkit.Particle.values()) {
|
||||||
|
String name = one.toString().toLowerCase().replace("_", "");
|
||||||
|
if (name.equalsIgnoreCase(n)) {
|
||||||
|
particle = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (particle == null) {
|
||||||
|
String n = getSecondaryName().replace("_", "").toLowerCase();
|
||||||
|
if (!n.isEmpty()) {
|
||||||
|
for (org.bukkit.Particle one : org.bukkit.Particle.values()) {
|
||||||
|
String name = one.toString().toLowerCase().replace("_", "");
|
||||||
|
if (name.equalsIgnoreCase(n)) {
|
||||||
|
particle = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (particle == null)
|
||||||
|
for (org.bukkit.Particle one : org.bukkit.Particle.values()) {
|
||||||
|
String name = one.toString().toLowerCase().replace("_", "");
|
||||||
|
if (name.contains(n)) {
|
||||||
|
particle = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return particle == null ? null : (org.bukkit.Particle) particle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getEnumParticle() {
|
||||||
|
return EnumParticle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnumParticle(Object enumParticle) {
|
||||||
|
EnumParticle = enumParticle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getExtra() {
|
||||||
|
return extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtra(int[] extra) {
|
||||||
|
this.extra = extra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
344
src/main/java/com/gamingmesh/jobs/CMILib/CMIItemStack.java
Normal file
344
src/main/java/com/gamingmesh/jobs/CMILib/CMIItemStack.java
Normal file
@ -0,0 +1,344 @@
|
|||||||
|
package com.gamingmesh.jobs.CMILib;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
|
import com.gamingmesh.jobs.stuff.VersionChecker.Version;
|
||||||
|
|
||||||
|
public class CMIItemStack {
|
||||||
|
|
||||||
|
private int id = 0;
|
||||||
|
private short data = 0;
|
||||||
|
private short durability = 0;
|
||||||
|
private int amount = 0;
|
||||||
|
|
||||||
|
private String bukkitName = null;
|
||||||
|
private String mojangName = null;
|
||||||
|
private CMIMaterial material = null;
|
||||||
|
private ItemStack item;
|
||||||
|
|
||||||
|
public CMIItemStack(Material material) {
|
||||||
|
this.material = CMIMaterial.get(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack(CMIMaterial material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack(ItemStack item) {
|
||||||
|
this.setItemStack(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CMIItemStack clone() {
|
||||||
|
CMIItemStack cm = new CMIItemStack(material);
|
||||||
|
cm.setId(id);
|
||||||
|
cm.setData(data);
|
||||||
|
cm.setAmount(amount);
|
||||||
|
cm.setDurability(durability);
|
||||||
|
cm.setBukkitName(bukkitName);
|
||||||
|
cm.setMojangName(mojangName);
|
||||||
|
cm.setCMIMaterial(material);
|
||||||
|
cm.setItemStack(this.item != null ? this.item.clone() : null);
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTool() {
|
||||||
|
return getMaxDurability() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getDurability() {
|
||||||
|
return this.getItemStack().getDurability();
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getMaxDurability() {
|
||||||
|
return this.material.getMaxDurability();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(short data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack setDisplayName(String name) {
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
if (name == null) {
|
||||||
|
meta.setDisplayName(null);
|
||||||
|
} else
|
||||||
|
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||||
|
}
|
||||||
|
this.getItemStack().setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
return meta == null || meta.getDisplayName() == null || meta.getDisplayName().isEmpty() ? this.material.getName() : meta.getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack addLore(String string) {
|
||||||
|
if (string == null)
|
||||||
|
return this;
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
List<String> lore = meta.getLore();
|
||||||
|
if (lore == null)
|
||||||
|
lore = new ArrayList<String>();
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', string));
|
||||||
|
meta.setLore(lore);
|
||||||
|
this.getItemStack().setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack clearLore() {
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
List<String> t = new ArrayList<String>();
|
||||||
|
meta.setLore(t);
|
||||||
|
this.getItemStack().setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack setLore(List<String> lore) {
|
||||||
|
if (lore == null || lore.isEmpty())
|
||||||
|
return this;
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
List<String> t = new ArrayList<String>();
|
||||||
|
for (String one : lore) {
|
||||||
|
t.add(ChatColor.translateAlternateColorCodes('&', one));
|
||||||
|
}
|
||||||
|
meta.setLore(t);
|
||||||
|
this.getItemStack().setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack addEnchant(Enchantment enchant, Integer level) {
|
||||||
|
if (enchant == null)
|
||||||
|
return this;
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
meta.addEnchant(enchant, level, true);
|
||||||
|
this.getItemStack().setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack addEnchant(HashMap<Enchantment, Integer> enchants) {
|
||||||
|
if (enchants == null || enchants.isEmpty())
|
||||||
|
return this;
|
||||||
|
for (Entry<Enchantment, Integer> oneEnch : enchants.entrySet()) {
|
||||||
|
this.addEnchant(oneEnch.getKey(), oneEnch.getValue());
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIItemStack clearEnchants() {
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
meta.getEnchants().clear();
|
||||||
|
this.getItemStack().setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getLore() {
|
||||||
|
ItemMeta meta = this.getItemStack().getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
List<String> lore = meta.getLore();
|
||||||
|
if (lore == null) {
|
||||||
|
lore = new ArrayList<String>();
|
||||||
|
meta.setLore(lore);
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta.getLore() == null ? new ArrayList<String>() : meta.getLore();
|
||||||
|
}
|
||||||
|
return new ArrayList<String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRealName() {
|
||||||
|
|
||||||
|
return this.material.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBukkitName() {
|
||||||
|
return bukkitName == null || bukkitName.isEmpty() ? null : bukkitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBukkitName(String bukkitName) {
|
||||||
|
this.bukkitName = bukkitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMojangName() {
|
||||||
|
return mojangName == null || mojangName.isEmpty() ? null : mojangName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMojangName(String mojangName) {
|
||||||
|
if (mojangName != null)
|
||||||
|
this.mojangName = mojangName.replace("minecraft:", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getType() {
|
||||||
|
if (material == null)
|
||||||
|
return null;
|
||||||
|
return material.getMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMIMaterial getCMIType() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public Material getMaterial() {
|
||||||
|
return getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaterial(Material material) {
|
||||||
|
this.material = CMIMaterial.get(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCMIMaterial(CMIMaterial material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
if (item == null) {
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) {
|
||||||
|
this.item = new ItemStack(material.getMaterial(), this.amount == 0 ? 1 : this.amount);
|
||||||
|
} else {
|
||||||
|
this.item = new ItemStack(material.getMaterial(), this.amount == 0 ? 1 : this.amount, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.item.getType() == Material.POTION || item.getType().name().contains("SPLASH_POTION") || item.getType().name().contains("TIPPED_ARROW")) {
|
||||||
|
PotionMeta potion = (PotionMeta) item.getItemMeta();
|
||||||
|
PotionEffectType effect = PotionEffectType.getById(data);
|
||||||
|
if (effect != null) {
|
||||||
|
potion.addCustomEffect(new PotionEffect(PotionEffectType.getById(data), 60, 0), true);
|
||||||
|
}
|
||||||
|
item.setItemMeta(potion);
|
||||||
|
item.setDurability((short) 0);
|
||||||
|
|
||||||
|
potion = (PotionMeta) item.getItemMeta();
|
||||||
|
potion.setDisplayName(this.getRealName());
|
||||||
|
item.setItemMeta(potion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CMIItemStack setItemStack(ItemStack item) {
|
||||||
|
this.item = item;
|
||||||
|
if (item != null) {
|
||||||
|
this.id = item.getType().getId();
|
||||||
|
this.amount = item.getAmount();
|
||||||
|
this.material = CMIMaterial.get(item);
|
||||||
|
if ((material.isBlock() || material.isSolid())) {
|
||||||
|
data = item.getData().getData();
|
||||||
|
}
|
||||||
|
if (item.getType().getMaxDurability() - item.getDurability() < 0) {
|
||||||
|
data = item.getData().getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType().getMaxDurability() > 15) {
|
||||||
|
data = (short) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType() == Material.POTION || item.getType().name().contains("SPLASH_POTION") || item.getType().name().contains("TIPPED_ARROW")) {
|
||||||
|
PotionMeta potion = (PotionMeta) item.getItemMeta();
|
||||||
|
try {
|
||||||
|
if (potion != null && potion.getBasePotionData() != null && potion.getBasePotionData().getType() != null && potion.getBasePotionData().getType().getEffectType() != null) {
|
||||||
|
data = (short) potion.getBasePotionData().getType().getEffectType().getId();
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodError e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSimilar(ItemStack item) {
|
||||||
|
return isSimilar(ItemManager.getItem(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSimilar(CMIItemStack item) {
|
||||||
|
if (item == null)
|
||||||
|
return false;
|
||||||
|
return this.material.equals(item.material) && this.getData() == item.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public boolean hasNbtTag() {
|
||||||
|
// return CMI.getInstance().getRef().hasNbt(this.getItemStack());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public List<Recipe> getRecipesFor() {
|
||||||
|
// ItemStack i = getItemStack().clone();
|
||||||
|
// i.getData().setData((byte) data);
|
||||||
|
// if (i.getType().getMaxDurability() > 15)
|
||||||
|
// i.setDurability((short) 0);
|
||||||
|
// return Bukkit.getRecipesFor(i);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public List<Recipe> getRecipesFrom() {
|
||||||
|
// ItemStack i = getItemStack().clone();
|
||||||
|
// i.getData().setData((byte) data);
|
||||||
|
// if (i.getType().getMaxDurability() > 15)
|
||||||
|
// i.setDurability((short) 0);
|
||||||
|
// Iterator<Recipe> it = Bukkit.recipeIterator();
|
||||||
|
// List<Recipe> recipes = new ArrayList<Recipe>();
|
||||||
|
// while (it.hasNext()) {
|
||||||
|
// Recipe rec = it.next();
|
||||||
|
// for (ItemStack one : CMI.getInstance().getRecipeManager().getIngredientsList(rec)) {
|
||||||
|
// if (one.isSimilar(i)) {
|
||||||
|
// recipes.add(rec);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return recipes;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public void setDurability(short durability) {
|
||||||
|
this.durability = durability;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public Set<Enchantment> getValidEnchants() {
|
||||||
|
// Set<Enchantment> enchants = new HashSet<Enchantment>();
|
||||||
|
// for (Enchantment one : CMIEnchantment.values()) {
|
||||||
|
// if (!CMIEnchantment.isEnabled(one))
|
||||||
|
// continue;
|
||||||
|
// if (one.canEnchantItem(this.getItemStack()))
|
||||||
|
// enchants.add(one);
|
||||||
|
// }
|
||||||
|
// return enchants;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
1913
src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java
Normal file
1913
src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java
Normal file
File diff suppressed because it is too large
Load Diff
162
src/main/java/com/gamingmesh/jobs/CMILib/ItemReflection.java
Normal file
162
src/main/java/com/gamingmesh/jobs/CMILib/ItemReflection.java
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2017 Zrips
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.gamingmesh.jobs.CMILib;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.stuff.VersionChecker.Version;
|
||||||
|
|
||||||
|
public class ItemReflection {
|
||||||
|
|
||||||
|
private static Class<?> CraftServerClass;
|
||||||
|
private static Object CraftServer;
|
||||||
|
private static Class<?> CraftItemStack;
|
||||||
|
private static Class<?> Item;
|
||||||
|
private static Class<?> IStack;
|
||||||
|
|
||||||
|
static {
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public ItemReflection() {
|
||||||
|
// initialize();
|
||||||
|
// }
|
||||||
|
|
||||||
|
private static void initialize() {
|
||||||
|
try {
|
||||||
|
CraftServerClass = getBukkitClass("CraftServer");
|
||||||
|
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CraftServer = CraftServerClass.cast(Bukkit.getServer());
|
||||||
|
} catch (SecurityException | IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CraftItemStack = getBukkitClass("inventory.CraftItemStack");
|
||||||
|
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Item = getMinecraftClass("Item");
|
||||||
|
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
IStack = getMinecraftClass("ItemStack");
|
||||||
|
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Class<?> getBukkitClass(String nmsClassString) throws ClassNotFoundException {
|
||||||
|
return Class.forName("org.bukkit.craftbukkit." + Jobs.getVersionCheckManager().getVersion() + "." + nmsClassString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Class<?> getMinecraftClass(String nmsClassString) throws ClassNotFoundException {
|
||||||
|
return Class.forName("net.minecraft.server." + Jobs.getVersionCheckManager().getVersion() + "." + nmsClassString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getItemMinecraftName(ItemStack item) {
|
||||||
|
try {
|
||||||
|
Object nmsStack = asNMSCopy(item);
|
||||||
|
Method itemMeth = Item.getMethod("getById", int.class);
|
||||||
|
Object res = itemMeth.invoke(Item, item.getType().getId());
|
||||||
|
|
||||||
|
String ff = "b";
|
||||||
|
switch (Jobs.getVersionCheckManager().getVersion()) {
|
||||||
|
case v1_10_R1:
|
||||||
|
case v1_9_R1:
|
||||||
|
case v1_9_R2:
|
||||||
|
case v1_8_R1:
|
||||||
|
case v1_8_R3:
|
||||||
|
case v1_8_R2:
|
||||||
|
ff = "a";
|
||||||
|
break;
|
||||||
|
case v1_11_R1:
|
||||||
|
case v1_11_R2:
|
||||||
|
case v1_12_R1:
|
||||||
|
case v1_12_R2:
|
||||||
|
ff = "b";
|
||||||
|
break;
|
||||||
|
case v1_13_R2:
|
||||||
|
case v1_13_R1:
|
||||||
|
case v1_14_R2:
|
||||||
|
case v1_14_R1:
|
||||||
|
case v1_15_R2:
|
||||||
|
case v1_15_R1:
|
||||||
|
ff = "h";
|
||||||
|
break;
|
||||||
|
case v1_7_R1:
|
||||||
|
case v1_7_R2:
|
||||||
|
case v1_7_R3:
|
||||||
|
case v1_7_R4:
|
||||||
|
ff = "n";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Method meth2 = res.getClass().getMethod(ff, IStack);
|
||||||
|
Object name = meth2.invoke(res, nmsStack);
|
||||||
|
return name.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return item != null ? item.getType().name() : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemMinecraftNamePath(ItemStack item) {
|
||||||
|
try {
|
||||||
|
Object nmsStack = asNMSCopy(item);
|
||||||
|
Method itemMeth = Item.getMethod("getById", int.class);
|
||||||
|
Object res = itemMeth.invoke(Item, item.getType().getId());
|
||||||
|
Method nameThingy = Item.getMethod("j", IStack);
|
||||||
|
Object resThingy = nameThingy.invoke(res, nmsStack);
|
||||||
|
return resThingy.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object asNMSCopy(ItemStack item) {
|
||||||
|
try {
|
||||||
|
Method meth = CraftItemStack.getMethod("asNMSCopy", ItemStack.class);
|
||||||
|
return meth.invoke(CraftItemStack, item);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object asBukkitCopy(Object item) {
|
||||||
|
try {
|
||||||
|
Method meth = CraftItemStack.getMethod("asBukkitCopy", IStack);
|
||||||
|
return meth.invoke(CraftItemStack, item);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getCraftServer() {
|
||||||
|
return CraftServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItemInOffHand(Player player) {
|
||||||
|
if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1))
|
||||||
|
return null;
|
||||||
|
return player.getInventory().getItemInOffHand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndermiteActive(Entity ent, boolean state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,208 +0,0 @@
|
|||||||
package com.gamingmesh.jobs.CmiItems;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
|
||||||
import com.gamingmesh.jobs.stuff.Util;
|
|
||||||
|
|
||||||
public class CMIItem {
|
|
||||||
|
|
||||||
private int id = 0;
|
|
||||||
private short data = 0;
|
|
||||||
private int amount = 0;
|
|
||||||
|
|
||||||
private String bukkitName = null;
|
|
||||||
private Material material = null;
|
|
||||||
private ItemStack item;
|
|
||||||
|
|
||||||
public CMIItem(Material material) {
|
|
||||||
this.material = material;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CMIItem clone() {
|
|
||||||
CMIItem cm = new CMIItem(material);
|
|
||||||
cm.setId(id);
|
|
||||||
cm.setData(data);
|
|
||||||
cm.setBukkitName(bukkitName);
|
|
||||||
cm.setItemStack(this.item);
|
|
||||||
return cm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTool() {
|
|
||||||
return getMaxDurability() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getDurability() {
|
|
||||||
return this.getItemStack().getDurability();
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getMaxDurability() {
|
|
||||||
return this.material.getMaxDurability();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(short data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CMIItem setDisplayName(String name) {
|
|
||||||
if (name == null)
|
|
||||||
return this;
|
|
||||||
ItemMeta meta = this.getItemStack().getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
|
||||||
this.getItemStack().setItemMeta(meta);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayName() {
|
|
||||||
ItemMeta meta = this.getItemStack().getItemMeta();
|
|
||||||
return meta.getDisplayName() == null ? this.getRealName() : meta.getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CMIItem addLore(String string) {
|
|
||||||
if (string == null)
|
|
||||||
return this;
|
|
||||||
ItemMeta meta = this.getItemStack().getItemMeta();
|
|
||||||
List<String> lore = meta.getLore();
|
|
||||||
if (lore == null)
|
|
||||||
lore = new ArrayList<String>();
|
|
||||||
lore.add(ChatColor.translateAlternateColorCodes('&', string));
|
|
||||||
meta.setLore(lore);
|
|
||||||
this.getItemStack().setItemMeta(meta);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CMIItem setLore(List<String> lore) {
|
|
||||||
if (lore == null)
|
|
||||||
return this;
|
|
||||||
ItemMeta meta = this.getItemStack().getItemMeta();
|
|
||||||
List<String> t = new ArrayList<String>();
|
|
||||||
for (String one : lore) {
|
|
||||||
t.add(ChatColor.translateAlternateColorCodes('&', one));
|
|
||||||
}
|
|
||||||
meta.setLore(t);
|
|
||||||
this.getItemStack().setItemMeta(meta);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CMIItem addEnchant(Enchantment enchant, Integer level) {
|
|
||||||
if (enchant == null)
|
|
||||||
return this;
|
|
||||||
ItemMeta meta = this.getItemStack().getItemMeta();
|
|
||||||
meta.addEnchant(enchant, level, true);
|
|
||||||
this.getItemStack().setItemMeta(meta);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CMIItem addEnchant(HashMap<Enchantment, Integer> enchants) {
|
|
||||||
if (enchants == null || enchants.isEmpty())
|
|
||||||
return this;
|
|
||||||
for (Entry<Enchantment, Integer> oneEnch : enchants.entrySet()) {
|
|
||||||
this.addEnchant(oneEnch.getKey(), oneEnch.getValue());
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CMIItem clearEnchants() {
|
|
||||||
ItemMeta meta = this.getItemStack().getItemMeta();
|
|
||||||
meta.getEnchants().clear();
|
|
||||||
this.getItemStack().setItemMeta(meta);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getLore() {
|
|
||||||
ItemMeta meta = this.getItemStack().getItemMeta();
|
|
||||||
return meta.getLore();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRealName() {
|
|
||||||
return Jobs.getItemManager().getRealName(this, true).getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBukkitName() {
|
|
||||||
return bukkitName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBukkitName(String bukkitName) {
|
|
||||||
this.bukkitName = bukkitName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial() {
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaterial(Material material) {
|
|
||||||
this.material = material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
if (item == null) {
|
|
||||||
this.item = new ItemStack(material, this.amount == 0 ? 1 : this.amount, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.item.getType() == Material.MOB_SPAWNER) {
|
|
||||||
if (data == 0)
|
|
||||||
data = 90;
|
|
||||||
EntityType type = EntityType.fromId(data);
|
|
||||||
if (type != null)
|
|
||||||
this.item = Util.setEntityType(this.item, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CMIItem setItemStack(ItemStack item) {
|
|
||||||
this.item = item;
|
|
||||||
if (item != null) {
|
|
||||||
this.amount = item.getAmount();
|
|
||||||
if ((material.isBlock() || material.isSolid()))
|
|
||||||
data = item.getData().getData();
|
|
||||||
if (item.getType().getMaxDurability() - item.getDurability() < 0)
|
|
||||||
data = item.getDurability();
|
|
||||||
if (item.getType() == Material.MOB_SPAWNER)
|
|
||||||
data = Util.getEntityType(item).getTypeId();
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAmount() {
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAmount(int amount) {
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSimilar(ItemStack item) {
|
|
||||||
return isSimilar(Jobs.getItemManager().getItem(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSimilar(CMIItem item) {
|
|
||||||
if (item == null)
|
|
||||||
return false;
|
|
||||||
return this.getMaterial().equals(item.material) && this.getData() == item.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -41,7 +41,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.CmiItems.ItemManager;
|
import com.gamingmesh.jobs.CMILib.*;
|
||||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||||
import com.gamingmesh.jobs.MyPet.MyPetManager;
|
import com.gamingmesh.jobs.MyPet.MyPetManager;
|
||||||
import com.gamingmesh.jobs.MythicMobs.MythicMobInterface;
|
import com.gamingmesh.jobs.MythicMobs.MythicMobInterface;
|
||||||
@ -153,7 +153,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
private static PermissionHandler permissionHandler;
|
private static PermissionHandler permissionHandler;
|
||||||
private static PermissionManager permissionManager;
|
private static PermissionManager permissionManager;
|
||||||
|
|
||||||
private static ItemManager itemManager;
|
// private static ItemManager itemManager;
|
||||||
|
|
||||||
public static BufferedPaymentThread paymentThread = null;
|
public static BufferedPaymentThread paymentThread = null;
|
||||||
private static DatabaseSaveThread saveTask = null;
|
private static DatabaseSaveThread saveTask = null;
|
||||||
@ -717,9 +717,9 @@ public class Jobs extends JavaPlugin {
|
|||||||
return permissionManager;
|
return permissionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemManager getItemManager() {
|
// public static ItemManager getItemManager() {
|
||||||
return itemManager;
|
// return itemManager;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the economy handler
|
* Sets the economy handler
|
||||||
@ -753,9 +753,12 @@ public class Jobs extends JavaPlugin {
|
|||||||
this.setEnabled(true);
|
this.setEnabled(true);
|
||||||
|
|
||||||
versionCheckManager = new VersionChecker(this);
|
versionCheckManager = new VersionChecker(this);
|
||||||
|
|
||||||
|
ItemManager.load();
|
||||||
|
|
||||||
version = versionCheckManager.getVersion().getShortVersion();
|
version = versionCheckManager.getVersion().getShortVersion();
|
||||||
|
|
||||||
itemManager = new ItemManager(this);
|
// itemManager = new ItemManager(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> nmsClass;
|
Class<?> nmsClass;
|
||||||
|
@ -15,7 +15,5 @@ public interface NMS {
|
|||||||
|
|
||||||
public ItemStack getItemInMainHand(Player player);
|
public ItemStack getItemInMainHand(Player player);
|
||||||
|
|
||||||
public Block getTargetBlock(Player player, int range);
|
|
||||||
|
|
||||||
void setItemInMainHand(Player player, ItemStack item);
|
void setItemInMainHand(Player player, ItemStack item);
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -48,7 +49,6 @@ import com.gamingmesh.jobs.container.CurrencyType;
|
|||||||
import com.gamingmesh.jobs.container.ItemBonusCache;
|
import com.gamingmesh.jobs.container.ItemBonusCache;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobCommands;
|
import com.gamingmesh.jobs.container.JobCommands;
|
||||||
import com.gamingmesh.jobs.container.JobItemBonus;
|
|
||||||
import com.gamingmesh.jobs.container.JobItems;
|
import com.gamingmesh.jobs.container.JobItems;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
@ -59,8 +59,6 @@ import com.gamingmesh.jobs.dao.JobsDAO;
|
|||||||
import com.gamingmesh.jobs.dao.JobsDAOData;
|
import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||||
import com.gamingmesh.jobs.economy.PaymentData;
|
import com.gamingmesh.jobs.economy.PaymentData;
|
||||||
import com.gamingmesh.jobs.economy.PointsData;
|
import com.gamingmesh.jobs.economy.PointsData;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||||
|
|
||||||
public class PlayerManager {
|
public class PlayerManager {
|
||||||
@ -796,7 +794,7 @@ public class PlayerManager {
|
|||||||
|
|
||||||
main: for (Entry<String, JobItems> one : prog.getItemBonus().entrySet()) {
|
main: for (Entry<String, JobItems> one : prog.getItemBonus().entrySet()) {
|
||||||
JobItems oneItem = one.getValue();
|
JobItems oneItem = one.getValue();
|
||||||
if (oneItem.getId() != item.getTypeId())
|
if (oneItem.getId() != item.getType().getId())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (oneItem.getName() != null && name != null)
|
if (oneItem.getName() != null && name != null)
|
||||||
|
@ -78,7 +78,7 @@ public class Reflections {
|
|||||||
try {
|
try {
|
||||||
Object nmsStack = asNMSCopy(item);
|
Object nmsStack = asNMSCopy(item);
|
||||||
Method itemMeth = Item.getMethod("getById", int.class);
|
Method itemMeth = Item.getMethod("getById", int.class);
|
||||||
Object res = itemMeth.invoke(Item, item.getTypeId());
|
Object res = itemMeth.invoke(Item, item.getType().getId());
|
||||||
|
|
||||||
String ff = "b";
|
String ff = "b";
|
||||||
switch (Jobs.getVersionCheckManager().getVersion()) {
|
switch (Jobs.getVersionCheckManager().getVersion()) {
|
||||||
|
@ -4,16 +4,16 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
||||||
import com.gamingmesh.jobs.container.CuboidArea;
|
import com.gamingmesh.jobs.container.CuboidArea;
|
||||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
|
|
||||||
public class area implements Cmd {
|
public class area implements Cmd {
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class area implements Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
|
if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", Material.getMaterial(Jobs.getGCManager().getSelectionTooldID).name().toLowerCase()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTooldID).getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
|
import com.gamingmesh.jobs.stuff.Util;
|
||||||
|
|
||||||
public class blockinfo implements Cmd {
|
public class blockinfo implements Cmd {
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ public class blockinfo implements Cmd {
|
|||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
Block block = Jobs.getNms().getTargetBlock(player, 15);
|
Block block = Util.getTargetBlock(player, 15);
|
||||||
|
|
||||||
if (block == null || block.getState().getType() == Material.AIR)
|
if (block == null || block.getState().getType() == Material.AIR)
|
||||||
return true;
|
return true;
|
||||||
@ -35,9 +36,9 @@ public class blockinfo implements Cmd {
|
|||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.name", "%blockname%", block.getType().name()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.name", "%blockname%", block.getType().name()));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getTypeId()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getType().getId()));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", getData(block)));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", getData(block)));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", block.getTypeId() + dataString,
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", block.getType().getId() + dataString,
|
||||||
"%second%", block.getType().name() + dataString));
|
"%second%", block.getType().name() + dataString));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.BlockProtection;
|
import com.gamingmesh.jobs.container.BlockProtection;
|
||||||
@ -53,11 +54,11 @@ public class bp implements Cmd {
|
|||||||
}
|
}
|
||||||
changedBlocks.add(l.getBlock());
|
changedBlocks.add(l.getBlock());
|
||||||
if (bp.getAction() == DBAction.DELETE)
|
if (bp.getAction() == DBAction.DELETE)
|
||||||
player.sendBlockChange(l, Material.STAINED_GLASS, (byte) 14);
|
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 14);
|
||||||
else if (time == -1)
|
else if (time == -1)
|
||||||
player.sendBlockChange(l, Material.STAINED_GLASS, (byte) 15);
|
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 15);
|
||||||
else
|
else
|
||||||
player.sendBlockChange(l, Material.STAINED_GLASS, (byte) 0);
|
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gamingmesh.jobs.commands.list;
|
package com.gamingmesh.jobs.commands.list;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -11,6 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
@ -21,6 +23,7 @@ import com.gamingmesh.jobs.stuff.ChatColor;
|
|||||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||||
import com.gamingmesh.jobs.stuff.Util;
|
import com.gamingmesh.jobs.stuff.Util;
|
||||||
|
import com.gamingmesh.jobs.stuff.VersionChecker.Version;
|
||||||
|
|
||||||
public class editjobs implements Cmd {
|
public class editjobs implements Cmd {
|
||||||
|
|
||||||
@ -378,7 +381,7 @@ public class editjobs implements Cmd {
|
|||||||
break;
|
break;
|
||||||
case "looking":
|
case "looking":
|
||||||
case "lookingat":
|
case "lookingat":
|
||||||
Block block = Jobs.getNms().getTargetBlock(player, 30);
|
Block block = Util.getTargetBlock(player, 30);
|
||||||
key = block.getType().name() + "-" + block.getData();
|
key = block.getType().name() + "-" + block.getData();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -396,10 +399,10 @@ public class editjobs implements Cmd {
|
|||||||
myKey = myKey.split("-")[0];
|
myKey = myKey.split("-")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = Material.matchMaterial(myKey);
|
CMIMaterial material = CMIMaterial.get(myKey);
|
||||||
|
|
||||||
if (material == null)
|
if (material == null)
|
||||||
material = Material.getMaterial(myKey.replace(" ", "_").toUpperCase());
|
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
|
||||||
|
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
// try integer method
|
// try integer method
|
||||||
@ -409,7 +412,7 @@ public class editjobs implements Cmd {
|
|||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
if (matId != null) {
|
if (matId != null) {
|
||||||
material = Material.getMaterial(matId);
|
material = CMIMaterial.get(matId);
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " " + actionT.getName() + " is using ID: " + key + "!");
|
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " " + actionT.getName() + " is using ID: " + key + "!");
|
||||||
player.sendMessage(ChatColor.GOLD + "Please use the Material name instead: " + material.toString() + "!");
|
player.sendMessage(ChatColor.GOLD + "Please use the Material name instead: " + material.toString() + "!");
|
||||||
@ -448,12 +451,12 @@ public class editjobs implements Cmd {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (material == Material.REDSTONE_ORE && actionT == ActionType.BREAK) {
|
if (material == CMIMaterial.REDSTONE_ORE && actionT == ActionType.BREAK) {
|
||||||
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
player.sendMessage(ChatColor.GOLD + "Job " + job.getName() + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||||
player.sendMessage(ChatColor.GOLD + "Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
player.sendMessage(ChatColor.GOLD + "Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||||
player.sendMessage(ChatColor.GOLD + "In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
player.sendMessage(ChatColor.GOLD + "In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||||
player.sendMessage(ChatColor.GOLD + "In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
player.sendMessage(ChatColor.GOLD + "In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
||||||
material = Material.GLOWING_REDSTONE_ORE;
|
material = CMIMaterial.GLOWING_REDSTONE_ORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = material.toString();
|
type = material.toString();
|
||||||
@ -518,8 +521,14 @@ public class editjobs implements Cmd {
|
|||||||
|
|
||||||
} else if (actionT == ActionType.ENCHANT) {
|
} else if (actionT == ActionType.ENCHANT) {
|
||||||
Enchantment enchant = Enchantment.getByName(myKey);
|
Enchantment enchant = Enchantment.getByName(myKey);
|
||||||
if (enchant != null)
|
if (enchant != null) {
|
||||||
id = enchant.getId();
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_12_R1)) {
|
||||||
|
try {
|
||||||
|
id = (int) enchant.getClass().getMethod("getId").invoke(enchant);
|
||||||
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
type = myKey;
|
type = myKey;
|
||||||
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL) {
|
} else if (actionT == ActionType.CUSTOMKILL || actionT == ActionType.SHEAR || actionT == ActionType.MMKILL) {
|
||||||
type = myKey;
|
type = myKey;
|
||||||
|
@ -44,10 +44,10 @@ public class iteminfo implements Cmd {
|
|||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.name", "%itemname%", iih.getType().name()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.name", "%itemname%", iih.getType().name()));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.id", "%itemid%", iih.getTypeId()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.id", "%itemid%", iih.getType().getId()));
|
||||||
if (!tool)
|
if (!tool)
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.data", "%itemdata%", iih.getData().getData()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.data", "%itemdata%", iih.getData().getData()));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.usage", "%first%", iih.getTypeId() + dataString,
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.usage", "%first%", iih.getType().getId() + dataString,
|
||||||
"%second%", iih.getType().name() + dataString));
|
"%second%", iih.getType().name() + dataString));
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public class BlockProtectionManager {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public Integer getBlockDelayTime(Block block) {
|
public Integer getBlockDelayTime(Block block) {
|
||||||
Integer time = Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getTypeId());
|
Integer time = Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getType().getId());
|
||||||
if (time == null && Jobs.getGCManager().useGlobalTimer)
|
if (time == null && Jobs.getGCManager().useGlobalTimer)
|
||||||
time = Jobs.getGCManager().globalblocktimer;
|
time = Jobs.getGCManager().globalblocktimer;
|
||||||
return time;
|
return time;
|
||||||
@ -156,6 +156,6 @@ public class BlockProtectionManager {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean isInBp(Block block) {
|
public boolean isInBp(Block block) {
|
||||||
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getTypeId()) != null;
|
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getType().getId()) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,6 +42,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
@ -56,6 +58,7 @@ import com.gamingmesh.jobs.container.Quest;
|
|||||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
|
import com.gamingmesh.jobs.stuff.VersionChecker.Version;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
@ -178,10 +181,10 @@ public class ConfigManager {
|
|||||||
myKey = myKey.split("-")[0];
|
myKey = myKey.split("-")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = Material.matchMaterial(myKey);
|
CMIMaterial material = CMIMaterial.get(myKey);
|
||||||
|
|
||||||
if (material == null)
|
if (material == null)
|
||||||
material = Material.getMaterial(myKey.replace(" ", "_").toUpperCase());
|
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
|
||||||
|
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
// try integer method
|
// try integer method
|
||||||
@ -191,7 +194,7 @@ public class ConfigManager {
|
|||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
if (matId != null) {
|
if (matId != null) {
|
||||||
material = Material.getMaterial(matId);
|
material = CMIMaterial.get(matId);
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
|
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
|
||||||
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
||||||
@ -242,12 +245,12 @@ public class ConfigManager {
|
|||||||
* future this hack may be removed and anybody using REDSTONE_ORE will have their
|
* future this hack may be removed and anybody using REDSTONE_ORE will have their
|
||||||
* configurations broken.
|
* configurations broken.
|
||||||
*/
|
*/
|
||||||
if (material == Material.REDSTONE_ORE && actionType == ActionType.BREAK) {
|
if (material == CMIMaterial.REDSTONE_ORE && actionType == ActionType.BREAK) {
|
||||||
Jobs.getPluginLogger().warning("Job " + jobName + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
Jobs.getPluginLogger().warning("Job " + jobName + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||||
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||||
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||||
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
||||||
material = Material.GLOWING_REDSTONE_ORE;
|
material = CMIMaterial.GLOWING_REDSTONE_ORE;
|
||||||
}
|
}
|
||||||
// END HACK
|
// END HACK
|
||||||
|
|
||||||
@ -313,8 +316,14 @@ public class ConfigManager {
|
|||||||
|
|
||||||
} else if (actionType == ActionType.ENCHANT) {
|
} else if (actionType == ActionType.ENCHANT) {
|
||||||
Enchantment enchant = Enchantment.getByName(myKey);
|
Enchantment enchant = Enchantment.getByName(myKey);
|
||||||
if (enchant != null)
|
if (enchant != null) {
|
||||||
id = enchant.getId();
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_12_R1)) {
|
||||||
|
try {
|
||||||
|
id = (int) enchant.getClass().getMethod("getId").invoke(enchant);
|
||||||
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
type = myKey;
|
type = myKey;
|
||||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
|
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
|
||||||
type = myKey;
|
type = myKey;
|
||||||
@ -531,14 +540,14 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gui item
|
// Gui item
|
||||||
ItemStack GUIitem = new ItemStack(Material.getMaterial(35), 1, (byte) 13);
|
ItemStack GUIitem = CMIMaterial.GREEN_WOOL.newItemStack();
|
||||||
if (jobSection.contains("Gui")) {
|
if (jobSection.contains("Gui")) {
|
||||||
ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui");
|
ConfigurationSection guiSection = jobSection.getConfigurationSection("Gui");
|
||||||
if (guiSection.contains("Id") && guiSection.contains("Data") && guiSection.isInt("Id") && guiSection.isInt("Data")) {
|
if (guiSection.contains("Id") && guiSection.contains("Data") && guiSection.isInt("Id") && guiSection.isInt("Data")) {
|
||||||
GUIitem = new ItemStack(Material.getMaterial(guiSection.getInt("Id")), 1, (byte) guiSection.getInt("Data"));
|
GUIitem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||||
} else if (guiSection.contains("CustomSkull")) {
|
} else if (guiSection.contains("CustomSkull")) {
|
||||||
String skullOwner = guiSection.getString("CustomSkull");
|
String skullOwner = guiSection.getString("CustomSkull");
|
||||||
GUIitem = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
|
GUIitem = CMIMaterial.PLAYER_HEAD.newItemStack();
|
||||||
SkullMeta skullMeta = (SkullMeta) GUIitem.getItemMeta();
|
SkullMeta skullMeta = (SkullMeta) GUIitem.getItemMeta();
|
||||||
if (skullOwner.length() == 36) {
|
if (skullOwner.length() == 36) {
|
||||||
try {
|
try {
|
||||||
@ -823,10 +832,10 @@ public class ConfigManager {
|
|||||||
myKey = myKey.split("-")[0];
|
myKey = myKey.split("-")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = Material.matchMaterial(myKey);
|
CMIMaterial material = CMIMaterial.get(myKey);
|
||||||
|
|
||||||
if (material == null)
|
if (material == null)
|
||||||
material = Material.getMaterial(myKey.replace(" ", "_").toUpperCase());
|
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
|
||||||
|
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
// try integer method
|
// try integer method
|
||||||
@ -836,7 +845,7 @@ public class ConfigManager {
|
|||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
if (matId != null) {
|
if (matId != null) {
|
||||||
material = Material.getMaterial(matId);
|
material = CMIMaterial.get(matId);
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
Jobs.getPluginLogger().warning("Job " + jobKey + " " + actionType.getName() + " is using ID: " + key + "!");
|
Jobs.getPluginLogger().warning("Job " + jobKey + " " + actionType.getName() + " is using ID: " + key + "!");
|
||||||
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
||||||
@ -887,12 +896,12 @@ public class ConfigManager {
|
|||||||
* future this hack may be removed and anybody using REDSTONE_ORE will have their
|
* future this hack may be removed and anybody using REDSTONE_ORE will have their
|
||||||
* configurations broken.
|
* configurations broken.
|
||||||
*/
|
*/
|
||||||
if (material == Material.REDSTONE_ORE && actionType == ActionType.BREAK) {
|
if (material == CMIMaterial.REDSTONE_ORE && actionType == ActionType.BREAK) {
|
||||||
Jobs.getPluginLogger().warning("Job " + jobKey + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
Jobs.getPluginLogger().warning("Job " + jobKey + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||||
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||||
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||||
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
||||||
material = Material.GLOWING_REDSTONE_ORE;
|
material = CMIMaterial.GLOWING_REDSTONE_ORE;
|
||||||
}
|
}
|
||||||
// END HACK
|
// END HACK
|
||||||
|
|
||||||
@ -958,8 +967,14 @@ public class ConfigManager {
|
|||||||
|
|
||||||
} else if (actionType == ActionType.ENCHANT) {
|
} else if (actionType == ActionType.ENCHANT) {
|
||||||
Enchantment enchant = Enchantment.getByName(myKey);
|
Enchantment enchant = Enchantment.getByName(myKey);
|
||||||
if (enchant != null)
|
if (enchant != null) {
|
||||||
id = enchant.getId();
|
if (Jobs.getVersionCheckManager().getVersion().isEqualOrLower(Version.v1_12_R1)) {
|
||||||
|
try {
|
||||||
|
id = (int) enchant.getClass().getMethod("getId").invoke(enchant);
|
||||||
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
type = myKey;
|
type = myKey;
|
||||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
|
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
|
||||||
type = myKey;
|
type = myKey;
|
||||||
|
@ -34,6 +34,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||||
import com.gamingmesh.jobs.container.CurrencyLimit;
|
import com.gamingmesh.jobs.container.CurrencyLimit;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
@ -445,7 +446,7 @@ public class GeneralConfigManager {
|
|||||||
|
|
||||||
c.getW().addComment("selectionTool", "Tool used when selecting bounds for restricted area");
|
c.getW().addComment("selectionTool", "Tool used when selecting bounds for restricted area");
|
||||||
getSelectionTooldID = c.get("selectionTool", 294);
|
getSelectionTooldID = c.get("selectionTool", 294);
|
||||||
if (Material.getMaterial(Jobs.getGCManager().getSelectionTooldID) == null)
|
if (CMIMaterial.get(Jobs.getGCManager().getSelectionTooldID) == null)
|
||||||
getSelectionTooldID = 294;
|
getSelectionTooldID = 294;
|
||||||
|
|
||||||
c.getW().addComment("MultiServerCompatability", "Enable if you are using one data base for multiple servers across bungee network",
|
c.getW().addComment("MultiServerCompatability", "Enable if you are using one data base for multiple servers across bungee network",
|
||||||
@ -924,7 +925,7 @@ public class GeneralConfigManager {
|
|||||||
Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN"));
|
Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN"));
|
||||||
guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0));
|
guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0));
|
||||||
tmat = Material.getMaterial(c.get("JobsGUI.Filler.Material", "STAINED_GLASS_PANE"));
|
tmat = Material.getMaterial(c.get("JobsGUI.Filler.Material", "STAINED_GLASS_PANE"));
|
||||||
guiFiller = new ItemStack(tmat == null ? Material.STAINED_GLASS_PANE : tmat, 1, (byte) c.get("JobsGUI.Filler.Data", 15));
|
guiFiller = new ItemStack(tmat == null ? CMIMaterial.GREEN_STAINED_GLASS_PANE.getMaterial() : tmat, 1, (byte) c.get("JobsGUI.Filler.Data", 15));
|
||||||
|
|
||||||
// c.getW().addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost");
|
// c.getW().addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost");
|
||||||
// useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false);
|
// useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false);
|
||||||
|
@ -9,7 +9,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.CmiItems.CMIItem;
|
import com.gamingmesh.jobs.CMILib.CMIItemStack;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager;
|
||||||
import com.gamingmesh.jobs.container.LocaleReader;
|
import com.gamingmesh.jobs.container.LocaleReader;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
|
|
||||||
@ -158,8 +159,8 @@ public class RestrictedBlockManager {
|
|||||||
for (String one : lss) {
|
for (String one : lss) {
|
||||||
if (((c.getC().isString("blocksTimer." + one + ".id")) || (c.getC().isInt("blocksTimer." + one + ".id"))) && (c.getC().isInt("blocksTimer." + one
|
if (((c.getC().isString("blocksTimer." + one + ".id")) || (c.getC().isInt("blocksTimer." + one + ".id"))) && (c.getC().isInt("blocksTimer." + one
|
||||||
+ ".cd"))) {
|
+ ".cd"))) {
|
||||||
CMIItem cm = Jobs.getItemManager().getItem(c.getC().getString("blocksTimer." + one + ".id"));
|
CMIItemStack cm = ItemManager.getItem(c.getC().getString("blocksTimer." + one + ".id"));
|
||||||
if ((cm == null) || (!cm.getMaterial().isBlock())) {
|
if ((cm == null) || (!cm.getCMIType().isBlock())) {
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] Your defined (" + c.getC().getString(new StringBuilder("blocksTimer.").append(one)
|
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] Your defined (" + c.getC().getString(new StringBuilder("blocksTimer.").append(one)
|
||||||
.append(".id").toString()) + ") protected block id/name is not correct!");
|
.append(".id").toString()) + ") protected block id/name is not correct!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,6 +20,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobItems;
|
import com.gamingmesh.jobs.container.JobItems;
|
||||||
@ -123,12 +124,13 @@ public class ShopManager {
|
|||||||
|
|
||||||
for (JobItems one : item.getitems()) {
|
for (JobItems one : item.getitems()) {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
Material mat = Material.getMaterial(one.getId());
|
CMIMaterial mat = CMIMaterial.get(one.getId(), one.getData());
|
||||||
|
|
||||||
if (mat == null)
|
if (mat == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(mat, one.getAmount(), (byte) one.getData());
|
ItemStack itemStack = mat.newItemStack();
|
||||||
|
itemStack.setAmount(one.getAmount());
|
||||||
|
|
||||||
ItemMeta meta = itemStack.getItemMeta();
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
|
|
||||||
@ -238,12 +240,12 @@ public class ShopManager {
|
|||||||
ArrayList<String> Lore = new ArrayList<String>();
|
ArrayList<String> Lore = new ArrayList<String>();
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
Material mat = Material.getMaterial(item.getIconId());
|
CMIMaterial mat = CMIMaterial.get(item.getIconId(), item.getIconData());
|
||||||
|
|
||||||
if (item.isHideWithoutPerm()) {
|
if (item.isHideWithoutPerm()) {
|
||||||
for (String onePerm : item.getRequiredPerm()) {
|
for (String onePerm : item.getRequiredPerm()) {
|
||||||
if (!Perm.hasPermission(player, onePerm)) {
|
if (!Perm.hasPermission(player, onePerm)) {
|
||||||
mat = Material.STONE_BUTTON;
|
mat = CMIMaterial.STONE_BUTTON;
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
|
Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -251,9 +253,10 @@ public class ShopManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mat == null)
|
if (mat == null)
|
||||||
mat = Material.STONE_BUTTON;
|
mat = CMIMaterial.STONE_BUTTON;
|
||||||
|
|
||||||
ItemStack GUIitem = new ItemStack(mat, item.getIconAmount(), (byte) item.getIconData());
|
ItemStack GUIitem = mat.newItemStack();
|
||||||
|
GUIitem.setAmount(item.getIconAmount());
|
||||||
|
|
||||||
ItemMeta meta = GUIitem.getItemMeta();
|
ItemMeta meta = GUIitem.getItemMeta();
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ package com.gamingmesh.jobs.container;
|
|||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
|
|
||||||
public enum ArmorTypes {
|
public enum ArmorTypes {
|
||||||
HELMET(5), CHESTPLATE(6), LEGGINGS(7), BOOTS(8), ELYTRA(6);
|
HELMET(5), CHESTPLATE(6), LEGGINGS(7), BOOTS(8), ELYTRA(6);
|
||||||
|
|
||||||
@ -15,27 +17,27 @@ public enum ArmorTypes {
|
|||||||
if (itemStack == null)
|
if (itemStack == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
switch (itemStack.getType()) {
|
switch (CMIMaterial.get(itemStack)) {
|
||||||
case DIAMOND_HELMET:
|
case DIAMOND_HELMET:
|
||||||
case GOLD_HELMET:
|
case GOLDEN_HELMET:
|
||||||
case IRON_HELMET:
|
case IRON_HELMET:
|
||||||
case CHAINMAIL_HELMET:
|
case CHAINMAIL_HELMET:
|
||||||
case LEATHER_HELMET:
|
case LEATHER_HELMET:
|
||||||
return HELMET;
|
return HELMET;
|
||||||
case DIAMOND_CHESTPLATE:
|
case DIAMOND_CHESTPLATE:
|
||||||
case GOLD_CHESTPLATE:
|
case GOLDEN_CHESTPLATE:
|
||||||
case IRON_CHESTPLATE:
|
case IRON_CHESTPLATE:
|
||||||
case CHAINMAIL_CHESTPLATE:
|
case CHAINMAIL_CHESTPLATE:
|
||||||
case LEATHER_CHESTPLATE:
|
case LEATHER_CHESTPLATE:
|
||||||
return CHESTPLATE;
|
return CHESTPLATE;
|
||||||
case DIAMOND_LEGGINGS:
|
case DIAMOND_LEGGINGS:
|
||||||
case GOLD_LEGGINGS:
|
case GOLDEN_LEGGINGS:
|
||||||
case IRON_LEGGINGS:
|
case IRON_LEGGINGS:
|
||||||
case CHAINMAIL_LEGGINGS:
|
case CHAINMAIL_LEGGINGS:
|
||||||
case LEATHER_LEGGINGS:
|
case LEATHER_LEGGINGS:
|
||||||
return LEGGINGS;
|
return LEGGINGS;
|
||||||
case DIAMOND_BOOTS:
|
case DIAMOND_BOOTS:
|
||||||
case GOLD_BOOTS:
|
case GOLDEN_BOOTS:
|
||||||
case IRON_BOOTS:
|
case IRON_BOOTS:
|
||||||
case CHAINMAIL_BOOTS:
|
case CHAINMAIL_BOOTS:
|
||||||
case LEATHER_BOOTS:
|
case LEATHER_BOOTS:
|
||||||
|
@ -24,13 +24,13 @@ import java.util.List;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
|
|
||||||
public class JobItems {
|
public class JobItems {
|
||||||
private String node;
|
private String node;
|
||||||
@ -63,7 +63,9 @@ public class JobItems {
|
|||||||
|
|
||||||
public ItemStack getItemStack(Player player, Job job) {
|
public ItemStack getItemStack(Player player, Job job) {
|
||||||
try {
|
try {
|
||||||
ItemStack item = new ItemStack(Material.getMaterial(id), amount, (short) data);
|
CMIMaterial cm = CMIMaterial.get(id, data);
|
||||||
|
ItemStack item = cm.newItemStack();
|
||||||
|
item.setAmount(amount);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (this.name != null)
|
if (this.name != null)
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||||
|
@ -148,7 +148,7 @@ public class JobsListener implements Listener {
|
|||||||
if (iih == null || iih.getType() == Material.AIR)
|
if (iih == null || iih.getType() == Material.AIR)
|
||||||
return;
|
return;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
int heldItemId = iih.getTypeId();
|
int heldItemId = iih.getType().getId();
|
||||||
if (heldItemId != Jobs.getGCManager().getSelectionTooldID())
|
if (heldItemId != Jobs.getGCManager().getSelectionTooldID())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -680,7 +680,7 @@ public class JobsListener implements Listener {
|
|||||||
for (JobLimitedItems oneItem : one.getJob().getLimitedItems()) {
|
for (JobLimitedItems oneItem : one.getJob().getLimitedItems()) {
|
||||||
if (one.getLevel() >= oneItem.getLevel())
|
if (one.getLevel() >= oneItem.getLevel())
|
||||||
continue;
|
continue;
|
||||||
if (!isThisItem(oneItem, iih.getTypeId(), name, lore, enchants))
|
if (!isThisItem(oneItem, iih.getType().getId(), name, lore, enchants))
|
||||||
continue;
|
continue;
|
||||||
meinOk = one.getJob().getName();
|
meinOk = one.getJob().getName();
|
||||||
break mein;
|
break mein;
|
||||||
|
@ -20,7 +20,6 @@ package com.gamingmesh.jobs.listeners;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -32,8 +31,8 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Furnace;
|
|
||||||
import org.bukkit.block.BrewingStand;
|
import org.bukkit.block.BrewingStand;
|
||||||
|
import org.bukkit.block.Furnace;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Damageable;
|
import org.bukkit.entity.Damageable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -52,11 +51,11 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.enchantment.EnchantItemEvent;
|
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
||||||
import org.bukkit.event.entity.EntityTameEvent;
|
import org.bukkit.event.entity.EntityTameEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.SlimeSplitEvent;
|
import org.bukkit.event.entity.SlimeSplitEvent;
|
||||||
@ -82,6 +81,7 @@ import org.bukkit.metadata.MetadataValue;
|
|||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.actions.BlockActionInfo;
|
import com.gamingmesh.jobs.actions.BlockActionInfo;
|
||||||
import com.gamingmesh.jobs.actions.CustomKillInfo;
|
import com.gamingmesh.jobs.actions.CustomKillInfo;
|
||||||
import com.gamingmesh.jobs.actions.EnchantActionInfo;
|
import com.gamingmesh.jobs.actions.EnchantActionInfo;
|
||||||
@ -95,7 +95,6 @@ import com.gamingmesh.jobs.container.ExploreRespond;
|
|||||||
import com.gamingmesh.jobs.container.FastPayment;
|
import com.gamingmesh.jobs.container.FastPayment;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
|
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
|
||||||
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling.ownershipFeedback;
|
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling.ownershipFeedback;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
@ -485,7 +484,7 @@ public class JobsPaymentListener implements Listener {
|
|||||||
for (int i = 0; i < sourceItems.length; i++) {
|
for (int i = 0; i < sourceItems.length; i++) {
|
||||||
if (sourceItems[i] == null)
|
if (sourceItems[i] == null)
|
||||||
continue;
|
continue;
|
||||||
int id = sourceItems[i].getTypeId();
|
int id = sourceItems[i].getType().getId();
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
if (id == 351)
|
if (id == 351)
|
||||||
DyeStack.add(sourceItems[i]);
|
DyeStack.add(sourceItems[i]);
|
||||||
@ -605,7 +604,7 @@ public class JobsPaymentListener implements Listener {
|
|||||||
return b == null;
|
return b == null;
|
||||||
else if (b == null)
|
else if (b == null)
|
||||||
return false;
|
return false;
|
||||||
return a.getTypeId() == b.getTypeId() && a.getDurability() == b.getDurability() && Objects.equal(a.getData(), b.getData()) && Objects.equal(a.getEnchantments(), b
|
return a.getType().getId() == b.getType().getId() && a.getDurability() == b.getDurability() && Objects.equal(a.getData(), b.getData()) && Objects.equal(a.getEnchantments(), b
|
||||||
.getEnchantments());
|
.getEnchantments());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1335,7 +1334,7 @@ public class JobsPaymentListener implements Listener {
|
|||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) {
|
if (CMIMaterial.get(block).equals(CMIMaterial.FURNACE) || CMIMaterial.get(block).equals(CMIMaterial.BURNING_FURNACE)) {
|
||||||
|
|
||||||
ownershipFeedback done = FurnaceBrewingHandling.registerFurnaces(event.getPlayer(), block);
|
ownershipFeedback done = FurnaceBrewingHandling.registerFurnaces(event.getPlayer(), block);
|
||||||
if (done.equals(ownershipFeedback.tooMany)) {
|
if (done.equals(ownershipFeedback.tooMany)) {
|
||||||
|
@ -74,9 +74,4 @@ public class v1_10 implements NMS {
|
|||||||
player.getInventory().setItemInHand(item);
|
player.getInventory().setItemInHand(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Block getTargetBlock(Player player, int range) {
|
|
||||||
return player.getTargetBlock((Set<Material>) null, range);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,4 @@ public class v1_11 implements NMS {
|
|||||||
public void setItemInMainHand(Player player, ItemStack item) {
|
public void setItemInMainHand(Player player, ItemStack item) {
|
||||||
player.getInventory().setItemInMainHand(item);
|
player.getInventory().setItemInMainHand(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Block getTargetBlock(Player player, int range) {
|
|
||||||
return player.getTargetBlock((Set<Material>) null, range);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,4 @@ public class v1_12 implements NMS {
|
|||||||
public void setItemInMainHand(Player player, ItemStack item) {
|
public void setItemInMainHand(Player player, ItemStack item) {
|
||||||
player.getInventory().setItemInMainHand(item);
|
player.getInventory().setItemInMainHand(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Block getTargetBlock(Player player, int range) {
|
|
||||||
return player.getTargetBlock((Set<Material>) null, range);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
51
src/main/java/com/gamingmesh/jobs/nmsUtil/v1_13.java
Normal file
51
src/main/java/com/gamingmesh/jobs/nmsUtil/v1_13.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.gamingmesh.jobs.nmsUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.NMS;
|
||||||
|
|
||||||
|
public class v1_13 implements NMS {
|
||||||
|
@Override
|
||||||
|
public List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
|
||||||
|
List<Block> blocks = new ArrayList<Block>();
|
||||||
|
blocks.addAll(event.getBlocks());
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRealType(Entity entity) {
|
||||||
|
switch (entity.getType().name()) {
|
||||||
|
case "WITHER_SKELETON":
|
||||||
|
return "skeletonwither";
|
||||||
|
case "STRAY":
|
||||||
|
return "SkeletonStray";
|
||||||
|
case "ZOMBIE_VILLAGER":
|
||||||
|
return "ZombieVillager";
|
||||||
|
case "HUSK":
|
||||||
|
return "ZombieHusk";
|
||||||
|
case "SKELETON_HORSE":
|
||||||
|
return "HorseSkeleton";
|
||||||
|
case "ZOMBIE_HORSE":
|
||||||
|
return "HorseZombie";
|
||||||
|
case "ELDER_GUARDIAN":
|
||||||
|
return "GuardianElder";
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -63,9 +63,4 @@ public class v1_7 implements NMS {
|
|||||||
player.getInventory().setItemInHand(item);
|
player.getInventory().setItemInHand(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public Block getTargetBlock(Player player, int range) {
|
|
||||||
return player.getTargetBlock((HashSet<Byte>) null, range);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,4 @@ public class v1_8 implements NMS {
|
|||||||
public void setItemInMainHand(Player player, ItemStack item) {
|
public void setItemInMainHand(Player player, ItemStack item) {
|
||||||
player.getInventory().setItemInHand(item);
|
player.getInventory().setItemInHand(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Block getTargetBlock(Player player, int range) {
|
|
||||||
return player.getTargetBlock((Set<Material>) null, range);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,4 @@ public class v1_9 implements NMS {
|
|||||||
public void setItemInMainHand(Player player, ItemStack item) {
|
public void setItemInMainHand(Player player, ItemStack item) {
|
||||||
player.getInventory().setItemInHand(item);
|
player.getInventory().setItemInHand(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Block getTargetBlock(Player player, int range) {
|
|
||||||
return player.getTargetBlock((Set<Material>) null, range);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.config.YmlMaker;
|
import com.gamingmesh.jobs.config.YmlMaker;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||||
@ -246,7 +247,7 @@ public class FurnaceBrewingHandling {
|
|||||||
|
|
||||||
public static ownershipFeedback registerFurnaces(Player player, Block block) {
|
public static ownershipFeedback registerFurnaces(Player player, Block block) {
|
||||||
|
|
||||||
if (block.getType() != Material.FURNACE && block.getType() != Material.BURNING_FURNACE) {
|
if (!CMIMaterial.get(block).equals(CMIMaterial.FURNACE) && !CMIMaterial.get(block).equals(CMIMaterial.BURNING_FURNACE)) {
|
||||||
return ownershipFeedback.invalid;
|
return ownershipFeedback.invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +345,7 @@ public class FurnaceBrewingHandling {
|
|||||||
if (block == null)
|
if (block == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (block.getType() != Material.FURNACE && block.getType() != Material.BURNING_FURNACE) {
|
if (!CMIMaterial.get(block).equals(CMIMaterial.FURNACE) && !CMIMaterial.get(block).equals(CMIMaterial.BURNING_FURNACE)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
||||||
|
@ -12,10 +12,13 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
|
|
||||||
public class GiveItem {
|
public class GiveItem {
|
||||||
public static boolean GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore, HashMap<Enchantment, Integer> hashMap) {
|
public static boolean GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore, HashMap<Enchantment, Integer> hashMap) {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
ItemStack itemStack = new ItemStack(Material.getMaterial(id), qty, (short) meta);
|
ItemStack itemStack = CMIMaterial.get(id, meta).newItemStack();
|
||||||
|
itemStack.setAmount(qty);
|
||||||
ItemMeta ItemMeta = itemStack.getItemMeta();
|
ItemMeta ItemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
if (lore != null) {
|
if (lore != null) {
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
package com.gamingmesh.jobs.stuff;
|
package com.gamingmesh.jobs.stuff;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.util.BlockIterator;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
@ -24,7 +30,7 @@ public class Util {
|
|||||||
public static ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException {
|
public static ItemStack setEntityType(ItemStack is, EntityType type) throws IllegalArgumentException {
|
||||||
boolean useMeta;
|
boolean useMeta;
|
||||||
try {
|
try {
|
||||||
ItemStack testis = new ItemStack(Material.MOB_SPAWNER, 1);
|
ItemStack testis = CMIMaterial.SPAWNER.newItemStack();
|
||||||
ItemMeta meta = testis.getItemMeta();
|
ItemMeta meta = testis.getItemMeta();
|
||||||
useMeta = meta instanceof BlockStateMeta;
|
useMeta = meta instanceof BlockStateMeta;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -62,4 +68,47 @@ public class Util {
|
|||||||
public static HashMap<UUID, String> getJobsEditorMap() {
|
public static HashMap<UUID, String> getJobsEditorMap() {
|
||||||
return jobsEditorMap;
|
return jobsEditorMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Block getTargetBlock(Player player, int distance, boolean ignoreNoneSolids) {
|
||||||
|
return getTargetBlock(player, null, distance, ignoreNoneSolids);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block getTargetBlock(Player player, int distance) {
|
||||||
|
return getTargetBlock(player, null, distance, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block getTargetBlock(Player player, Material lookingFor, int distance) {
|
||||||
|
return getTargetBlock(player, lookingFor, distance, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block getTargetBlock(Player player, Material lookingFor, int distance, boolean ignoreNoneSolids) {
|
||||||
|
if (distance > 15 * 16)
|
||||||
|
distance = 15 * 16;
|
||||||
|
if (distance < 1)
|
||||||
|
distance = 1;
|
||||||
|
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
|
Iterator<Block> itr = new BlockIterator(player, distance);
|
||||||
|
while (itr.hasNext()) {
|
||||||
|
Block block = itr.next();
|
||||||
|
blocks.add(block);
|
||||||
|
if (distance != 0 && blocks.size() > distance) {
|
||||||
|
blocks.remove(0);
|
||||||
|
}
|
||||||
|
Material material = block.getType();
|
||||||
|
|
||||||
|
if (ignoreNoneSolids && !block.getType().isSolid())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (lookingFor == null) {
|
||||||
|
if (!CMIMaterial.AIR.equals(material) && !CMIMaterial.CAVE_AIR.equals(material) && !CMIMaterial.VOID_AIR.equals(material)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (lookingFor.equals(material)) {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !blocks.isEmpty() ? blocks.get(blocks.size() - 1) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,50 +29,67 @@ public class VersionChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum Version {
|
public enum Version {
|
||||||
v1_7_R1(),
|
v1_7_R1(171, "v1_7"),
|
||||||
v1_7_R2(),
|
v1_7_R2(172, "v1_7"),
|
||||||
v1_7_R3(),
|
v1_7_R3(173, "v1_7"),
|
||||||
v1_7_R4(),
|
v1_7_R4(174, "v1_7"),
|
||||||
v1_8_R1(),
|
v1_8_R1(181, "v1_8"),
|
||||||
v1_8_R2(),
|
v1_8_R2(182, "v1_8"),
|
||||||
v1_8_R3(),
|
v1_8_R3(183, "v1_8"),
|
||||||
v1_9_R1(),
|
v1_9_R1(191, "v1_9"),
|
||||||
v1_9_R2(),
|
v1_9_R2(192, "v1_9"),
|
||||||
v1_10_R1(),
|
v1_10_R1(1101, "v1_10"),
|
||||||
v1_11_R1(),
|
v1_11_R1(1111, "v1_11"),
|
||||||
v1_11_R2(),
|
v1_11_R2(1112, "v1_11"),
|
||||||
v1_11_R3(),
|
v1_12_R1(1121, "v1_12"),
|
||||||
v1_12_R1(),
|
v1_12_R2(1122, "v1_12"),
|
||||||
v1_12_R2(),
|
v1_13_R1(1131, "v1_13"),
|
||||||
v1_12_R3(),
|
v1_13_R2(1132, "v1_13"),
|
||||||
v1_13_R1(),
|
v1_14_R1(1141, "v1_14"),
|
||||||
v1_13_R2(),
|
v1_14_R2(1142, "v1_14"),
|
||||||
v1_13_R3();
|
v1_15_R1(1151, "v1_15"),
|
||||||
|
v1_15_R2(1152, "v1_15");
|
||||||
|
|
||||||
private Integer value = null;
|
private Integer value;
|
||||||
private String shortVersion = null;
|
private String shortVersion;
|
||||||
|
|
||||||
|
Version(Integer value, String ShortVersion) {
|
||||||
|
this.value = value;
|
||||||
|
shortVersion = ShortVersion;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getValue() {
|
public Integer getValue() {
|
||||||
if (value == null)
|
return value;
|
||||||
try {
|
|
||||||
value = Integer.valueOf(this.name().replaceAll("[^\\d.]", ""));
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
return this.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getShortVersion() {
|
public String getShortVersion() {
|
||||||
if (shortVersion == null)
|
|
||||||
shortVersion = this.name().split("_R")[0];
|
|
||||||
return shortVersion;
|
return shortVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Version getCurrent() {
|
||||||
|
String[] v = Bukkit.getServer().getClass().getPackage().getName().split("\\.");
|
||||||
|
String vv = v[v.length - 1];
|
||||||
|
for (Version one : values()) {
|
||||||
|
if (one.name().equalsIgnoreCase(vv))
|
||||||
|
return one;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLower(Version version) {
|
||||||
|
return getValue() < version.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isHigher(Version version) {
|
public boolean isHigher(Version version) {
|
||||||
return getValue() > version.getValue();
|
return getValue() > version.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLower(Version version) {
|
public boolean isEqualOrLower(Version version) {
|
||||||
return getValue() < version.getValue();
|
return getValue() <= version.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEqualOrHigher(Version version) {
|
||||||
|
return getValue() >= version.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
name: Jobs
|
name: Jobs
|
||||||
description: Jobs Plugin for the BukkitAPI
|
description: Jobs Plugin for the BukkitAPI
|
||||||
main: com.gamingmesh.jobs.Jobs
|
main: com.gamingmesh.jobs.Jobs
|
||||||
version: 4.5.3
|
version: 4.5.4
|
||||||
|
api-version: 1.13
|
||||||
website: https://www.spigotmc.org/resources/jobs-reborn.4216/
|
website: https://www.spigotmc.org/resources/jobs-reborn.4216/
|
||||||
author: phrstbrn
|
author: phrstbrn
|
||||||
softdepend: [Vault, iConomy, MythicMobs, McMMO, WorldGuard, MyPet]
|
softdepend: [Vault, iConomy, MythicMobs, McMMO, WorldGuard, MyPet]
|
||||||
|
Loading…
Reference in New Issue
Block a user