1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Initial support for 1.16.2

- Added option for block protection to allow continous break payment for ore generators

Closes #886
Closes #885
This commit is contained in:
montlikadani 2020-08-13 17:06:26 +02:00
parent 9a6d657c61
commit c01a56759a
11 changed files with 239 additions and 394 deletions

View File

@ -33,7 +33,6 @@ public class CMIChatColor {
}
}
}
for (float x = 0.0F; x <= 1; x += 0.1) {
for (float z = 0.1F; z <= 1; z += 0.1) {
for (float y = 0; y <= 1; y += 0.03) {
@ -89,7 +88,7 @@ public class CMIChatColor {
public static final CMIChatColor LIGHT_PURPLE = new CMIChatColor("Light_Purple", 'd', 255, 85, 255);
public static final CMIChatColor YELLOW = new CMIChatColor("Yellow", 'e', 255, 255, 85);
public static final CMIChatColor WHITE = new CMIChatColor("White", 'f', 255, 255, 255);
public static final CMIChatColor MAGIC = new CMIChatColor("Obfuscated", 'k', false);
public static final CMIChatColor OBFUSCATED = new CMIChatColor("Obfuscated", 'k', false);
public static final CMIChatColor BOLD = new CMIChatColor("Bold", 'l', false);
public static final CMIChatColor STRIKETHROUGH = new CMIChatColor("Strikethrough", 'm', false);
public static final CMIChatColor UNDERLINE = new CMIChatColor("Underline", 'n', false);
@ -121,9 +120,13 @@ public class CMIChatColor {
this.hex = hex;
this.name = name;
red = Integer.valueOf(this.hex.substring(0, 2), 16);
green = Integer.valueOf(this.hex.substring(2, 4), 16);
blue = Integer.parseInt(this.hex.substring(4, 6), 16);
try {
red = Integer.valueOf(this.hex.substring(0, 2), 16);
green = Integer.valueOf(this.hex.substring(2, 4), 16);
blue = Integer.parseInt(this.hex.substring(4, 6), 16);
} catch (Throwable e) {
this.hex = null;
}
}
public CMIChatColor(String name, char c, Boolean color) {
@ -159,8 +162,9 @@ public class CMIChatColor {
CMIChatColor c1 = CMIChatColor.getColor(CMIChatColor.colorCodePrefix + gradientMatch.group(2).replace("#", "") + CMIChatColor.colorCodeSuffix);
CMIChatColor c2 = CMIChatColor.getColor(CMIChatColor.colorCodePrefix + gradientMatch.group(5).replace("#", "") + CMIChatColor.colorCodeSuffix);
if (c1 == null || c2 == null)
if (c1 == null || c2 == null) {
continue;
}
String gtext = gradientMatch.group(3);
@ -168,12 +172,19 @@ public class CMIChatColor {
String updated = "";
gtext = stripColor(gtext);
for (int i = 0; i < gtext.length(); i++) {
char ch = gtext.charAt(i);
int length = gtext.length();
length = length < 2 ? 2 : length;
CMIChatColor mix = CMIChatColor.mixColors(c1, c2, (i * 100D) / (gtext.length() - 1));
double percent = (i * 100D) / (length - 1);
CMIChatColor mix = CMIChatColor.mixColors(c1, c2, percent);
updated += CMIChatColor.colorCodePrefix + mix.getHex() + CMIChatColor.colorCodeSuffix;
updated += ch;
updated += String.valueOf(ch);
}
if (continuous) {
@ -262,7 +273,6 @@ public class CMIChatColor {
public static String deColorize(String text) {
if (text == null)
return null;
text = CMIChatColor.translate(text);
text = text.replace("§", "&");
@ -509,7 +519,7 @@ public class CMIChatColor {
public Color getRGBColor() {
if (blue < 0)
return null;
return Color.fromBGR(blue, green, red);
return Color.fromRGB(red, green, blue);
}
public String getHex() {

View File

@ -2,6 +2,7 @@ package com.gamingmesh.jobs.CMILib;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.block.CreatureSpawner;
@ -252,6 +253,9 @@ public enum CMIEntityType {
STRIDER(927, "Strider", Arrays.asList("MThhOWFkZjc4MGVjN2RkNDYyNWM5YzA3NzkwNTJlNmExNWE0NTE4NjY2MjM1MTFlNGM4MmU5NjU1NzE0YjNjMSJ9fX0=")),
ZOGLIN(928, "Zoglin", Arrays.asList("ZTY3ZTE4NjAyZTAzMDM1YWQ2ODk2N2NlMDkwMjM1ZDg5OTY2NjNmYjllYTQ3NTc4ZDNhN2ViYmM0MmE1Y2NmOSJ9fX0=")),
// 1.16.2
PIGLIN_BRUTE(929, "Piglin Brute", Arrays.asList("M2UzMDBlOTAyNzM0OWM0OTA3NDk3NDM4YmFjMjllM2E0Yzg3YTg0OGM1MGIzNGMyMTI0MjcyN2I1N2Y0ZTFjZiJ9fX0=")),
// if possible we can remove this string for each texture to save up some space
// eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUv
UNKNOWN(999, "Unknown");
@ -260,6 +264,18 @@ public enum CMIEntityType {
private String name;
private String secondaryName;
EntityType type = null;
public static HashMap<String, ItemStack> cache = new HashMap<>();
static HashMap<String, CMIEntityType> byName = new HashMap<>();
static {
for (CMIEntityType one : CMIEntityType.values()) {
byName.put(one.toString().replace("_", "").toLowerCase(), one);
byName.put(one.getName().replace("_", "").replace(" ", "").toLowerCase(), one);
byName.put(String.valueOf(one.getId()), one);
if (one.secondaryName != null)
byName.put(one.secondaryName.replace("_", "").replace(" ", "").toLowerCase(), one);
}
}
CMIEntityType(int id, String name, List<String> headTextures) {
this(id, name, null, headTextures);
@ -277,11 +293,6 @@ public enum CMIEntityType {
this.id = id;
this.name = name;
this.secondaryName = secondaryName;
for (String one : headTextures) {
String text = one;
if (text.length() < 150)
text = "" + text;
}
}
public int getId() {
@ -293,11 +304,8 @@ public enum CMIEntityType {
}
public static CMIEntityType getById(int id) {
for (CMIEntityType one : CMIEntityType.values()) {
if (one.getId() == id)
return one;
}
return CMIEntityType.PIG;
CMIEntityType ttype = getByName(String.valueOf(id));
return ttype == null ? CMIEntityType.PIG : ttype;
}
public static CMIEntityType getByType(EntityType entity) {
@ -326,96 +334,7 @@ public enum CMIEntityType {
}
public static CMIEntityType getByName(String name) {
String main = name;
String sub = null;
if (name.contains("_")) {
main = name.split("_")[0];
sub = name.split("_")[1];
}
if (name.contains(":")) {
main = name.split(":")[0];
sub = name.split(":")[1];
}
String updated = (main + (sub == null ? "" : sub)).toLowerCase();
String reverse = ((sub == null ? "" : sub) + main).toLowerCase();
CMIEntityType type = null;
Integer id = null;
try {
id = Integer.parseInt(main);
} catch (NumberFormatException e) {
}
for (CMIEntityType one : CMIEntityType.values()) {
if (one.name().replace("_", "").equalsIgnoreCase(updated) || one.name.replace(" ", "").equalsIgnoreCase(updated)) {
type = one;
break;
}
}
if (type == null)
for (CMIEntityType one : CMIEntityType.values()) {
if (one.secondaryName == null)
continue;
String oneN = one.secondaryName;
oneN = oneN.replace("_", "");
if (oneN.equalsIgnoreCase(name)) {
type = one;
break;
}
}
if (type == null)
for (CMIEntityType one : CMIEntityType.values()) {
if (one.name.replace("_", "").contains(updated)) {
type = one;
break;
}
}
if (sub != null) {
if (type == null)
for (CMIEntityType one : CMIEntityType.values()) {
if (one.name().replace("_", "").equalsIgnoreCase(reverse) || one.name.replace(" ", "").equalsIgnoreCase(reverse)) {
type = one;
break;
}
}
if (type == null)
for (CMIEntityType one : CMIEntityType.values()) {
if (one.name.replace("_", "").contains(reverse)) {
type = one;
break;
}
}
}
if (id != null) {
if (type == null)
for (CMIEntityType one : CMIEntityType.values()) {
if (one.getId() == id) {
type = one;
break;
}
}
}
if (type == null)
for (CMIEntityType one : CMIEntityType.values()) {
if (one.name.contains("_"))
continue;
if (one.name.equalsIgnoreCase(main)) {
type = one;
break;
}
}
return type;
return byName.get(name.toLowerCase().replace("_", ""));
}
public EntityType getType() {
@ -431,11 +350,11 @@ public enum CMIEntityType {
}
public boolean isAlive() {
return getType() == null ? false : getType().isAlive();
return getType() != null && getType().isAlive();
}
public boolean isSpawnable() {
return getType() == null ? false : getType().isSpawnable();
return getType() != null && getType().isSpawnable();
}
public static String getRealNameByType(EntityType type) {
@ -452,12 +371,7 @@ public enum CMIEntityType {
}
public CMIMaterial getSpawnEggMaterial() {
CMIMaterial m = CMIMaterial.get((this.equals(CMIEntityType.MUSHROOM_COW) ? "Mooshroom".toLowerCase() : this.toString().toLowerCase()) + "_spawn_egg");
if (m != null && m.isMonsterEgg())
return m;
return null;
return m != null && m.isMonsterEgg() ? m : null;
}
}
}

View File

@ -1000,109 +1000,112 @@ public enum CMIMaterial {
HONEY_BLOCK("Honey Block"),
HONEY_BOTTLE("Honey Bottle"),
//1.16
ANCIENT_DEBRIS("ancient debris"),
BASALT("basalt"),
BLACKSTONE("blackstone"),
BLACKSTONE_SLAB("blackstone slab"),
BLACKSTONE_STAIRS("blackstone stairs"),
BLACKSTONE_WALL("blackstone wall"),
CHAIN("chain"),
CHISELED_NETHER_BRICKS("chiseled nether bricks"),
CHISELED_POLISHED_BLACKSTONE("chiseled polished blackstone"),
CRACKED_NETHER_BRICKS("cracked nether bricks"),
CRACKED_POLISHED_BLACKSTONE_BRICKS("cracked polished blackstone bricks"),
CRIMSON_BUTTON("crimson button"),
CRIMSON_DOOR("crimson door"),
CRIMSON_FENCE("crimson fence"),
CRIMSON_FENCE_GATE("crimson fence gate"),
CRIMSON_FUNGUS("crimson fungus"),
CRIMSON_HYPHAE("crimson hyphae"),
CRIMSON_NYLIUM("crimson nylium"),
CRIMSON_PLANKS("crimson planks"),
CRIMSON_PRESSURE_PLATE("crimson pressure plate"),
CRIMSON_ROOTS("crimson roots"),
CRIMSON_SIGN("crimson sign"),
CRIMSON_SLAB("crimson slab"),
CRIMSON_STAIRS("crimson stairs"),
CRIMSON_STEM("crimson stem"),
CRIMSON_TRAPDOOR("crimson trapdoor"),
CRIMSON_WALL_SIGN("crimson wall sign"),
CRYING_OBSIDIAN("crying obsidian"),
GILDED_BLACKSTONE("gilded blackstone"),
HOGLIN_SPAWN_EGG("hoglin spawn egg"),
LODESTONE("lodestone"),
MUSIC_DISC_PIGSTEP("music disc pigstep"),
NETHERITE_AXE("netherite axe"),
NETHERITE_BLOCK("netherite block"),
NETHERITE_BOOTS("netherite boots"),
NETHERITE_CHESTPLATE("netherite chestplate"),
NETHERITE_HELMET("netherite helmet"),
NETHERITE_HOE("netherite hoe"),
NETHERITE_INGOT("netherite ingot"),
NETHERITE_LEGGINGS("netherite leggings"),
NETHERITE_PICKAXE("netherite pickaxe"),
NETHERITE_SCRAP("netherite scrap"),
NETHERITE_SHOVEL("netherite shovel"),
NETHERITE_SWORD("netherite sword"),
NETHER_GOLD_ORE("nether gold ore"),
NETHER_SPROUTS("nether sprouts"),
PIGLIN_BANNER_PATTERN("piglin banner pattern"),
PIGLIN_SPAWN_EGG("piglin spawn egg"),
POLISHED_BASALT("polished basalt"),
POLISHED_BLACKSTONE("polished blackstone"),
POLISHED_BLACKSTONE_BRICKS("polished blackstone bricks"),
POLISHED_BLACKSTONE_BRICK_SLAB("polished blackstone brick slab"),
POLISHED_BLACKSTONE_BRICK_STAIRS("polished blackstone brick stairs"),
POLISHED_BLACKSTONE_BRICK_WALL("polished blackstone brick wall"),
POLISHED_BLACKSTONE_BUTTON("polished blackstone button"),
POLISHED_BLACKSTONE_PRESSURE_PLATE("polished blackstone pressure plate"),
POLISHED_BLACKSTONE_SLAB("polished blackstone slab"),
POLISHED_BLACKSTONE_STAIRS("polished blackstone stairs"),
POLISHED_BLACKSTONE_WALL("polished blackstone wall"),
POTTED_CRIMSON_FUNGUS("potted crimson fungus"),
POTTED_CRIMSON_ROOTS("potted crimson roots"),
POTTED_WARPED_FUNGUS("potted warped fungus"),
POTTED_WARPED_ROOTS("potted warped roots"),
QUARTZ_BRICKS("quartz bricks"),
RESPAWN_ANCHOR("respawn anchor"),
SHROOMLIGHT("shroomlight"),
SOUL_CAMPFIRE("soul campfire"),
SOUL_FIRE("soul fire"),
SOUL_LANTERN("soul lantern"),
SOUL_SOIL("soul soil"),
SOUL_TORCH("soul torch"),
SOUL_WALL_TORCH("soul wall torch"),
STRIDER_SPAWN_EGG("strider spawn egg"),
STRIPPED_CRIMSON_HYPHAE("stripped crimson hyphae"),
STRIPPED_CRIMSON_STEM("stripped crimson stem"),
STRIPPED_WARPED_HYPHAE("stripped warped hyphae"),
STRIPPED_WARPED_STEM("stripped warped stem"),
TARGET("target"),
TWISTING_VINES("twisting vines"),
TWISTING_VINES_PLANT("twisting vines plant"),
WARPED_BUTTON("warped button"),
WARPED_DOOR("warped door"),
WARPED_FENCE("warped fence"),
WARPED_FENCE_GATE("warped fence gate"),
WARPED_FUNGUS("warped fungus"),
WARPED_FUNGUS_ON_A_STICK("warped fungus on a stick"),
WARPED_HYPHAE("warped hyphae"),
WARPED_NYLIUM("warped nylium"),
WARPED_PLANKS("warped planks"),
WARPED_PRESSURE_PLATE("warped pressure plate"),
WARPED_ROOTS("warped roots"),
WARPED_SIGN("warped sign"),
WARPED_SLAB("warped slab"),
WARPED_STAIRS("warped stairs"),
WARPED_STEM("warped stem"),
WARPED_TRAPDOOR("warped trapdoor"),
WARPED_WALL_SIGN("warped wall sign"),
WARPED_WART_BLOCK("warped wart block"),
WEEPING_VINES("weeping vines"),
WEEPING_VINES_PLANT("weeping vines plant"),
ZOGLIN_SPAWN_EGG("zoglin spawn egg"),
ZOMBIFIED_PIGLIN_SPAWN_EGG("zombified piglin spawn egg"),
//1.16.1
ANCIENT_DEBRIS("Ancient Debris"),
BASALT("Basalt"),
BLACKSTONE("Blackstone"),
BLACKSTONE_SLAB("Blackstone Slab"),
BLACKSTONE_STAIRS("Blackstone Stairs"),
BLACKSTONE_WALL("Blackstone Wall"),
CHAIN("Chain"),
CHISELED_NETHER_BRICKS("Chiseled Nether Bricks"),
CHISELED_POLISHED_BLACKSTONE("Chiseled Polished Blackstone"),
CRACKED_NETHER_BRICKS("Cracked Nether Bricks"),
CRACKED_POLISHED_BLACKSTONE_BRICKS("Cracked Polished Blackstone Bricks"),
CRIMSON_BUTTON("Crimson Button"),
CRIMSON_DOOR("Crimson Door"),
CRIMSON_FENCE("Crimson Fence"),
CRIMSON_FENCE_GATE("Crimson Fence Gate"),
CRIMSON_FUNGUS("Crimson Fungus"),
CRIMSON_HYPHAE("Crimson Hyphae"),
CRIMSON_NYLIUM("Crimson Nylium"),
CRIMSON_PLANKS("Crimson Planks"),
CRIMSON_PRESSURE_PLATE("Crimson Pressure Plate"),
CRIMSON_ROOTS("Crimson Roots"),
CRIMSON_SIGN("Crimson Sign"),
CRIMSON_SLAB("Crimson Slab"),
CRIMSON_STAIRS("Crimson Stairs"),
CRIMSON_STEM("Crimson Stem"),
CRIMSON_TRAPDOOR("Crimson Trapdoor"),
CRIMSON_WALL_SIGN("Crimson Wall Sign"),
CRYING_OBSIDIAN("Crying Obsidian"),
GILDED_BLACKSTONE("Gilded Blackstone"),
HOGLIN_SPAWN_EGG("Hoglin Spawn Egg"),
LODESTONE("Lodestone"),
MUSIC_DISC_PIGSTEP("Music Disc Pigstep"),
NETHERITE_AXE("Netherite Axe"),
NETHERITE_BLOCK("Netherite Block", "netherite"),
NETHERITE_BOOTS("Netherite Boots"),
NETHERITE_CHESTPLATE("Netherite Chestplate"),
NETHERITE_HELMET("Netherite Helmet"),
NETHERITE_HOE("Netherite Hoe"),
NETHERITE_INGOT("Netherite Ingot"),
NETHERITE_LEGGINGS("Netherite Leggings"),
NETHERITE_PICKAXE("Netherite Pickaxe"),
NETHERITE_SCRAP("Netherite Scrap"),
NETHERITE_SHOVEL("Netherite Shovel"),
NETHERITE_SWORD("Netherite Sword"),
NETHER_GOLD_ORE("Nether Gold Ore"),
NETHER_SPROUTS("Nether Sprouts"),
PIGLIN_BANNER_PATTERN("Piglin Banner Pattern"),
PIGLIN_SPAWN_EGG("Piglin Spawn Egg"),
POLISHED_BASALT("Polished Basalt"),
POLISHED_BLACKSTONE("Polished Blackstone"),
POLISHED_BLACKSTONE_BRICKS("Polished Blackstone Bricks"),
POLISHED_BLACKSTONE_BRICK_SLAB("Polished Blackstone Brick Slab"),
POLISHED_BLACKSTONE_BRICK_STAIRS("Polished Blackstone Brick Stairs"),
POLISHED_BLACKSTONE_BRICK_WALL("Polished Blackstone Brick Wall"),
POLISHED_BLACKSTONE_BUTTON("Polished Blackstone Button"),
POLISHED_BLACKSTONE_PRESSURE_PLATE("Polished Blackstone Pressure Plate"),
POLISHED_BLACKSTONE_SLAB("Polished Blackstone Slab"),
POLISHED_BLACKSTONE_STAIRS("Polished Blackstone Stairs"),
POLISHED_BLACKSTONE_WALL("Polished Blackstone Wall"),
POTTED_CRIMSON_FUNGUS("Potted Crimson Fungus"),
POTTED_CRIMSON_ROOTS("Potted Crimson Roots"),
POTTED_WARPED_FUNGUS("Potted Warped Fungus"),
POTTED_WARPED_ROOTS("Potted Warped Roots"),
QUARTZ_BRICKS("Quartz Bricks"),
RESPAWN_ANCHOR("Respawn Anchor"),
SHROOMLIGHT("Shroomlight"),
SOUL_CAMPFIRE("Soul Campfire"),
SOUL_FIRE("Soul Fire"),
SOUL_LANTERN("Soul Lantern"),
SOUL_SOIL("Soul Soil"),
SOUL_TORCH("Soul Torch"),
SOUL_WALL_TORCH("Soul Wall Torch"),
STRIDER_SPAWN_EGG("Strider Spawn Egg"),
STRIPPED_CRIMSON_HYPHAE("Stripped Crimson Hyphae"),
STRIPPED_CRIMSON_STEM("Stripped Crimson Stem"),
STRIPPED_WARPED_HYPHAE("Stripped Warped Hyphae"),
STRIPPED_WARPED_STEM("Stripped Warped Stem"),
TARGET("Target"),
TWISTING_VINES("Twisting Vines"),
TWISTING_VINES_PLANT("Twisting Vines Plant"),
WARPED_BUTTON("Warped Button"),
WARPED_DOOR("Warped Door"),
WARPED_FENCE("Warped Fence"),
WARPED_FENCE_GATE("Warped Fence Gate"),
WARPED_FUNGUS("Warped Fungus"),
WARPED_FUNGUS_ON_A_STICK("Warped Fungus On A Stick"),
WARPED_HYPHAE("Warped Hyphae"),
WARPED_NYLIUM("Warped Nylium"),
WARPED_PLANKS("Warped Planks"),
WARPED_PRESSURE_PLATE("Warped Pressure Plate"),
WARPED_ROOTS("Warped Roots"),
WARPED_SIGN("Warped Sign"),
WARPED_SLAB("Warped Slab"),
WARPED_STAIRS("Warped Stairs"),
WARPED_STEM("Warped Stem"),
WARPED_TRAPDOOR("Warped Trapdoor"),
WARPED_WALL_SIGN("Warped Wall Sign", "Warped Wall"),
WARPED_WART_BLOCK("Warped Wart Block", "Warped Wart"),
WEEPING_VINES("Weeping Vines"),
WEEPING_VINES_PLANT("Weeping Vines Plant"),
ZOGLIN_SPAWN_EGG("Zoglin Spawn Egg"),
ZOMBIFIED_PIGLIN_SPAWN_EGG("Zombified Piglin Spawn Egg"),
// 1.16.2
PIGLIN_BRUTE_SPAWN_EGG("Piglin Brute Spawn Egg"),
// Legacy
LEGACY_STATIONARY_WATER(9, 0, null, "Stationary Water"),
@ -2034,6 +2037,26 @@ public enum CMIMaterial {
return false;
}
public static boolean isPickaxe(Material mat) {
CMIMaterial m = CMIMaterial.get(mat);
return m != null && m.isPickaxe();
}
public boolean isPickaxe() {
switch (this) {
case NETHERITE_PICKAXE:
case DIAMOND_PICKAXE:
case GOLDEN_PICKAXE:
case IRON_PICKAXE:
case STONE_PICKAXE:
case WOODEN_PICKAXE:
return true;
default:
break;
}
return false;
}
public static boolean isValidItem(Material mat) {
CMIMaterial m = CMIMaterial.get(mat);
return m != null && m.isValidItem();
@ -2387,6 +2410,24 @@ public enum CMIMaterial {
case CREEPER_HEAD:
case DRAGON_HEAD:
case ZOMBIE_HEAD:
case LEGACY_SKULL:
return true;
default:
break;
}
return false;
}
public static boolean isPlayerHead(Material mat) {
CMIMaterial m = CMIMaterial.get(mat);
return m != null && m.isPlayerHead();
}
public boolean isPlayerHead() {
switch (this) {
case PLAYER_HEAD:
case LEGACY_SKULL:
case PLAYER_WALL_HEAD:
return true;
default:
break;
@ -2616,7 +2657,7 @@ public enum CMIMaterial {
}
public boolean equals(Material mat) {
return getMaterial() == null ? false : getMaterial() == mat;
return getMaterial() != null && getMaterial() == mat;
}
public List<String> getLegacyNames() {
@ -2658,6 +2699,6 @@ public enum CMIMaterial {
}
public boolean containsCriteria(CMIMaterialCriteria criteria) {
return (this.criteria == null || criteria == null) ? false : this.criteria.contains(criteria);
return this.criteria != null && criteria != null && this.criteria.contains(criteria);
}
}

View File

@ -1,18 +1,20 @@
package com.gamingmesh.jobs.CMILib;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import com.gamingmesh.jobs.container.Potion;
import com.gamingmesh.jobs.stuff.Util;
@SuppressWarnings("deprecation")
public class ItemManager {
static HashMap<Material, CMIMaterial> byRealMaterial = new HashMap<>();
@ -31,9 +33,7 @@ public class ItemManager {
for (CMIMaterial one : CMIMaterial.values()) {
if (one == null)
continue;
one.updateMaterial();
Material mat = one.getMaterial();
if (mat == null) {
continue;
@ -47,34 +47,30 @@ public class ItemManager {
String mojangName = null;
try {
if (Version.isCurrentEqualOrLower(Version.v1_14_R1) || mat.isItem())
mojangName = CMIReflections.getItemMinecraftName(new ItemStack(mat));
mojangName = CMIReflections.getItemMinecraftName(new ItemStack(mat));
} catch (Exception e) {
e.printStackTrace();
}
mojangName = mojangName == null ? mat.toString().replace("_", "").replace(" ", "").toLowerCase()
: mojangName.replace("_", "").replace(" ", "").toLowerCase();
if (one.isCanHavePotionType()) {
for (Potion p : Potion.values()) {
byName.put(cmiName + ":" + p.getName().toLowerCase(), one);
}
} else if (byName.containsKey(cmiName)) {
if (byName.containsKey(cmiName)) {
byName.put(cmiName + ":" + data, one);
} else
byName.put(cmiName, one);
byName.put(materialName, one);
if (!byName.containsKey(cmiName + ":" + data))
byName.put(cmiName + ":" + data, one);
if (byName.containsKey(materialName))
byName.put(materialName + ":" + data, one);
else
byName.put(materialName, one);
if (!one.getLegacyNames().isEmpty()) {
for (String oneL : one.getLegacyNames()) {
String legacyName = oneL.replace("_", "").replace(" ", "").toLowerCase();
if (byName.containsKey(legacyName) || data > 0) {
if (byName.containsKey(legacyName) || data > 0)
byName.put(legacyName + ":" + data, one);
}
byName.put(legacyName, one);
else
byName.put(legacyName, one);
}
}
@ -107,11 +103,11 @@ public class ItemManager {
@Deprecated
public CMIItemStack getItem(Material mat) {
CMIMaterial cmat = CMIMaterial.get(mat);
return (cmat == null || cmat == CMIMaterial.NONE) ? null : new CMIItemStack(cmat);
return cmat == null || cmat == CMIMaterial.NONE ? null : new CMIItemStack(cmat);
}
public static CMIItemStack getItem(CMIMaterial mat) {
return (mat == null || mat == CMIMaterial.NONE) ? null : new CMIItemStack(mat);
return mat == null || mat == CMIMaterial.NONE ? null : new CMIItemStack(mat);
}
public static CMIItemStack getItem(ItemStack item) {
@ -214,7 +210,7 @@ public class ItemManager {
cmat = CMIMaterial.get(name);
}
if (cmat != null && cmat != CMIMaterial.NONE) {
if (cmat != null && !cmat.equals(CMIMaterial.NONE)) {
cm = cmat.newCMIItemStack();
} else
cmat = CMIMaterial.get(subdata == null ? original : original + ":" + subdata);
@ -222,100 +218,6 @@ public class ItemManager {
if (cmat != null && cmat != CMIMaterial.NONE)
cm = cmat.newCMIItemStack();
// main: if (cm == null) {
// cm = byBukkitName.get(name);
// if (subdata != null && cm != null) {
// cm = byBukkitName.get(cm.getCMIType() + ":" + subdata);
// if (cm != null)
// break main;
// }
// cm = byBukkitName.get(name);
//
// if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) {
// if (cm != null && data != -999) {
// CMIMaterial t = CMIMaterial.get(cm.getCMIType().getLegacyId(), data);
// if (t != null) {
// cm = byMaterial.get(t);
// }
// }
// }
//
// if (data != -999) {
// try {
// cm = byId.get(Integer.parseInt(name));
// CMIMaterial t = CMIMaterial.get(original);
// if (t != null) {
// cm = this.byMaterial.get(t);
// }
// } catch (Exception e) {
// }
// }
//
// if (cm == null) {
// try {
// cm = byId.get(Integer.parseInt(name));
// } catch (Exception e) {
// }
//
// if (cm == null) {
// cm = byMojangName.get(name);
// if (cm == null) {
// for (Material one : Material.class.getEnumConstants()) {
// if (one.name().replace("_", "").equalsIgnoreCase(name)) {
// cm = byMaterial.get(CMIMaterial.get(one));
// break;
// }
// }
// if (cm == null) {
// for (CMIMaterial one : CMIMaterial.values()) {
// if (one.getName().replace(" ", "").equalsIgnoreCase(name)) {
// cm = byMaterial.get(one);
// if (cm != null && data == -999) {
// data = one.getData();
// }
// break;
// }
// }
// if (cm == null) {
// for (CMIMaterial one : CMIMaterial.values()) {
// if (one.getName().replace(" ", "").toLowerCase().startsWith(name)) {
// cm = byMaterial.get(one);
// if (cm != null && data == -999) {
// data = one.getData();
// }
// break;
// }
// }
// }
// if (cm == null) {
// for (CMIMaterial one : CMIMaterial.values()) {
// if (one.getName().replace(" ", "").toLowerCase().contains(name)) {
// cm = byMaterial.get(one);
// if (cm != null && data == -999) {
// data = one.getData();
// }
// break;
// }
// }
// }
// if (cm == null) {
// for (Entry<String, CMIItemStack> one : byMojangName.entrySet()) {
// if (one.getKey().contains(name)) {
// cm = one.getValue();
// if (cm != null && data == -999) {
// data = one.getValue().getData();
// }
// break;
// }
// }
// }
// }
// }
//// }
// }
// }
// }
CMIItemStack ncm = null;
if (cm != null)
ncm = cm.clone();
@ -380,31 +282,4 @@ public class ItemManager {
CMIItemStack cm = getItem(name);
return cm == null ? Material.AIR : cm.getType();
}
// public CMIMaterial getRealName(CMIItemStack item) {
// return getRealName(item, false);
// }
//
// public CMIMaterial getRealName(CMIItemStack item, boolean safe) {
//
//// for (CMIMaterial one : CMIMaterial.values()) {
//// if (one.getId() == item.getId() && one.getDataList().contains(item.getData()))
//// return one;
//// }
//// if (safe)
//// for (CMIMaterial one : CMIMaterial.values()) {
//// if (one.getId() == item.getId())
//// return one;
//// }
//// return safe ? CMIMaterial.AIR : null;
// return item.getRealName();
// }
// private static CMIMaterialLegacy proccessItemName(CMIMaterialLegacy one) {
// if (one.getName().contains("[colorNames]"))
// one.setName(one.getName().replace("[colorNames]", colorNames.getById(one.getData()).getName()));
// else if (one.getName().contains("[entityNames]"))
// one.setName(one.getName().replace("[entityNames]", CMIEntityType.getById(one.getData()).getName()));
// return one;
// }
}

View File

@ -116,7 +116,7 @@ public class RawMessage {
options.append("\"italic\":true");
else if (format.equals(CMIChatColor.STRIKETHROUGH))
options.append("\"strikethrough\":true");
else if (format.equals(CMIChatColor.MAGIC))
else if (format.equals(CMIChatColor.OBFUSCATED))
options.append("\"obfuscated\":true");
}
if (!options.toString().isEmpty()) {
@ -149,13 +149,13 @@ public class RawMessage {
oldColors.append("&o");
else if (format.equals(CMIChatColor.STRIKETHROUGH))
oldColors.append("&m");
else if (format.equals(CMIChatColor.MAGIC))
else if (format.equals(CMIChatColor.OBFUSCATED))
oldColors.append("&k");
}
t = oldColors.toString() + t;
}
finalText.append("\"text\":\"" + t + "\"");
finalText.append("\"text\":\"" + escape(t, hover ? false : this.isDontBreakLine()) + "\"");
}
if (finalText.toString().isEmpty())
@ -247,7 +247,6 @@ public class RawMessage {
}
public RawMessage addText(String text) {
// CMIDebug.c(text);
if (text == null || text.isEmpty())
return this;
if (temp.containsKey(RawMessagePartType.Text))
@ -256,7 +255,7 @@ public class RawMessage {
// if (this.isDontBreakLine()) {
onlyText.add(CMIChatColor.translate(text));
text = escape(text, this.isDontBreakLine());
// text = escape(text, this.isDontBreakLine());
// }
text = textIntoJson(text, false);
String f = "";
@ -287,9 +286,8 @@ public class RawMessage {
if (hover == null || hover.isEmpty())
return this;
hover = escape(hover, false);
hover = textIntoJson(hover, true);
// hover = escape(hover, false);
String f = "";
if (hover.isEmpty())
f = "\"text\":\"\"";
@ -306,7 +304,8 @@ public class RawMessage {
return this;
if (!command.startsWith("/"))
command = "/" + command;
String f = "\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + CMIChatColor.deColorize(command) + "\"}";
command = escape(command, true);
String f = "\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + CMIChatColor.deColorize(command).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "\"}";
temp.put(RawMessagePartType.ClickCommand, f);
return this;
}
@ -315,7 +314,7 @@ public class RawMessage {
if (suggestion == null || suggestion.isEmpty())
return this;
suggestion = escape(suggestion, true);
String f = "\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + CMIChatColor.deColorize(suggestion) + "\"}";
String f = "\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + CMIChatColor.deColorize(suggestion).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "\"}";
temp.put(RawMessagePartType.ClickSuggestion, f);
return this;
}
@ -324,7 +323,7 @@ public class RawMessage {
if (insertion == null || insertion.isEmpty())
return this;
insertion = escape(insertion, true);
String f = "\"insertion\":\"" + CMIChatColor.deColorize(insertion) + "\"";
String f = "\"insertion\":\"" + CMIChatColor.deColorize(insertion).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "\"";
temp.put(RawMessagePartType.ClickInsertion, f);
return this;
}
@ -344,7 +343,8 @@ public class RawMessage {
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
url = "http://" + url;
String f = "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}";
String f = "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + CMIChatColor.deColorize(url).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "\"}";
temp.put(RawMessagePartType.ClickLink, f);
return this;
@ -379,7 +379,7 @@ public class RawMessage {
escape(s, sb);
if (escapeNewLn)
return sb.toString().replace(nl, "\\\\n");
return sb.toString().replace(nl, "\n");
return sb.toString().replace(nl, "\\n");
}
private static final String nl = "\u00A5n";
@ -398,11 +398,7 @@ public class RawMessage {
sb.append("\\n");
break;
case '\\':
// if (escapeNewLn) {
sb.append("\\\\");
// } else {
// sb.append("\\");
// }
break;
case '\b':
sb.append("\\b");
@ -547,7 +543,7 @@ public class RawMessage {
if (sender instanceof Player) {
show((Player) sender);
} else {
sender.sendMessage(CMIChatColor.translate(this.combineClean().combinedClean));
sender.sendMessage(this.combineClean().combinedClean);
}
return this;
}

View File

@ -79,9 +79,7 @@ public class TitleMessageManager {
case v1_13_R1:
case v1_13_R2:
case v1_14_R1:
case v1_14_R2:
case v1_15_R1:
case v1_15_R2:
case v1_16_R1:
default:
receivingPacket.sendTitle(t, s, fadeIn, keep, fadeOut);

View File

@ -17,15 +17,22 @@ public enum Version {
v1_12_R1,
v1_13_R1,
v1_13_R2,
v1_13_R3,
v1_14_R1,
v1_14_R2,
v1_15_R1,
v1_15_R2,
v1_16_R1,
v1_16_R2,
v1_17_R1,
v1_17_R2;
v1_17_R2,
v1_18_R1,
v1_18_R2,
v1_19_R1,
v1_19_R2,
v1_20_R1,
v1_20_R2,
v1_21_R1,
v1_21_R2,
v1_22_R1,
v1_22_R2;
private Integer value;
private String shortVersion;

View File

@ -1132,6 +1132,11 @@ public class Jobs extends JavaPlugin {
return true;
if (info.getType() == ActionType.BREAK) {
if (GconfigManager.allowBreakPaymentForOreGenerators) {
getBpManager().remove(block);
return true;
}
if (block.hasMetadata("JobsExploit")) {
//player.sendMessage("This block is protected using Rukes' system!");
return false;

View File

@ -132,9 +132,6 @@ public class SignUtil {
reader = new ConfigReader(f);
} catch (Exception e1) {
e1.printStackTrace();
}
if (reader == null) {
return;
}

View File

@ -101,7 +101,7 @@ public class GeneralConfigManager {
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel,
BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
LoggingUse;
LoggingUse, allowBreakPaymentForOreGenerators;
public ItemStack guiBackButton, guiNextButton, guiFiller;
@ -803,6 +803,10 @@ public class GeneralConfigManager {
BlockProtectionDays = c.get("ExploitProtections.General.KeepDataFor", 14);
BlockProtectionDays = BlockProtectionDays > 14 ? 14 : BlockProtectionDays;
c.addComment("ExploitProtections.General.AllowBreakPaymentForOreGenerators", "It allows you to pay for ore generator plugins continuously"
+ " once you have broken the block in one place.");
allowBreakPaymentForOreGenerators = c.get("ExploitProtections.General.AllowBreakPaymentForOreGenerators", false);
c.addComment("ExploitProtections.General.GlobalBlockTimer", "All blocks will be protected X sec after player places it on ground.");
useGlobalTimer = c.get("ExploitProtections.General.GlobalBlockTimer.use", true);
globalblocktimer = c.get("ExploitProtections.General.GlobalBlockTimer.timer", 3);

View File

@ -33,8 +33,6 @@ import org.bukkit.inventory.ItemStack;
import java.util.*;
import java.util.function.BiPredicate;
import javax.swing.Box.Filler;
public class Job {
private EnumMap<ActionType, List<JobInfo>> jobInfo = new EnumMap<>(ActionType.class);