mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-30 21:07:48 +01:00
Initial transition towards CMILib
This commit is contained in:
parent
da807bef5e
commit
3d429e7cb9
BIN
libs/CMILib1.0.2.2.jar
Normal file
BIN
libs/CMILib1.0.2.2.jar
Normal file
Binary file not shown.
@ -1,392 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMIGUI;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.CmiInventoryType;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.CommandType;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIButtonLocation;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIClickType;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIFieldType;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIRows;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.InvType;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
|
||||
public class CMIGui {
|
||||
|
||||
private InventoryType invType;
|
||||
private GUIRows gUIRows;
|
||||
private Player player;
|
||||
private Inventory inv;
|
||||
private String title;
|
||||
private HashMap<Integer, CMIGuiButton> buttons = new HashMap<Integer, CMIGuiButton>();
|
||||
private LinkedHashSet<CMIGuiButton> noSlotButtons = new LinkedHashSet<CMIGuiButton>();
|
||||
|
||||
private HashMap<InvType, GUIFieldType> lock = new HashMap<InvType, GUIFieldType>();
|
||||
private HashMap<InvType, String> permLock = new HashMap<InvType, String>();
|
||||
|
||||
private CmiInventoryType type = CmiInventoryType.regular;
|
||||
private Object whatShows;
|
||||
|
||||
private boolean allowShift = false;
|
||||
|
||||
public CMIGui() {
|
||||
}
|
||||
|
||||
public CMIGui(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CMIGui clone() {
|
||||
CMIGui g = new CMIGui(player);
|
||||
g.setInvSize(gUIRows);
|
||||
g.setButtons(buttons);
|
||||
g.setInv(inv);
|
||||
g.setInvType(invType);
|
||||
g.setTitle(title);
|
||||
g.setCmiInventoryType(type);
|
||||
g.setWhatShows(whatShows);
|
||||
return g;
|
||||
}
|
||||
|
||||
public boolean isSimilar(CMIGui gui) {
|
||||
|
||||
if (this.getInvSize() != gui.getInvSize())
|
||||
return false;
|
||||
|
||||
if (this.getInvType() != gui.getInvType())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public CMIGui open() {
|
||||
GUIManager.openGui(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIGui update() {
|
||||
GUIManager.softUpdateContent(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public InventoryType getInvType() {
|
||||
if (invType == null)
|
||||
invType = InventoryType.CHEST;
|
||||
return invType;
|
||||
}
|
||||
|
||||
public void setInvType(InventoryType invType) {
|
||||
this.invType = invType;
|
||||
}
|
||||
|
||||
public GUIRows getInvSize() {
|
||||
if (gUIRows == null)
|
||||
autoResize();
|
||||
return gUIRows;
|
||||
}
|
||||
|
||||
public void setInvSize(GUIRows GUIRows) {
|
||||
this.gUIRows = GUIRows;
|
||||
}
|
||||
|
||||
public void setInvSize(int rows) {
|
||||
this.gUIRows = GUIRows.getByRows(rows);
|
||||
}
|
||||
|
||||
public void autoResize() {
|
||||
this.combineButtons();
|
||||
int max = 0;
|
||||
for (Entry<Integer, CMIGuiButton> one : this.buttons.entrySet()) {
|
||||
if (one.getKey() > max)
|
||||
max = one.getKey();
|
||||
}
|
||||
|
||||
if (max < 9) {
|
||||
this.gUIRows = GUIRows.r1;
|
||||
} else if (max < 18) {
|
||||
this.gUIRows = GUIRows.r2;
|
||||
} else if (max < 27) {
|
||||
this.gUIRows = GUIRows.r3;
|
||||
} else if (max < 36) {
|
||||
this.gUIRows = GUIRows.r4;
|
||||
} else if (max < 45) {
|
||||
this.gUIRows = GUIRows.r5;
|
||||
} else {
|
||||
this.gUIRows = GUIRows.r6;
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Inventory getInv() {
|
||||
if (inv == null)
|
||||
GUIManager.generateInventory(this);
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void setInv(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
if (title == null)
|
||||
title = "";
|
||||
return CMIChatColor.translate(title);
|
||||
}
|
||||
|
||||
public void updateTitle(String title) {
|
||||
setTitle(title);
|
||||
// Jobs.getNms().updateInventoryTitle(player, this.title);
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_16_R1)) {
|
||||
if (CMIChatColor.stripColor(title).length() > 64) {
|
||||
title = title.substring(0, 63) + "~";
|
||||
}
|
||||
} else {
|
||||
if (title.length() > 32) {
|
||||
title = title.substring(0, 31) + "~";
|
||||
}
|
||||
}
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<Integer, CMIGuiButton> getButtons() {
|
||||
combineButtons();
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public CMIGui addButton(CMIGuiButton button) {
|
||||
return addButton(button, 54);
|
||||
}
|
||||
|
||||
public CMIGui addButton(CMIGuiButton button, int maxSlot) {
|
||||
if (button.getSlot() != null && buttons.get(button.getSlot()) != null) {
|
||||
for (int ii = button.getSlot(); ii < maxSlot; ii++) {
|
||||
CMIGuiButton b = buttons.get(ii);
|
||||
if (b == null) {
|
||||
buttons.put(ii, button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
if (button.getSlot() == null) {
|
||||
noSlotButtons.add(button);
|
||||
return this;
|
||||
}
|
||||
buttons.put(button.getSlot(), button);
|
||||
setInv(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIGui updateButton(CMIGuiButton button) {
|
||||
buttons.put(button.getSlot(), button);
|
||||
setInv(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void combineButtons() {
|
||||
for (CMIGuiButton button : noSlotButtons) {
|
||||
for (int ii = 0; ii < 54; ii++) {
|
||||
CMIGuiButton b = buttons.get(ii);
|
||||
if (b == null) {
|
||||
buttons.put(ii, button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
noSlotButtons.clear();
|
||||
}
|
||||
|
||||
public void fillEmptyButtons() {
|
||||
combineButtons();
|
||||
for (int i = 0; i < this.getInvSize().getFields(); i++) {
|
||||
if (this.buttons.containsKey(i))
|
||||
continue;
|
||||
addEmptyButton(i);
|
||||
}
|
||||
}
|
||||
|
||||
private CMIMaterial filler = CMIMaterial.BLACK_STAINED_GLASS_PANE;
|
||||
|
||||
public void addEmptyButton(int slot) {
|
||||
ItemStack MiscInfo = filler.newItemStack();
|
||||
if (!CMIMaterial.isAir(MiscInfo.getType())) {
|
||||
ItemMeta MiscInfoMeta = MiscInfo.getItemMeta();
|
||||
if (MiscInfoMeta != null) {
|
||||
MiscInfoMeta.setDisplayName(" ");
|
||||
MiscInfo.setItemMeta(MiscInfoMeta);
|
||||
}
|
||||
}
|
||||
addButton(new CMIGuiButton(slot, GUIFieldType.Locked, MiscInfo));
|
||||
}
|
||||
|
||||
public void setButtons(HashMap<Integer, CMIGuiButton> buttons) {
|
||||
// for (Entry<Integer, CMIGuiButton> one : buttons.entrySet()) {
|
||||
// CMIGuiButton old = this.buttons.get(one.getKey());
|
||||
// if (old == null)
|
||||
// old = one.getValue();
|
||||
// buttons.put(one.getKey(), old);
|
||||
// }
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public boolean isLocked(InvType type) {
|
||||
return lock.containsKey(type) ? (lock.get(type) == GUIFieldType.Locked) : false;
|
||||
}
|
||||
|
||||
public void addLock(InvType type) {
|
||||
addLock(type, GUIFieldType.Locked);
|
||||
}
|
||||
|
||||
public void addLock(InvType type, GUIFieldType lock) {
|
||||
this.lock.put(type, lock);
|
||||
}
|
||||
|
||||
public boolean isPermLocked(InvType type) {
|
||||
return permLock.containsKey(type) ? (!this.player.hasPermission(permLock.get(type))) : true;
|
||||
}
|
||||
|
||||
public void addPermLock(InvType type, String perm) {
|
||||
this.permLock.put(type, perm);
|
||||
}
|
||||
|
||||
public CmiInventoryType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setCmiInventoryType(CmiInventoryType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Object getWhatShows() {
|
||||
return whatShows;
|
||||
}
|
||||
|
||||
public void setWhatShows(Object whatShows) {
|
||||
this.whatShows = whatShows;
|
||||
}
|
||||
|
||||
public Integer getSlot(GUIButtonLocation place) {
|
||||
GUIRows size = this.getInvSize();
|
||||
int v = place.getCollumn() * 9;
|
||||
v = place.getCollumn() > 0 ? v - 1 : v;
|
||||
Integer value = (((place.getRow() * (size.getRows())) * 9) - 8) + v;
|
||||
value = place.getRow() > 0 ? value : value + 9;
|
||||
return value - 1;
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
|
||||
}
|
||||
|
||||
public boolean click(int slot) {
|
||||
return click(slot, null, null);
|
||||
}
|
||||
|
||||
public boolean click(int slot, GUIClickType type, ItemStack currentItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPagination(PageInfo pi, Object cmd, String pagePref) {
|
||||
addPagination(pi, JobsCommands.LABEL + " " + cmd.getClass().getSimpleName(), pagePref);
|
||||
}
|
||||
|
||||
public void addPagination(PageInfo pi, String cmd, String pagePref) {
|
||||
|
||||
if (!cmd.startsWith("/"))
|
||||
cmd = "/" + cmd;
|
||||
// String separator = this.getMsg(LC.info_fliperSimbols);
|
||||
|
||||
int CurrentPage = pi.getCurrentPage();
|
||||
int pageCount = pi.getTotalPages();
|
||||
int totalEntries = pi.getTotalEntries();
|
||||
|
||||
if (pageCount == 1)
|
||||
return;
|
||||
if (this.getInvSize().getRows() < 6)
|
||||
this.setInvSize(GUIRows.r6);
|
||||
|
||||
Integer prevSlot = this.getSlot(GUIButtonLocation.bottomLeft);
|
||||
Integer nextSlot = this.getSlot(GUIButtonLocation.bottomRight);
|
||||
Integer midSlot = this.getSlot(GUIButtonLocation.bottomRight) - 4;
|
||||
|
||||
String pagePrefix = pagePref == null ? "" : pagePref;
|
||||
|
||||
int NextPage = CurrentPage + 1;
|
||||
NextPage = CurrentPage < pageCount ? NextPage : CurrentPage;
|
||||
int Prevpage = CurrentPage - 1;
|
||||
Prevpage = CurrentPage > 1 ? Prevpage : CurrentPage;
|
||||
|
||||
// RawMessage rm = new RawMessage();
|
||||
|
||||
if (pageCount != 0) {
|
||||
|
||||
for (int i = GUIRows.r5.getFields(); i < GUIRows.r6.getFields(); i++) {
|
||||
this.getButtons().remove(i);
|
||||
}
|
||||
|
||||
CMIGuiButton button = new CMIGuiButton(midSlot, CMIMaterial.WHITE_WOOL.newItemStack());
|
||||
button.setName(Jobs.getLanguage().getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount));
|
||||
button.addLore(Jobs.getLanguage().getMessage("pageCountHover", "[totalEntries]", totalEntries));
|
||||
this.addButton(button);
|
||||
|
||||
if (this.getButtons().get(prevSlot) == null && CurrentPage > 1) {
|
||||
button = new CMIGuiButton(prevSlot, CMIMaterial.WHITE_WOOL.newItemStack());
|
||||
button.setName(Jobs.getLanguage().getMessage("command.help.output.prevPageGui"));
|
||||
button.addLore(Jobs.getLanguage().getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount));
|
||||
button.addCommand(cmd + " " + pagePrefix + Prevpage, CommandType.silent);
|
||||
this.addButton(button);
|
||||
}
|
||||
|
||||
if (this.getButtons().get(nextSlot) == null && pageCount > CurrentPage) {
|
||||
button = new CMIGuiButton(nextSlot, CMIMaterial.WHITE_WOOL.newItemStack());
|
||||
button.setName(Jobs.getLanguage().getMessage("command.help.output.nextPageGui"));
|
||||
button.addLore(Jobs.getLanguage().getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount));
|
||||
button.addCommand(cmd + " " + pagePrefix + NextPage, CommandType.silent);
|
||||
this.addButton(button);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAllowShift() {
|
||||
return allowShift;
|
||||
}
|
||||
|
||||
public void setAllowShift(boolean allowShift) {
|
||||
this.allowShift = allowShift;
|
||||
}
|
||||
|
||||
public CMIMaterial getFiller() {
|
||||
return filler;
|
||||
}
|
||||
|
||||
public void setFiller(CMIMaterial filler) {
|
||||
this.filler = filler;
|
||||
}
|
||||
}
|
@ -1,301 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMIGUI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.CommandType;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIClickType;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIFieldType;
|
||||
import com.gamingmesh.jobs.CMILib.CMIItemStack;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
|
||||
public class CMIGuiButton {
|
||||
|
||||
private Integer slot = null;
|
||||
private GUIFieldType fieldType = GUIFieldType.Locked;
|
||||
private boolean closeInv = false;
|
||||
|
||||
private HashMap<GUIClickType, List<GUIButtonCommand>> commandMap = new HashMap<>();
|
||||
|
||||
private List<String> permissions = new ArrayList<String>();
|
||||
private ItemStack item = null;
|
||||
|
||||
@Override
|
||||
public CMIGuiButton clone() {
|
||||
CMIGuiButton b = new CMIGuiButton(slot, fieldType, item);
|
||||
b.setPermissions(new ArrayList<String>(permissions));
|
||||
b.setCommandMap(new HashMap<GUIClickType, List<GUIButtonCommand>>(commandMap));
|
||||
return b;
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, GUIFieldType fieldType, ItemStack item) {
|
||||
this.slot = slot;
|
||||
this.fieldType = fieldType;
|
||||
this.item = item == null ? null : item.clone();
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public CMIGuiButton(ItemStack item) {
|
||||
this.item = item == null ? null : item.clone();
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, CMIItemStack item) {
|
||||
this(slot, item.getItemStack());
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, ItemStack item) {
|
||||
this.slot = slot;
|
||||
this.item = item == null ? null : item.clone();
|
||||
if (this.item != null && this.item.getDurability() == 32767) {
|
||||
CMIMaterial d = CMIMaterial.getRandom(CMIMaterial.get(this.item));
|
||||
if (d != null && d.getLegacyData() != -1)
|
||||
this.item.setDurability((short) d.getLegacyData());
|
||||
}
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, Material material) {
|
||||
this.slot = slot;
|
||||
this.item = new ItemStack(material);
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, CMIMaterial material) {
|
||||
this.slot = slot;
|
||||
this.item = material.newItemStack();
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, Material material, int data) {
|
||||
this(slot, material, data, null);
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, Material material, String name) {
|
||||
this(slot, material, 0, name);
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, CMIMaterial material, String name) {
|
||||
this(slot, material.getMaterial(), material.getLegacyData() != -1 ? material.getLegacyData() : 0, name);
|
||||
}
|
||||
|
||||
public CMIGuiButton(Integer slot, Material material, int data, String name) {
|
||||
this.slot = slot;
|
||||
this.item = new ItemStack(material, 1, (short) data);
|
||||
if (name != null) {
|
||||
ItemMeta meta = this.item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
this.item.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public CMIGuiButton setSlot(Integer slot) {
|
||||
this.slot = slot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GUIFieldType getFieldType() {
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
public CMIGuiButton setFieldType(GUIFieldType fieldType) {
|
||||
this.fieldType = fieldType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIGuiButton lockField() {
|
||||
this.fieldType = GUIFieldType.Locked;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIGuiButton unlockField() {
|
||||
this.fieldType = GUIFieldType.Free;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return this.fieldType.equals(GUIFieldType.Locked);
|
||||
}
|
||||
|
||||
public List<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public CMIGuiButton addPermission(String perm) {
|
||||
this.permissions.add(perm);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setPermissions(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public List<GUIButtonCommand> getCommands(GUIClickType type) {
|
||||
List<GUIButtonCommand> list = commandMap.get(type);
|
||||
if (list == null)
|
||||
list = new ArrayList<GUIButtonCommand>();
|
||||
return list;
|
||||
}
|
||||
|
||||
public CMIGuiButton setName(String name) {
|
||||
if (this.item == null)
|
||||
return this;
|
||||
ItemMeta meta = this.item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
this.item.setItemMeta(meta);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIGuiButton addLore(List<String> l) {
|
||||
l = spreadList(l);
|
||||
for (String one : l) {
|
||||
addLore(one);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> spreadList(List<String> ls) {
|
||||
List<String> s = new ArrayList<String>();
|
||||
for (int i = 0; i < ls.size(); i++) {
|
||||
if (ls.get(i).contains(" \\n")) {
|
||||
s.addAll(Arrays.asList(ls.get(i).split(" \\\\n")));
|
||||
} else
|
||||
s.add(ls.get(i));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public CMIGuiButton addLore(String l) {
|
||||
if (this.item == null)
|
||||
return this;
|
||||
ItemMeta meta = this.item.getItemMeta();
|
||||
if (meta != null) {
|
||||
List<String> lore = meta.getLore();
|
||||
if (lore == null)
|
||||
lore = new ArrayList<String>();
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', l));
|
||||
meta.setLore(lore);
|
||||
this.item.setItemMeta(meta);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIGuiButton addItemName(String name) {
|
||||
if (this.item == null)
|
||||
return this;
|
||||
ItemMeta meta = this.item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
this.item.setItemMeta(meta);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIGuiButton addCommand(String command) {
|
||||
return addCommand(null, command);
|
||||
}
|
||||
|
||||
public CMIGuiButton addCommand(String command, CommandType vis) {
|
||||
return addCommand(null, command, vis);
|
||||
}
|
||||
|
||||
public CMIGuiButton addCommand(GUIClickType type, String command) {
|
||||
return addCommand(type, command, CommandType.gui);
|
||||
}
|
||||
|
||||
public CMIGuiButton addCommand(GUIClickType type, String command, CommandType vis) {
|
||||
if (type == null) {
|
||||
for (GUIClickType one : GUIClickType.values()) {
|
||||
List<GUIButtonCommand> list = commandMap.get(one);
|
||||
if (list == null)
|
||||
list = new ArrayList<GUIButtonCommand>();
|
||||
list.add(new GUIButtonCommand(command, vis));
|
||||
commandMap.put(one, list);
|
||||
}
|
||||
} else {
|
||||
List<GUIButtonCommand> list = commandMap.get(type);
|
||||
if (list == null)
|
||||
list = new ArrayList<GUIButtonCommand>();
|
||||
list.add(new GUIButtonCommand(command, vis));
|
||||
commandMap.put(type, list);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void click() {
|
||||
|
||||
}
|
||||
|
||||
public void click(GUIClickType type) {
|
||||
|
||||
}
|
||||
|
||||
public CMIGuiButton addCommand(Location loc) {
|
||||
if (loc == null)
|
||||
return this;
|
||||
addCommand("cmi tppos " + loc.getWorld().getName() + " " + loc.getX() + " " + loc.getY() + " " + loc.getBlockZ() + " " + loc.getPitch() + " " + loc.getYaw());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return getItem(null);
|
||||
}
|
||||
|
||||
public ItemStack getItem(Player player) {
|
||||
|
||||
if (item != null) {
|
||||
ItemStack i = item.clone();
|
||||
|
||||
if (isLocked()) {
|
||||
i = CMIReflections.setNbt(item, GUIManager.CMIGUIIcon, GUIManager.LIProtection);
|
||||
}
|
||||
|
||||
ItemMeta meta = i.getItemMeta();
|
||||
|
||||
if (player != null) {
|
||||
// if (meta != null && meta.hasDisplayName()) {
|
||||
// meta.setDisplayName(CMI.getInstance().getPlaceholderAPIManager().updatePlaceHolders(player, meta.getDisplayName()));
|
||||
// }
|
||||
//
|
||||
// if (meta != null && meta.hasLore()) {
|
||||
// meta.setLore(CMI.getInstance().getPlaceholderAPIManager().updatePlaceHolders(player, meta.getLore()));
|
||||
// }
|
||||
}
|
||||
i.setItemMeta(meta);
|
||||
return i;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public CMIGuiButton setItem(ItemStack item) {
|
||||
this.item = item == null ? null : item.clone();
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setCommandMap(HashMap<GUIClickType, List<GUIButtonCommand>> commandMap) {
|
||||
this.commandMap = commandMap;
|
||||
}
|
||||
|
||||
public boolean isCloseInv() {
|
||||
return closeInv;
|
||||
}
|
||||
|
||||
public void setCloseInv(boolean closeInv) {
|
||||
this.closeInv = closeInv;
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMIGUI;
|
||||
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.CommandType;
|
||||
|
||||
class GUIButtonCommand {
|
||||
private String command;
|
||||
private CommandType vis = CommandType.gui;
|
||||
|
||||
public GUIButtonCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public GUIButtonCommand(String command, CommandType vis) {
|
||||
this.command = command;
|
||||
this.vis = vis;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public CommandType getCommandType() {
|
||||
return vis;
|
||||
}
|
||||
|
||||
public void setCommandType(CommandType vis) {
|
||||
this.vis = vis;
|
||||
}
|
||||
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMIGUI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
|
||||
public class GUIListener implements Listener {
|
||||
Jobs plugin;
|
||||
|
||||
public GUIListener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onNormalInventoryClose(InventoryCloseEvent event) {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
if (GUIManager.isOpenedGui(player)) {
|
||||
if (GUIManager.removePlayer(player)) {
|
||||
player.updateInventory();
|
||||
clearIconItems(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void clearIconItems(Player player) {
|
||||
for (ItemStack one : player.getInventory().getContents()) {
|
||||
Object res = CMIReflections.getNbt(one, GUIManager.CMIGUIIcon);
|
||||
if (res == null || !(res instanceof String) || !((String) res).equalsIgnoreCase(GUIManager.LIProtection))
|
||||
continue;
|
||||
player.getInventory().remove(one);
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<UUID, Long> LastClick = new HashMap<>();
|
||||
|
||||
private boolean canClickByTimer(UUID uuid) {
|
||||
Long time = LastClick.get(uuid);
|
||||
if (time == null) {
|
||||
LastClick.put(uuid, System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (time + 51 > System.currentTimeMillis()) {
|
||||
LastClick.put(uuid, System.currentTimeMillis());
|
||||
return false;
|
||||
}
|
||||
|
||||
LastClick.put(uuid, System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryClick(final InventoryClickEvent event) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
|
||||
if (!GUIManager.isOpenedGui(player))
|
||||
return;
|
||||
|
||||
CMIGui gui = GUIManager.getGui(player);
|
||||
if (event.getClick() == ClickType.DOUBLE_CLICK || event.getHotbarButton() != -1) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gui.isAllowShift() && event.isShiftClick())
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!event.getAction().equals(InventoryAction.PICKUP_ALL) &&
|
||||
!event.getAction().equals(InventoryAction.PICKUP_ONE) &&
|
||||
!event.getAction().equals(InventoryAction.PICKUP_HALF) &&
|
||||
!event.getAction().equals(InventoryAction.PICKUP_SOME) &&
|
||||
!event.getAction().equals(InventoryAction.PLACE_ALL) &&
|
||||
!event.getAction().equals(InventoryAction.PLACE_ONE) &&
|
||||
!event.getAction().equals(InventoryAction.PLACE_SOME) &&
|
||||
!gui.isAllowShift() && !event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY))
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!canClickByTimer(player.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Integer> buttons = new ArrayList<>();
|
||||
buttons.add(event.getRawSlot());
|
||||
if (!GUIManager.canClick(player, buttons)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (GUIManager.isLockedPart(player, buttons))
|
||||
event.setCancelled(true);
|
||||
|
||||
InventoryAction action = event.getAction();
|
||||
if (!GUIManager.processClick(player, event.getCurrentItem(), buttons, GUIManager.getClickType(event.isLeftClick(), event.isShiftClick(), action))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gui.isAllowShift() && event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) && event.getClickedInventory().getType().equals(InventoryType.PLAYER)) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack item = event.getCurrentItem().clone();
|
||||
|
||||
for (int i = 0; i < gui.getInvSize().getFields(); i++) {
|
||||
CMIGuiButton b = gui.getButtons().get(i);
|
||||
|
||||
if ((b == null || !b.isLocked() && b.getItem() == null) && gui.getInv().getItem(i) == null) {
|
||||
gui.getInv().setItem(i, item);
|
||||
event.setCurrentItem(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryMove(final InventoryDragEvent event) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
|
||||
if (!GUIManager.isOpenedGui(player))
|
||||
return;
|
||||
|
||||
if (!canClickByTimer(player.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Integer> buttons = new ArrayList<>();
|
||||
buttons.addAll(event.getRawSlots());
|
||||
if (!GUIManager.canClick(player, buttons)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (GUIManager.isLockedPart(player, buttons)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!GUIManager.processClick(player, null, buttons, GUIManager.getClickType(true, false, null))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,431 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMIGUI;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
|
||||
public class GUIManager {
|
||||
|
||||
private static HashMap<UUID, CMIGui> map = new HashMap<>();
|
||||
|
||||
public final static String CMIGUIIcon = "CMIGUIIcon";
|
||||
public final static String LIProtection = "LIProtection";
|
||||
|
||||
static {
|
||||
registerListener();
|
||||
}
|
||||
|
||||
public static void registerListener() {
|
||||
Jobs plugin = org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class);
|
||||
plugin.getServer().getPluginManager().registerEvents(new GUIListener(plugin), plugin);
|
||||
}
|
||||
|
||||
public enum GUIButtonLocation {
|
||||
topLeft(0, 0), topRight(0, 1), bottomLeft(1, 0), bottomRight(1, 1);
|
||||
|
||||
private Integer row;
|
||||
private Integer collumn;
|
||||
|
||||
GUIButtonLocation(Integer row, Integer collumn) {
|
||||
this.collumn = collumn;
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
public Integer getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
public Integer getCollumn() {
|
||||
return collumn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum GUIRows {
|
||||
r1(1), r2(2), r3(3), r4(4), r5(5), r6(6);
|
||||
|
||||
private int rows;
|
||||
|
||||
GUIRows(int rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public Integer getFields() {
|
||||
return rows * 9;
|
||||
}
|
||||
|
||||
public Integer getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public static GUIRows getByRows(Integer rows) {
|
||||
if (rows > 9)
|
||||
rows = rows / 9;
|
||||
for (GUIRows one : GUIRows.values()) {
|
||||
if (one.getRows().equals(rows))
|
||||
return one;
|
||||
}
|
||||
return GUIRows.r6;
|
||||
}
|
||||
}
|
||||
|
||||
public enum GUIFieldType {
|
||||
Free, Locked
|
||||
}
|
||||
|
||||
public enum InvType {
|
||||
Gui, Main, Quickbar
|
||||
}
|
||||
|
||||
public enum CmiInventoryType {
|
||||
regular, SavedInv, EditableInv, RecipeCreator, ArmorStandEditor, EntityInventoryEditor, Recipes, SellHand
|
||||
}
|
||||
|
||||
public enum GUIClickType {
|
||||
Left, LeftShift, Right, RightShift, MiddleMouse;
|
||||
|
||||
public boolean isShiftClick() {
|
||||
switch (this) {
|
||||
case Left:
|
||||
case MiddleMouse:
|
||||
case Right:
|
||||
break;
|
||||
case RightShift:
|
||||
case LeftShift:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLeftClick() {
|
||||
switch (this) {
|
||||
case MiddleMouse:
|
||||
case Right:
|
||||
case RightShift:
|
||||
break;
|
||||
case Left:
|
||||
case LeftShift:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRightClick() {
|
||||
switch (this) {
|
||||
case Right:
|
||||
case RightShift:
|
||||
return true;
|
||||
case Left:
|
||||
case LeftShift:
|
||||
case MiddleMouse:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isMiddleClick() {
|
||||
switch (this) {
|
||||
case MiddleMouse:
|
||||
return true;
|
||||
case Right:
|
||||
case RightShift:
|
||||
case Left:
|
||||
case LeftShift:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeAll() {
|
||||
for (Entry<UUID, CMIGui> one : map.entrySet()) {
|
||||
Player player = Bukkit.getPlayer(one.getKey());
|
||||
if (player == null)
|
||||
continue;
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public static GUIClickType getClickType(boolean left, boolean shift, InventoryAction action) {
|
||||
|
||||
if (!left && !shift && (action.equals(InventoryAction.NOTHING) || action.equals(InventoryAction.CLONE_STACK)))
|
||||
return GUIClickType.MiddleMouse;
|
||||
|
||||
if (left && !shift) {
|
||||
return GUIClickType.Left;
|
||||
} else if (left && shift) {
|
||||
return GUIClickType.LeftShift;
|
||||
} else if (!left && !shift) {
|
||||
return GUIClickType.Right;
|
||||
} else {
|
||||
return GUIClickType.RightShift;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean processClick(final Player player, ItemStack currentItem, List<Integer> buttons, final GUIClickType clickType) {
|
||||
CMIGui gui = map.get(player.getUniqueId());
|
||||
if (gui == null)
|
||||
return true;
|
||||
|
||||
for (Integer one : buttons) {
|
||||
|
||||
final CMIGuiButton button = gui.getButtons().get(one);
|
||||
|
||||
if (!gui.click(one, clickType, currentItem))
|
||||
return false;
|
||||
|
||||
if (button == null)
|
||||
continue;
|
||||
boolean canClick = true;
|
||||
for (String oneC : button.getPermissions()) {
|
||||
if (!player.hasPermission(oneC))
|
||||
canClick = false;
|
||||
}
|
||||
|
||||
if (canClick) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (GUIButtonCommand oneC : button.getCommands(clickType)) {
|
||||
performCommand(player, oneC.getCommand(), oneC.getCommandType());
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
button.click();
|
||||
button.click(clickType);
|
||||
|
||||
if (button.isCloseInv())
|
||||
player.closeInventory();
|
||||
|
||||
if (!button.getCommands(clickType).isEmpty())
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performCommand(CommandSender sender, String command, CommandType type) {
|
||||
if (sender instanceof Player) {
|
||||
performCommand((Player) sender, command, type);
|
||||
} else {
|
||||
ServerCommandEvent event = new ServerCommandEvent(sender, command.startsWith("/") ? command : "/" + command);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getCommand().startsWith("/") ? event.getCommand().substring(1, event.getCommand().length()) : event.getCommand());
|
||||
}
|
||||
if (!type.equals(CommandType.silent))
|
||||
Bukkit.getLogger().log(Level.INFO, sender.getName() + " issued " + type.name() + " command: /" + command);
|
||||
}
|
||||
}
|
||||
|
||||
public static void performCommand(Player player, String command, CommandType type) {
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, command.startsWith("/") ? command : "/" + command);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
player.performCommand(event.getMessage().startsWith("/") ? event.getMessage().substring(1, event.getMessage().length()) : event.getMessage());
|
||||
}
|
||||
if (!type.equals(CommandType.silent))
|
||||
Bukkit.getLogger().log(Level.INFO, player.getName() + " issued " + type.name() + " command: /" + command);
|
||||
}
|
||||
|
||||
public enum CommandType {
|
||||
gui, warmup, acmd, rank, silent
|
||||
}
|
||||
|
||||
public static boolean isLockedPart(Player player, List<Integer> buttons) {
|
||||
CMIGui gui = map.get(player.getUniqueId());
|
||||
if (gui == null)
|
||||
return false;
|
||||
|
||||
int size = gui.getInv().getSize();
|
||||
int mainInvMax = size + 36 - 9;
|
||||
int quickbar = size + 36;
|
||||
|
||||
for (Integer one : buttons) {
|
||||
if (one > quickbar || quickbar < 0)
|
||||
continue;
|
||||
if (one < size && (gui.isLocked(InvType.Gui) && gui.isPermLocked(InvType.Gui))) {
|
||||
return true;
|
||||
} else if (one >= size && one < mainInvMax && (gui.isLocked(InvType.Main) && gui.isPermLocked(InvType.Main))) {
|
||||
return true;
|
||||
} else if (one >= mainInvMax && one < quickbar && ((gui.isLocked(InvType.Quickbar) && gui.isPermLocked(InvType.Quickbar)) || (gui.isLocked(InvType.Main) && gui.isPermLocked(InvType.Main)))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canClick(Player player, List<Integer> buttons) {
|
||||
try {
|
||||
CMIGui gui = map.get(player.getUniqueId());
|
||||
if (gui == null)
|
||||
return true;
|
||||
|
||||
for (Integer one : buttons) {
|
||||
CMIGuiButton button = gui.getButtons().get(one);
|
||||
if (button == null)
|
||||
continue;
|
||||
if (button.getFieldType() == GUIFieldType.Locked)
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static CMIGui getGui(Player player) {
|
||||
return map.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static boolean isOpenedGui(Player player) {
|
||||
CMIGui gui = map.get(player.getUniqueId());
|
||||
if (gui == null)
|
||||
return false;
|
||||
if (player.getOpenInventory() == null)
|
||||
return false;
|
||||
// if (!player.getOpenInventory().getTopInventory().equals(gui.getInv()))
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean removePlayer(Player player) {
|
||||
CMIGui removed = map.remove(player.getUniqueId());
|
||||
if (removed == null)
|
||||
return false;
|
||||
|
||||
removed.onClose();
|
||||
|
||||
if (player.getOpenInventory() != null && player.getOpenInventory().getTopInventory().equals(removed.getInv()))
|
||||
player.closeInventory();
|
||||
|
||||
// CMIGUICloseEvent event = new CMIGUICloseEvent(player, removed);
|
||||
// Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void generateInventory(CMIGui gui) {
|
||||
|
||||
Inventory GuiInv = null;
|
||||
if (gui.getInvSize() != null)
|
||||
GuiInv = Bukkit.createInventory(null, gui.getInvSize().getFields(), gui.getTitle());
|
||||
else
|
||||
GuiInv = Bukkit.createInventory(null, gui.getInvType(), gui.getTitle());
|
||||
|
||||
if (GuiInv == null)
|
||||
return;
|
||||
|
||||
for (Entry<Integer, CMIGuiButton> one : gui.getButtons().entrySet()) {
|
||||
if (one.getKey() > GuiInv.getSize())
|
||||
continue;
|
||||
try {
|
||||
ItemStack item = one.getValue().getItem(gui.getPlayer());
|
||||
item = item == null ? null : item.clone();
|
||||
if (item != null && one.getValue().isLocked()) {
|
||||
item = CMIReflections.setNbt(item, CMIGUIIcon, LIProtection);
|
||||
}
|
||||
GuiInv.setItem(one.getKey(), item);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
gui.setInv(GuiInv);
|
||||
}
|
||||
|
||||
// public void updateInventory(CMIGui old, CMIGui gui) {
|
||||
//
|
||||
// Inventory GuiInv = gui.getInv();
|
||||
// if (GuiInv == null)
|
||||
// return;
|
||||
//
|
||||
// plugin.getNMS().updateInventoryTitle(gui.getPlayer(), gui.getTitle());
|
||||
//
|
||||
// for (Entry<Integer, CMIGuiButton> one : gui.getButtons().entrySet()) {
|
||||
// if (one.getKey() > GuiInv.getSize())
|
||||
// continue;
|
||||
// GuiInv.setItem(one.getKey(), one.getValue().getItem());
|
||||
// }
|
||||
// gui.setInv(GuiInv);
|
||||
// }
|
||||
|
||||
public static void openGui(CMIGui gui) {
|
||||
Player player = gui.getPlayer();
|
||||
if (player.isSleeping())
|
||||
return;
|
||||
|
||||
CMIGui oldGui = null;
|
||||
if (isOpenedGui(player)) {
|
||||
oldGui = getGui(player);
|
||||
if (!gui.isSimilar(oldGui)) {
|
||||
oldGui = null;
|
||||
}
|
||||
}
|
||||
if (oldGui == null) {
|
||||
generateInventory(gui);
|
||||
player.closeInventory();
|
||||
player.openInventory(gui.getInv());
|
||||
map.put(player.getUniqueId(), gui);
|
||||
} else {
|
||||
updateContent(gui);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void updateContent(CMIGui gui) {
|
||||
Player player = gui.getPlayer();
|
||||
if (player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
// Jobs.getNms().updateInventoryTitle(player, gui.getTitle());
|
||||
player.getOpenInventory().getTopInventory().setContents(gui.getInv().getContents());
|
||||
gui.setInv(player.getOpenInventory().getTopInventory());
|
||||
map.put(player.getUniqueId(), gui);
|
||||
}
|
||||
|
||||
public static void softUpdateContent(CMIGui gui) {
|
||||
Player player = gui.getPlayer();
|
||||
if (player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
// plugin.getNMS().updateInventoryTitle(player, gui.getTitle());
|
||||
|
||||
for (int i = 0; i < player.getOpenInventory().getTopInventory().getSize(); i++) {
|
||||
CMIGuiButton button = gui.getButtons().get(i);
|
||||
if (button == null)
|
||||
continue;
|
||||
if (!button.isLocked())
|
||||
continue;
|
||||
player.getOpenInventory().getTopInventory().setItem(i, button.getItem(gui.getPlayer()));
|
||||
}
|
||||
gui.setInv(player.getOpenInventory().getTopInventory());
|
||||
map.put(player.getUniqueId(), gui);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ActionBarManager {
|
||||
private static Object packet;
|
||||
private static Method getHandle;
|
||||
private static Method sendPacket;
|
||||
private static Field playerConnection;
|
||||
private static Class<?> nmsChatSerializer;
|
||||
private static Class<?> nmsIChatBaseComponent;
|
||||
private static Class<?> packetType;
|
||||
|
||||
private static Class<?> ChatMessageclz;
|
||||
private static Class<?> sub;
|
||||
private static Object[] consts;
|
||||
|
||||
static {
|
||||
if (Version.isCurrentHigher(Version.v1_7_R4)) {
|
||||
Version version = Version.getCurrent();
|
||||
try {
|
||||
packetType = Class.forName("net.minecraft.server." + version + ".PacketPlayOutChat");
|
||||
Class<?> typeCraftPlayer = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftPlayer");
|
||||
Class<?> typeNMSPlayer = Class.forName("net.minecraft.server." + version + ".EntityPlayer");
|
||||
Class<?> typePlayerConnection = Class.forName("net.minecraft.server." + version + ".PlayerConnection");
|
||||
nmsChatSerializer = Class.forName(getChatSerializerClasspath());
|
||||
nmsIChatBaseComponent = Class.forName("net.minecraft.server." + version + ".IChatBaseComponent");
|
||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName("net.minecraft.server." + version + ".Packet"));
|
||||
if (Version.isCurrentHigher(Version.v1_11_R1)) {
|
||||
ChatMessageclz = Class.forName("net.minecraft.server." + version + ".ChatMessageType");
|
||||
consts = ChatMessageclz.getEnumConstants();
|
||||
sub = consts[2].getClass();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Bukkit.getConsoleSender().sendMessage(ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(CommandSender receivingPacket, String msg) {
|
||||
if (receivingPacket instanceof Player)
|
||||
send((Player) receivingPacket, msg);
|
||||
else
|
||||
receivingPacket.sendMessage(msg);
|
||||
}
|
||||
|
||||
public static void send(Player receivingPacket, String msg) {
|
||||
if (receivingPacket == null || !receivingPacket.isOnline() || msg == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
if (!Version.getCurrent().isHigher(Version.v1_7_R4) || nmsChatSerializer == null) {
|
||||
receivingPacket.sendMessage(CMIChatColor.translate(msg));
|
||||
return;
|
||||
}
|
||||
|
||||
RawMessage rm = new RawMessage().addText(msg);
|
||||
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, CMIChatColor.translate(rm.getRaw()));
|
||||
if (Version.isCurrentHigher(Version.v1_15_R1))
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, sub, UUID.class).newInstance(serialized, consts[2], receivingPacket.getUniqueId());
|
||||
else if (Version.isCurrentHigher(Version.v1_11_R1)) {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, sub).newInstance(serialized, consts[2]);
|
||||
} else if (Version.isCurrentHigher(Version.v1_7_R4)) {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, byte.class).newInstance(serialized, (byte) 2);
|
||||
} else {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, int.class).newInstance(serialized, 2);
|
||||
}
|
||||
Object player = getHandle.invoke(receivingPacket);
|
||||
Object connection = playerConnection.get(player);
|
||||
|
||||
sendPacket.invoke(connection, packet);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getChatSerializerClasspath() {
|
||||
if (!Version.isCurrentHigher(Version.v1_8_R2))
|
||||
return "net.minecraft.server." + Version.getCurrent() + ".ChatSerializer";
|
||||
return "net.minecraft.server." + Version.getCurrent() + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CMIAsyncHead {
|
||||
private boolean head = false;
|
||||
private boolean force = false;
|
||||
|
||||
public void afterAsyncUpdate(ItemStack item) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isAsyncHead() {
|
||||
return head;
|
||||
}
|
||||
|
||||
public void setAsyncHead(boolean head) {
|
||||
this.head = head;
|
||||
}
|
||||
|
||||
public boolean isForce() {
|
||||
return force;
|
||||
}
|
||||
|
||||
public void setForce(boolean force) {
|
||||
this.force = force;
|
||||
}
|
||||
}
|
@ -1,611 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
|
||||
public class CMIChatColor {
|
||||
|
||||
private static final Map<Character, CMIChatColor> BY_CHAR = new HashMap<>();
|
||||
private static final Map<String, CMIChatColor> BY_NAME = new HashMap<>();
|
||||
private static final LinkedHashMap<String, CMIChatColor> CUSTOM_BY_NAME = new LinkedHashMap<>();
|
||||
private static final Map<String, CMIChatColor> CUSTOM_BY_HEX = new HashMap<>();
|
||||
private static final TreeMap<String, CMIChatColor> CUSTOM_BY_RGB = new TreeMap<>();
|
||||
|
||||
static {
|
||||
for (CMICustomColors one : CMICustomColors.values()) {
|
||||
CUSTOM_BY_NAME.put(one.name().toLowerCase().replace("_", ""), new CMIChatColor(one.toString(), one.getHex()));
|
||||
CUSTOM_BY_HEX.put(one.getHex().toLowerCase(), new CMIChatColor(one.toString(), one.getHex()));
|
||||
if (one.getExtra() != null) {
|
||||
for (String extra : one.getExtra()) {
|
||||
CUSTOM_BY_NAME.put(extra.toLowerCase().replace("_", ""), new CMIChatColor(extra.replace(' ', '_'), one.getHex()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
java.awt.Color color = java.awt.Color.getHSBColor(y, x, z);
|
||||
String hex = Integer.toHexString((color.getRed() << 16) + (color.getGreen() << 8) + color.getBlue() & 0xffffff);
|
||||
while (hex.length() < 6) {
|
||||
hex = "0" + hex;
|
||||
}
|
||||
CMIChatColor.getClosest(hex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final static String colorReplacerPlaceholder = "\uFF06";
|
||||
|
||||
public static final String colorFontPrefix = "{@";
|
||||
public static final String colorCodePrefix = "{#";
|
||||
public static final String colorCodeSuffix = "}";
|
||||
|
||||
private static String escape(String text) {
|
||||
return text.replace("#", "\\#").replace("{", "\\{").replace("}", "\\}");
|
||||
}
|
||||
|
||||
public static final String hexColorRegex = "(\\" + colorCodePrefix + ")([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})(\\" + colorCodeSuffix + ")";
|
||||
public static final Pattern hexColorRegexPattern = Pattern.compile(CMIChatColor.hexColorRegex);
|
||||
public static final Pattern hexColorRegexPatternLast = Pattern.compile(CMIChatColor.hexColorRegex + "(?!.*\\{#)");
|
||||
public static final Pattern hexDeColorNamePattern = Pattern.compile("(&x)((&[0-9A-Fa-f]){6})");
|
||||
public static final String ColorNameRegex = "(\\" + colorCodePrefix + ")([a-zA-Z_]{3,})(\\" + colorCodeSuffix + ")";
|
||||
public static final Pattern hexColorNamePattern = Pattern.compile(CMIChatColor.ColorNameRegex);
|
||||
public static final Pattern hexColorNamePatternLast = Pattern.compile(ColorNameRegex + "(?!.*\\{#)");
|
||||
|
||||
public static final String ColorFontRegex = "(\\" + colorFontPrefix + ")([a-zA-Z_]{3,})(\\" + colorCodeSuffix + ")";
|
||||
|
||||
public static final Pattern gradientPattern = Pattern.compile("(\\{(#[^\\{]*?)>\\})(.*?)(\\{(#.*?)<(>?)\\})");
|
||||
|
||||
public static final String hexColorDecolRegex = "(&x)(&[0-9A-Fa-f]){6}";
|
||||
|
||||
public static final Pattern postGradientPattern = Pattern.compile("(" + CMIChatColor.hexColorRegex + "|" + CMIChatColor.ColorNameRegex + ")" + "(.)" + "(" + CMIChatColor.hexColorRegex + "|"
|
||||
+ CMIChatColor.ColorNameRegex + ")");
|
||||
public static final Pattern fullPattern = Pattern.compile("(&[0123456789abcdefklmnorABCDEFKLMNOR])|" + CMIChatColor.hexColorRegex + "|" + CMIChatColor.ColorNameRegex + "|"
|
||||
+ CMIChatColor.ColorFontRegex);
|
||||
|
||||
public static final CMIChatColor BLACK = new CMIChatColor("Black", '0', 0, 0, 0);
|
||||
public static final CMIChatColor DARK_BLUE = new CMIChatColor("Dark_Blue", '1', 0, 0, 170);
|
||||
public static final CMIChatColor DARK_GREEN = new CMIChatColor("Dark_Green", '2', 0, 170, 0);
|
||||
public static final CMIChatColor DARK_AQUA = new CMIChatColor("Dark_Aqua", '3', 0, 170, 170);
|
||||
public static final CMIChatColor DARK_RED = new CMIChatColor("Dark_Red", '4', 170, 0, 0);
|
||||
public static final CMIChatColor DARK_PURPLE = new CMIChatColor("Dark_Purple", '5', 170, 0, 170);
|
||||
public static final CMIChatColor GOLD = new CMIChatColor("Gold", '6', 255, 170, 0);
|
||||
public static final CMIChatColor GRAY = new CMIChatColor("Gray", '7', 170, 170, 170);
|
||||
public static final CMIChatColor DARK_GRAY = new CMIChatColor("Dark_Gray", '8', 85, 85, 85);
|
||||
public static final CMIChatColor BLUE = new CMIChatColor("Blue", '9', 85, 85, 255);
|
||||
public static final CMIChatColor GREEN = new CMIChatColor("Green", 'a', 85, 255, 85);
|
||||
public static final CMIChatColor AQUA = new CMIChatColor("Aqua", 'b', 85, 255, 255);
|
||||
public static final CMIChatColor RED = new CMIChatColor("Red", 'c', 255, 85, 85);
|
||||
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 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);
|
||||
public static final CMIChatColor ITALIC = new CMIChatColor("Italic", 'o', false);
|
||||
public static final CMIChatColor RESET = new CMIChatColor("Reset", 'r', false, true);
|
||||
public static final CMIChatColor HEX = new CMIChatColor("Hex", 'x', false, false);
|
||||
|
||||
private char c;
|
||||
private boolean color = true;
|
||||
private boolean reset = false;
|
||||
private Pattern pattern = null;
|
||||
private int red;
|
||||
private int green;
|
||||
private int blue;
|
||||
private String hex = null;
|
||||
private String name;
|
||||
|
||||
public CMIChatColor(String name, char c, int red, int green, int blue) {
|
||||
this(name, c, true, false, red, green, blue);
|
||||
}
|
||||
|
||||
public CMIChatColor(String hex) {
|
||||
this(null, hex);
|
||||
}
|
||||
|
||||
public CMIChatColor(String name, String hex) {
|
||||
if (hex.startsWith("#"))
|
||||
hex = hex.substring(1);
|
||||
this.hex = hex;
|
||||
this.name = name;
|
||||
|
||||
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) {
|
||||
this(name, c, color, false);
|
||||
}
|
||||
|
||||
public CMIChatColor(String name, char c, Boolean color, Boolean reset) {
|
||||
this(name, c, color, reset, -1, -1, -1);
|
||||
}
|
||||
|
||||
public CMIChatColor(String name, char c, Boolean color, Boolean reset, int red, int green, int blue) {
|
||||
this.name = name;
|
||||
this.c = c;
|
||||
this.color = color;
|
||||
this.reset = reset;
|
||||
this.pattern = Pattern.compile("(?i)(&[" + c + "])");
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
|
||||
if (Version.isCurrentLower(Version.v1_16_R1) && name.equalsIgnoreCase("Hex"))
|
||||
return;
|
||||
BY_CHAR.put(Character.valueOf(c), this);
|
||||
BY_NAME.put(this.getName().toLowerCase().replace("_", ""), this);
|
||||
}
|
||||
|
||||
public static String processGradient(String text) {
|
||||
|
||||
Matcher gradientMatch = gradientPattern.matcher(text);
|
||||
|
||||
while (gradientMatch.find()) {
|
||||
String fullmatch = gradientMatch.group();
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String gtext = gradientMatch.group(3);
|
||||
|
||||
boolean continuous = !gradientMatch.group(6).isEmpty();
|
||||
|
||||
String updated = "";
|
||||
|
||||
gtext = stripColor(gtext);
|
||||
|
||||
if (gtext != null)
|
||||
for (int i = 0; i < gtext.length(); i++) {
|
||||
char ch = gtext.charAt(i);
|
||||
int length = gtext.length();
|
||||
length = length < 2 ? 2 : length;
|
||||
double percent = (i * 100D) / (length - 1);
|
||||
CMIChatColor mix = CMIChatColor.mixColors(c1, c2, percent);
|
||||
updated += CMIChatColor.colorCodePrefix + mix.getHex() + CMIChatColor.colorCodeSuffix;
|
||||
updated += String.valueOf(ch);
|
||||
}
|
||||
|
||||
if (continuous) {
|
||||
updated += CMIChatColor.colorCodePrefix + gradientMatch.group(5).replace("#", "") + ">" + CMIChatColor.colorCodeSuffix;
|
||||
}
|
||||
|
||||
text = text.replace(fullmatch, updated);
|
||||
|
||||
if (continuous) {
|
||||
text = processGradient(text);
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String translate(String text) {
|
||||
|
||||
if (text == null)
|
||||
return null;
|
||||
|
||||
text = processGradient(text);
|
||||
|
||||
if (text.contains(colorCodePrefix)) {
|
||||
|
||||
Matcher match = hexColorRegexPattern.matcher(text);
|
||||
while (match.find()) {
|
||||
String string = match.group();
|
||||
|
||||
StringBuilder magic = new StringBuilder("§x");
|
||||
for (char c : string.substring(2, string.length() - 1).toCharArray()) {
|
||||
magic.append('§').append(c);
|
||||
if (string.substring(2, string.length() - 1).length() == 3)
|
||||
magic.append('§').append(c);
|
||||
}
|
||||
text = text.replace(string, magic.toString());
|
||||
}
|
||||
|
||||
Matcher nameMatch = hexColorNamePattern.matcher(text);
|
||||
while (nameMatch.find()) {
|
||||
String string = nameMatch.group(2);
|
||||
CMIChatColor cn = getByCustomName(string.toLowerCase().replace("_", ""));
|
||||
if (cn == null)
|
||||
continue;
|
||||
String gex = cn.getHex();
|
||||
StringBuilder magic = new StringBuilder("§x");
|
||||
for (char c : gex.toCharArray()) {
|
||||
magic.append('§').append(c);
|
||||
}
|
||||
text = text.replace(nameMatch.group(), magic.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
public static String applyEqualGradient(String text, List<CMIChatColor> gradients) {
|
||||
if (gradients == null || gradients.isEmpty())
|
||||
return text;
|
||||
int size = text.length() / gradients.size();
|
||||
StringBuilder messageWithGradient = new StringBuilder();
|
||||
messageWithGradient.append(gradients.get(0).getFormatedHex(">"));
|
||||
for (int y = 0; y <= gradients.size() - 1; y++) {
|
||||
if (y > 0 && size > 0)
|
||||
messageWithGradient.append(gradients.get(y).getFormatedHex("<>"));
|
||||
for (int i = 0; i < size; i++) {
|
||||
messageWithGradient.append(text.charAt(0));
|
||||
text = text.substring(1);
|
||||
}
|
||||
}
|
||||
messageWithGradient.append(text + gradients.get(gradients.size() - 1).getFormatedHex("<"));
|
||||
return messageWithGradient.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String translateAlternateColorCodes(String text) {
|
||||
return translate(text);
|
||||
}
|
||||
|
||||
public static String colorize(String text) {
|
||||
if (text == null)
|
||||
return null;
|
||||
return translate(text);
|
||||
}
|
||||
|
||||
public static String deColorize(String text) {
|
||||
if (text == null)
|
||||
return null;
|
||||
text = CMIChatColor.translate(text);
|
||||
text = text.replace("§", "&");
|
||||
|
||||
if (text.contains("&x")) {
|
||||
Matcher match = hexDeColorNamePattern.matcher(text);
|
||||
while (match.find()) {
|
||||
String reg = match.group(2).replace("&", "");
|
||||
CMIChatColor custom = CUSTOM_BY_HEX.get(reg.toLowerCase());
|
||||
if (custom != null) {
|
||||
text = text.replace(match.group(), colorCodePrefix + custom.getName().toLowerCase().replace("_", "") + colorCodeSuffix);
|
||||
} else {
|
||||
text = text.replace(match.group(), colorCodePrefix + reg + colorCodeSuffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
public static List<String> deColorize(List<String> lore) {
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
lore.set(i, deColorize(lore.get(i)));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
public static String stripColor(String text) {
|
||||
if (text == null)
|
||||
return null;
|
||||
text = CMIChatColor.translate(text);
|
||||
return ChatColor.stripColor(text);
|
||||
}
|
||||
|
||||
public static String getLastColors(String text) {
|
||||
if (text == null)
|
||||
return null;
|
||||
|
||||
text = deColorize(text);
|
||||
Matcher match = hexColorRegexPatternLast.matcher(text);
|
||||
if (match.find()) {
|
||||
String colorByHex = match.group(0);
|
||||
if (text.endsWith(colorByHex))
|
||||
return colorByHex;
|
||||
String[] split = text.split(escape(colorByHex), 2);
|
||||
if (split == null)
|
||||
return colorByHex;
|
||||
String last = getLastColors(split[1]);
|
||||
return last == null || last.isEmpty() ? colorByHex : last;
|
||||
|
||||
}
|
||||
|
||||
match = hexColorNamePatternLast.matcher(text);
|
||||
if (match.find()) {
|
||||
String colorByName = match.group();
|
||||
if (text.endsWith(colorByName))
|
||||
return colorByName;
|
||||
String[] split = text.split(escape(colorByName), 2);
|
||||
if (split == null)
|
||||
return colorByName;
|
||||
String last = getLastColors(split[1]);
|
||||
return last == null || last.isEmpty() ? colorByName : last;
|
||||
}
|
||||
|
||||
return ChatColor.getLastColors(translate(text));
|
||||
}
|
||||
|
||||
public String getColorCode() {
|
||||
if (hex != null)
|
||||
return colorCodePrefix + hex + colorCodeSuffix;
|
||||
return "&" + c;
|
||||
}
|
||||
|
||||
public String getBukkitColorCode() {
|
||||
if (hex != null)
|
||||
return translate(colorCodePrefix + hex + colorCodeSuffix);
|
||||
return "§" + c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getBukkitColorCode();
|
||||
}
|
||||
|
||||
public char getChar() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public void setChar(char c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public boolean isColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isFormat() {
|
||||
return !color && !reset;
|
||||
}
|
||||
|
||||
public boolean isReset() {
|
||||
return reset;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return ChatColor.getByChar(this.getChar());
|
||||
}
|
||||
|
||||
public static CMIChatColor getColor(String text) {
|
||||
|
||||
if (text == null)
|
||||
return null;
|
||||
|
||||
String or = deColorize(text);
|
||||
|
||||
if (or.contains(colorCodePrefix)) {
|
||||
Matcher match = hexColorRegexPatternLast.matcher(or);
|
||||
if (match.find()) {
|
||||
return new CMIChatColor(match.group(2));
|
||||
}
|
||||
match = hexColorNamePatternLast.matcher(or);
|
||||
if (match.find()) {
|
||||
return CMIChatColor.getByCustomName(match.group(2));
|
||||
}
|
||||
}
|
||||
|
||||
text = deColorize(text).replace("&", "");
|
||||
|
||||
if (text.length() > 1) {
|
||||
String formated = text.toLowerCase().replace("_", "");
|
||||
CMIChatColor got = BY_NAME.get(formated);
|
||||
if (got != null)
|
||||
return got;
|
||||
|
||||
got = CUSTOM_BY_NAME.get(formated);
|
||||
if (got != null)
|
||||
return got;
|
||||
}
|
||||
|
||||
if (or.length() > 1 && String.valueOf(or.charAt(or.length() - 2)).equalsIgnoreCase("&")) {
|
||||
text = text.substring(text.length() - 1, text.length());
|
||||
|
||||
for (Entry<Character, CMIChatColor> one : BY_CHAR.entrySet()) {
|
||||
if (String.valueOf(one.getKey()).equalsIgnoreCase(text)) {
|
||||
return one.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CMIChatColor getRandomColor() {
|
||||
List<CMIChatColor> ls = new ArrayList<>();
|
||||
for (CMIChatColor one : BY_NAME.values()) {
|
||||
if (!one.isColor())
|
||||
continue;
|
||||
ls.add(one);
|
||||
}
|
||||
Collections.shuffle(ls);
|
||||
return ls.get(0);
|
||||
}
|
||||
|
||||
public Pattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public Color getRGBColor() {
|
||||
if (blue < 0)
|
||||
return null;
|
||||
return Color.fromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
public String getHex() {
|
||||
return hex;
|
||||
}
|
||||
|
||||
public String getFormatedHex() {
|
||||
return getFormatedHex(null);
|
||||
}
|
||||
|
||||
public String getFormatedHex(String subSuffix) {
|
||||
return colorCodePrefix + hex + (subSuffix == null ? "" : subSuffix) + colorCodeSuffix;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getCleanName() {
|
||||
return name.replace("_", "");
|
||||
}
|
||||
|
||||
public static CMIChatColor getByCustomName(String name) {
|
||||
if (name.equalsIgnoreCase("random")) {
|
||||
List<CMIChatColor> valuesList = new ArrayList<>(CUSTOM_BY_NAME.values());
|
||||
int randomIndex = new Random().nextInt(valuesList.size());
|
||||
return valuesList.get(randomIndex);
|
||||
}
|
||||
|
||||
return CUSTOM_BY_NAME.get(name.toLowerCase().replace("_", ""));
|
||||
}
|
||||
|
||||
public static CMIChatColor getByHex(String hex) {
|
||||
if (hex.startsWith(colorCodePrefix))
|
||||
hex = hex.substring(colorCodePrefix.length());
|
||||
if (hex.endsWith(colorCodeSuffix))
|
||||
hex = hex.substring(0, hex.length() - colorCodeSuffix.length());
|
||||
return CUSTOM_BY_HEX.get(hex.toLowerCase().replace("_", ""));
|
||||
}
|
||||
|
||||
public static Map<String, CMIChatColor> getByName() {
|
||||
return BY_NAME;
|
||||
}
|
||||
|
||||
public static Map<String, CMIChatColor> getByCustomName() {
|
||||
return CUSTOM_BY_NAME;
|
||||
}
|
||||
|
||||
public static String getHexFromCoord(int x, int y) {
|
||||
x = x < 0 ? 0 : x > 255 ? 255 : x;
|
||||
y = y < 0 ? 0 : y > 255 ? 255 : y;
|
||||
|
||||
int blue = (int) (255 - y * 255 * (1.0 + Math.sin(6.3 * x)) / 2);
|
||||
int green = (int) (255 - y * 255 * (1.0 + Math.cos(6.3 * x)) / 2);
|
||||
int red = (int) (255 - y * 255 * (1.0 - Math.sin(6.3 * x)) / 2);
|
||||
String hex = Integer.toHexString((red << 16) + (green << 8) + blue & 0xffffff);
|
||||
while (hex.length() < 6) {
|
||||
hex = "0" + hex;
|
||||
}
|
||||
return "#" + hex;
|
||||
}
|
||||
|
||||
public static String getHexRedGreenByPercent(int percentage, int parts) {
|
||||
float percent = (percentage * 33F / 100F) / 100F;
|
||||
|
||||
java.awt.Color color = java.awt.Color.getHSBColor(percent, 1, 1);
|
||||
String hex = Integer.toHexString((color.getRed() << 16) + (color.getGreen() << 8) + color.getBlue() & 0xffffff);
|
||||
while (hex.length() < 6) {
|
||||
hex = "0" + hex;
|
||||
}
|
||||
return "#" + hex;
|
||||
}
|
||||
|
||||
public int getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public int getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public int getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
public static CMIChatColor getClosest(String hex) {
|
||||
if (hex.startsWith("#"))
|
||||
hex = hex.substring(1);
|
||||
|
||||
CMIChatColor closest = CUSTOM_BY_RGB.get(hex);
|
||||
if (closest != null)
|
||||
return closest;
|
||||
|
||||
java.awt.Color c2 = null;
|
||||
try {
|
||||
c2 = new java.awt.Color(
|
||||
Integer.valueOf(hex.substring(0, 2), 16),
|
||||
Integer.valueOf(hex.substring(2, 4), 16),
|
||||
Integer.valueOf(hex.substring(4, 6), 16));
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
double distance = Double.MAX_VALUE;
|
||||
for (CMIChatColor one : CUSTOM_BY_HEX.values()) {
|
||||
|
||||
java.awt.Color c1 = new java.awt.Color(
|
||||
Integer.valueOf(one.hex.substring(0, 2), 16),
|
||||
Integer.valueOf(one.hex.substring(2, 4), 16),
|
||||
Integer.valueOf(one.hex.substring(4, 6), 16));
|
||||
|
||||
int red1 = c1.getRed();
|
||||
int red2 = c2.getRed();
|
||||
int rmean = (red1 + red2) >> 1;
|
||||
int r = red1 - red2;
|
||||
int g = c1.getGreen() - c2.getGreen();
|
||||
int b = c1.getBlue() - c2.getBlue();
|
||||
double dist = Math.sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8));
|
||||
if (dist < distance) {
|
||||
closest = one;
|
||||
distance = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (closest != null) {
|
||||
CUSTOM_BY_RGB.put(hex, closest);
|
||||
return closest;
|
||||
}
|
||||
CUSTOM_BY_RGB.put(hex, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CMIChatColor mixColors(CMIChatColor color, double percent) {
|
||||
return mixColors(this, color, percent);
|
||||
}
|
||||
|
||||
public static CMIChatColor mixColors(CMIChatColor color1, CMIChatColor color2, double percent) {
|
||||
percent = percent / 100D;
|
||||
double inverse_percent = 1.0 - percent;
|
||||
int redPart = (int) (color2.getRed() * percent + color1.getRed() * inverse_percent);
|
||||
int greenPart = (int) (color2.getGreen() * percent + color1.getGreen() * inverse_percent);
|
||||
int bluePart = (int) (color2.getBlue() * percent + color1.getBlue() * inverse_percent);
|
||||
String hexCode = String.format("#%02x%02x%02x", redPart, greenPart, bluePart);
|
||||
return new CMIChatColor(hexCode);
|
||||
}
|
||||
|
||||
// public static CMIChatColor getClosest(Long rgb) {
|
||||
//
|
||||
// Entry<Long, customColors> low = CUSTOM_BY_RGB.floorEntry(rgb);
|
||||
// Entry<Long, customColors> high = CUSTOM_BY_RGB.ceilingEntry(rgb);
|
||||
// customColors res = null;
|
||||
// if (low != null && high != null) {
|
||||
// res = Math.abs(rgb - low.getKey()) < Math.abs(rgb - high.getKey()) ? low.getValue() : high.getValue();
|
||||
// } else if (low != null || high != null) {
|
||||
// res = low != null ? low.getValue() : high == null ? null : high.getValue();
|
||||
// }
|
||||
// if (res == null) {
|
||||
// return null;
|
||||
// }
|
||||
// return new CMIChatColor(res.name(), res.hex);
|
||||
// }
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import net.Zrips.CMILib.Container.CMIText;
|
||||
|
||||
public enum CMIEnchantment {
|
||||
|
||||
@ -206,7 +206,7 @@ public enum CMIEnchantment {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return Util.firstToUpperCase(toString());
|
||||
return CMIText.firstToUpperCase(toString());
|
||||
}
|
||||
|
||||
public static String getName(Enchantment enchant) {
|
||||
|
@ -1,377 +0,0 @@
|
||||
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;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
|
||||
public enum CMIEntityType {
|
||||
|
||||
DROPPED_ITEM(1, "Item"),
|
||||
EXPERIENCE_ORB(2, "Experience Orb"),
|
||||
AREA_EFFECT_CLOUD(3, "Area Effect Cloud"),
|
||||
ELDER_GUARDIAN(4, "Elder Guardian", Arrays.asList(
|
||||
"MWM3OTc0ODJhMTRiZmNiODc3MjU3Y2IyY2ZmMWI2ZTZhOGI4NDEzMzM2ZmZiNGMyOWE2MTM5Mjc4YjQzNmIifX19")),
|
||||
WITHER_SKELETON(5, "Wither Skeleton", Arrays.asList(
|
||||
"Nzk1M2I2YzY4NDQ4ZTdlNmI2YmY4ZmIyNzNkNzIwM2FjZDhlMWJlMTllODE0ODFlYWQ1MWY0NWRlNTlhOCJ9fX0=",
|
||||
"NDk2YmM4ZWJkNGUxM2Y0OTZkOGQ3NGM1NjVkZDU2ZTk5YTRhZjJlMmVhN2EyN2E5NmMxYWJkMjg0MTg0YiJ9fX0=",
|
||||
"ZjVlYzk2NDY0NWE4ZWZhYzc2YmUyZjE2MGQ3Yzk5NTYzNjJmMzJiNjUxNzM5MGM1OWMzMDg1MDM0ZjA1MGNmZiJ9fX0=")),
|
||||
STRAY(6, "Stray", Arrays.asList(
|
||||
"NzhkZGY3NmU1NTVkZDVjNGFhOGEwYTVmYzU4NDUyMGNkNjNkNDg5YzI1M2RlOTY5ZjdmMjJmODVhOWEyZDU2In19fQ==")),
|
||||
EGG(7, "Thrown Egg"),
|
||||
LEASH_HITCH(8, "Leash Knot"),
|
||||
PAINTING(9, "Painting"),
|
||||
ARROW(10, "Arrow"),
|
||||
SNOWBALL(11, "Snowball"),
|
||||
FIREBALL(12, "Fireball"),
|
||||
SMALL_FIREBALL(13, "Small Fireball"),
|
||||
ENDER_PEARL(14, "Thrown Ender Pearl"),
|
||||
ENDER_SIGNAL(15, "End Signal"),
|
||||
SPLASH_POTION(16, "Splash Potion"),
|
||||
THROWN_EXP_BOTTLE(17, "Thrown Bottle o' Enchanting"),
|
||||
ITEM_FRAME(18, "Item Frame"),
|
||||
WITHER_SKULL(19, "Wither Skull"),
|
||||
PRIMED_TNT(20, "Primed TNT"),
|
||||
FALLING_BLOCK(21, "Falling Block"),
|
||||
FIREWORK(22, "Firework Rocket"),
|
||||
HUSK(23, "Husk", Arrays.asList(
|
||||
"Nzc3MDY4MWQxYTI1NWZiNGY3NTQ3OTNhYTA1NWIyMjA0NDFjZGFiOWUxMTQxZGZhNTIzN2I0OTkzMWQ5YjkxYyJ9fX0=")),
|
||||
SPECTRAL_ARROW(24, "Spectral Arrow"),
|
||||
SHULKER_BULLET(25, "Shulker Bullet"),
|
||||
DRAGON_FIREBALL(26, "Dragon Fireball"),
|
||||
ZOMBIE_VILLAGER(27, "Zombie Villager", Arrays.asList(
|
||||
"NDRmMDhlYmQ0ZTI1Y2RhM2FkZTQ1Yjg2MzM3OGFkMzc3ZjE4YzUxMGRiNGQyOGU4MmJiMjQ0NTE0MzliMzczNCJ9fX0=",
|
||||
"OTYxZjE5ZmZkOGFlNDI1NzkyYzRiMTgxNzU2YWRmZjhkNDgxNzRhZWVmNThhMGYzMjdhMjhjNzQyYzcyNDQyIn19fQ==",
|
||||
"NTI4YzJiYWQ1Mzg5Y2IzNTkyYjU2NWIzYzQ3ZWNjMTg5ZTA1NDJhODc4MzUwMjhkNjE0OGJiZTMzNDU2NDUifX19",
|
||||
"YTE2MTU1ZmNmMzY2Y2Y0ZTA2Y2U1ZGZmYzQ4Y2E1NGU4ZWE0OGRmZTUyNTM1OGI2MTJkYzQ0ZmQ0MzIifX19",
|
||||
"Y2ZmMDQ4MmZkMzJmYWIyY2U5ZjVmYTJlMmQ5YjRkYzc1NjFkYTQyMjE1MmM5OWZjODA0YjkxMzljYWYyNTZiIn19fQ==",
|
||||
"MzdlODM4Y2NjMjY3NzZhMjE3YzY3ODM4NmY2YTY1NzkxZmU4Y2RhYjhjZTljYTRhYzZiMjgzOTdhNGQ4MWMyMiJ9fX0=")),
|
||||
SKELETON_HORSE(28, "Skeleton Horse", Arrays.asList(
|
||||
"NDdlZmZjZTM1MTMyYzg2ZmY3MmJjYWU3N2RmYmIxZDIyNTg3ZTk0ZGYzY2JjMjU3MGVkMTdjZjg5NzNhIn19fQ==")),
|
||||
ZOMBIE_HORSE(29, "Zombie Horse", Arrays.asList(
|
||||
"ZDIyOTUwZjJkM2VmZGRiMThkZTg2ZjhmNTVhYzUxOGRjZTczZjEyYTZlMGY4NjM2ZDU1MWQ4ZWI0ODBjZWVjIn19fQ==")),
|
||||
ARMOR_STAND(30, "Armor Stand"),
|
||||
DONKEY(31, "Donkey", Arrays.asList(
|
||||
"ZGZiNmMzYzA1MmNmNzg3ZDIzNmEyOTE1ZjgwNzJiNzdjNTQ3NDk3NzE1ZDFkMmY4Y2JjOWQyNDFkODhhIn19fQ==")),
|
||||
MULE(32, "Mule", Arrays.asList(
|
||||
"YTA0ODZhNzQyZTdkZGEwYmFlNjFjZTJmNTVmYTEzNTI3ZjFjM2IzMzRjNTdjMDM0YmI0Y2YxMzJmYjVmNWYifX19")),
|
||||
EVOKER_FANGS(33, "Evoker Fangs"),
|
||||
EVOKER(34, "Evoker", Arrays.asList(
|
||||
"YTAwZDNmZmYxNmMyZGNhNTliOWM1OGYwOTY1MjVjODY5NzExNjZkYmFlMTMzYjFiMDUwZTVlZTcxNjQ0MyJ9fX0=")),
|
||||
VEX(35, "Vex", Arrays.asList(
|
||||
"NWU3MzMwYzdkNWNkOGEwYTU1YWI5ZTk1MzIxNTM1YWM3YWUzMGZlODM3YzM3ZWE5ZTUzYmVhN2JhMmRlODZiIn19fQ==")),
|
||||
VINDICATOR(36, "Vindicator", Arrays.asList(
|
||||
"YTAwZDNmZmYxNmMyZGNhNTliOWM1OGYwOTY1MjVjODY5NzExNjZkYmFlMTMzYjFiMDUwZTVlZTcxNjQ0MyJ9fX0=")),
|
||||
ILLUSIONER(37, "Illusioner", Arrays.asList(
|
||||
"NTEyNTEyZTdkMDE2YTIzNDNhN2JmZjFhNGNkMTUzNTdhYjg1MTU3OWYxMzg5YmQ0ZTNhMjRjYmViODhiIn19fQ==",
|
||||
"MmYyODgyZGQwOTcyM2U0N2MwYWI5NjYzZWFiMDgzZDZhNTk2OTI3MzcwNjExMGM4MjkxMGU2MWJmOGE4ZjA3ZSJ9fX0=")),
|
||||
MINECART_COMMAND(40, "Minecart with Command Block"),
|
||||
BOAT(41, "Boat"),
|
||||
MINECART(42, "Minecart"),
|
||||
MINECART_CHEST(43, "Minecart with Chest"),
|
||||
MINECART_FURNACE(44, "Minecart with Furnace"),
|
||||
MINECART_TNT(45, "Minecart with TNT"),
|
||||
MINECART_HOPPER(46, "Minecart with Hopper"),
|
||||
MINECART_MOB_SPAWNER(47, "Minecart with Spawner"),
|
||||
CREEPER(50, "Creeper", Arrays.asList(
|
||||
"ZjQyNTQ4MzhjMzNlYTIyN2ZmY2EyMjNkZGRhYWJmZTBiMDIxNWY3MGRhNjQ5ZTk0NDQ3N2Y0NDM3MGNhNjk1MiJ9fX0=",
|
||||
"YTNmMTcyZDI5Y2Y5NGJjODk1NjA4YjdhNWRjMmFmMGRlNDljNzg4ZDViZWNiMTYwNWYxZjUzNDg4YTAxNzBiOCJ9fX0=")),
|
||||
SKELETON(51, "Skeleton", Arrays.asList(
|
||||
"MzAxMjY4ZTljNDkyZGExZjBkODgyNzFjYjQ5MmE0YjMwMjM5NWY1MTVhN2JiZjc3ZjRhMjBiOTVmYzAyZWIyIn19fQ==",
|
||||
"Yjk1MDc4ZDNiM2IxNzAxZDQ1NzI5ZDNhMTQyMjQ2N2IyOWRiYjJlMWE5MTI4MTMzYTJmMTYzZWJlODVkMmRiOSJ9fX0=")),
|
||||
SPIDER(52, "Spider", Arrays.asList(
|
||||
"Y2Q1NDE1NDFkYWFmZjUwODk2Y2QyNThiZGJkZDRjZjgwYzNiYTgxNjczNTcyNjA3OGJmZTM5MzkyN2U1N2YxIn19fQ==")),
|
||||
GIANT(53, "Giant"),
|
||||
ZOMBIE(54, "Zombie", Arrays.asList(
|
||||
"NTZmYzg1NGJiODRjZjRiNzY5NzI5Nzk3M2UwMmI3OWJjMTA2OTg0NjBiNTFhNjM5YzYwZTVlNDE3NzM0ZTExIn19fQ==",
|
||||
"MzExZGQ5MWVlNGQzMWRkZDU5MWQyODMyZWExZWMwODBmMmVkZWQzM2FiODllZTFkYjhiMDRiMjZhNjhhIn19fQ==")),
|
||||
SLIME(55, "Slime", Arrays.asList(
|
||||
"MTZhZDIwZmMyZDU3OWJlMjUwZDNkYjY1OWM4MzJkYTJiNDc4YTczYTY5OGI3ZWExMGQxOGM5MTYyZTRkOWI1In19fQ==")),
|
||||
GHAST(56, "Ghast", Arrays.asList(
|
||||
"OGI2YTcyMTM4ZDY5ZmJiZDJmZWEzZmEyNTFjYWJkODcxNTJlNGYxYzk3ZTVmOTg2YmY2ODU1NzFkYjNjYzAifX19")),
|
||||
PIG_ZOMBIE(57, "Zombie Pigman", Arrays.asList(
|
||||
"NzRlOWM2ZTk4NTgyZmZkOGZmOGZlYjMzMjJjZDE4NDljNDNmYjE2YjE1OGFiYjExY2E3YjQyZWRhNzc0M2ViIn19fQ==")),
|
||||
ENDERMAN(58, "Enderman", Arrays.asList(
|
||||
"N2E1OWJiMGE3YTMyOTY1YjNkOTBkOGVhZmE4OTlkMTgzNWY0MjQ1MDllYWRkNGU2YjcwOWFkYTUwYjljZiJ9fX0=")),
|
||||
CAVE_SPIDER(59, "Cave Spider", Arrays.asList(
|
||||
"NDE2NDVkZmQ3N2QwOTkyMzEwN2IzNDk2ZTk0ZWViNWMzMDMyOWY5N2VmYzk2ZWQ3NmUyMjZlOTgyMjQifX19")),
|
||||
SILVERFISH(60, "Silverfish", Arrays.asList(
|
||||
"ZGE5MWRhYjgzOTFhZjVmZGE1NGFjZDJjMGIxOGZiZDgxOWI4NjVlMWE4ZjFkNjIzODEzZmE3NjFlOTI0NTQwIn19fQ==")),
|
||||
BLAZE(61, "Blaze", Arrays.asList(
|
||||
"Yjc4ZWYyZTRjZjJjNDFhMmQxNGJmZGU5Y2FmZjEwMjE5ZjViMWJmNWIzNWE0OWViNTFjNjQ2Nzg4MmNiNWYwIn19fQ==")),
|
||||
MAGMA_CUBE(62, "Magma Cube", Arrays.asList(
|
||||
"Mzg5NTdkNTAyM2M5MzdjNGM0MWFhMjQxMmQ0MzQxMGJkYTIzY2Y3OWE5ZjZhYjM2Yjc2ZmVmMmQ3YzQyOSJ9fX0=")),
|
||||
ENDER_DRAGON(63, "Ender Dragon"),
|
||||
WITHER(64, "Wither", Arrays.asList(
|
||||
"ZGRhZmIyM2VmYzU3ZjI1MTg3OGU1MzI4ZDExY2IwZWVmODdiNzljODdiMjU0YTdlYzcyMjk2ZjkzNjNlZjdjIn19fQ==",
|
||||
"M2U0ZjQ5NTM1YTI3NmFhY2M0ZGM4NDEzM2JmZTgxYmU1ZjJhNDc5OWE0YzA0ZDlhNGRkYjcyZDgxOWVjMmIyYiJ9fX0=",
|
||||
"OTY0ZTFjM2UzMTVjOGQ4ZmZmYzM3OTg1YjY2ODFjNWJkMTZhNmY5N2ZmZDA3MTk5ZThhMDVlZmJlZjEwMzc5MyJ9fX0=",
|
||||
"Y2RmNzRlMzIzZWQ0MTQzNjk2NWY1YzU3ZGRmMjgxNWQ1MzMyZmU5OTllNjhmYmI5ZDZjZjVjOGJkNDEzOWYifX19",
|
||||
"YTQzNTE2NGMwNWNlYTI5OWEzZjAxNmJiYmVkMDU3MDZlYmI3MjBkYWM5MTJjZTQzNTFjMjI5NjYyNmFlY2Q5YSJ9fX0=")),
|
||||
BAT(65, "Bat", Arrays.asList(
|
||||
"NGNmMWIzYjNmNTM5ZDJmNjNjMTcyZTk0Y2FjZmFhMzkxZThiMzg1Y2RkNjMzZjNiOTkxYzc0ZTQ0YjI4In19fQ==")),
|
||||
WITCH(66, "Witch", Arrays.asList(
|
||||
"ODllOGI1ZjE1YTliMjlhMWUzODljOTUyMThmZDM3OTVmMzI4NzJlNWFlZTk0NjRhNzY0OTVjNTI3ZDIyNDUifX19")),
|
||||
ENDERMITE(67, "Endermite", Arrays.asList(
|
||||
"ODRhYWZmYTRjMDllMmVhZmI4NWQzNTIyMTIyZGIwYWE0NTg3NGJlYTRlM2Y1ZTc1NjZiNGQxNjZjN2RmOCJ9fX0=")),
|
||||
GUARDIAN(68, "Guardian", Arrays.asList(
|
||||
"ZGZiNjc1Y2I1YTdlM2ZkMjVlMjlkYTgyNThmMjRmYzAyMGIzZmE5NTAzNjJiOGJjOGViMjUyZTU2ZTc0In19fQ==")),
|
||||
SHULKER(69, "Shulker", Arrays.asList(
|
||||
"MWU3MzgzMmUyNzJmODg0NGM0NzY4NDZiYzQyNGEzNDMyZmI2OThjNThlNmVmMmE5ODcxYzdkMjlhZWVhNyJ9fX0=")),
|
||||
PIG(90, "Pig", Arrays.asList(
|
||||
"NjIxNjY4ZWY3Y2I3OWRkOWMyMmNlM2QxZjNmNGNiNmUyNTU5ODkzYjZkZjRhNDY5NTE0ZTY2N2MxNmFhNCJ9fX0=",
|
||||
"YzNhYmQ0NGFlNjdkOWM5MjU0ZDE3N2U5NjU4ZGE4NDg0MzM4OWQ1ZTFmZmQyYWYxZmI1MTIxN2M3NWMyOTgifX19")),
|
||||
SHEEP(91, "Sheep", Arrays.asList(
|
||||
"MjZhNDExMmRmMWU0YmNlMmE1ZTI4NDE3ZjNhYWZmNzljZDY2ZTg4NWMzNzI0NTU0MTAyY2VmOGViOCJ9fX0=",
|
||||
"ZjMxZjljY2M2YjNlMzJlY2YxM2I4YTExYWMyOWNkMzNkMThjOTVmYzczZGI4YTY2YzVkNjU3Y2NiOGJlNzAifX19",
|
||||
"Y2UxYWM2ODM5OTNiZTM1NTEyZTFiZTMxZDFmNGY5OGU1ODNlZGIxNjU4YTllMjExOTJjOWIyM2I1Y2NjZGMzIn19fQ==",
|
||||
"ODM5YWY0NzdlYjYyNzgxNWY3MjNhNTY2MjU1NmVjOWRmY2JhYjVkNDk0ZDMzOGJkMjE0MjMyZjIzZTQ0NiJ9fX0=",
|
||||
"YWU1Mjg2N2FmZWYzOGJiMTRhMjZkMTQyNmM4YzBmMTE2YWQzNDc2MWFjZDkyZTdhYWUyYzgxOWEwZDU1Yjg1In19fQ==",
|
||||
"MmFjNzRhMmI5YjkxNDUyZTU2ZmExZGRhNWRiODEwNzc4NTZlNDlmMjdjNmUyZGUxZTg0MWU1Yzk1YTZmYzVhYiJ9fX0=",
|
||||
"ZjA5ODM5N2EyNzBiNGMzZDJiMWU1NzRiOGNmZDNjYzRlYTM0MDkwNjZjZWZlMzFlYTk5MzYzM2M5ZDU3NiJ9fX0=",
|
||||
"MTgzNjU2NWM3ODk3ZDQ5YTcxYmMxODk4NmQxZWE2NTYxMzIxYTBiYmY3MTFkNDFhNTZjZTNiYjJjMjE3ZTdhIn19fQ==",
|
||||
"OTJhMjQ0OGY1OGE0OTEzMzI0MzRlODVjNDVkNzg2ZDg3NDM5N2U4MzBhM2E3ODk0ZTZkOTI2OTljNDJiMzAifX19",
|
||||
"MWM4YTk3YTM4ODU2NTE0YTE2NDEzZTJjOTk1MjEyODlmNGM1MzYzZGM4MmZjOWIyODM0Y2ZlZGFjNzhiODkifX19",
|
||||
"YTAxNzIxNWM3ZjhkYjgyMDQwYWEyYzQ3Mjk4YjY2NTQxYzJlYjVmN2Y5MzA0MGE1ZDIzZDg4ZjA2ODdkNGIzNCJ9fX0=",
|
||||
"NDI4N2ViNTAxMzkxZjI3NTM4OWYxNjZlYzlmZWJlYTc1ZWM0YWU5NTFiODhiMzhjYWU4N2RmN2UyNGY0YyJ9fX0=",
|
||||
"NDZmNmM3ZTdmZDUxNGNlMGFjYzY4NTkzMjI5ZTQwZmNjNDM1MmI4NDE2NDZlNGYwZWJjY2NiMGNlMjNkMTYifX19",
|
||||
"YTU1YWQ2ZTVkYjU2OTJkODdmNTE1MTFmNGUwOWIzOWZmOWNjYjNkZTdiNDgxOWE3Mzc4ZmNlODU1M2I4In19fQ==",
|
||||
"ZDllYzIyODE4ZDFmYmZjODE2N2ZiZTM2NzI4YjI4MjQwZTM0ZTE2NDY5YTI5MjlkMDNmZGY1MTFiZjJjYTEifX19",
|
||||
"MzI2NTIwODNmMjhlZDFiNjFmOWI5NjVkZjFhYmYwMTBmMjM0NjgxYzIxNDM1OTUxYzY3ZDg4MzY0NzQ5ODIyIn19fQ==")),
|
||||
COW(92, "Cow", Arrays.asList(
|
||||
"NWQ2YzZlZGE5NDJmN2Y1ZjcxYzMxNjFjNzMwNmY0YWVkMzA3ZDgyODk1ZjlkMmIwN2FiNDUyNTcxOGVkYzUifX19",
|
||||
"YzVhOWNkNThkNGM2N2JjY2M4ZmIxZjVmNzU2YTJkMzgxYzlmZmFjMjkyNGI3ZjRjYjcxYWE5ZmExM2ZiNWMifX19")),
|
||||
CHICKEN(93, "Chicken", Arrays.asList(
|
||||
"MTYzODQ2OWE1OTljZWVmNzIwNzUzNzYwMzI0OGE5YWIxMWZmNTkxZmQzNzhiZWE0NzM1YjM0NmE3ZmFlODkzIn19fQ==")),
|
||||
SQUID(94, "Squid", Arrays.asList(
|
||||
"MDE0MzNiZTI0MjM2NmFmMTI2ZGE0MzRiODczNWRmMWViNWIzY2IyY2VkZTM5MTQ1OTc0ZTljNDgzNjA3YmFjIn19fQ==")),
|
||||
WOLF(95, "Wolf", Arrays.asList(
|
||||
"ZTk1Y2JiNGY3NWVhODc2MTdmMmY3MTNjNmQ0OWRhYzMyMDliYTFiZDRiOTM2OTY1NGIxNDU5ZWExNTMxNyJ9fX0=")),
|
||||
MUSHROOM_COW(96, "Mushroom Cow", "Mooshroom", Arrays.asList(
|
||||
"ZDBiYzYxYjk3NTdhN2I4M2UwM2NkMjUwN2EyMTU3OTEzYzJjZjAxNmU3YzA5NmE0ZDZjZjFmZTFiOGRiIn19fQ==")),
|
||||
SNOWMAN(97, "Snowman", Arrays.asList(
|
||||
"MWZkZmQxZjc1MzhjMDQwMjU4YmU3YTkxNDQ2ZGE4OWVkODQ1Y2M1ZWY3MjhlYjVlNjkwNTQzMzc4ZmNmNCJ9fX0=")),
|
||||
OCELOT(98, "Ocelot", "Cat", Arrays.asList(
|
||||
"YWI4ODFjMzliM2FmZGNjNzlmOTFmZTVkZTNjZGQwMTViYzMzNTM4NDNmNTkxZjRkMjNjZDMwMjdkZTRlNiJ9fX0=",
|
||||
"YTc1NWU3ZGYwNGQxOGIzMWQ2M2MxN2Y0YTdiNGM3MzkyNGJkNjI2NWRhNjllMTEzZWRkZDk3NTE2ZmM3In19fQ==",
|
||||
"ZjJhNjYyZjJhZTdkZWJlZTY1MjkyYzJiZjQyZmJiMDliOTdiMmZmYmRiMjcwNTIwYzJkYjk2ZTUxZDg5NDUifX19",
|
||||
"NTY1N2NkNWMyOTg5ZmY5NzU3MGZlYzRkZGNkYzY5MjZhNjhhMzM5MzI1MGMxYmUxZjBiMTE0YTFkYjEifX19")),
|
||||
IRON_GOLEM(99, "Iron Golem", Arrays.asList(
|
||||
"ODkwOTFkNzllYTBmNTllZjdlZjk0ZDdiYmE2ZTVmMTdmMmY3ZDQ1NzJjNDRmOTBmNzZjNDgxOWE3MTQifX19")),
|
||||
HORSE(100, "Horse", Arrays.asList(
|
||||
"NjE5MDI4OTgzMDg3MzBjNDc0NzI5OWNiNWE1ZGE5YzI1ODM4YjFkMDU5ZmU0NmZjMzY4OTZmZWU2NjI3MjkifX19")),
|
||||
RABBIT(101, "Rabbit", Arrays.asList(
|
||||
"Y2I4Y2ZmNGIxNWI4Y2EzN2UyNTc1MGYzNDU3MThmMjg5Y2IyMmM1YjNhZDIyNjI3YTcxMjIzZmFjY2MifX19",
|
||||
"NzJjNTgxMTZhMTQ3ZDFhOWEyNjI2OTIyNGE4YmUxODRmZThlNWYzZjNkZjliNjE3NTEzNjlhZDg3MzgyZWM5In19fQ==",
|
||||
"Yzk3N2EzMjY2YmYzYjllYWYxN2U1YTAyZWE1ZmJiNDY4MDExNTk4NjNkZDI4OGI5M2U2YzEyYzljYiJ9fX0=")),
|
||||
POLAR_BEAR(102, "Polar Bear", Arrays.asList(
|
||||
"ZDQ2ZDIzZjA0ODQ2MzY5ZmEyYTM3MDJjMTBmNzU5MTAxYWY3YmZlODQxOTk2NjQyOTUzM2NkODFhMTFkMmIifX19")),
|
||||
LLAMA(103, "Llama", Arrays.asList(
|
||||
"ODAyNzdlNmIzZDlmNzgxOWVmYzdkYTRiNDI3NDVmN2FiOWE2M2JhOGYzNmQ2Yjg0YTdhMjUwYzZkMWEzNThlYiJ9fX0=",
|
||||
"Y2YyNGU1NmZkOWZmZDcxMzNkYTZkMWYzZTJmNDU1OTUyYjFkYTQ2MjY4NmY3NTNjNTk3ZWU4MjI5OWEifX19",
|
||||
"YzJiMWVjZmY3N2ZmZTNiNTAzYzMwYTU0OGViMjNhMWEwOGZhMjZmZDY3Y2RmZjM4OTg1NWQ3NDkyMTM2OCJ9fX0=",
|
||||
"NGQ2N2ZkNGJmZjI5MzI2OWNiOTA4OTc0ZGNhODNjMzM0ODVlNDM1ZWQ1YThlMWRiZDY1MjFjNjE2ODcxNDAifX19")),
|
||||
LLAMA_SPIT(104, "Llama Spit"),
|
||||
PARROT(105, "Parrot", Arrays.asList(
|
||||
"YTRiYThkNjZmZWNiMTk5MmU5NGI4Njg3ZDZhYjRhNTMyMGFiNzU5NGFjMTk0YTI2MTVlZDRkZjgxOGVkYmMzIn19fQ==",
|
||||
"Yjc4ZTFjNWY0OGE3ZTEyYjI2Mjg1MzU3MWVmMWY1OTdhOTJlZjU4ZGE4ZmFhZmUwN2JiN2MwZTY5ZTkzIn19fQ==",
|
||||
"YWI5YTM2YzU1ODlmM2EyZTU5YzFjYWE5YjNiODhmYWRhNzY3MzJiZGI0YTc5MjYzODhhOGMwODhiYmJjYiJ9fX0=",
|
||||
"M2Q2ZjRhMjFlMGQ2MmFmODI0Zjg3MDhhYzYzNDEwZjFhMDFiYmI0MWQ3ZjRhNzAyZDk0NjljNjExMzIyMiJ9fX0=",
|
||||
"MmI5NGYyMzZjNGE2NDJlYjJiY2RjMzU4OWI5YzNjNGEwYjViZDVkZjljZDVkNjhmMzdmOGM4M2Y4ZTNmMSJ9fX0=",
|
||||
"ZGFjNjcwM2RlZDQ2ZDkzOWE2MjBmZTIyYzQzZTE4Njc0ZTEzZDIzYzk3NDRiZTAzNmIzNDgzYzFkMWNkZCJ9fX0=",
|
||||
"ZjBiZmE4NTBmNWRlNGIyOTgxY2NlNzhmNTJmYzJjYzdjZDdiNWM2MmNhZWZlZGRlYjljZjMxMWU4M2Q5MDk3In19fQ==",
|
||||
"ZjhhODJjOGI3NWRkMWMyY2U4MTMzYzBiYTkzOWI4YzUyZTQ3ZDNlYzM3NDk1MGY0N2RkZGJiZTM0NWUyMCJ9fX0=",
|
||||
"YWNhNTgwYjA1MWM2M2JlMjlkYTU0NWE5YWE3ZmY3ZTEzNmRmNzdhODFjNjdkYzFlZTllNjE3MGMxNGZiMzEwIn19fQ==")),
|
||||
VILLAGER(120, "Villager", Arrays.asList(
|
||||
"ODIyZDhlNzUxYzhmMmZkNGM4OTQyYzQ0YmRiMmY1Y2E0ZDhhZThlNTc1ZWQzZWIzNGMxOGE4NmU5M2IifX19")),
|
||||
ENDER_CRYSTAL(200, "End Crystal"),
|
||||
TURTLE(901, "Turtle", Arrays.asList(
|
||||
"MGE0MDUwZTdhYWNjNDUzOTIwMjY1OGZkYzMzOWRkMTgyZDdlMzIyZjlmYmNjNGQ1Zjk5YjU3MThhIn19fQ==")),
|
||||
PHANTOM(902, "Phantom", Arrays.asList(
|
||||
"NDExZDI1YmNkYWJhZmFkNWZkNmUwMTBjNWIxY2Y3YTAwYzljY2E0MGM1YTQ2NzQ3ZjcwNmRjOWNiM2EifX19",
|
||||
"YWQyZmE1NjE4NDQ3NzYyZTI2MTExZTA2MGRjNTkzZWE2MjJkNWRkZmMzODVkN2U0MjUzMmU0NjMyN2Y4MDdjMCJ9fX0=")),
|
||||
TRIDENT(903, "Trident"),
|
||||
COD(904, "Cod", Arrays.asList(
|
||||
"NmY5OWI1ODBkNDVhNzg0ZTdhOTY0ZTdkM2IxZjk3Y2VjZTc0OTExMTczYmQyMWMxZDdjNTZhY2RjMzg1ZWQ1In19fQ==")),
|
||||
SALMON(905, "Salmon", Arrays.asList(
|
||||
"YWRmYzU3ZDA5MDU5ZTQ3OTlmYTkyYzE1ZTI4NTEyYmNmYWExMzE1NTc3ZmUzYTI3YWVkMzg5ZTRmNzUyMjg5YSJ9fX0=")),
|
||||
PUFFERFISH(906, "Pufferfish", Arrays.asList(
|
||||
"YTk1NTkzODg5OTNmZTc4MmY2N2JkNThkOThjNGRmNTZiY2Q0MzBlZGNiMmY2NmVmNTc3N2E3M2MyN2RlMyJ9fX0=")),
|
||||
TROPICAL_FISH(907, "Tropical Fish", Arrays.asList(
|
||||
"MzZkMTQ5ZTRkNDk5OTI5NjcyZTI3Njg5NDllNjQ3Nzk1OWMyMWU2NTI1NDYxM2IzMjdiNTM4ZGYxZTRkZiJ9fX0=")),
|
||||
DROWNED(908, "Drowned", Arrays.asList(
|
||||
"YzNmN2NjZjYxZGJjM2Y5ZmU5YTYzMzNjZGUwYzBlMTQzOTllYjJlZWE3MWQzNGNmMjIzYjNhY2UyMjA1MSJ9fX0=",
|
||||
"MWY4YmFhNDhiOGY1MTE5OTBlNDdkYjk2ODMyNGMxNTJiZDExNjc3MzFkZGYwMzQ1MzAwNDQ3MzVhNmJkMmVkNCJ9fX0=",
|
||||
"YzFhNzMyNTI0MDFhNmU5NDZmNjFkYmFjMGUwMjdkMTgzZTBhY2U1ODc1MmZhMTVhNjRkMjQ0OWZjZjUwODdiNyJ9fX0=",
|
||||
"Yzg0ZGY3OWM0OTEwNGIxOThjZGFkNmQ5OWZkMGQwYmNmMTUzMWM5MmQ0YWI2MjY5ZTQwYjdkM2NiYmI4ZTk4YyJ9fX0=",
|
||||
"ZmIxNTMxYzA0ZTI1ZDdmYTY0NTc2OTgyNjg0OTFjYjg5NmQzMzAyZDI2ODg0ZmNmZGYxYTBiMmY5MmQ3N2M4ZiJ9fX0=",
|
||||
"NTZkYWY1MGVhZjc2YzNhNmQ1YWQzOWM5NjZmMjk4NzdiOTFkOTUwZGQxZTM3MTIyZTljODE5NTg1Yzg5ZDkyZSJ9fX0=")),
|
||||
DOLPHIN(909, "Dolphin", Arrays.asList(
|
||||
"OGU5Njg4Yjk1MGQ4ODBiNTViN2FhMmNmY2Q3NmU1YTBmYTk0YWFjNmQxNmY3OGU4MzNmNzQ0M2VhMjlmZWQzIn19fQ==")),
|
||||
LINGERING_POTION(910, "Lingering Potion"),
|
||||
FISHING_HOOK(911, "Fishing Hook"),
|
||||
LIGHTNING(912, "Lightning Bolt"),
|
||||
WEATHER(913, "Weather"),
|
||||
PLAYER(914, "Player"),
|
||||
COMPLEX_PART(915, "Complex Part"),
|
||||
TIPPED_ARROW(916, "Tipped Arrow"),
|
||||
|
||||
PANDA(917, "Panda", Arrays.asList(
|
||||
"ZDE4OGM5ODBhYWNmYTk0Y2YzMzA4ODUxMmIxYjk1MTdiYTgyNmIxNTRkNGNhZmMyNjJhZmY2OTc3YmU4YSJ9fX0=")),
|
||||
PILLAGER(918, "Pillager", Arrays.asList(
|
||||
"NGFlZTZiYjM3Y2JmYzkyYjBkODZkYjVhZGE0NzkwYzY0ZmY0NDY4ZDY4Yjg0OTQyZmRlMDQ0MDVlOGVmNTMzMyJ9fX0=")),
|
||||
RAVAGER(919, "Ravager", Arrays.asList(
|
||||
"MWNiOWYxMzlmOTQ4OWQ4NmU0MTBhMDZkOGNiYzY3MGM4MDI4MTM3NTA4ZTNlNGJlZjYxMmZlMzJlZGQ2MDE5MyJ9fX0=",
|
||||
"M2I2MjUwMWNkMWI4N2IzN2Y2MjgwMTgyMTBlYzU0MDBjYjY1YTRkMWFhYjc0ZTZhM2Y3ZjYyYWE4NWRiOTdlZSJ9fX0=")),
|
||||
TRADER_LLAMA(920, "Trader Llama", Arrays.asList(
|
||||
"ODQyNDc4MGIzYzVjNTM1MWNmNDlmYjViZjQxZmNiMjg5NDkxZGY2YzQzMDY4M2M4NGQ3ODQ2MTg4ZGI0Zjg0ZCJ9fX0=",
|
||||
"NzA4N2E1NTZkNGZmYTk1ZWNkMjg0NGYzNTBkYzQzZTI1NGU1ZDUzNWZhNTk2ZjU0MGQ3ZTc3ZmE2N2RmNDY5NiJ9fX0=",
|
||||
"YmU0ZDhhMGJjMTVmMjM5OTIxZWZkOGJlMzQ4MGJhNzdhOThlZTdkOWNlMDA3MjhjMGQ3MzNmMGEyZDYxNGQxNiJ9fX0=")),
|
||||
WANDERING_TRADER(921, "Wandering Trader", Arrays.asList(
|
||||
"NWYxMzc5YTgyMjkwZDdhYmUxZWZhYWJiYzcwNzEwZmYyZWMwMmRkMzRhZGUzODZiYzAwYzkzMGM0NjFjZjkzMiJ9fX0=")),
|
||||
FOX(922, "Fox", Arrays.asList(
|
||||
"YjZmZWI3NjFiMmY1OWZhYmU1Y2MzY2M4MmE5MzRiNTM0ZWE5OWVkYjkxMzJjY2RhOWY0ODRiZDU5ODZkNyJ9fX0=",
|
||||
"MjRhMDM0NzQzNjQzNGViMTNkNTM3YjllYjZiNDViNmVmNGM1YTc4Zjg2ZTkxODYzZWY2MWQyYjhhNTNiODIifX19",
|
||||
"MTZkYjdkNTA3Mzg5YTE0YmJlYzM5ZGU2OTIyMTY1YjMyZDQzNjU3YmNiNmFhZjRiNTE4MjgyNWIyMmI0In19fQ==")),
|
||||
CAT(923, "Cat", Arrays.asList(
|
||||
"N2M5Yjc0MDllN2I1MzgzYzE5YjM2MmIyYTBjYjQzZDUwOTNiMTNlMmIyMzRlOGExODkxNTYzZTU1ZWFlOWQ2OCJ9fX0=",
|
||||
"NTg4MDNmMDI3MGY4Y2RmNGUwZmU5NzMyZDQ5NjdjY2NjMGEyZjRmY2QxMThjZDE1MDAwOTc5YjE4ODg1MTQ0ZiJ9fX0=")),
|
||||
BEE(924, "Bee", Arrays.asList(
|
||||
"OTQ3MzIyZjgzMWUzYzE2OGNmYmQzZTI4ZmU5MjUxNDRiMjYxZTc5ZWIzOWM3NzEzNDlmYWM1NWE4MTI2NDczIn19fQ==",
|
||||
"OTlkYzNmMDBlY2FiMjI0OWJiNmExNmM4YzUxMTVjZWI5ZjIzMjA1YTBkNTVjYzBlOWJhYmQyNTYyZjc5NTljNCJ9fX0==",
|
||||
"ZTZiNzRlMDUyYjc0Mjg4Nzk5YmE2ZDlmMzVjNWQwMjIxY2Y4YjA0MzMxNTQ3ZWMyZjY4ZDczNTk3YWUyYzliIn19fQ==",
|
||||
"YmIxNzc3NDY2MjUxMmQ3ODdlZjc3YjFhNDZhMDRlMmM2ZmQ2Nzc5NGJmN2Y3Nzk1NjZlYjIxYzgxNDNhYWQ5ZSJ9fX0=")),
|
||||
|
||||
ZOMBIFIED_PIGLIN(925, "Zombified Piglin", Arrays.asList("N2VhYmFlY2M1ZmFlNWE4YTQ5Yzg4NjNmZjQ4MzFhYWEyODQxOThmMWEyMzk4ODkwYzc2NWUwYThkZTE4ZGE4YyJ9fX0=")),
|
||||
HOGLIN(926, "Hoglin", Arrays.asList("OWJiOWJjMGYwMWRiZDc2MmEwOGQ5ZTc3YzA4MDY5ZWQ3Yzk1MzY0YWEzMGNhMTA3MjIwODU2MWI3MzBlOGQ3NSJ9fX0=")),
|
||||
PIGLIN(927, "Piglin", Arrays.asList("OWYxODEwN2QyNzVmMWNiM2E5Zjk3M2U1OTI4ZDU4NzlmYTQwMzI4ZmYzMjU4MDU0ZGI2ZGQzZTdjMGNhNjMzMCJ9fX0=")),
|
||||
STRIDER(928, "Strider", Arrays.asList("MThhOWFkZjc4MGVjN2RkNDYyNWM5YzA3NzkwNTJlNmExNWE0NTE4NjY2MjM1MTFlNGM4MmU5NjU1NzE0YjNjMSJ9fX0=")),
|
||||
ZOGLIN(929, "Zoglin", Arrays.asList("ZTY3ZTE4NjAyZTAzMDM1YWQ2ODk2N2NlMDkwMjM1ZDg5OTY2NjNmYjllYTQ3NTc4ZDNhN2ViYmM0MmE1Y2NmOSJ9fX0=")),
|
||||
|
||||
// 1.16.2
|
||||
PIGLIN_BRUTE(930, "Piglin Brute", Arrays.asList("M2UzMDBlOTAyNzM0OWM0OTA3NDk3NDM4YmFjMjllM2E0Yzg3YTg0OGM1MGIzNGMyMTI0MjcyN2I1N2Y0ZTFjZiJ9fX0=")),
|
||||
|
||||
// if possible we can remove this string for each texture to save up some space
|
||||
// eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUv
|
||||
UNKNOWN(999, "Unknown");
|
||||
|
||||
private int id;
|
||||
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);
|
||||
}
|
||||
|
||||
CMIEntityType(int id, String name) {
|
||||
this(id, name, null, new ArrayList<String>());
|
||||
}
|
||||
|
||||
CMIEntityType(int id, String name, String secondaryName) {
|
||||
this(id, name, secondaryName, new ArrayList<String>());
|
||||
}
|
||||
|
||||
CMIEntityType(int id, String name, String secondaryName, List<String> headTextures) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.secondaryName = secondaryName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static CMIEntityType getById(int id) {
|
||||
CMIEntityType ttype = getByName(String.valueOf(id));
|
||||
return ttype == null ? CMIEntityType.PIG : ttype;
|
||||
}
|
||||
|
||||
public static CMIEntityType getByType(EntityType entity) {
|
||||
return getByName(entity.toString());
|
||||
}
|
||||
|
||||
public static CMIEntityType getByItem(ItemStack item) {
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
if (CMIMaterial.isMonsterEgg(item.getType())) {
|
||||
String name = item.getType().toString().replace("_SPAWN_EGG", "");
|
||||
return getByName(name);
|
||||
}
|
||||
|
||||
if (CMIMaterial.SPAWNER.equals(item.getType())) {
|
||||
if (item.getItemMeta() instanceof BlockStateMeta) {
|
||||
BlockStateMeta bsm = (BlockStateMeta) item.getItemMeta();
|
||||
if (bsm.getBlockState() instanceof CreatureSpawner) {
|
||||
CreatureSpawner bs = (CreatureSpawner) bsm.getBlockState();
|
||||
return CMIEntityType.getByType(bs.getSpawnedType());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CMIEntityType getByName(String name) {
|
||||
return byName.get(name.toLowerCase().replace("_", ""));
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
if (type != null)
|
||||
return type;
|
||||
for (EntityType one : EntityType.values()) {
|
||||
if (one.toString().equalsIgnoreCase(this.name())) {
|
||||
type = one;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return getType() != null && getType().isAlive();
|
||||
}
|
||||
|
||||
public boolean isSpawnable() {
|
||||
return getType() != null && getType().isSpawnable();
|
||||
}
|
||||
|
||||
public static String getRealNameByType(EntityType type) {
|
||||
if (type == null)
|
||||
return null;
|
||||
CMIEntityType ctype = CMIEntityType.getByType(type);
|
||||
if (ctype != null)
|
||||
return ctype.getName();
|
||||
String name = type.name();
|
||||
|
||||
name = name.toLowerCase().replace('_', ' ');
|
||||
name = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
return name;
|
||||
}
|
||||
|
||||
public CMIMaterial getSpawnEggMaterial() {
|
||||
CMIMaterial m = CMIMaterial.get((this.equals(CMIEntityType.MUSHROOM_COW) ? "Mooshroom".toLowerCase() : this.toString().toLowerCase()) + "_spawn_egg");
|
||||
return m != null && m.isMonsterEgg() ? m : null;
|
||||
}
|
||||
}
|
@ -1,547 +0,0 @@
|
||||
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.Material;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.material.SpawnEgg;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class CMIItemStack {
|
||||
|
||||
@Deprecated
|
||||
private int id = 0;
|
||||
@Deprecated
|
||||
private short data = 0;
|
||||
private short durability = 0;
|
||||
private int amount = 0;
|
||||
|
||||
private String bukkitName = null;
|
||||
private String mojangName = null;
|
||||
private CMIMaterial cmiMaterial = null;
|
||||
private Material material = null;
|
||||
private CMIEntityType entityType = null;
|
||||
private ItemStack item;
|
||||
|
||||
public CMIItemStack(Material material) {
|
||||
this.material = material;
|
||||
this.cmiMaterial = CMIMaterial.get(material);
|
||||
}
|
||||
|
||||
public CMIItemStack(CMIMaterial cmiMaterial) {
|
||||
this.cmiMaterial = cmiMaterial;
|
||||
if (cmiMaterial != null)
|
||||
this.material = cmiMaterial.getMaterial();
|
||||
}
|
||||
|
||||
public CMIItemStack(ItemStack item) {
|
||||
setItemStack(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CMIItemStack clone() {
|
||||
CMIItemStack cm = new CMIItemStack(material);
|
||||
cm.entityType = this.entityType;
|
||||
cm.setId(id);
|
||||
cm.setData(data);
|
||||
cm.setAmount(amount);
|
||||
cm.setDurability(durability);
|
||||
cm.setBukkitName(bukkitName);
|
||||
cm.setMojangName(mojangName);
|
||||
cm.setCMIMaterial(cmiMaterial);
|
||||
cm.setMaterial(material);
|
||||
cm.setItemStack(item != null ? item.clone() : null);
|
||||
return cm;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public short getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean isTool() {
|
||||
return getMaxDurability() > 0;
|
||||
}
|
||||
|
||||
public boolean isArmor() {
|
||||
if (this.getCMIType() != null && this.getCMIType().isArmor())
|
||||
return true;
|
||||
return CMIMaterial.isArmor(this.getType());
|
||||
}
|
||||
|
||||
public short getDurability() {
|
||||
return Util.getDurability(getItemStack());
|
||||
}
|
||||
|
||||
public short getMaxDurability() {
|
||||
return material.getMaxDurability();
|
||||
}
|
||||
|
||||
public void setData(short data) {
|
||||
this.data = data;
|
||||
if (this.getCMIType() != null) {
|
||||
ItemMeta meta = null;
|
||||
if (item != null && item.hasItemMeta()) {
|
||||
meta = item.getItemMeta();
|
||||
}
|
||||
this.item = null;
|
||||
if (meta != null && this.getItemStack() != null) {
|
||||
this.getItemStack().setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CMIItemStack setDisplayName(String name) {
|
||||
ItemMeta meta = getItemStack().getItemMeta();
|
||||
if (meta != null) {
|
||||
if (name == null) {
|
||||
meta.setDisplayName(null);
|
||||
} else
|
||||
meta.setDisplayName(CMIChatColor.translate(name));
|
||||
}
|
||||
getItemStack().setItemMeta(meta);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
ItemMeta meta = getItemStack().getItemMeta();
|
||||
return meta == null || meta.getDisplayName() == null || meta.getDisplayName().isEmpty() ? getRealName() : meta.getDisplayName();
|
||||
}
|
||||
|
||||
public CMIItemStack addLore(String string) {
|
||||
if (string == null)
|
||||
return this;
|
||||
ItemMeta meta = getItemStack().getItemMeta();
|
||||
List<String> lore = meta.getLore();
|
||||
if (lore == null)
|
||||
lore = new ArrayList<>();
|
||||
lore.add(CMIChatColor.translate(string));
|
||||
meta.setLore(lore);
|
||||
getItemStack().setItemMeta(meta);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIItemStack clearLore() {
|
||||
ItemMeta meta = getItemStack().getItemMeta();
|
||||
if (meta != null) {
|
||||
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 = getItemStack().getItemMeta();
|
||||
List<String> t = new ArrayList<>();
|
||||
for (String one : lore) {
|
||||
t.add(CMIChatColor.translate(one));
|
||||
}
|
||||
meta.setLore(t);
|
||||
getItemStack().setItemMeta(meta);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIItemStack addEnchant(Enchantment enchant, Integer level) {
|
||||
if (enchant == null)
|
||||
return this;
|
||||
|
||||
if (getItemStack().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) getItemStack().getItemMeta();
|
||||
meta.addStoredEnchant(enchant, level, true);
|
||||
getItemStack().setItemMeta(meta);
|
||||
} else {
|
||||
ItemMeta meta = getItemStack().getItemMeta();
|
||||
meta.addEnchant(enchant, level, true);
|
||||
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()) {
|
||||
addEnchant(oneEnch.getKey(), oneEnch.getValue());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CMIItemStack clearEnchants() {
|
||||
ItemMeta meta = getItemStack().getItemMeta();
|
||||
meta.getEnchants().clear();
|
||||
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<>();
|
||||
meta.setLore(lore);
|
||||
}
|
||||
|
||||
return meta.getLore() == null ? new ArrayList<>() : meta.getLore();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getRealName() {
|
||||
return getCMIType() == null || getCMIType() == CMIMaterial.NONE ? getType().name() : getCMIType().getName();
|
||||
// if (this.getItemStack() != null) {
|
||||
//
|
||||
//// String translated = CMI.getInstance().getItemManager().getTranslatedName(this.getItemStack());
|
||||
//// if (translated != null)
|
||||
//// return translated;
|
||||
// try {
|
||||
// return CMI.getInstance().getRef().getItemMinecraftName(this.getItemStack());
|
||||
// } catch (Exception e) {
|
||||
// }
|
||||
// }
|
||||
// return CMI.getInstance().getItemManager().getRealName(this, true).getName();
|
||||
}
|
||||
|
||||
public String getBukkitName() {
|
||||
return bukkitName == null || bukkitName.isEmpty() ? null : bukkitName;
|
||||
}
|
||||
|
||||
public void setBukkitName(String bukkitName) {
|
||||
this.bukkitName = bukkitName;
|
||||
}
|
||||
|
||||
public String getMojangName() {
|
||||
// if (getCMIType().isSkull() && !Version.isCurrentEqualOrHigher(Version.v1_13_R1))
|
||||
// mojangName = "skull";
|
||||
// try {
|
||||
// mojangName = CMI.getInstance().getRef().getItemMinecraftName(getItemStack()).replace("minecraft:", "");
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
return mojangName == null || mojangName.isEmpty() ? getCMIType().getMaterial().name() : mojangName;
|
||||
}
|
||||
|
||||
public void setMojangName(String mojangName) {
|
||||
if (mojangName != null)
|
||||
this.mojangName = mojangName.replace("minecraft:", "");
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
if (material == null && cmiMaterial != null)
|
||||
return cmiMaterial.getMaterial();
|
||||
return material;
|
||||
}
|
||||
|
||||
public CMIMaterial getCMIType() {
|
||||
return cmiMaterial == null ? CMIMaterial.get(material) : cmiMaterial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the material
|
||||
*
|
||||
* @deprecated Use {@link #getType()}
|
||||
* @return Material
|
||||
*/
|
||||
@Deprecated
|
||||
public Material getMaterial() {
|
||||
return getType();
|
||||
}
|
||||
|
||||
public void setMaterial(Material material) {
|
||||
this.cmiMaterial = CMIMaterial.get(material);
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public void setCMIMaterial(CMIMaterial material) {
|
||||
this.cmiMaterial = material;
|
||||
this.material = material == null ? null : material.getMaterial();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack getItemStack() {
|
||||
if (item == null) {
|
||||
try {
|
||||
if (!this.getType().isItem()) {
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
if (cmiMaterial.isMonsterEgg()) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||
item = new ItemStack(getType());
|
||||
item.setAmount(getAmount());
|
||||
} else
|
||||
item = new ItemStack(getType(), amount == 0 ? 1 : amount, data == 0 ? (short) 90 : data);
|
||||
} else {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||
item = new ItemStack(getType());
|
||||
item.setAmount(getAmount());
|
||||
} else
|
||||
item = new ItemStack(getType(), amount == 0 ? 1 : amount, data);
|
||||
}
|
||||
|
||||
if (getCMIType().isPotion() || 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(effect, 60, 0), true);
|
||||
}
|
||||
item.setItemMeta(potion);
|
||||
item.setDurability((short) 0);
|
||||
potion = (PotionMeta) item.getItemMeta();
|
||||
potion.setDisplayName(getRealName());
|
||||
item.setItemMeta(potion);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public CMIItemStack setItemStack(ItemStack item) {
|
||||
this.item = item;
|
||||
if (item != null) {
|
||||
this.amount = item.getAmount();
|
||||
this.material = item.getType();
|
||||
this.cmiMaterial = CMIMaterial.get(item);
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) {
|
||||
this.id = item.getType().getId();
|
||||
if ((this.getType().isBlock() || this.getType().isSolid())) {
|
||||
data = item.getData().getData();
|
||||
}
|
||||
if (item.getType().getMaxDurability() - item.getDurability() < 0) {
|
||||
data = item.getData().getData();
|
||||
}
|
||||
} else if (cmiMaterial != null) {
|
||||
this.id = cmiMaterial.getId();
|
||||
}
|
||||
|
||||
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().getType().getEffectType() != null) {
|
||||
data = (short) potion.getBasePotionData().getType().getEffectType().getId();
|
||||
}
|
||||
} catch (NoSuchMethodError e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount <= 0 ? 1 : amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
if (item != null)
|
||||
this.item.setAmount(this.amount == 0 ? item.getAmount() : this.amount);
|
||||
}
|
||||
|
||||
public boolean isSimilar(ItemStack item) {
|
||||
return isSimilar(ItemManager.getItem(item));
|
||||
}
|
||||
|
||||
public boolean isSimilar(CMIItemStack item) {
|
||||
if (item == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
if ((item.getCMIType().isPotion() || item.getCMIType() == CMIMaterial.TIPPED_ARROW) &&
|
||||
(getCMIType().isPotion() || getCMIType() == CMIMaterial.TIPPED_ARROW) &&
|
||||
getType() == item.getType()) {
|
||||
PotionMeta potion = (PotionMeta) item.getItemStack().getItemMeta();
|
||||
PotionMeta potion2 = (PotionMeta) getItemStack().getItemMeta();
|
||||
try {
|
||||
if (potion != null && potion.getBasePotionData() != null) {
|
||||
PotionData base1 = potion.getBasePotionData();
|
||||
if (base1.getType() != null) {
|
||||
if (potion2 != null && potion2.getBasePotionData() != null) {
|
||||
PotionData base2 = potion2.getBasePotionData();
|
||||
if (base2.getType() != null) {
|
||||
if (base1.getType() == base2.getType() && base1.isExtended() == base2.isExtended() && base1.isUpgraded() == base2.isUpgraded())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (NoSuchMethodError e) {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (this.getItemStack().getItemMeta() instanceof EnchantmentStorageMeta && item.getItemStack().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta meta1 = (EnchantmentStorageMeta) this.getItemStack().getItemMeta();
|
||||
EnchantmentStorageMeta meta2 = (EnchantmentStorageMeta) item.getItemStack().getItemMeta();
|
||||
|
||||
for (Entry<Enchantment, Integer> one : meta1.getEnchants().entrySet()) {
|
||||
if (!meta2.getEnchants().containsKey(one.getKey()) || meta2.getEnchants().get(one.getKey()) != one.getValue())
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Entry<Enchantment, Integer> one : meta1.getStoredEnchants().entrySet()) {
|
||||
if (!meta2.getStoredEnchants().containsKey(one.getKey()) || meta2.getStoredEnchants().get(one.getKey()) != one.getValue())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if ((item.getCMIType() == CMIMaterial.SPAWNER || item.getCMIType().isMonsterEgg()) && (getCMIType() == CMIMaterial.SPAWNER || getCMIType().isMonsterEgg())) {
|
||||
if (this.cmiMaterial != item.cmiMaterial)
|
||||
return false;
|
||||
if (getEntityType() != item.getEntityType())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getCMIType() == CMIMaterial.PLAYER_HEAD && this.getCMIType() == CMIMaterial.PLAYER_HEAD) {
|
||||
try {
|
||||
SkullMeta skullMeta = (SkullMeta) item.getItemStack().getItemMeta();
|
||||
SkullMeta skullMeta2 = (SkullMeta) getItemStack().getItemMeta();
|
||||
|
||||
if (skullMeta.getOwner() != null && skullMeta2.getOwner() == null || skullMeta.getOwner() == null && skullMeta2.getOwner() != null)
|
||||
return false;
|
||||
if (skullMeta.getOwner() != null && skullMeta2.getOwner() != null && !skullMeta.getOwner().equals(skullMeta2.getOwner()))
|
||||
return false;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1))
|
||||
return this.cmiMaterial == item.cmiMaterial;
|
||||
return this.cmiMaterial == item.cmiMaterial && this.getData() == item.getData();
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
if (this.getItemStack() == null)
|
||||
return null;
|
||||
|
||||
if (this.entityType != null)
|
||||
return this.entityType.getType();
|
||||
|
||||
ItemStack is = this.getItemStack().clone();
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_8_R1) && is.getItemMeta() instanceof org.bukkit.inventory.meta.BlockStateMeta) {
|
||||
org.bukkit.inventory.meta.BlockStateMeta bsm = (org.bukkit.inventory.meta.BlockStateMeta) is.getItemMeta();
|
||||
if (bsm.getBlockState() instanceof CreatureSpawner) {
|
||||
CreatureSpawner bs = (CreatureSpawner) bsm.getBlockState();
|
||||
return bs.getSpawnedType();
|
||||
}
|
||||
}
|
||||
|
||||
if (is.getData() instanceof SpawnEgg) {
|
||||
return CMIReflections.getEggType(is);
|
||||
}
|
||||
|
||||
if (CMIMaterial.get(is) != null && CMIMaterial.get(is).isMonsterEgg()) {
|
||||
return CMIReflections.getEggType(is);
|
||||
}
|
||||
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_12_R1))
|
||||
return EntityType.fromId(is.getData().getData());
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDurability(short durability) {
|
||||
this.durability = durability;
|
||||
}
|
||||
|
||||
public String toOneLiner() {
|
||||
String liner = getType().toString();
|
||||
if (getCMIType().isPotion() || getType().name().contains("TIPPED_ARROW")) {
|
||||
PotionMeta potion = (PotionMeta) item.getItemMeta();
|
||||
try {
|
||||
if (potion != null && potion.getBasePotionData().getType().getEffectType() != null) {
|
||||
liner += ":" + potion.getBasePotionData().getType().getEffectType().getName() + "-" + potion.getBasePotionData().isUpgraded() + "-" + potion.getBasePotionData().isExtended();
|
||||
}
|
||||
} catch (NoSuchMethodError e) {
|
||||
}
|
||||
} else {
|
||||
if (Version.isCurrentLower(Version.v1_13_R1))
|
||||
liner += ":" + getData();
|
||||
}
|
||||
if (this.getItemStack().getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) getItemStack().getItemMeta();
|
||||
String s = "";
|
||||
for (Entry<Enchantment, Integer> one : meta.getStoredEnchants().entrySet()) {
|
||||
if (!s.isEmpty())
|
||||
s += ";";
|
||||
s += CMIEnchantment.get(one.getKey()) + "x" + one.getValue();
|
||||
}
|
||||
|
||||
for (Entry<Enchantment, Integer> one : meta.getEnchants().entrySet()) {
|
||||
if (!s.isEmpty())
|
||||
s += ";";
|
||||
s += CMIEnchantment.get(one.getKey()) + "x" + one.getValue();
|
||||
}
|
||||
if (!s.isEmpty())
|
||||
liner += ":" + s;
|
||||
}
|
||||
|
||||
return liner;
|
||||
}
|
||||
|
||||
public static ItemStack getHead(String texture) {
|
||||
if (texture == null || texture.isEmpty())
|
||||
return null;
|
||||
if (texture.length() < 120)
|
||||
texture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUv" + texture;
|
||||
ItemStack cached = CMIEntityType.cache.get(texture);
|
||||
if (cached != null) {
|
||||
return cached.clone();
|
||||
}
|
||||
ItemStack item = CMIMaterial.PLAYER_HEAD.newItemStack();
|
||||
item = CMIReflections.setSkullTexture(item, null, texture);
|
||||
CMIEntityType.cache.put(texture, item);
|
||||
return item.clone();
|
||||
}
|
||||
|
||||
public void setEntityType(CMIEntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public void setEntityType(EntityType entityType) {
|
||||
setEntityType(CMIEntityType.getByType(entityType));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
public enum CMIMaterialCriteria {
|
||||
|
||||
seeThrow, stars, slab, door, carpet, wool, monsteregg
|
||||
|
||||
}
|
@ -1,344 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CMINBT {
|
||||
|
||||
Object tag;
|
||||
Object object;
|
||||
|
||||
nmbtType type;
|
||||
|
||||
public enum nmbtType {
|
||||
item, block, entity;
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
}
|
||||
|
||||
public CMINBT(ItemStack item) {
|
||||
tag = CMIReflections.getNbt(item);
|
||||
object = item;
|
||||
type = nmbtType.item;
|
||||
}
|
||||
|
||||
public Integer getInt(String path) {
|
||||
if (tag == null)
|
||||
return null;
|
||||
if (!this.hasNBT(path))
|
||||
return null;
|
||||
try {
|
||||
return (Integer) tag.getClass().getMethod("getInt", String.class).invoke(tag, path);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Byte getByte(String path) {
|
||||
if (tag == null)
|
||||
return null;
|
||||
if (!this.hasNBT(path))
|
||||
return null;
|
||||
try {
|
||||
return (Byte) tag.getClass().getMethod("getByte", String.class).invoke(tag, path);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Long getLong(String path) {
|
||||
if (tag == null)
|
||||
return null;
|
||||
if (!this.hasNBT(path))
|
||||
return null;
|
||||
try {
|
||||
return (Long) tag.getClass().getMethod("getLong", String.class).invoke(tag, path);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getBoolean(String path) {
|
||||
if (tag == null)
|
||||
return null;
|
||||
if (!this.hasNBT(path))
|
||||
return null;
|
||||
try {
|
||||
return (Boolean) tag.getClass().getMethod("getBoolean", String.class).invoke(tag, path);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String path) {
|
||||
if (tag == null)
|
||||
return null;
|
||||
if (!this.hasNBT(path))
|
||||
return null;
|
||||
try {
|
||||
|
||||
if (tag != null && path.contains(".")) {
|
||||
List<String> keys = new ArrayList<String>();
|
||||
keys.addAll(Arrays.asList(path.split("\\.")));
|
||||
try {
|
||||
Object nbtbase = tag.getClass().getMethod("get", String.class).invoke(tag, keys.get(0));
|
||||
for (int i = 1; i < keys.size(); i++) {
|
||||
if (i + 1 < keys.size()) {
|
||||
nbtbase = nbtbase.getClass().getMethod("get", String.class).invoke(nbtbase, keys.get(i));
|
||||
} else {
|
||||
return nbtbase != null ? (String) nbtbase.getClass().getMethod("getString", String.class).invoke(nbtbase, keys.get(i)) : null;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
||||
return (String) tag.getClass().getMethod("getString", String.class).invoke(tag, path);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getList(String path) {
|
||||
if (tag == null)
|
||||
return null;
|
||||
if (!this.hasNBT(path))
|
||||
return null;
|
||||
List<String> list = new ArrayList<String>();
|
||||
try {
|
||||
Object ls = tag.getClass().getMethod("getList", String.class, int.class).invoke(tag, path, 8);
|
||||
int size = (int) ls.getClass().getMethod("size").invoke(ls);
|
||||
Method method = ls.getClass().getMethod("get", int.class);
|
||||
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_12_R1)) {
|
||||
method = ls.getClass().getMethod("getString", int.class);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Object ress = method.invoke(ls, i);
|
||||
String line = (String) ress;
|
||||
list.add(line);
|
||||
}
|
||||
} else {
|
||||
Object nbtbase = tag.getClass().getMethod("get", String.class).invoke(tag, path);
|
||||
Method baseMethod = nbtbase.getClass().getMethod(Version.isCurrentEqualOrLower(Version.v1_12_R1) ? "toString" : "asString");
|
||||
for (int i = 0; i < size; i++) {
|
||||
list.add((String) baseMethod.invoke(method.invoke(ls, i)));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Short getShort(String path) {
|
||||
if (tag == null)
|
||||
return null;
|
||||
try {
|
||||
return (Short) tag.getClass().getMethod("getShort", String.class).invoke(tag, path);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object setBoolean(String path, Boolean value) {
|
||||
switch (type) {
|
||||
case block:
|
||||
break;
|
||||
case entity:
|
||||
break;
|
||||
case item:
|
||||
try {
|
||||
if (value == null) {
|
||||
Method meth = tag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(tag, path);
|
||||
} else {
|
||||
Method meth = tag.getClass().getMethod("setBoolean", String.class, boolean.class);
|
||||
meth.invoke(tag, path, value);
|
||||
}
|
||||
return CMIReflections.setTag((ItemStack) object, tag);
|
||||
} catch (Throwable e) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_7_R4))
|
||||
e.printStackTrace();
|
||||
return object;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public Object setByte(String path, Byte value) {
|
||||
switch (type) {
|
||||
case block:
|
||||
break;
|
||||
case entity:
|
||||
break;
|
||||
case item:
|
||||
try {
|
||||
if (value == null) {
|
||||
Method meth = tag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(tag, path);
|
||||
} else {
|
||||
Method meth = tag.getClass().getMethod("setByte", String.class, byte.class);
|
||||
meth.invoke(tag, path, value);
|
||||
}
|
||||
return CMIReflections.setTag((ItemStack) object, tag);
|
||||
} catch (Throwable e) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_7_R4))
|
||||
e.printStackTrace();
|
||||
return object;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public Object setShort(String path, Short value) {
|
||||
switch (type) {
|
||||
case block:
|
||||
break;
|
||||
case entity:
|
||||
break;
|
||||
case item:
|
||||
try {
|
||||
if (value == null) {
|
||||
Method meth = tag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(tag, path);
|
||||
} else {
|
||||
Method meth = tag.getClass().getMethod("setShort", String.class, short.class);
|
||||
meth.invoke(tag, path, value);
|
||||
}
|
||||
return CMIReflections.setTag((ItemStack) object, tag);
|
||||
} catch (Throwable e) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_7_R4))
|
||||
e.printStackTrace();
|
||||
return object;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public Object setString(String path, String value) {
|
||||
switch (type) {
|
||||
case block:
|
||||
break;
|
||||
case entity:
|
||||
break;
|
||||
case item:
|
||||
try {
|
||||
if (value == null) {
|
||||
Method meth = tag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(tag, path);
|
||||
} else {
|
||||
Method meth = tag.getClass().getMethod("setString", String.class, String.class);
|
||||
meth.invoke(tag, path, value);
|
||||
}
|
||||
return CMIReflections.setTag((ItemStack) object, tag);
|
||||
} catch (Throwable e) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_7_R4))
|
||||
e.printStackTrace();
|
||||
return object;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public Object setInt(String path, Integer value) {
|
||||
switch (type) {
|
||||
case block:
|
||||
break;
|
||||
case entity:
|
||||
break;
|
||||
case item:
|
||||
try {
|
||||
|
||||
if (value == null) {
|
||||
Method meth = tag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(tag, path);
|
||||
} else {
|
||||
Method meth = tag.getClass().getMethod("setInt", String.class, int.class);
|
||||
meth.invoke(tag, path, value);
|
||||
}
|
||||
return CMIReflections.setTag((ItemStack) object, tag);
|
||||
} catch (Throwable e) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_7_R4))
|
||||
e.printStackTrace();
|
||||
return object;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public Object setLong(String path, Long value) {
|
||||
switch (type) {
|
||||
case block:
|
||||
break;
|
||||
case entity:
|
||||
break;
|
||||
case item:
|
||||
try {
|
||||
if (value == null) {
|
||||
Method meth = tag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(tag, path, value);
|
||||
} else {
|
||||
Method meth = tag.getClass().getMethod("setLong", String.class, long.class);
|
||||
meth.invoke(tag, path, value);
|
||||
}
|
||||
return CMIReflections.setTag((ItemStack) object, tag);
|
||||
} catch (Throwable e) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_7_R4))
|
||||
e.printStackTrace();
|
||||
return object;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public boolean hasNBT() {
|
||||
return tag != null;
|
||||
}
|
||||
|
||||
public boolean hasNBT(String key) {
|
||||
if (tag != null && key.contains(".")) {
|
||||
List<String> keys = new ArrayList<String>();
|
||||
keys.addAll(Arrays.asList(key.split("\\.")));
|
||||
try {
|
||||
Object nbtbase = tag.getClass().getMethod("get", String.class).invoke(tag, keys.get(0));
|
||||
for (int i = 1; i < keys.size(); i++) {
|
||||
if (i + 1 < keys.size()) {
|
||||
nbtbase = nbtbase.getClass().getMethod("get", String.class).invoke(nbtbase, keys.get(i));
|
||||
} else {
|
||||
return nbtbase != null && (Boolean) nbtbase.getClass().getMethod("hasKey", String.class).invoke(nbtbase, keys.get(i));
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return tag != null && (Boolean) tag.getClass().getMethod("hasKey", String.class).invoke(tag, key);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getNbt() {
|
||||
return tag;
|
||||
}
|
||||
}
|
@ -1,406 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2017 Zrips
|
||||
*/
|
||||
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
public class CMIReflections {
|
||||
|
||||
//private Class<?> CraftServerClass;
|
||||
//private Object CraftServer;
|
||||
|
||||
private static Class<?> NBTTagCompound;
|
||||
private static Class<?> NBTBase;
|
||||
// private Class<?> NBTTagList;
|
||||
|
||||
private static Class<?> CraftItemStack;
|
||||
private static Class<?> Item;
|
||||
private static Class<?> IStack;
|
||||
|
||||
static {
|
||||
try {
|
||||
//CraftServerClass = getBukkitClass("CraftServer");
|
||||
//CraftServer = CraftServerClass.cast(Bukkit.getServer());
|
||||
NBTTagCompound = getMinecraftClass("NBTTagCompound");
|
||||
NBTBase = getMinecraftClass("NBTBase");
|
||||
/*try {
|
||||
NBTTagList = getMinecraftClass("NBTTagList");
|
||||
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
CraftItemStack = getBukkitClass("inventory.CraftItemStack");
|
||||
try {
|
||||
Item = getMinecraftClass("Item");
|
||||
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
IStack = getMinecraftClass("ItemStack");
|
||||
} catch (ClassCastException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String toJson(ItemStack item) {
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
|
||||
try {
|
||||
Method meth = IStack.getMethod("save", NBTTagCompound);
|
||||
Object res = meth.invoke(nmsStack, NBTTagCompound.newInstance());
|
||||
return res.toString();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Class<?> getBukkitClass(String nmsClassString) throws ClassNotFoundException {
|
||||
return Class.forName("org.bukkit.craftbukkit." + Version.getCurrent() + "." + nmsClassString);
|
||||
}
|
||||
|
||||
public static Class<?> getMinecraftClass(String nmsClassString) throws ClassNotFoundException {
|
||||
return Class.forName("net.minecraft.server." + Version.getCurrent() + "." + nmsClassString);
|
||||
}
|
||||
|
||||
public ItemStack removeNbt(ItemStack item, String base, String path) {
|
||||
if (item == null)
|
||||
return null;
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
Method methTag = nmsStack.getClass().getMethod("getTag");
|
||||
Object tag = methTag.invoke(nmsStack);
|
||||
if (tag == null)
|
||||
return item;
|
||||
|
||||
Method compountMeth = tag.getClass().getMethod("getCompound", String.class);
|
||||
Object compountTag = compountMeth.invoke(tag, base);
|
||||
|
||||
if (compountTag == null)
|
||||
return item;
|
||||
|
||||
Method meth = compountTag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(compountTag, path);
|
||||
|
||||
Method mm = tag.getClass().getMethod("set", String.class, NBTBase);
|
||||
mm.invoke(tag, base, compountTag);
|
||||
|
||||
Method meth2 = nmsStack.getClass().getMethod("setTag", NBTTagCompound);
|
||||
meth2.invoke(nmsStack, tag);
|
||||
return (ItemStack) asBukkitCopy(nmsStack);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack removeNbt(ItemStack item, String path) {
|
||||
if (item == null)
|
||||
return null;
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
Method methTag = nmsStack.getClass().getMethod("getTag");
|
||||
Object tag = methTag.invoke(nmsStack);
|
||||
if (tag == null)
|
||||
return item;
|
||||
|
||||
Method meth = tag.getClass().getMethod("remove", String.class);
|
||||
meth.invoke(tag, path);
|
||||
|
||||
Method meth2 = nmsStack.getClass().getMethod("setTag", NBTTagCompound);
|
||||
meth2.invoke(nmsStack, tag);
|
||||
return (ItemStack) asBukkitCopy(nmsStack);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasNbt(ItemStack item, String base) {
|
||||
if (item == null)
|
||||
return false;
|
||||
try {
|
||||
Object nbt = getNbt(item);
|
||||
if (nbt == null)
|
||||
return false;
|
||||
Method meth = nbt.getClass().getMethod("getCompound", String.class);
|
||||
Object res = meth.invoke(nbt, base);
|
||||
return res != null;
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasNbtString(ItemStack item, String base) {
|
||||
if (item == null)
|
||||
return false;
|
||||
try {
|
||||
Object nbt = getNbt(item);
|
||||
if (nbt == null)
|
||||
return false;
|
||||
Method meth = nbt.getClass().getMethod("getString", String.class);
|
||||
Object res = meth.invoke(nbt, base);
|
||||
return res != null;
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getNbt(ItemStack item) {
|
||||
if (item == null)
|
||||
return null;
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
Method methTag = nmsStack.getClass().getMethod("getTag");
|
||||
Object tag = methTag.invoke(nmsStack);
|
||||
return tag;
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getNbt(ItemStack item, String base, String path) {
|
||||
if (item == null)
|
||||
return null;
|
||||
try {
|
||||
Object nbt = getNbt(item);
|
||||
if (nbt == null)
|
||||
return null;
|
||||
|
||||
Method compoundMeth = nbt.getClass().getMethod("getCompound", String.class);
|
||||
Object compoundRes = compoundMeth.invoke(nbt, base);
|
||||
|
||||
if (compoundRes == null)
|
||||
return null;
|
||||
|
||||
Method meth = compoundRes.getClass().getMethod("getString", String.class);
|
||||
Object res = meth.invoke(compoundRes, path);
|
||||
return res;
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack setNbt(ItemStack item, String path, String value) {
|
||||
if (item == null)
|
||||
return null;
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
if (nmsStack == null)
|
||||
return item;
|
||||
Method methTag = nmsStack.getClass().getMethod("getTag");
|
||||
Object tag = methTag.invoke(nmsStack);
|
||||
if (tag == null)
|
||||
tag = NBTTagCompound.newInstance();
|
||||
Method meth = tag.getClass().getMethod("setString", String.class, String.class);
|
||||
meth.invoke(tag, path, value);
|
||||
Method meth2 = nmsStack.getClass().getMethod("setTag", NBTTagCompound);
|
||||
meth2.invoke(nmsStack, tag);
|
||||
return (ItemStack) asBukkitCopy(nmsStack);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getNbt(ItemStack item, String path) {
|
||||
if (item == null)
|
||||
return null;
|
||||
try {
|
||||
Object nbt = getNbt(item);
|
||||
if (nbt == null)
|
||||
return null;
|
||||
|
||||
Method meth = nbt.getClass().getMethod("getString", String.class);
|
||||
Object res = meth.invoke(nbt, path);
|
||||
return res;
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object asNMSCopy(ItemStack item) {
|
||||
try {
|
||||
Method meth = CraftItemStack.getMethod("asNMSCopy", ItemStack.class);
|
||||
return meth.invoke(CraftItemStack, item);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object asBukkitCopy(Object item) {
|
||||
try {
|
||||
Method meth = CraftItemStack.getMethod("asBukkitCopy", IStack);
|
||||
return meth.invoke(CraftItemStack, item);
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getItemMinecraftName(ItemStack item) {
|
||||
try {
|
||||
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
if (nmsStack == null)
|
||||
return null;
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||
Object pre = nmsStack.getClass().getMethod("getItem").invoke(nmsStack);
|
||||
Object n = pre.getClass().getMethod("getName").invoke(pre);
|
||||
Class<?> ll = Class.forName("net.minecraft.server." + Version.getCurrent() + ".LocaleLanguage");
|
||||
Object lla = ll.getMethod("a").invoke(ll);
|
||||
return (String) lla.getClass().getMethod("a", String.class).invoke(lla, (String) n);
|
||||
}
|
||||
|
||||
Field field = Item.getField("REGISTRY");
|
||||
Object reg = field.get(field);
|
||||
Method meth = reg.getClass().getMethod("b", Object.class);
|
||||
meth.setAccessible(true);
|
||||
Method secmeth = nmsStack.getClass().getMethod("getItem");
|
||||
Object res2 = secmeth.invoke(nmsStack);
|
||||
Object res = meth.invoke(reg, res2);
|
||||
return res.toString();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getItemMinecraftNamePath(ItemStack item) {
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
Method itemMeth = Item.getMethod("getById", int.class);
|
||||
@SuppressWarnings("deprecation")
|
||||
Object res = itemMeth.invoke(Item, item.getType().getId());
|
||||
Method nameThingy = Item.getMethod("j", IStack);
|
||||
Object resThingy = nameThingy.invoke(res, nmsStack);
|
||||
return resThingy.toString();
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemInOffHand(org.bukkit.entity.Player player) {
|
||||
return Version.getCurrent().isLower(Version.v1_9_R1) ? null : player.getInventory().getItemInOffHand();
|
||||
}
|
||||
|
||||
public static int getEggId(ItemStack item) {
|
||||
EntityType type = getEggType(item);
|
||||
return type == null ? 0 : type.getTypeId();
|
||||
}
|
||||
|
||||
public static EntityType getEggType(ItemStack item) {
|
||||
if (!CMIMaterial.isMonsterEgg(item.getType()))
|
||||
return null;
|
||||
|
||||
if (Version.isCurrentEqual(Version.v1_12_R1)) {
|
||||
try {
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_11_R1)) {
|
||||
CMIEntityType cmiType = CMIEntityType.getById(item.getData().getData());
|
||||
if (cmiType != null)
|
||||
return cmiType.getType();
|
||||
}
|
||||
Object tag = getNbt(item);
|
||||
Object base = tag.getClass().getMethod("getCompound", String.class).invoke(tag, "EntityTag");
|
||||
String type = (String) base.getClass().getMethod("getString", String.class).invoke(base, "id");
|
||||
return EntityType.fromName(type.replace("minecraft:", "").toUpperCase());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
CMIEntityType type = CMIEntityType.getByName(item.getType().toString().replace("_SPAWN_EGG", ""));
|
||||
return type == null ? null : type.getType();
|
||||
}
|
||||
|
||||
public static ItemStack setEggType(ItemStack item, EntityType etype) {
|
||||
if (!item.getType().toString().contains("_EGG"))
|
||||
return null;
|
||||
try {
|
||||
Object tag = getNbt(item);
|
||||
|
||||
Object ttag = tag.getClass().getMethod("getCompound", String.class).invoke(tag, "EntityTag");
|
||||
|
||||
if (ttag == null)
|
||||
ttag = NBTTagCompound.newInstance();
|
||||
|
||||
CMIEntityType ce = CMIEntityType.getByType(etype);
|
||||
if (ce == null)
|
||||
return item;
|
||||
|
||||
ttag.getClass().getMethod("setString", String.class, String.class).invoke(ttag, "id", ce.getName());
|
||||
|
||||
tag.getClass().getMethod("set", String.class, NBTTagCompound).invoke(tag, "EntityTag", ttag);
|
||||
setTag(item, tag);
|
||||
|
||||
return (ItemStack) asBukkitCopy(item);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack setTag(ItemStack item, Object tag) {
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
if (nmsStack == null) {
|
||||
return null;
|
||||
}
|
||||
Method meth2 = nmsStack.getClass().getMethod("setTag", NBTTagCompound);
|
||||
meth2.invoke(nmsStack, tag);
|
||||
return (ItemStack) asBukkitCopy(nmsStack);
|
||||
} catch (Throwable e) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_7_R4))
|
||||
e.printStackTrace();
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack setSkullTexture(ItemStack item, String customProfileName, String texture) {
|
||||
if (item == null)
|
||||
return null;
|
||||
try {
|
||||
|
||||
GameProfile prof = new GameProfile(UUID.nameUUIDFromBytes(texture.getBytes()), null);
|
||||
prof.getProperties().removeAll("textures");
|
||||
prof.getProperties().put("textures", new Property("textures", texture));
|
||||
|
||||
// ItemMeta headMeta = item.getItemMeta();
|
||||
SkullMeta headMeta = (SkullMeta) item.getItemMeta();
|
||||
|
||||
Field profileField = null;
|
||||
try {
|
||||
profileField = headMeta.getClass().getDeclaredField("profile");
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (profileField != null) {
|
||||
profileField.setAccessible(true);
|
||||
try {
|
||||
profileField.set(headMeta, prof);
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
item.setItemMeta(headMeta);
|
||||
}
|
||||
|
||||
Object i = new CMINBT(item).setString("Id", UUID.nameUUIDFromBytes(texture.getBytes()).toString());
|
||||
|
||||
return i == null ? null : (ItemStack) i;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
public enum CMISlabType {
|
||||
TOP,
|
||||
BOTTOM,
|
||||
DOUBLE,
|
||||
NOTSLAB;
|
||||
}
|
@ -1,465 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
/*
|
||||
* Made by Zrips
|
||||
*/
|
||||
|
||||
public class ConfigReader extends YamlConfiguration {
|
||||
private HashMap<String, String> comments;
|
||||
private HashMap<String, Object> contents;
|
||||
private YamlConfiguration config;
|
||||
private String p = null;
|
||||
private File file = null;
|
||||
private boolean recordContents = false;
|
||||
|
||||
public ConfigReader(String fileName) {
|
||||
this(new File(Jobs.getFolder(), fileName));
|
||||
}
|
||||
|
||||
public ConfigReader(File file) {
|
||||
super();
|
||||
comments = new HashMap<>();
|
||||
contents = new HashMap<>();
|
||||
this.file = file;
|
||||
this.config = getyml(file);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
try {
|
||||
this.load(file);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String file) throws IOException {
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
}
|
||||
|
||||
save(new File(file));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(File file) throws IOException {
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
}
|
||||
Files.createParentDirs(file);
|
||||
String data = insertComments(saveToString());
|
||||
PrintWriter writer = new PrintWriter(file, "UTF-8");
|
||||
try {
|
||||
writer.write(data);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
private String insertComments(String yaml) {
|
||||
if (!comments.isEmpty()) {
|
||||
String[] yamlContents = yaml.split("[" + System.getProperty("line.separator") + "]");
|
||||
StringBuilder newContents = new StringBuilder();
|
||||
StringBuilder currentPath = new StringBuilder();
|
||||
boolean commentedPath = false;
|
||||
boolean node = false;
|
||||
int depth = 0;
|
||||
|
||||
boolean firstLine = true;
|
||||
for (final String line : yamlContents) {
|
||||
if (firstLine) {
|
||||
firstLine = false;
|
||||
if (line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
boolean keyOk = true;
|
||||
if (line.contains(": ")) {
|
||||
int index = 0;
|
||||
index = line.indexOf(": ");
|
||||
if (index < 0) {
|
||||
index = line.length() - 1;
|
||||
}
|
||||
int whiteSpace = 0;
|
||||
for (int n = 0; n < line.length(); n++) {
|
||||
if (line.charAt(n) == ' ') {
|
||||
whiteSpace++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
String key = line.substring(whiteSpace, index);
|
||||
if (key.contains(" "))
|
||||
keyOk = false;
|
||||
else if (key.contains("&"))
|
||||
keyOk = false;
|
||||
else if (key.contains("."))
|
||||
keyOk = false;
|
||||
else if (key.contains("'"))
|
||||
keyOk = false;
|
||||
else if (key.contains("\""))
|
||||
keyOk = false;
|
||||
}
|
||||
|
||||
if (line.contains(": ") && keyOk || (line.length() > 1 && line.charAt(line.length() - 1) == ':')) {
|
||||
commentedPath = false;
|
||||
node = true;
|
||||
|
||||
int index = 0;
|
||||
index = line.indexOf(": ");
|
||||
if (index < 0) {
|
||||
index = line.length() - 1;
|
||||
}
|
||||
if (currentPath.toString().isEmpty()) {
|
||||
currentPath = new StringBuilder(line.substring(0, index));
|
||||
} else {
|
||||
int whiteSpace = 0;
|
||||
for (int n = 0; n < line.length(); n++) {
|
||||
if (line.charAt(n) == ' ') {
|
||||
whiteSpace++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (whiteSpace / 2 > depth) {
|
||||
currentPath.append(".").append(line.substring(whiteSpace, index));
|
||||
depth++;
|
||||
} else if (whiteSpace / 2 < depth) {
|
||||
int newDepth = whiteSpace / 2;
|
||||
for (int i = 0; i < depth - newDepth; i++) {
|
||||
currentPath.replace(currentPath.lastIndexOf("."), currentPath.length(), "");
|
||||
}
|
||||
int lastIndex = currentPath.lastIndexOf(".");
|
||||
if (lastIndex < 0) {
|
||||
currentPath = new StringBuilder();
|
||||
} else {
|
||||
currentPath.replace(currentPath.lastIndexOf("."), currentPath.length(), "").append(".");
|
||||
}
|
||||
currentPath.append(line.substring(whiteSpace, index));
|
||||
depth = newDepth;
|
||||
} else {
|
||||
int lastIndex = currentPath.lastIndexOf(".");
|
||||
if (lastIndex < 0) {
|
||||
currentPath = new StringBuilder();
|
||||
} else {
|
||||
currentPath.replace(currentPath.lastIndexOf("."), currentPath.length(), "").append(".");
|
||||
}
|
||||
currentPath.append(line.substring(whiteSpace, index));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
node = false;
|
||||
}
|
||||
StringBuilder newLine = new StringBuilder(line);
|
||||
if (node) {
|
||||
String comment = null;
|
||||
if (!commentedPath) {
|
||||
comment = comments.get(currentPath.toString());
|
||||
}
|
||||
if (comment != null && !comment.isEmpty()) {
|
||||
newLine.insert(0, System.getProperty("line.separator")).insert(0, comment);
|
||||
comment = null;
|
||||
commentedPath = true;
|
||||
}
|
||||
}
|
||||
newLine.append(System.getProperty("line.separator"));
|
||||
newContents.append(newLine.toString());
|
||||
}
|
||||
|
||||
return newContents.toString();
|
||||
}
|
||||
return yaml;
|
||||
}
|
||||
|
||||
public void appendComment(String path, String... commentLines) {
|
||||
addComment(path, true, commentLines);
|
||||
}
|
||||
|
||||
public void addComment(String path, String... commentLines) {
|
||||
addComment(path, false, commentLines);
|
||||
}
|
||||
|
||||
public void addComment(String path, boolean append, String... commentLines) {
|
||||
if (this.p != null)
|
||||
path = this.p + path;
|
||||
|
||||
StringBuilder commentstring = new StringBuilder();
|
||||
if (append && comments.containsKey(path)) {
|
||||
commentstring.append(comments.get(path));
|
||||
}
|
||||
|
||||
String leadingSpaces = "";
|
||||
for (int n = 0; n < path.length(); n++) {
|
||||
if (path.charAt(n) == '.') {
|
||||
leadingSpaces += " ";
|
||||
}
|
||||
}
|
||||
for (String line : commentLines) {
|
||||
if (!line.isEmpty()) {
|
||||
line = leadingSpaces + "# " + line;
|
||||
}
|
||||
if (commentstring.length() > 0) {
|
||||
commentstring.append(System.getProperty("line.separator"));
|
||||
}
|
||||
commentstring.append(line);
|
||||
}
|
||||
comments.put(path, commentstring.toString());
|
||||
}
|
||||
|
||||
public YamlConfiguration getyml(File file) {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
FileInputStream fileinputstream = null;
|
||||
|
||||
try {
|
||||
fileinputstream = new FileInputStream(file);
|
||||
InputStreamReader str = new InputStreamReader(fileinputstream, Charset.forName("UTF-8"));
|
||||
|
||||
config.load(str);
|
||||
str.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (InvalidConfigurationException | IOException e) {
|
||||
saveToBackup();
|
||||
System.out.println(e.getLocalizedMessage());
|
||||
} finally {
|
||||
if (fileinputstream != null)
|
||||
try {
|
||||
fileinputstream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public void saveToBackup() {
|
||||
saveToBackup(true);
|
||||
}
|
||||
|
||||
public void saveToBackup(boolean inform) {
|
||||
File cc = new File(Jobs.getFolder(), "FileBackups");
|
||||
if (!cc.isDirectory())
|
||||
cc.mkdir();
|
||||
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss ");
|
||||
String newFileName = dateFormat.format(date) + file.getName();
|
||||
if (inform)
|
||||
Jobs.consoleMsg("&cFailed to load " + file.getName() + "! Backup have been saved into " + Jobs.getFolder().getPath() + File.separator + "FileBackups"
|
||||
+ File.separator + newFileName);
|
||||
|
||||
File f = new File(Jobs.getFolder(), "FileBackups" + File.separator + newFileName);
|
||||
// file.renameTo(f);
|
||||
try {
|
||||
Files.copy(file, f);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void newLn(StringBuilder header) {
|
||||
header.append(System.lineSeparator());
|
||||
}
|
||||
|
||||
private static StringBuilder formStringBuilder(List<String> list) {
|
||||
StringBuilder header = new StringBuilder();
|
||||
for (String one : list) {
|
||||
header.append(one);
|
||||
newLn(header);
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
public void header(List<String> list) {
|
||||
options().header(formStringBuilder(list).toString());
|
||||
}
|
||||
|
||||
String[] waitingComment = null;
|
||||
|
||||
private void checkWaitingComment(String path) {
|
||||
if (waitingComment == null)
|
||||
return;
|
||||
addComment(path, waitingComment);
|
||||
waitingComment = null;
|
||||
}
|
||||
|
||||
public YamlConfiguration getC() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void copyDefaults(boolean value) {
|
||||
getC().options().copyDefaults(value);
|
||||
}
|
||||
|
||||
private String process(String path, Object value) {
|
||||
if (this.p != null)
|
||||
path = this.p + path;
|
||||
checkWaitingComment(path);
|
||||
config.addDefault(path, value);
|
||||
copySetting(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
public Boolean get(String path, Boolean boo) {
|
||||
path = process(path, boo);
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
public Object get(String path, Location boo) {
|
||||
path = process(path, boo);
|
||||
return config.get(path);
|
||||
}
|
||||
|
||||
public int get(String path, int boo) {
|
||||
path = process(path, boo);
|
||||
return config.getInt(path);
|
||||
}
|
||||
|
||||
public int get(String path, Integer boo) {
|
||||
path = process(path, boo);
|
||||
return config.getInt(path);
|
||||
}
|
||||
|
||||
public List<Integer> getIntList(String path, List<Integer> list) {
|
||||
path = process(path, list);
|
||||
return config.getIntegerList(path);
|
||||
}
|
||||
|
||||
public List<String> get(String path, List<String> list) {
|
||||
path = process(path, list);
|
||||
if (recordContents) {
|
||||
contents.put(path, config.isList(path) ? config.getStringList(path) : list);
|
||||
}
|
||||
|
||||
List<String> ls = config.getStringList(path);
|
||||
for (int p = 0; p < ls.size(); p++) {
|
||||
String st = convertUnicode(ls.get(p));
|
||||
ls.set(p, st);
|
||||
}
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
public String get(String path, String boo) {
|
||||
path = process(path, boo);
|
||||
if (recordContents)
|
||||
contents.put(path, config.isString(path) ? config.getString(path) : boo);
|
||||
|
||||
return convertUnicode(config.getString(path));
|
||||
}
|
||||
|
||||
public Double get(String path, Double boo) {
|
||||
path = process(path, boo);
|
||||
return config.getDouble(path);
|
||||
}
|
||||
|
||||
private static String convertUnicode(String st) {
|
||||
try {
|
||||
if (!st.contains("\\u"))
|
||||
return st;
|
||||
|
||||
StringBuilder sb = new StringBuilder(st.length());
|
||||
for (int i = 0; i < st.length(); i++) {
|
||||
char ch = st.charAt(i);
|
||||
if (ch == '\\') {
|
||||
char nextChar = (i == st.length() - 1) ? '\\' : st.charAt(i + 1);
|
||||
if (nextChar >= '0' && nextChar <= '7') {
|
||||
String code = "" + nextChar;
|
||||
i++;
|
||||
if ((i < st.length() - 1) && st.charAt(i + 1) >= '0' && st.charAt(i + 1) <= '7') {
|
||||
code += st.charAt(i + 1);
|
||||
i++;
|
||||
if ((i < st.length() - 1) && st.charAt(i + 1) >= '0' && st.charAt(i + 1) <= '7') {
|
||||
code += st.charAt(i + 1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
sb.append((char) Integer.parseInt(code, 8));
|
||||
continue;
|
||||
}
|
||||
switch (nextChar) {
|
||||
case 'u':
|
||||
if (i >= st.length() - 5) {
|
||||
ch = 'u';
|
||||
break;
|
||||
}
|
||||
try {
|
||||
int code = Integer.parseInt("" + st.charAt(i + 2) + st.charAt(i + 3) + st.charAt(i + 4) + st.charAt(i + 5), 16);
|
||||
sb.append(Character.toChars(code));
|
||||
} catch (NumberFormatException e) {
|
||||
sb.append("\\");
|
||||
continue;
|
||||
}
|
||||
i += 5;
|
||||
continue;
|
||||
default:
|
||||
sb.append("\\");
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
sb.append(ch);
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return st;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void copySetting(String path) {
|
||||
set(path, config.get(path));
|
||||
}
|
||||
|
||||
public void resetP() {
|
||||
p = null;
|
||||
}
|
||||
|
||||
public void setP(String cmd) {
|
||||
this.p = cmd;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
public void setRecordContents(boolean recordContents) {
|
||||
this.recordContents = recordContents;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
}
|
@ -1,422 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
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.Jobs;
|
||||
|
||||
public class ItemManager {
|
||||
|
||||
static HashMap<Material, CMIMaterial> byRealMaterial = new HashMap<>();
|
||||
static HashMap<Integer, CMIMaterial> byId = new HashMap<>();
|
||||
static HashMap<String, CMIMaterial> byName = new HashMap<>();
|
||||
|
||||
public HashMap<Integer, CMIMaterial> idMap() {
|
||||
return byId;
|
||||
}
|
||||
|
||||
public HashMap<String, CMIMaterial> NameMap() {
|
||||
return byName;
|
||||
}
|
||||
|
||||
static {
|
||||
byRealMaterial.clear();
|
||||
for (CMIMaterial one : CMIMaterial.values()) {
|
||||
if (one == null)
|
||||
continue;
|
||||
|
||||
// Ignoring legacy materials on new servers
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1) && one.isLegacy()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
one.updateMaterial();
|
||||
Material mat = one.getMaterial();
|
||||
|
||||
if (mat == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Integer id = one.getId();
|
||||
short data = one.getLegacyData();
|
||||
Integer legacyId = one.getLegacyId();
|
||||
String cmiName = one.getName().replace("_", "").replace(" ", "").toLowerCase();
|
||||
String materialName = one.toString().replace("_", "").replace(" ", "").toLowerCase();
|
||||
|
||||
String mojangName = null;
|
||||
try {
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_14_R1) || mat.isItem())
|
||||
mojangName = CMIReflections.getItemMinecraftName(new ItemStack(mat));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (mojangName == null) {
|
||||
mojangName = mat.toString();
|
||||
}
|
||||
|
||||
mojangName = mojangName == null ? mat.toString().replace("_", "").replace(" ", "").toLowerCase() : mojangName.replace("_", "").replace(" ", "").toLowerCase();
|
||||
|
||||
if (one.isCanHavePotionType()) {
|
||||
for (PotionType potType : PotionType.values()) {
|
||||
byName.put(cmiName + ":" + potType.toString().toLowerCase(), one);
|
||||
}
|
||||
}
|
||||
if (byName.containsKey(cmiName) && Version.isCurrentEqualOrLower(Version.v1_13_R1)) {
|
||||
byName.put(cmiName + ":" + data, one);
|
||||
} else
|
||||
byName.put(cmiName, one);
|
||||
|
||||
byName.put(materialName, one);
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_13_R1) && !byName.containsKey(cmiName + ":" + data))
|
||||
byName.put(cmiName + ":" + data, one);
|
||||
|
||||
if (!one.getLegacyNames().isEmpty()) {
|
||||
for (String oneL : one.getLegacyNames()) {
|
||||
String legacyName = oneL.replace("_", "").replace(" ", "").toLowerCase();
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_13_R1) && (byName.containsKey(legacyName) || data > 0)) {
|
||||
byName.put(legacyName + ":" + data, one);
|
||||
}
|
||||
byName.put(legacyName, one);
|
||||
}
|
||||
}
|
||||
|
||||
if (byName.containsKey(mojangName) && Version.isCurrentEqualOrLower(Version.v1_13_R1))
|
||||
byName.put(mojangName + ":" + data, one);
|
||||
else
|
||||
byName.put(mojangName, one);
|
||||
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_13_R1)) {
|
||||
Integer id = one.getId();
|
||||
if (byName.containsKey(String.valueOf(id)) || data > 0)
|
||||
byName.put(id + ":" + data, one);
|
||||
else
|
||||
byName.put(String.valueOf(id), one);
|
||||
if (!byId.containsKey(id))
|
||||
byId.put(id, one);
|
||||
if (!byId.containsKey(one.getLegacyId()))
|
||||
byId.put(one.getLegacyId(), one);
|
||||
if (one.getLegacyData() == 0)
|
||||
byId.put(one.getLegacyId(), one);
|
||||
if (byName.containsKey(String.valueOf(legacyId)) || data > 0)
|
||||
byName.put(legacyId + ":" + data, one);
|
||||
else
|
||||
byName.put(String.valueOf(legacyId), one);
|
||||
}
|
||||
|
||||
byRealMaterial.put(mat, one);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public CMIItemStack getItem(Material mat) {
|
||||
CMIMaterial cmat = CMIMaterial.get(mat);
|
||||
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);
|
||||
}
|
||||
|
||||
public static CMIItemStack getItem(ItemStack item) {
|
||||
if (item == null)
|
||||
item = new ItemStack(Material.AIR);
|
||||
CMIItemStack cm = getItem(CMIMaterial.get(item));
|
||||
if (cm == null)
|
||||
return new CMIItemStack(Material.AIR);
|
||||
cm.setItemStack(item);
|
||||
return cm;
|
||||
}
|
||||
|
||||
HashMap<String, ItemStack> headCache = new HashMap<>();
|
||||
|
||||
public CMIItemStack getItem(String name) {
|
||||
return getItem(name, null);
|
||||
}
|
||||
|
||||
public CMIItemStack getItem(String name, CMIAsyncHead ahead) {
|
||||
if (name == null)
|
||||
return null;
|
||||
// if (byBukkitName.isEmpty())
|
||||
// load();
|
||||
CMIItemStack cm = null;
|
||||
String original = name.replace("minecraft:", "");
|
||||
name = name.toLowerCase().replace("minecraft:", "");
|
||||
name = name.replace("_", "");
|
||||
Integer amount = null;
|
||||
CMIEntityType entityType = null;
|
||||
|
||||
String tag = null;
|
||||
|
||||
if (name.contains("{") && name.contains("}")) {
|
||||
Pattern ptr = Pattern.compile("(\\{).+(\\})");
|
||||
Matcher match = ptr.matcher(name);
|
||||
if (match.find()) {
|
||||
tag = match.group();
|
||||
name = name.replace(match.group(), "");
|
||||
}
|
||||
name = name.replace(" ", " ");
|
||||
}
|
||||
|
||||
String subdata = null;
|
||||
if (name.contains(":")) {
|
||||
CMIMaterial mat = byName.get(name);
|
||||
if (mat != null)
|
||||
return new CMIItemStack(mat);
|
||||
try {
|
||||
subdata = name.split(":")[1];
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (name.contains("-")) {
|
||||
String[] split = name.split("-");
|
||||
if (split.length > 1) {
|
||||
String a = name.split("-")[1];
|
||||
try {
|
||||
amount = Integer.parseInt(a);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
name = name.split("-")[0];
|
||||
}
|
||||
|
||||
if (name.contains(">")) {
|
||||
String[] split = name.split(">");
|
||||
if (split.length > 1) {
|
||||
String a = name.split(">")[1];
|
||||
try {
|
||||
amount = Integer.parseInt(a);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
name = name.split(">")[0];
|
||||
}
|
||||
|
||||
short data = -999;
|
||||
|
||||
if (name.contains(":")) {
|
||||
try {
|
||||
data = (short) Integer.parseInt(name.split(":")[1]);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
entityType = CMIEntityType.getByName(name.split(":")[1]);
|
||||
if (entityType != null)
|
||||
data = (short) entityType.getId();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
name = name.split(":")[0];
|
||||
}
|
||||
|
||||
switch (name.toLowerCase()) {
|
||||
case "skull":
|
||||
cm = CMIMaterial.SKELETON_SKULL.newCMIItemStack();
|
||||
break;
|
||||
case "door":
|
||||
cm = CMIMaterial.SPRUCE_DOOR.newCMIItemStack();
|
||||
break;
|
||||
case "head":
|
||||
cm = CMIMaterial.PLAYER_HEAD.newCMIItemStack();
|
||||
data = 3;
|
||||
|
||||
if (original.contains(":")) {
|
||||
ItemStack old = headCache.get(original);
|
||||
if (old != null) {
|
||||
cm.setItemStack(old);
|
||||
} else {
|
||||
String[] split = original.split(":");
|
||||
if (split.length > 1) {
|
||||
String d = split[1];
|
||||
|
||||
if (d.length() > 36 || d.startsWith("eyJ0ZXh0dXJlcy")) {
|
||||
ItemStack skull = CMIItemStack.getHead(d);
|
||||
headCache.put(original, skull);
|
||||
cm.setItemStack(skull);
|
||||
} else {
|
||||
ItemStack skull = CMIMaterial.PLAYER_HEAD.newItemStack();
|
||||
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
|
||||
if (d.length() == 36) {
|
||||
try {
|
||||
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(d));
|
||||
skullMeta.setOwningPlayer(offPlayer);
|
||||
skull.setItemMeta(skullMeta);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_16_R3)) {
|
||||
|
||||
if ((ahead != null && !ahead.isForce() || ahead == null) && Bukkit.getPlayer(d) != null) {
|
||||
Player player = Bukkit.getPlayer(d);
|
||||
skullMeta.setOwningPlayer(player);
|
||||
skull.setItemMeta(skullMeta);
|
||||
headCache.put(original, skull);
|
||||
} else {
|
||||
|
||||
if (ahead != null) {
|
||||
ahead.setAsyncHead(true);
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> {
|
||||
OfflinePlayer offlineP = Bukkit.getOfflinePlayer(d);
|
||||
if (offlineP != null) {
|
||||
skullMeta.setOwningPlayer(offlineP);
|
||||
skull.setItemMeta(skullMeta);
|
||||
headCache.put(original, skull);
|
||||
|
||||
// Forcing server to load skin information
|
||||
Bukkit.createInventory(null, InventoryType.CHEST, "").addItem(skull);
|
||||
|
||||
skull.setItemMeta(skullMeta);
|
||||
headCache.put(original, skull);
|
||||
|
||||
if (ahead != null)
|
||||
ahead.afterAsyncUpdate(skull);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
skullMeta.setOwner(d);
|
||||
skull.setItemMeta(skullMeta);
|
||||
}
|
||||
|
||||
if (ahead == null || !ahead.isAsyncHead()) {
|
||||
skull.setItemMeta(skullMeta);
|
||||
headCache.put(original, skull);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "map":
|
||||
cm = CMIMaterial.FILLED_MAP.newCMIItemStack();
|
||||
|
||||
if (original.contains(":") && data > 0) {
|
||||
ItemStack stack = cm.getItemStack();
|
||||
MapMeta map = (MapMeta) stack.getItemMeta();
|
||||
map.setMapId(data);
|
||||
stack.setItemMeta(map);
|
||||
cm.setItemStack(stack);
|
||||
return cm;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
CMIMaterial cmat = CMIMaterial.get(subdata == null ? name : name + ":" + subdata);
|
||||
if (cmat == null || cmat.equals(CMIMaterial.NONE)) {
|
||||
cmat = CMIMaterial.get(name);
|
||||
}
|
||||
|
||||
if (cmat != null && !cmat.equals(CMIMaterial.NONE)) {
|
||||
cm = cmat.newCMIItemStack();
|
||||
} else
|
||||
cmat = CMIMaterial.get(subdata == null ? original : original + ":" + subdata);
|
||||
|
||||
if (cmat != null && !cmat.equals(CMIMaterial.NONE))
|
||||
cm = cmat.newCMIItemStack();
|
||||
|
||||
if (cm == null) {
|
||||
try {
|
||||
Material match = Material.matchMaterial(original);
|
||||
if (match != null) {
|
||||
if (Version.isCurrentLower(Version.v1_13_R1) || !CMIMaterial.get(match).isLegacy() && CMIMaterial.get(match) != CMIMaterial.NONE) {
|
||||
cm = new CMIItemStack(match);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (cm != null && entityType != null)
|
||||
cm.setEntityType(entityType);
|
||||
|
||||
CMIItemStack ncm = null;
|
||||
if (cm != null)
|
||||
ncm = cm.clone();
|
||||
|
||||
if (ncm != null && data != -999) {
|
||||
if (ncm.getMaxDurability() > 15) {
|
||||
ncm.setData((short) 0);
|
||||
} else {
|
||||
ncm.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
// if (ncm != null && tag != null) {
|
||||
// ncm.setTag(CMIChatColor.translate(tag));
|
||||
// }
|
||||
|
||||
if (ncm != null && amount != null)
|
||||
ncm.setAmount(amount);
|
||||
|
||||
if (ncm != null && subdata != null) {
|
||||
if (ncm.getCMIType().isPotion() || ncm.getCMIType() == CMIMaterial.SPLASH_POTION
|
||||
|| ncm.getCMIType() == CMIMaterial.TIPPED_ARROW) {
|
||||
Integer d = null;
|
||||
PotionEffectType type = null;
|
||||
Boolean upgraded = false;
|
||||
Boolean extended = false;
|
||||
String[] split = subdata.split("-");
|
||||
try {
|
||||
d = Integer.parseInt(split.length > 0 ? split[0] : subdata);
|
||||
type = PotionEffectType.getById(d);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
String n = (split.length > 0 ? split[0] : subdata).replace("_", "");
|
||||
for (PotionEffectType one : PotionEffectType.values()) {
|
||||
if (one == null)
|
||||
continue;
|
||||
if (n.equalsIgnoreCase(one.getName().replace("_", ""))) {
|
||||
type = one;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (split.length > 1) {
|
||||
upgraded = Boolean.parseBoolean(split[1]);
|
||||
}
|
||||
if (split.length > 2) {
|
||||
extended = Boolean.parseBoolean(split[2]);
|
||||
}
|
||||
ItemStack item = ncm.getItemStack();
|
||||
if (extended && upgraded)
|
||||
extended = false;
|
||||
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
||||
meta.setBasePotionData(new PotionData(PotionType.getByEffect(type), extended, upgraded));
|
||||
item.setItemMeta(meta);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ncm;
|
||||
}
|
||||
|
||||
public Material getMaterial(String name) {
|
||||
CMIItemStack cm = getItem(name);
|
||||
return cm == null ? Material.AIR : cm.getType();
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2017 Zrips
|
||||
*/
|
||||
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private static void initialize() {
|
||||
try {
|
||||
CraftServerClass = getBukkitClass("CraftServer");
|
||||
CraftServer = CraftServerClass.cast(Bukkit.getServer());
|
||||
CraftItemStack = getBukkitClass("inventory.CraftItemStack");
|
||||
Item = getMinecraftClass("Item");
|
||||
IStack = getMinecraftClass("ItemStack");
|
||||
} catch (ClassCastException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> getBukkitClass(String nmsClassString) throws ClassNotFoundException {
|
||||
return Class.forName("org.bukkit.craftbukkit." + Version.getCurrent() + "." + nmsClassString);
|
||||
}
|
||||
|
||||
public static Class<?> getMinecraftClass(String nmsClassString) throws ClassNotFoundException {
|
||||
return Class.forName("net.minecraft.server." + Version.getCurrent() + "." + nmsClassString);
|
||||
}
|
||||
|
||||
public static String getItemMinecraftName(ItemStack item) {
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
Field field = Item.getField("REGISTRY");
|
||||
Object reg = field.get(field);
|
||||
Method meth = reg.getClass().getMethod("b", Object.class);
|
||||
meth.setAccessible(true);
|
||||
Method secmeth = nmsStack.getClass().getMethod("getItem");
|
||||
Object res2 = secmeth.invoke(nmsStack);
|
||||
Object res = meth.invoke(reg, res2);
|
||||
return res.toString();
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getItemMinecraftNamePath(ItemStack item) {
|
||||
try {
|
||||
Object nmsStack = asNMSCopy(item);
|
||||
Method itemMeth = Item.getMethod("getById", int.class);
|
||||
@SuppressWarnings("deprecation")
|
||||
Object res = itemMeth.invoke(Item, item.getType().getId());
|
||||
Method nameThingy = Item.getMethod("j", IStack);
|
||||
Object resThingy = nameThingy.invoke(res, nmsStack);
|
||||
return resThingy.toString();
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object asNMSCopy(ItemStack item) {
|
||||
try {
|
||||
Method meth = CraftItemStack.getMethod("asNMSCopy", ItemStack.class);
|
||||
return meth.invoke(CraftItemStack, item);
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object asBukkitCopy(Object item) {
|
||||
try {
|
||||
Method meth = CraftItemStack.getMethod("asBukkitCopy", IStack);
|
||||
return meth.invoke(CraftItemStack, item);
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getCraftServer() {
|
||||
return CraftServer;
|
||||
}
|
||||
|
||||
public static ItemStack getItemInOffHand(org.bukkit.entity.Player player) {
|
||||
return Version.getCurrent().isLower(Version.v1_9_R1) ? null : player.getInventory().getItemInOffHand();
|
||||
}
|
||||
|
||||
public void setEndermiteActive(Entity ent, boolean state) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,607 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class RawMessage {
|
||||
|
||||
List<String> parts = new ArrayList<String>();
|
||||
List<String> onlyText = new ArrayList<String>();
|
||||
|
||||
LinkedHashMap<RawMessagePartType, String> temp = new LinkedHashMap<RawMessagePartType, String>();
|
||||
|
||||
RawMessageFragment fragment = new RawMessageFragment();
|
||||
RawMessageFragment hoverFragment = new RawMessageFragment();
|
||||
|
||||
private RawMessageFragment frozenFragment = new RawMessageFragment();
|
||||
private boolean freezeFormat = false;
|
||||
|
||||
private String combined = "";
|
||||
String combinedClean = "";
|
||||
|
||||
private boolean dontBreakLine = false;
|
||||
|
||||
public void clear() {
|
||||
parts = new ArrayList<String>();
|
||||
onlyText = new ArrayList<String>();
|
||||
combined = "";
|
||||
combinedClean = "";
|
||||
}
|
||||
|
||||
private String textIntoJson(String text, boolean hover) {
|
||||
if (text.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
if (text.equalsIgnoreCase(" ")) {
|
||||
return " ";
|
||||
}
|
||||
text = CMIChatColor.deColorize(text);
|
||||
|
||||
Matcher match = CMIChatColor.fullPattern.matcher(text);
|
||||
String matcher = null;
|
||||
|
||||
List<RawMessageFragment> fragments = new ArrayList<RawMessageFragment>();
|
||||
|
||||
RawMessageFragment f = hover ? hoverFragment : fragment;
|
||||
|
||||
String lastText = "";
|
||||
while (match.find()) {
|
||||
matcher = match.group();
|
||||
String[] split = text.split(matcher.replace("#", "\\#").replace("{", "\\{").replace("}", "\\}"), 2);
|
||||
text = "";
|
||||
for (int i = 1; i < split.length; i++) {
|
||||
text += split[i];
|
||||
}
|
||||
if (split[0] != null && !split[0].isEmpty()) {
|
||||
String t = split[0];
|
||||
|
||||
String t2 = lastText;
|
||||
lastText = t;
|
||||
|
||||
if (t2.endsWith(" ") && t.startsWith(" ")) {
|
||||
t = t.substring(1);
|
||||
}
|
||||
|
||||
f.setText(t);
|
||||
fragments.add(f);
|
||||
f = new RawMessageFragment(f);
|
||||
}
|
||||
|
||||
if (matcher.startsWith(CMIChatColor.colorFontPrefix)) {
|
||||
f.setFont(matcher);
|
||||
continue;
|
||||
}
|
||||
|
||||
CMIChatColor color = CMIChatColor.getColor(matcher);
|
||||
if (color == null)
|
||||
continue;
|
||||
|
||||
if (color.isColor()) {
|
||||
f.setLastColor(color);
|
||||
} else {
|
||||
f.addFormat(color);
|
||||
}
|
||||
}
|
||||
|
||||
if (!text.isEmpty()) {
|
||||
|
||||
if (lastText.endsWith(" ") && text.startsWith(" "))
|
||||
text = text.substring(1);
|
||||
|
||||
RawMessageFragment t = new RawMessageFragment(f);
|
||||
|
||||
t.setText(text);
|
||||
fragments.add(t);
|
||||
}
|
||||
|
||||
if (hover)
|
||||
hoverFragment = f;
|
||||
else
|
||||
fragment = f;
|
||||
|
||||
StringBuilder finalText = new StringBuilder();
|
||||
|
||||
for (RawMessageFragment one : fragments) {
|
||||
if (!finalText.toString().isEmpty())
|
||||
finalText.append("},{");
|
||||
StringBuilder options = new StringBuilder();
|
||||
for (CMIChatColor format : one.getFormats()) {
|
||||
if (!options.toString().isEmpty())
|
||||
options.append(',');
|
||||
if (format.equals(CMIChatColor.UNDERLINE))
|
||||
options.append("\"underlined\":true");
|
||||
else if (format.equals(CMIChatColor.BOLD))
|
||||
options.append("\"bold\":true");
|
||||
else if (format.equals(CMIChatColor.ITALIC))
|
||||
options.append("\"italic\":true");
|
||||
else if (format.equals(CMIChatColor.STRIKETHROUGH))
|
||||
options.append("\"strikethrough\":true");
|
||||
else if (format.equals(CMIChatColor.OBFUSCATED))
|
||||
options.append("\"obfuscated\":true");
|
||||
}
|
||||
if (!options.toString().isEmpty()) {
|
||||
finalText.append(options.toString());
|
||||
finalText.append(',');
|
||||
}
|
||||
|
||||
if (one.getFont() != null) {
|
||||
finalText.append("\"font\":\"" + one.getFont() + "\",");
|
||||
|
||||
}
|
||||
|
||||
if (one.getLastColor() != null) {
|
||||
if (one.getLastColor().getHex() != null)
|
||||
finalText.append("\"color\":\"#" + one.getLastColor().getHex() + "\",");
|
||||
else if (one.getLastColor().getName() != null) {
|
||||
finalText.append("\"color\":\"" + one.getLastColor().getName().toLowerCase() + "\",");
|
||||
}
|
||||
}
|
||||
|
||||
String t = one.getText();
|
||||
|
||||
// Old server support, we need to add colors and formats to the text directly
|
||||
if (Version.isCurrentLower(Version.v1_16_R1)) {
|
||||
StringBuilder oldColors = new StringBuilder();
|
||||
if (one.getLastColor() != null && one.getLastColor().getName() != null) {
|
||||
oldColors.append(one.getLastColor().getColorCode());
|
||||
}
|
||||
for (CMIChatColor format : one.getFormats()) {
|
||||
if (format.equals(CMIChatColor.UNDERLINE))
|
||||
oldColors.append("&n");
|
||||
else if (format.equals(CMIChatColor.BOLD))
|
||||
oldColors.append("&l");
|
||||
else if (format.equals(CMIChatColor.ITALIC))
|
||||
oldColors.append("&o");
|
||||
else if (format.equals(CMIChatColor.STRIKETHROUGH))
|
||||
oldColors.append("&m");
|
||||
else if (format.equals(CMIChatColor.OBFUSCATED))
|
||||
oldColors.append("&k");
|
||||
}
|
||||
t = oldColors.toString() + t;
|
||||
}
|
||||
|
||||
finalText.append("\"text\":\"" + escape(t, hover ? false : this.isDontBreakLine()) + "\"");
|
||||
}
|
||||
|
||||
if (finalText.toString().isEmpty())
|
||||
return "";
|
||||
// CMIDebug.d(finalText);
|
||||
return "{" + finalText.toString() + "}";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage add(String text, String hoverText, String command, String suggestion, String url) {
|
||||
add(text, hoverText, command, suggestion, url, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage add(String text, String hoverText, String command, String suggestion, String url, String insertion) {
|
||||
this.addText(text);
|
||||
this.addHover(hoverText);
|
||||
this.addCommand(command);
|
||||
this.addSuggestion(suggestion);
|
||||
this.addUrl(url);
|
||||
this.addInsertion(insertion);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage addUrl(String text, String url) {
|
||||
addUrl(text, url, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage addUrl(String text, String url, String hoverText) {
|
||||
this.addText(text);
|
||||
this.addHover(hoverText);
|
||||
this.addUrl(url);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage add(String text) {
|
||||
return add(text, null, null, null, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage add(String text, String hoverText) {
|
||||
return add(text, hoverText, null, null, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage add(String text, List<String> hoverText) {
|
||||
|
||||
String hover = "";
|
||||
if (hoverText != null)
|
||||
for (String one : hoverText) {
|
||||
if (!hover.isEmpty())
|
||||
hover += "\n";
|
||||
hover += one;
|
||||
}
|
||||
return add(text, hover.isEmpty() ? null : hover, null, null, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage add(String text, String hoverText, String command) {
|
||||
return add(text, hoverText, command, null, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage add(String text, String hoverText, String command, String suggestion) {
|
||||
return add(text, hoverText, command, suggestion, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage addHoverText(List<String> hoverText) {
|
||||
return addHover(hoverText);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RawMessage addHoverText(String hover) {
|
||||
return addHover(hover);
|
||||
}
|
||||
|
||||
public RawMessage addItem(String text, ItemStack item, String command, String suggestion, String insertion) {
|
||||
this.addText(text);
|
||||
this.addCommand(command);
|
||||
this.addSuggestion(suggestion);
|
||||
this.addInsertion(insertion);
|
||||
this.addItem(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage addText(String text) {
|
||||
if (text == null || text.isEmpty())
|
||||
return this;
|
||||
if (temp.containsKey(RawMessagePartType.Text))
|
||||
build();
|
||||
|
||||
// if (this.isDontBreakLine()) {
|
||||
onlyText.add(CMIChatColor.translate(text));
|
||||
|
||||
// text = escape(text, this.isDontBreakLine());
|
||||
// }
|
||||
text = textIntoJson(text, false);
|
||||
String f = "";
|
||||
if (text.isEmpty())
|
||||
f = "\"text\":\"\"";
|
||||
else if (text.equalsIgnoreCase(" "))
|
||||
f = "\"text\":\" \"";
|
||||
else
|
||||
f = "\"text\":\"\",\"extra\":[" + CMIChatColor.translate(text).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "]";
|
||||
temp.put(RawMessagePartType.Text, f);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage addHover(List<String> hoverText) {
|
||||
StringBuilder hover = new StringBuilder();
|
||||
if (hoverText != null) {
|
||||
for (String one : hoverText) {
|
||||
if (!hover.toString().isEmpty())
|
||||
hover.append("\n");
|
||||
hover.append(one);
|
||||
}
|
||||
}
|
||||
return addHover(hover.toString());
|
||||
}
|
||||
|
||||
public RawMessage addHover(String hover) {
|
||||
hoverFragment = new RawMessageFragment();
|
||||
if (hover == null || hover.isEmpty())
|
||||
return this;
|
||||
|
||||
hover = textIntoJson(hover, true);
|
||||
// hover = escape(hover, false);
|
||||
String f = "";
|
||||
if (hover.isEmpty())
|
||||
f = "\"text\":\"\"";
|
||||
else if (hover.equalsIgnoreCase(" "))
|
||||
f = "\"text\":\" \"";
|
||||
else
|
||||
f = "\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + CMIChatColor.translate(hover).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "]}}";
|
||||
temp.put(RawMessagePartType.HoverText, f);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage addCommand(String command) {
|
||||
if (command == null || command.isEmpty())
|
||||
return this;
|
||||
if (!command.startsWith("/"))
|
||||
command = "/" + 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;
|
||||
}
|
||||
|
||||
public RawMessage addSuggestion(String suggestion) {
|
||||
if (suggestion == null || suggestion.isEmpty())
|
||||
return this;
|
||||
suggestion = escape(suggestion, true);
|
||||
String f = "\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + CMIChatColor.deColorize(suggestion).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "\"}";
|
||||
temp.put(RawMessagePartType.ClickSuggestion, f);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage addInsertion(String insertion) {
|
||||
if (insertion == null || insertion.isEmpty())
|
||||
return this;
|
||||
insertion = escape(insertion, true);
|
||||
String f = "\"insertion\":\"" + CMIChatColor.deColorize(insertion).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "\"";
|
||||
temp.put(RawMessagePartType.ClickInsertion, f);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage addItem(ItemStack item) {
|
||||
if (item == null)
|
||||
return this;
|
||||
String res = CMIReflections.toJson(item.clone());
|
||||
String f = "\"hoverEvent\":{\"action\":\"show_item\",\"value\":\"" + escape(res, true) + "\"}";
|
||||
temp.put(RawMessagePartType.HoverItem, f);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage addUrl(String url) {
|
||||
if (url == null || url.isEmpty())
|
||||
return this;
|
||||
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
|
||||
url = "http://" + url;
|
||||
|
||||
String f = "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + CMIChatColor.deColorize(url).replace(CMIChatColor.colorReplacerPlaceholder, "&") + "\"}";
|
||||
|
||||
temp.put(RawMessagePartType.ClickLink, f);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage build() {
|
||||
if (temp.isEmpty())
|
||||
return this;
|
||||
|
||||
if (!temp.containsKey(RawMessagePartType.Text))
|
||||
return this;
|
||||
String part = "";
|
||||
for (RawMessagePartType one : RawMessagePartType.values()) {
|
||||
String t = temp.get(one);
|
||||
if (t == null)
|
||||
continue;
|
||||
if (!part.isEmpty())
|
||||
part += ",";
|
||||
part += t;
|
||||
}
|
||||
part = "{" + part + "}";
|
||||
temp.clear();
|
||||
parts.add(part);
|
||||
return this;
|
||||
}
|
||||
|
||||
private static String escape(String s, boolean escapeNewLn) {
|
||||
|
||||
if (s == null)
|
||||
return null;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
escape(s, sb);
|
||||
if (escapeNewLn)
|
||||
return sb.toString().replace(nl, "\\\\n");
|
||||
return sb.toString().replace(nl, "\\n");
|
||||
}
|
||||
|
||||
private static final String nl = "\u00A5n";
|
||||
|
||||
private static void escape(String s, StringBuffer sb) {
|
||||
s = s.replace("\n", nl);
|
||||
s = s.replace("\\n", nl);
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
|
||||
switch (ch) {
|
||||
case '"':
|
||||
sb.append("\\\"");
|
||||
break;
|
||||
case '\n':
|
||||
sb.append("\\n");
|
||||
break;
|
||||
case '\\':
|
||||
sb.append("\\\\");
|
||||
break;
|
||||
case '\b':
|
||||
sb.append("\\b");
|
||||
break;
|
||||
case '\f':
|
||||
sb.append("\\f");
|
||||
break;
|
||||
case '\r':
|
||||
sb.append("\\r");
|
||||
break;
|
||||
case '\t':
|
||||
sb.append("\\t");
|
||||
break;
|
||||
case '/':
|
||||
sb.append("\\/");
|
||||
break;
|
||||
default:
|
||||
if ((ch >= '\u0000' && ch <= '\u001F') || (ch >= '\u007F' && ch <= '\u009F') || (ch >= '\u2000' && ch <= '\u20FF')) {
|
||||
String ss = Integer.toHexString(ch);
|
||||
sb.append("\\u");
|
||||
for (int k = 0; k < 4 - ss.length(); k++) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(ss.toUpperCase());
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for (int i = 0; i < s.length(); i++) {
|
||||
// char ch = s.charAt(i);
|
||||
// if (String.valueOf(ch).equals(nl)) {
|
||||
// if (escapeNewLn) {
|
||||
// sb.append("\\n");
|
||||
// } else {
|
||||
// sb.append("\n");
|
||||
// }
|
||||
// } else
|
||||
// sb.append(ch);
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
public List<String> softCombine() {
|
||||
List<String> ls = new ArrayList<String>();
|
||||
String f = "";
|
||||
for (String part : parts) {
|
||||
if (f.isEmpty())
|
||||
f = "[\"\",";
|
||||
else {
|
||||
if (f.length() > 30000) {
|
||||
ls.add(f + "]");
|
||||
f = "[\"\"," + part;
|
||||
continue;
|
||||
}
|
||||
f += ",";
|
||||
}
|
||||
f += part;
|
||||
}
|
||||
if (!f.isEmpty())
|
||||
f += "]";
|
||||
ls.add(f);
|
||||
return ls;
|
||||
}
|
||||
|
||||
private RawMessage combine() {
|
||||
String f = "";
|
||||
for (String part : parts) {
|
||||
if (f.isEmpty())
|
||||
f = "[\"\",";
|
||||
else
|
||||
f += ",";
|
||||
f += part;
|
||||
}
|
||||
if (!f.isEmpty())
|
||||
f += "]";
|
||||
|
||||
if (f.isEmpty())
|
||||
f = "{\"text\":\" \"}";
|
||||
|
||||
combined = f;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage combineClean() {
|
||||
String f = "";
|
||||
for (String part : onlyText) {
|
||||
f += part.replace("\\\"", "\"");
|
||||
}
|
||||
combinedClean = f;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RawMessage show(Player player) {
|
||||
return show(player, true);
|
||||
}
|
||||
|
||||
public RawMessage show(Player player, boolean softCombined) {
|
||||
if (player == null)
|
||||
return this;
|
||||
if (combined.isEmpty()) {
|
||||
this.build();
|
||||
combine();
|
||||
}
|
||||
|
||||
if (!player.isOnline())
|
||||
return this;
|
||||
|
||||
if (softCombined) {
|
||||
for (String one : softCombine()) {
|
||||
if (one.isEmpty())
|
||||
continue;
|
||||
RawMessageManager.send(player, one);
|
||||
}
|
||||
} else {
|
||||
RawMessageManager.send(player, combined);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getFinalLenght() {
|
||||
String f = "";
|
||||
for (String part : parts) {
|
||||
if (f.isEmpty())
|
||||
f = "[\"\",";
|
||||
else
|
||||
f += ",";
|
||||
f += part;
|
||||
}
|
||||
if (!f.isEmpty())
|
||||
f += "]";
|
||||
return f.length();
|
||||
}
|
||||
|
||||
public RawMessage show(CommandSender sender) {
|
||||
if (combined.isEmpty()) {
|
||||
this.build();
|
||||
combine();
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
show((Player) sender);
|
||||
} else {
|
||||
sender.sendMessage(this.combineClean().combinedClean);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRaw() {
|
||||
if (combined.isEmpty()) {
|
||||
build();
|
||||
combine();
|
||||
}
|
||||
return combined;
|
||||
}
|
||||
|
||||
public void setCombined(String combined) {
|
||||
this.combined = combined;
|
||||
}
|
||||
|
||||
public String getShortRaw() {
|
||||
build();
|
||||
String f = "";
|
||||
for (String part : parts) {
|
||||
if (!f.isEmpty())
|
||||
f += ",";
|
||||
f += part;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
public boolean isDontBreakLine() {
|
||||
return dontBreakLine;
|
||||
}
|
||||
|
||||
public void setDontBreakLine(boolean dontBreakLine) {
|
||||
this.dontBreakLine = dontBreakLine;
|
||||
}
|
||||
|
||||
public boolean isFormatFrozen() {
|
||||
return freezeFormat;
|
||||
}
|
||||
|
||||
public void freezeFormat() {
|
||||
frozenFragment = new RawMessageFragment(fragment);
|
||||
this.freezeFormat = true;
|
||||
}
|
||||
|
||||
public void unFreezeFormat() {
|
||||
fragment = new RawMessageFragment(frozenFragment);
|
||||
this.freezeFormat = false;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class RawMessageFragment {
|
||||
|
||||
private CMIChatColor lastColor = null;
|
||||
private Set<CMIChatColor> formats = new HashSet<CMIChatColor>();
|
||||
private String font = null;
|
||||
private String text = "";
|
||||
|
||||
public RawMessageFragment() {
|
||||
}
|
||||
|
||||
public RawMessageFragment(RawMessageFragment old) {
|
||||
this.lastColor = old.lastColor;
|
||||
this.formats = new HashSet<CMIChatColor>(old.formats);
|
||||
this.font = old.font;
|
||||
}
|
||||
|
||||
public CMIChatColor getLastColor() {
|
||||
return lastColor;
|
||||
}
|
||||
|
||||
public void setLastColor(CMIChatColor lastColor) {
|
||||
this.lastColor = lastColor;
|
||||
formats.clear();
|
||||
}
|
||||
|
||||
public Set<CMIChatColor> getFormats() {
|
||||
return formats;
|
||||
}
|
||||
|
||||
public void setFormats(Set<CMIChatColor> formats) {
|
||||
this.formats = formats;
|
||||
}
|
||||
|
||||
public void addFormat(CMIChatColor format) {
|
||||
if (format.isReset()) {
|
||||
this.formats.clear();
|
||||
this.lastColor = null;
|
||||
return;
|
||||
}
|
||||
this.formats.add(format);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getFont() {
|
||||
return font;
|
||||
}
|
||||
|
||||
public void setFont(String font) {
|
||||
if (font.startsWith(CMIChatColor.colorFontPrefix) && font.length() > CMIChatColor.colorFontPrefix.length())
|
||||
font = font.substring(CMIChatColor.colorFontPrefix.length());
|
||||
if (font.endsWith(CMIChatColor.colorCodeSuffix) && font.length() > CMIChatColor.colorCodeSuffix.length())
|
||||
font = font.substring(0, font.length() - CMIChatColor.colorCodeSuffix.length());
|
||||
this.font = font;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RawMessageManager {
|
||||
|
||||
private static Object packet;
|
||||
private static Method getHandle;
|
||||
private static Method sendPacket;
|
||||
private static Field playerConnection;
|
||||
private static Class<?> nmsChatSerializer;
|
||||
private static Class<?> nmsIChatBaseComponent;
|
||||
private static Class<?> packetType;
|
||||
|
||||
private static Class<?> ChatMessageclz;
|
||||
private static Class<?> sub;
|
||||
private static Object[] consts;
|
||||
|
||||
static {
|
||||
Version version = Version.getCurrent();
|
||||
try {
|
||||
packetType = Class.forName("net.minecraft.server." + version + ".PacketPlayOutChat");
|
||||
Class<?> typeCraftPlayer = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftPlayer");
|
||||
Class<?> typeNMSPlayer = Class.forName("net.minecraft.server." + version + ".EntityPlayer");
|
||||
Class<?> typePlayerConnection = Class.forName("net.minecraft.server." + version + ".PlayerConnection");
|
||||
nmsChatSerializer = Class.forName(getChatSerializerClasspath());
|
||||
nmsIChatBaseComponent = Class.forName("net.minecraft.server." + version + ".IChatBaseComponent");
|
||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName("net.minecraft.server." + version + ".Packet"));
|
||||
if (Version.isCurrentHigher(Version.v1_11_R1)) {
|
||||
ChatMessageclz = Class.forName("net.minecraft.server." + version + ".ChatMessageType");
|
||||
consts = ChatMessageclz.getEnumConstants();
|
||||
sub = consts[2].getClass();
|
||||
}
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | NoSuchFieldException ex) {
|
||||
Bukkit.getConsoleSender().sendMessage("Error {0} ");
|
||||
Bukkit.getConsoleSender().sendMessage(ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(CommandSender receivingPacket, String msg) {
|
||||
if (receivingPacket instanceof Player)
|
||||
send((Player) receivingPacket, msg);
|
||||
else
|
||||
receivingPacket.sendMessage(msg);
|
||||
}
|
||||
|
||||
public static void send(Player receivingPacket, String json) {
|
||||
if (receivingPacket == null)
|
||||
return;
|
||||
if (!receivingPacket.isOnline())
|
||||
return;
|
||||
if (json == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, json);
|
||||
if (Version.isCurrentHigher(Version.v1_15_R1))
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, sub, UUID.class).newInstance(serialized, consts[1], receivingPacket.getUniqueId());
|
||||
else if (Version.isCurrentHigher(Version.v1_11_R1))
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, sub).newInstance(serialized, consts[1]);
|
||||
else if (Version.isCurrentHigher(Version.v1_7_R4)) {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, byte.class).newInstance(serialized, (byte) 1);
|
||||
} else {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, int.class).newInstance(serialized, 1);
|
||||
}
|
||||
Object player = getHandle.invoke(receivingPacket);
|
||||
Object connection = playerConnection.get(player);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Bukkit.getConsoleSender().sendMessage("Failed to show json message with packets, using command approach");
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:tellraw \"" + receivingPacket.getName() + "\" " + json);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getChatSerializerClasspath() {
|
||||
if (!Version.isCurrentHigher(Version.v1_8_R2))
|
||||
return "net.minecraft.server." + Version.getCurrent() + ".ChatSerializer";
|
||||
return "net.minecraft.server." + Version.getCurrent() + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
public enum RawMessagePartType {
|
||||
Text, HoverText, HoverItem, HoverEntity, HoverAchievement, ClickLink, ClickCommand, ClickSuggestion, ClickInsertion;
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
public class TitleMessageManager {
|
||||
private static Method getHandle;
|
||||
private static Method sendPacket;
|
||||
private static Field playerConnection;
|
||||
private static Class<?> nmsIChatBaseComponent;
|
||||
|
||||
private static Constructor<?> nmsPacketPlayOutTitle;
|
||||
private static Constructor<?> nmsPacketPlayOutTimes;
|
||||
private static Class<?> enumTitleAction;
|
||||
private static Method fromString;
|
||||
private static boolean simpleTitleMessages = false;
|
||||
|
||||
static {
|
||||
if (Version.isCurrentHigher(Version.v1_7_R4)) {
|
||||
Version version = Version.getCurrent();
|
||||
try {
|
||||
Class<?> typeCraftPlayer = Class.forName("org.bukkit.craftbukkit." + version + ".entity.CraftPlayer");
|
||||
Class<?> typeNMSPlayer = Class.forName("net.minecraft.server." + version + ".EntityPlayer");
|
||||
Class<?> typePlayerConnection = Class.forName("net.minecraft.server." + version + ".PlayerConnection");
|
||||
nmsIChatBaseComponent = Class.forName("net.minecraft.server." + version + ".IChatBaseComponent");
|
||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName("net.minecraft.server." + version + ".Packet"));
|
||||
} catch (ReflectiveOperationException | SecurityException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
|
||||
}
|
||||
|
||||
// Title
|
||||
try {
|
||||
Class<?> typePacketPlayOutTitle = Class.forName(getPacketPlayOutTitleClasspath());
|
||||
enumTitleAction = Class.forName(getEnumTitleActionClasspath());
|
||||
nmsPacketPlayOutTitle = typePacketPlayOutTitle.getConstructor(enumTitleAction, nmsIChatBaseComponent);
|
||||
nmsPacketPlayOutTimes = typePacketPlayOutTitle.getConstructor(int.class, int.class, int.class);
|
||||
fromString = Class.forName("org.bukkit.craftbukkit." + version + ".util.CraftChatMessage").getMethod("fromString", String.class);
|
||||
} catch (ReflectiveOperationException | SecurityException ex) {
|
||||
simpleTitleMessages = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(final Player receivingPacket, final Object title, final Object subtitle) {
|
||||
send(receivingPacket, title, subtitle, 0, 40, 10);
|
||||
}
|
||||
|
||||
public static void send(final Player receivingPacket, final Object title, final Object subtitle, final int fadeIn, final int keep, final int fadeOut) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String t = title == null ? "" : CMIChatColor.translate((String) title);
|
||||
String s = subtitle == null ? "" : CMIChatColor.translate((String) subtitle);
|
||||
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_7_R4)) {
|
||||
ActionBarManager.send(receivingPacket, t + s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (simpleTitleMessages) {
|
||||
receivingPacket.sendMessage(t);
|
||||
receivingPacket.sendMessage(s);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
switch (Version.getCurrent()) {
|
||||
case v1_12_R1:
|
||||
case v1_13_R1:
|
||||
case v1_13_R2:
|
||||
case v1_14_R1:
|
||||
case v1_15_R1:
|
||||
case v1_16_R1:
|
||||
default:
|
||||
receivingPacket.sendTitle(t, s, fadeIn, keep, fadeOut);
|
||||
break;
|
||||
case v1_9_R1:
|
||||
case v1_9_R2:
|
||||
case v1_10_R1:
|
||||
case v1_11_R1:
|
||||
case v1_8_R1:
|
||||
case v1_8_R2:
|
||||
case v1_8_R3:
|
||||
Object packetTimes = nmsPacketPlayOutTimes.newInstance(fadeIn, keep, fadeOut);
|
||||
sendPacket(receivingPacket, packetTimes);
|
||||
if (title != null) {
|
||||
Object packetTitle = nmsPacketPlayOutTitle.newInstance(enumTitleAction.getField("TITLE").get(null), ((Object[]) fromString.invoke(null, t))[0]);
|
||||
sendPacket(receivingPacket, packetTitle);
|
||||
}
|
||||
if (subtitle != null) {
|
||||
if (title == null) {
|
||||
Object packetTitle = nmsPacketPlayOutTitle.newInstance(enumTitleAction.getField("TITLE").get(null), ((Object[]) fromString.invoke(null, ""))[0]);
|
||||
sendPacket(receivingPacket, packetTitle);
|
||||
}
|
||||
Object packetSubtitle = nmsPacketPlayOutTitle.newInstance(enumTitleAction.getField("SUBTITLE").get(null), ((Object[]) fromString.invoke(null, s))[0]);
|
||||
sendPacket(receivingPacket, packetSubtitle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (ReflectiveOperationException | SecurityException | IllegalArgumentException ex) {
|
||||
simpleTitleMessages = true;
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Your server can't fully support title messages. They will be shown in chat instead.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void sendPacket(Player player, Object packet) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
Object handle = getHandle.invoke(player);
|
||||
Object connection = playerConnection.get(handle);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
private static String getPacketPlayOutTitleClasspath() {
|
||||
return "net.minecraft.server." + Version.getCurrent() + ".PacketPlayOutTitle";
|
||||
}
|
||||
|
||||
private static String getEnumTitleActionClasspath() {
|
||||
return getPacketPlayOutTitleClasspath() + "$EnumTitleAction";
|
||||
}
|
||||
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public enum Version {
|
||||
v1_7_R1,
|
||||
v1_7_R2,
|
||||
v1_7_R3,
|
||||
v1_7_R4,
|
||||
v1_8_R1,
|
||||
v1_8_R2,
|
||||
v1_8_R3,
|
||||
v1_9_R1,
|
||||
v1_9_R2,
|
||||
v1_10_R1,
|
||||
v1_11_R1,
|
||||
v1_12_R1,
|
||||
v1_13_R1,
|
||||
v1_13_R2,
|
||||
v1_14_R1,
|
||||
v1_15_R1,
|
||||
v1_16_R1,
|
||||
v1_16_R2,
|
||||
v1_16_R3,
|
||||
v1_17_R1,
|
||||
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;
|
||||
private static Version current;
|
||||
|
||||
Version() {
|
||||
try {
|
||||
value = Integer.parseInt(name().replaceAll("[^\\d.]", ""));
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
shortVersion = name().substring(0, name().length() - 3);
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getShortVersion() {
|
||||
return shortVersion;
|
||||
}
|
||||
|
||||
public static Version getCurrent() {
|
||||
if (current != null)
|
||||
return current;
|
||||
|
||||
String[] v = Bukkit.getServer().getClass().getPackage().getName().split("\\.");
|
||||
String vv = v[v.length - 1];
|
||||
for (Version one : values()) {
|
||||
if (one.name().equalsIgnoreCase(vv)) {
|
||||
current = one;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
public boolean isLower(Version version) {
|
||||
return getValue() < version.getValue();
|
||||
}
|
||||
|
||||
public boolean isHigher(Version version) {
|
||||
return getValue() > version.getValue();
|
||||
}
|
||||
|
||||
public boolean isEqualOrLower(Version version) {
|
||||
return getValue() <= version.getValue();
|
||||
}
|
||||
|
||||
public boolean isEqualOrHigher(Version version) {
|
||||
return getValue() >= version.getValue();
|
||||
}
|
||||
|
||||
public static boolean isCurrentEqualOrHigher(Version v) {
|
||||
return getCurrent().getValue() >= v.getValue();
|
||||
}
|
||||
|
||||
public static boolean isCurrentHigher(Version v) {
|
||||
return getCurrent().getValue() > v.getValue();
|
||||
}
|
||||
|
||||
public static boolean isCurrentLower(Version v) {
|
||||
return getCurrent().getValue() < v.getValue();
|
||||
}
|
||||
|
||||
public static boolean isCurrentEqualOrLower(Version v) {
|
||||
return getCurrent().getValue() <= v.getValue();
|
||||
}
|
||||
|
||||
public static boolean isCurrentEqual(Version v) {
|
||||
return getCurrent().getValue() == v.getValue();
|
||||
}
|
||||
}
|
@ -11,10 +11,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMIGUI.CMIGui;
|
||||
import com.gamingmesh.jobs.CMIGUI.CMIGuiButton;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIClickType;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
@ -23,6 +19,12 @@ import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
import net.Zrips.CMILib.CMILib;
|
||||
import net.Zrips.CMILib.GUI.CMIGui;
|
||||
import net.Zrips.CMILib.GUI.CMIGuiButton;
|
||||
import net.Zrips.CMILib.GUI.GUIManager;
|
||||
import net.Zrips.CMILib.GUI.GUIManager.GUIClickType;
|
||||
|
||||
public class GuiManager {
|
||||
|
||||
private Jobs plugin;
|
||||
@ -306,8 +308,8 @@ public class GuiManager {
|
||||
i++;
|
||||
}
|
||||
|
||||
int guiSize = GUIManager.isOpenedGui(player) && GUIManager.getGui(player) != null ?
|
||||
GUIManager.getGui(player).getInvSize().getFields() : Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||
int guiSize = CMILib.getInstance().getGUIManager().isOpenedGui(player) && CMILib.getInstance().getGUIManager().getGui(player) != null ?
|
||||
CMILib.getInstance().getGUIManager().getGui(player).getInvSize().getFields() : Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName()));
|
||||
@ -456,8 +458,8 @@ public class GuiManager {
|
||||
i++;
|
||||
}
|
||||
|
||||
int guiSize = GUIManager.isOpenedGui(player) && GUIManager.getGui(player) != null ?
|
||||
GUIManager.getGui(player).getInvSize().getFields() : Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||
int guiSize = CMILib.getInstance().getGUIManager().isOpenedGui(player) && CMILib.getInstance().getGUIManager().getGui(player) != null ?
|
||||
CMILib.getInstance().getGUIManager().getGui(player).getInvSize().getFields() : Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||
int backButton = Jobs.getGCManager().getJobsGUIBackButton();
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
|
@ -13,23 +13,30 @@ import java.util.Set;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class ItemBoostManager {
|
||||
|
||||
private static final Map<String, JobItems> ITEMS = new HashMap<>();
|
||||
private static final Map<String, JobItems> LEGACY = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void load() {
|
||||
ConfigReader cfg = new ConfigReader("boostedItems.yml");
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void load() {
|
||||
ConfigReader cfg;
|
||||
try {
|
||||
cfg = new ConfigReader(Jobs.getInstance(), "boostedItems.yml");
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
ITEMS.clear();
|
||||
LEGACY.clear();
|
||||
@ -69,7 +76,12 @@ public class ItemBoostManager {
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
cfg = new ConfigReader("boostedItems.yml");
|
||||
try {
|
||||
cfg = new ConfigReader(Jobs.getInstance(), "boostedItems.yml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> keys = cfg.getC().getKeys(false);
|
||||
|
@ -18,42 +18,21 @@
|
||||
|
||||
package com.gamingmesh.jobs;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
import com.gamingmesh.jobs.CMILib.VersionChecker;
|
||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||
import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook;
|
||||
import com.gamingmesh.jobs.Placeholders.Placeholder;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||
import com.gamingmesh.jobs.api.JobsPrePaymentEvent;
|
||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||
import com.gamingmesh.jobs.config.*;
|
||||
import com.gamingmesh.jobs.container.*;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
|
||||
import com.gamingmesh.jobs.dao.JobsDAO;
|
||||
import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||
import com.gamingmesh.jobs.dao.JobsManager;
|
||||
import com.gamingmesh.jobs.economy.*;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPayment14Listener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||
import com.gamingmesh.jobs.stuff.*;
|
||||
import com.gamingmesh.jobs.stuff.complement.JobsChatEvent;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement1;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement2;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
|
||||
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
@ -64,11 +43,80 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Logger;
|
||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||
import com.gamingmesh.jobs.Placeholders.Placeholder;
|
||||
import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||
import com.gamingmesh.jobs.api.JobsPrePaymentEvent;
|
||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||
import com.gamingmesh.jobs.config.BlockProtectionManager;
|
||||
import com.gamingmesh.jobs.config.BossBarManager;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.config.ExploreManager;
|
||||
import com.gamingmesh.jobs.config.GeneralConfigManager;
|
||||
import com.gamingmesh.jobs.config.LanguageManager;
|
||||
import com.gamingmesh.jobs.config.NameTranslatorManager;
|
||||
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
||||
import com.gamingmesh.jobs.config.RestrictedBlockManager;
|
||||
import com.gamingmesh.jobs.config.ScheduleManager;
|
||||
import com.gamingmesh.jobs.config.ShopManager;
|
||||
import com.gamingmesh.jobs.config.TitleManager;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.ArchivedJobs;
|
||||
import com.gamingmesh.jobs.container.BlockProtection;
|
||||
import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.Convert;
|
||||
import com.gamingmesh.jobs.container.CurrencyLimit;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.DBAction;
|
||||
import com.gamingmesh.jobs.container.FastPayment;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.Log;
|
||||
import com.gamingmesh.jobs.container.PlayerInfo;
|
||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||
import com.gamingmesh.jobs.container.Quest;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
|
||||
import com.gamingmesh.jobs.dao.JobsDAO;
|
||||
import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||
import com.gamingmesh.jobs.dao.JobsManager;
|
||||
import com.gamingmesh.jobs.economy.BufferedEconomy;
|
||||
import com.gamingmesh.jobs.economy.BufferedPayment;
|
||||
import com.gamingmesh.jobs.economy.Economy;
|
||||
import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.economy.PointsData;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPayment14Listener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||
import com.gamingmesh.jobs.stuff.CMIScoreboardManager;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
||||
import com.gamingmesh.jobs.stuff.VersionChecker;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement1;
|
||||
import com.gamingmesh.jobs.stuff.complement.Complement2;
|
||||
import com.gamingmesh.jobs.stuff.complement.JobsChatEvent;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
|
||||
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class Jobs extends JavaPlugin {
|
||||
|
||||
@ -90,7 +138,7 @@ public class Jobs extends JavaPlugin {
|
||||
private static JobsManager dbManager;
|
||||
private static ConfigManager configManager;
|
||||
private static GeneralConfigManager gConfigManager;
|
||||
private static CMIReflections reflections;
|
||||
|
||||
private static BufferedEconomy economy;
|
||||
private static PermissionHandler permissionHandler;
|
||||
private static PermissionManager permissionManager;
|
||||
@ -229,12 +277,6 @@ public class Jobs extends JavaPlugin {
|
||||
return bpManager;
|
||||
}
|
||||
|
||||
public static CMIReflections getReflections() {
|
||||
if (reflections == null)
|
||||
reflections = new CMIReflections();
|
||||
return reflections;
|
||||
}
|
||||
|
||||
public static JobsManager getDBManager() {
|
||||
if (dbManager == null)
|
||||
dbManager = new JobsManager(instance);
|
||||
@ -764,8 +806,6 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
HandlerList.unregisterAll(instance);
|
||||
|
||||
com.gamingmesh.jobs.CMIGUI.GUIManager.registerListener();
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
|
||||
pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), instance);
|
||||
}
|
||||
@ -1284,7 +1324,7 @@ public class Jobs extends JavaPlugin {
|
||||
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
||||
if (inform && player.canGetPaid(info)) {
|
||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
||||
ActionBarManager.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
|
||||
CMIActionBar.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1313,7 +1353,7 @@ public class Jobs extends JavaPlugin {
|
||||
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
|
||||
if (inform && player.canGetPaid(info)) {
|
||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
||||
ActionBarManager.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
|
||||
CMIActionBar.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
|
||||
}
|
||||
|
||||
getBpManager().add(block, cd);
|
||||
|
@ -39,9 +39,6 @@ import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
import com.gamingmesh.jobs.api.JobsJoinEvent;
|
||||
import com.gamingmesh.jobs.api.JobsLeaveEvent;
|
||||
import com.gamingmesh.jobs.api.JobsLevelUpEvent;
|
||||
@ -64,6 +61,12 @@ import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.CMILib;
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.NBT.CMINBT;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class PlayerManager {
|
||||
|
||||
private final ConcurrentMap<String, JobsPlayer> playersCache = new ConcurrentHashMap<>();
|
||||
@ -648,7 +651,7 @@ public class PlayerManager {
|
||||
if (player != null && (Jobs.getGCManager().LevelChangeActionBar || Jobs.getGCManager().LevelChangeChat)) {
|
||||
for (String line : message.split("\n")) {
|
||||
if (Jobs.getGCManager().LevelChangeActionBar)
|
||||
ActionBarManager.send(player, line);
|
||||
CMIActionBar.send(player, line);
|
||||
|
||||
if (Jobs.getGCManager().LevelChangeChat)
|
||||
player.sendMessage(line);
|
||||
@ -756,11 +759,11 @@ public class PlayerManager {
|
||||
for (String line : message.split("\n")) {
|
||||
if (Jobs.getGCManager().isBroadcastingLevelups()) {
|
||||
if (Jobs.getGCManager().BroadcastingLevelUpLevels.contains(oldLevel + 1)
|
||||
|| Jobs.getGCManager().BroadcastingLevelUpLevels.contains(0))
|
||||
|| Jobs.getGCManager().BroadcastingLevelUpLevels.contains(0))
|
||||
plugin.getComplement().broadcastMessage(line);
|
||||
} else if (player != null) {
|
||||
if (Jobs.getGCManager().LevelChangeActionBar)
|
||||
ActionBarManager.send(player, line);
|
||||
CMIActionBar.send(player, line);
|
||||
|
||||
if (Jobs.getGCManager().LevelChangeChat)
|
||||
player.sendMessage(line);
|
||||
@ -772,7 +775,7 @@ public class PlayerManager {
|
||||
if (player != null && Jobs.getGCManager().SoundTitleChangeUse) {
|
||||
try {
|
||||
player.getWorld().playSound(player.getLocation(), levelUpEvent.getTitleChangeSound(), levelUpEvent.getTitleChangeVolume(),
|
||||
levelUpEvent.getTitleChangePitch());
|
||||
levelUpEvent.getTitleChangePitch());
|
||||
} catch (Exception e) { // If it fails, we can ignore it
|
||||
}
|
||||
}
|
||||
@ -792,7 +795,7 @@ public class PlayerManager {
|
||||
plugin.getComplement().broadcastMessage(line);
|
||||
} else if (player != null) {
|
||||
if (Jobs.getGCManager().TitleChangeActionBar)
|
||||
ActionBarManager.send(player, line);
|
||||
CMIActionBar.send(player, line);
|
||||
|
||||
if (Jobs.getGCManager().TitleChangeChat)
|
||||
player.sendMessage(line);
|
||||
@ -956,7 +959,7 @@ public class PlayerManager {
|
||||
|
||||
// Check mainhand slot
|
||||
if (Jobs.getGCManager().boostedItemsInMainHand) {
|
||||
jitems.add(getJobsItemByNbt(Util.getItemInMainHand(player)));
|
||||
jitems.add(getJobsItemByNbt(CMIItemStack.getItemInMainHand(player)));
|
||||
}
|
||||
|
||||
// Check offhand slot
|
||||
@ -987,24 +990,24 @@ public class PlayerManager {
|
||||
private final String jobsItemBoost = "JobsItemBoost";
|
||||
|
||||
public boolean containsItemBoostByNBT(ItemStack item) {
|
||||
return item != null && Jobs.getReflections().hasNbtString(item, jobsItemBoost);
|
||||
return item != null && new CMINBT(item).hasNBT(jobsItemBoost);
|
||||
}
|
||||
|
||||
public JobItems getJobsItemByNbt(ItemStack item) {
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
Object itemName = CMIReflections.getNbt(item, jobsItemBoost);
|
||||
Object itemName = new CMINBT(item).getString(jobsItemBoost);
|
||||
|
||||
if (itemName == null || itemName.toString().isEmpty()) {
|
||||
// Checking old boost items and converting to new format if needed
|
||||
if (Jobs.getReflections().hasNbt(item, jobsItemBoost)) {
|
||||
if (new CMINBT(item).hasNBT(jobsItemBoost)) {
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
itemName = Jobs.getReflections().getNbt(item, jobsItemBoost, one.getName());
|
||||
itemName = new CMINBT(item).getString(jobsItemBoost + "." + one.getName());
|
||||
if (itemName != null) {
|
||||
JobItems b = ItemBoostManager.getItemByKey(itemName.toString());
|
||||
if (b != null) {
|
||||
ItemStack ic = CMIReflections.setNbt(item, jobsItemBoost, b.getNode());
|
||||
ItemStack ic = (ItemStack) new CMINBT(item).setString(jobsItemBoost, b.getNode());
|
||||
item.setItemMeta(ic.getItemMeta());
|
||||
}
|
||||
break;
|
||||
|
@ -17,12 +17,13 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class SignUtil {
|
||||
|
||||
private final Map<String, Map<String, jobsSign>> signsByType = new HashMap<>();
|
||||
@ -137,8 +138,14 @@ public class SignUtil {
|
||||
File f = new File(Jobs.getFolder(), "Signs.yml");
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
ConfigReader reader = new ConfigReader(f);
|
||||
|
||||
ConfigReader reader = null;
|
||||
try {
|
||||
reader = new ConfigReader(f);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (reader == null)
|
||||
return;
|
||||
conf.options().copyDefaults(true);
|
||||
reader.addComment("Signs", "DO NOT EDIT THIS FILE BY HAND!");
|
||||
|
||||
|
@ -20,9 +20,10 @@ package com.gamingmesh.jobs.actions;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class BlockActionInfo extends MaterialActionInfo {
|
||||
public BlockActionInfo(Block block, ActionType type) {
|
||||
super(block.getType(), CMIMaterial.getBlockData(block), type);
|
||||
|
@ -13,8 +13,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
@ -23,9 +21,12 @@ import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.Title;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class JobsCommands implements CommandExecutor {
|
||||
|
||||
public static final String LABEL = "jobs";
|
||||
@ -123,13 +124,13 @@ public class JobsCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (page < 1) {
|
||||
ActionBarManager.send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
|
||||
CMIActionBar.send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PageInfo pi = new PageInfo(7, commands.size(), page);
|
||||
if (page > pi.getTotalPages()) {
|
||||
ActionBarManager.send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
|
||||
CMIActionBar.send(sender, Jobs.getLanguage().getMessage("general.error.noHelpPage"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class archive implements Cmd {
|
||||
|
||||
@Override
|
||||
|
@ -7,13 +7,14 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
||||
import com.gamingmesh.jobs.container.CuboidArea;
|
||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class area implements Cmd {
|
||||
|
||||
@Override
|
||||
|
@ -3,12 +3,14 @@ package com.gamingmesh.jobs.commands.list;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class blockinfo implements Cmd {
|
||||
|
||||
@Override
|
||||
|
@ -2,10 +2,9 @@ package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.PlayerManager.BoostOf;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
@ -13,6 +12,9 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class bonus implements Cmd {
|
||||
|
||||
@Override
|
||||
|
@ -10,12 +10,13 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.BlockProtection;
|
||||
import com.gamingmesh.jobs.container.DBAction;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class bp implements Cmd {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -7,11 +7,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class browse implements Cmd {
|
||||
|
||||
|
@ -4,11 +4,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
public class demote implements Cmd {
|
||||
|
||||
@Override
|
||||
|
@ -7,15 +7,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.NBT.CMINBT;
|
||||
|
||||
public class edititembonus implements Cmd {
|
||||
|
||||
@ -70,7 +71,7 @@ public class edititembonus implements Cmd {
|
||||
if (jPlayer == null)
|
||||
return false;
|
||||
|
||||
ItemStack iih = Util.getItemInMainHand(player);
|
||||
ItemStack iih = CMIItemStack.getItemInMainHand(player);
|
||||
if (iih == null || iih.getType() == Material.AIR)
|
||||
return false;
|
||||
|
||||
@ -78,14 +79,14 @@ public class edititembonus implements Cmd {
|
||||
case add:
|
||||
if (jobitem == null)
|
||||
return false;
|
||||
iih = CMIReflections.setNbt(iih, "JobsItemBoost", jobitem.getNode());
|
||||
Util.setItemInMainHand(player, iih);
|
||||
iih = (ItemStack) new CMINBT(iih).setString("JobsItemBoost", jobitem.getNode());
|
||||
CMIItemStack.setItemInMainHand(player, iih);
|
||||
break;
|
||||
case list:
|
||||
break;
|
||||
case remove:
|
||||
iih = Jobs.getReflections().removeNbt(iih, "JobsItemBoost");
|
||||
Util.setItemInMainHand(player, iih);
|
||||
iih = (ItemStack) new CMINBT(iih).remove("JobsItemBoost");
|
||||
CMIItemStack.setItemInMainHand(player, iih);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -93,7 +94,7 @@ public class edititembonus implements Cmd {
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
|
||||
|
||||
Object key = CMIReflections.getNbt(iih, "JobsItemBoost");
|
||||
Object key = new CMINBT(iih).getString("JobsItemBoost");
|
||||
if (key == null)
|
||||
return true;
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.ItemReflection;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.config.ConfigManager.KeyValues;
|
||||
@ -10,14 +14,12 @@ import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class editjobs implements Cmd {
|
||||
|
||||
@ -335,11 +337,11 @@ public class editjobs implements Cmd {
|
||||
String key = args[3];
|
||||
switch (args[3]) {
|
||||
case "hand":
|
||||
ItemStack item = Util.getItemInMainHand(player);
|
||||
ItemStack item = CMIItemStack.getItemInMainHand(player);
|
||||
key = item.getType().name() + "-" + item.getData().getData();
|
||||
break;
|
||||
case "offhand":
|
||||
item = ItemReflection.getItemInOffHand(player);
|
||||
item = CMIItemStack.getItemInOffHand(player);
|
||||
key = item.getType().name() + "-" + item.getData().getData();
|
||||
break;
|
||||
case "looking":
|
||||
|
@ -13,21 +13,22 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEntityType;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ItemReflection;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.Quest;
|
||||
import com.gamingmesh.jobs.container.QuestObjective;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class editquests implements Cmd {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -318,11 +319,11 @@ public class editquests implements Cmd {
|
||||
String key = args[4];
|
||||
switch (args[4]) {
|
||||
case "hand":
|
||||
ItemStack item = Util.getItemInMainHand(player);
|
||||
ItemStack item = CMIItemStack.getItemInMainHand(player);
|
||||
key = item.getType().name() + "-" + item.getData().getData();
|
||||
break;
|
||||
case "offhand":
|
||||
item = ItemReflection.getItemInOffHand(player);
|
||||
item = CMIItemStack.getItemInOffHand(player);
|
||||
key = item.getType().name() + "-" + item.getData().getData();
|
||||
break;
|
||||
case "looking":
|
||||
|
@ -2,10 +2,12 @@ package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
public class entitylist implements Cmd {
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,8 @@ import org.bukkit.scoreboard.DisplaySlot;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
|
||||
public class gtop implements Cmd {
|
||||
|
||||
|
@ -17,9 +17,11 @@ import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class itembonus implements Cmd {
|
||||
|
||||
@ -36,7 +38,7 @@ public class itembonus implements Cmd {
|
||||
if (jPlayer == null)
|
||||
return false;
|
||||
|
||||
ItemStack iih = Util.getItemInMainHand(player);
|
||||
ItemStack iih = CMIItemStack.getItemInMainHand(player);
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
|
||||
|
@ -5,11 +5,14 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class iteminfo implements Cmd {
|
||||
|
||||
@Override
|
||||
@ -25,7 +28,7 @@ public class iteminfo implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack iih = Util.getItemInMainHand((Player) sender);
|
||||
ItemStack iih = CMIItemStack.getItemInMainHand((Player) sender);
|
||||
|
||||
if (iih == null || iih.getType() == Material.AIR)
|
||||
return true;
|
||||
|
@ -8,7 +8,8 @@ import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class join implements Cmd {
|
||||
|
||||
|
@ -5,11 +5,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders;
|
||||
import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceholderType;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class placeholders implements Cmd {
|
||||
|
||||
|
@ -15,7 +15,8 @@ import com.gamingmesh.jobs.container.Quest;
|
||||
import com.gamingmesh.jobs.container.QuestObjective;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class quests implements Cmd {
|
||||
|
||||
|
@ -4,11 +4,12 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
|
||||
public class stats implements Cmd {
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,8 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
import com.gamingmesh.jobs.stuff.PageInfo;
|
||||
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
|
||||
public class top implements Cmd {
|
||||
|
||||
|
@ -9,10 +9,11 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.container.BlockProtection;
|
||||
import com.gamingmesh.jobs.container.DBAction;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class BlockProtectionManager {
|
||||
|
||||
private final HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> map = new HashMap<>();
|
||||
|
@ -9,13 +9,14 @@ import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.BossBarInfo;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
||||
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class BossBarManager {
|
||||
|
||||
private Jobs plugin;
|
||||
|
@ -37,12 +37,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEntityType;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
@ -60,6 +55,12 @@ import com.gamingmesh.jobs.resources.jfep.ParseError;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
@Deprecated
|
||||
@ -79,7 +80,16 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
private void updateExampleFile() {
|
||||
ConfigReader cfg = new ConfigReader(new File(Jobs.getFolder(), "jobs" + File.separator + EXAMPLEJOBNAME.toUpperCase() + ".yml"));
|
||||
ConfigReader cfg = null;
|
||||
try {
|
||||
cfg = new ConfigReader(new File(Jobs.getFolder(), "jobs" + File.separator + EXAMPLEJOBNAME.toUpperCase() + ".yml"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (cfg == null)
|
||||
return;
|
||||
|
||||
if (!cfg.getFile().isFile())
|
||||
return;
|
||||
cfg.load();
|
||||
@ -888,7 +898,14 @@ public class ConfigManager {
|
||||
Jobs.getPluginLogger().info("Done. Migrated jobs amount: " + jobFiles.size());
|
||||
}
|
||||
|
||||
ConfigReader cfg = new ConfigReader("jobConfig.yml");
|
||||
ConfigReader cfg = null;
|
||||
try {
|
||||
cfg = new ConfigReader(Jobs.getInstance(), "jobConfig.yml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
cfg.saveToBackup(false);
|
||||
cfg.header(Arrays.asList("-----------------------------------------------------",
|
||||
"Jobs have been moved into jobs subfolder",
|
||||
|
@ -37,13 +37,14 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.CurrencyLimit;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class GeneralConfigManager {
|
||||
|
||||
public List<Integer> BroadcastingLevelUpLevels = new ArrayList<>();
|
||||
@ -281,7 +282,14 @@ public class GeneralConfigManager {
|
||||
* loads from Jobs/generalConfig.yml
|
||||
*/
|
||||
private void loadGeneralSettings() {
|
||||
c = new ConfigReader("generalConfig.yml");
|
||||
try {
|
||||
c = new ConfigReader(Jobs.getInstance(), "generalConfig.yml");
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (c == null)
|
||||
return;
|
||||
|
||||
c.header(Arrays.asList("General configuration.",
|
||||
" The general configuration for the jobs plugin mostly includes how often the plugin",
|
||||
|
@ -7,9 +7,10 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
|
||||
public class LanguageManager {
|
||||
|
||||
public final List<String> signKeys = new ArrayList<>();
|
||||
@ -60,7 +61,13 @@ public class LanguageManager {
|
||||
f = new File(Jobs.getFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
|
||||
}
|
||||
|
||||
ConfigReader c = new ConfigReader(f);
|
||||
ConfigReader c;
|
||||
try {
|
||||
c = new ConfigReader(f);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
c.copyDefaults(true);
|
||||
|
||||
Jobs.getGCManager().getCommandArgs().clear();
|
||||
|
@ -1,7 +1,12 @@
|
||||
package com.gamingmesh.jobs.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -10,15 +15,16 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEntityType;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.NameList;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class NameTranslatorManager {
|
||||
|
||||
private final Map<CMIMaterial, NameList> listOfNames = new HashMap<>();
|
||||
@ -299,7 +305,13 @@ public class NameTranslatorManager {
|
||||
f = new File(tWordsFolder, "Words_" + lang + ".yml");
|
||||
}
|
||||
|
||||
ConfigReader c = new ConfigReader(f);
|
||||
ConfigReader c;
|
||||
try {
|
||||
c = new ConfigReader(f);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
c.copyDefaults(true);
|
||||
|
||||
for (CMIMaterial mat : CMIMaterial.values()) {
|
||||
|
@ -4,10 +4,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIItemStack;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.CMILib.ItemManager;
|
||||
|
||||
import net.Zrips.CMILib.CMILib;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Items.ItemManager;
|
||||
|
||||
public class RestrictedBlockManager {
|
||||
|
||||
@ -21,7 +23,15 @@ public class RestrictedBlockManager {
|
||||
if (!Jobs.getGCManager().useBlockProtection)
|
||||
return;
|
||||
|
||||
ConfigReader cfg = new ConfigReader("restrictedBlocks.yml");
|
||||
ConfigReader cfg = null;
|
||||
try {
|
||||
cfg = new ConfigReader(Jobs.getInstance(), "restrictedBlocks.yml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (cfg == null)
|
||||
return;
|
||||
|
||||
cfg.addComment("blocksTimer", "Block protected by timer in sec",
|
||||
"Category name can be any you like to be easily recognized",
|
||||
@ -33,7 +43,7 @@ public class RestrictedBlockManager {
|
||||
if (section != null) {
|
||||
for (String one : section.getKeys(false)) {
|
||||
if ((section.isString(one + ".id") || section.isInt(one + ".id")) && section.isInt(one + ".cd")) {
|
||||
CMIItemStack cm = ItemManager.getItem(CMIMaterial.get(section.getString(one + ".id")));
|
||||
CMIItemStack cm = CMIMaterial.get(section.getString(one + ".id")).newCMIItemStack();
|
||||
CMIMaterial mat = cm == null ? null : cm.getCMIType();
|
||||
|
||||
if (mat == null || !mat.isBlock()) {
|
||||
|
@ -5,8 +5,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -22,14 +22,7 @@ import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMIGUI.CMIGui;
|
||||
import com.gamingmesh.jobs.CMIGUI.CMIGuiButton;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIClickType;
|
||||
import com.gamingmesh.jobs.CMIGUI.GUIManager.GUIRows;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
@ -39,6 +32,14 @@ import com.gamingmesh.jobs.container.ShopItem;
|
||||
import com.gamingmesh.jobs.stuff.GiveItem;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.GUI.CMIGui;
|
||||
import net.Zrips.CMILib.GUI.CMIGuiButton;
|
||||
import net.Zrips.CMILib.GUI.GUIManager.GUIClickType;
|
||||
import net.Zrips.CMILib.GUI.GUIManager.GUIRows;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ShopManager {
|
||||
|
||||
|
@ -7,10 +7,11 @@ import java.util.List;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.container.Title;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
|
||||
public class TitleManager {
|
||||
|
||||
protected final List<Title> titles = new ArrayList<>();
|
||||
@ -43,7 +44,13 @@ public class TitleManager {
|
||||
void load() {
|
||||
titles.clear();
|
||||
|
||||
ConfigReader c = new ConfigReader("titleConfig.yml");
|
||||
ConfigReader c;
|
||||
try {
|
||||
c = new ConfigReader(Jobs.getInstance(), "titleConfig.yml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
c.copyDefaults(true);
|
||||
|
||||
c.header(Arrays.asList(
|
||||
|
@ -2,7 +2,7 @@ package com.gamingmesh.jobs.container;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public enum ArmorTypes {
|
||||
HELMET(5), CHESTPLATE(6), LEGGINGS(7), BOOTS(8), ELYTRA(6);
|
||||
|
@ -36,11 +36,12 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.actions.PotionItemActionInfo;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class Job {
|
||||
|
||||
private Map<ActionType, List<JobInfo>> jobInfo = new EnumMap<>(ActionType.class);
|
||||
|
@ -19,9 +19,10 @@
|
||||
package com.gamingmesh.jobs.container;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
public class JobInfo {
|
||||
private ActionType actionType;
|
||||
private int id;
|
||||
|
@ -34,10 +34,11 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import net.Zrips.CMILib.CMILib;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.NBT.CMINBT;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class JobItems {
|
||||
@ -124,7 +125,8 @@ public class JobItems {
|
||||
}
|
||||
|
||||
item.setAmount(amount);
|
||||
item = CMIReflections.setNbt(item, "JobsItemBoost", node);
|
||||
CMINBT nbt = new CMINBT(item);
|
||||
item = (ItemStack) nbt.setString("JobsItemBoost", node);
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
|
@ -28,8 +28,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class JobLimitedItems {
|
||||
private String node;
|
||||
|
@ -32,9 +32,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.Signs.SignTopType;
|
||||
import com.gamingmesh.jobs.api.JobsLevelUpEvent;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockTypes;
|
||||
@ -43,6 +40,10 @@ import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class JobsPlayer {
|
||||
|
||||
private final Jobs plugin = org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class);
|
||||
@ -237,7 +238,7 @@ public class JobsPlayer {
|
||||
}
|
||||
|
||||
if (data.isAnnounceTime(limit.getAnnouncementDelay()) && player.isOnline())
|
||||
ActionBarManager.send(player, Jobs.getLanguage().getMessage("command.limit.output." + name + "time", "%time%", TimeManage.to24hourShort(data.getLeftTime(type))));
|
||||
CMIActionBar.send(player, Jobs.getLanguage().getMessage("command.limit.output." + name + "time", "%time%", TimeManage.to24hourShort(data.getLeftTime(type))));
|
||||
|
||||
if (data.isReseted(type))
|
||||
data.setReseted(type, false);
|
||||
|
@ -5,7 +5,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
public class Schedule {
|
||||
|
||||
|
@ -20,7 +20,7 @@ package com.gamingmesh.jobs.container;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
/**
|
||||
* Container class for titles
|
||||
|
@ -15,276 +15,277 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.blockLoc;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class BlockOwnerShip {
|
||||
|
||||
private CMIMaterial material;
|
||||
private BlockTypes type;
|
||||
private String metadataName = "";
|
||||
private CMIMaterial material;
|
||||
private BlockTypes type;
|
||||
private String metadataName = "";
|
||||
|
||||
private final Map<UUID, List<blockLoc>> blockOwnerShips = new HashMap<>();
|
||||
private final Map<UUID, List<blockLoc>> blockOwnerShips = new HashMap<>();
|
||||
|
||||
private final Jobs plugin = org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class);
|
||||
private final Jobs plugin = org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class);
|
||||
|
||||
public BlockOwnerShip(CMIMaterial type) {
|
||||
// Type should be any type of furnace, smoker or brewing stand
|
||||
if (type != CMIMaterial.FURNACE && type != CMIMaterial.LEGACY_BURNING_FURNACE
|
||||
&& type != CMIMaterial.BLAST_FURNACE && type != CMIMaterial.SMOKER && type != CMIMaterial.BREWING_STAND
|
||||
&& type != CMIMaterial.LEGACY_BREWING_STAND) {
|
||||
throw new IllegalArgumentException("Material types should be any type of furnace, smoker or brewing stand");
|
||||
}
|
||||
|
||||
material = type;
|
||||
|
||||
switch (this.type = BlockTypes.getFromCMIMaterial(type)) {
|
||||
case BLAST_FURNACE:
|
||||
metadataName = "jobsBlastFurnaceOwner";
|
||||
break;
|
||||
case BREWING_STAND:
|
||||
metadataName = "jobsBrewingOwner";
|
||||
break;
|
||||
case FURNACE:
|
||||
metadataName = "jobsFurnaceOwner";
|
||||
break;
|
||||
case SMOKER:
|
||||
metadataName = "jobsSmokerOwner";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
public BlockOwnerShip(CMIMaterial type) {
|
||||
// Type should be any type of furnace, smoker or brewing stand
|
||||
if (type != CMIMaterial.FURNACE && type != CMIMaterial.LEGACY_BURNING_FURNACE
|
||||
&& type != CMIMaterial.BLAST_FURNACE && type != CMIMaterial.SMOKER && type != CMIMaterial.BREWING_STAND
|
||||
&& type != CMIMaterial.LEGACY_BREWING_STAND) {
|
||||
throw new IllegalArgumentException("Material types should be any type of furnace, smoker or brewing stand");
|
||||
}
|
||||
|
||||
public BlockTypes getType() {
|
||||
return type;
|
||||
material = type;
|
||||
|
||||
switch (this.type = BlockTypes.getFromCMIMaterial(type)) {
|
||||
case BLAST_FURNACE:
|
||||
metadataName = "jobsBlastFurnaceOwner";
|
||||
break;
|
||||
case BREWING_STAND:
|
||||
metadataName = "jobsBrewingOwner";
|
||||
break;
|
||||
case FURNACE:
|
||||
metadataName = "jobsFurnaceOwner";
|
||||
break;
|
||||
case SMOKER:
|
||||
metadataName = "jobsSmokerOwner";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockTypes getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public CMIMaterial getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public String getMetadataName() {
|
||||
return metadataName;
|
||||
}
|
||||
|
||||
public Map<UUID, List<blockLoc>> getBlockOwnerShips() {
|
||||
return blockOwnerShips;
|
||||
}
|
||||
|
||||
public ownershipFeedback register(Player player, Block block) {
|
||||
if (type != BlockTypes.getFromCMIMaterial(CMIMaterial.get(block))) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
|
||||
public CMIMaterial getMaterial() {
|
||||
return material;
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
|
||||
public String getMetadataName() {
|
||||
return metadataName;
|
||||
int max = jPlayer.getMaxOwnerShipAllowed(type);
|
||||
int have = getTotal(jPlayer.getUniqueId());
|
||||
|
||||
boolean owner = false;
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
if (!data.get(0).asString().equals(jPlayer.getUniqueId().toString())) {
|
||||
return ownershipFeedback.notOwn;
|
||||
}
|
||||
|
||||
if (have > max && max > 0) {
|
||||
remove(block);
|
||||
}
|
||||
|
||||
owner = true;
|
||||
}
|
||||
|
||||
public Map<UUID, List<blockLoc>> getBlockOwnerShips() {
|
||||
return blockOwnerShips;
|
||||
if (owner)
|
||||
return ownershipFeedback.old;
|
||||
|
||||
if (have >= max && max > 0)
|
||||
return ownershipFeedback.tooMany;
|
||||
|
||||
block.setMetadata(metadataName, new FixedMetadataValue(plugin, jPlayer.getUniqueId().toString()));
|
||||
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign() && !Jobs.getGCManager().isFurnacesReassign()
|
||||
&& !Jobs.getGCManager().BlastFurnacesReassign && !Jobs.getGCManager().SmokerReassign) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
public ownershipFeedback register(Player player, Block block) {
|
||||
if (type != BlockTypes.getFromCMIMaterial(CMIMaterial.get(block))) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
List<blockLoc> ls = blockOwnerShips.getOrDefault(jPlayer.getUniqueId(), new ArrayList<>());
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
blockOwnerShips.put(jPlayer.getUniqueId(), ls);
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
public boolean remove(Block block) {
|
||||
UUID uuid = null;
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
|
||||
int max = jPlayer.getMaxOwnerShipAllowed(type);
|
||||
int have = getTotal(jPlayer.getUniqueId());
|
||||
|
||||
boolean owner = false;
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
if (!data.get(0).asString().equals(jPlayer.getUniqueId().toString())) {
|
||||
return ownershipFeedback.notOwn;
|
||||
}
|
||||
|
||||
if (have > max && max > 0) {
|
||||
remove(block);
|
||||
}
|
||||
|
||||
owner = true;
|
||||
}
|
||||
|
||||
if (owner)
|
||||
return ownershipFeedback.old;
|
||||
|
||||
if (have >= max && max > 0)
|
||||
return ownershipFeedback.tooMany;
|
||||
|
||||
block.setMetadata(metadataName, new FixedMetadataValue(plugin, jPlayer.getUniqueId().toString()));
|
||||
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign() && !Jobs.getGCManager().isFurnacesReassign()
|
||||
&& !Jobs.getGCManager().BlastFurnacesReassign && !Jobs.getGCManager().SmokerReassign) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = blockOwnerShips.getOrDefault(jPlayer.getUniqueId(), new ArrayList<>());
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
blockOwnerShips.put(jPlayer.getUniqueId(), ls);
|
||||
return ownershipFeedback.newReg;
|
||||
if (!data.isEmpty()) {
|
||||
try {
|
||||
uuid = UUID.fromString(data.get(0).asString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(Block block) {
|
||||
UUID uuid = null;
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
|
||||
if (!data.isEmpty()) {
|
||||
try {
|
||||
uuid = UUID.fromString(data.get(0).asString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new ArrayList<>());
|
||||
org.bukkit.Location blockLoc = block.getLocation();
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
if (one.getLocation().equals(blockLoc)) {
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
ls.remove(one);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int clear(UUID uuid) {
|
||||
List<blockLoc> ls = blockOwnerShips.remove(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
List<blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new ArrayList<>());
|
||||
org.bukkit.Location blockLoc = block.getLocation();
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
one.getBlock().removeMetadata(metadataName, plugin);
|
||||
}
|
||||
|
||||
return ls.size();
|
||||
for (blockLoc one : ls) {
|
||||
if (one.getLocation().equals(blockLoc)) {
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
ls.remove(one);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<MetadataValue> getBlockMetadatas(Block block) {
|
||||
return block.getMetadata(metadataName);
|
||||
return false;
|
||||
}
|
||||
|
||||
public int clear(UUID uuid) {
|
||||
List<blockLoc> ls = blockOwnerShips.remove(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
one.getBlock().removeMetadata(metadataName, plugin);
|
||||
}
|
||||
|
||||
public int getTotal(UUID uuid) {
|
||||
List<blockLoc> list = blockOwnerShips.get(uuid);
|
||||
return list == null ? 0 : list.size();
|
||||
return ls.size();
|
||||
}
|
||||
|
||||
public List<MetadataValue> getBlockMetadatas(Block block) {
|
||||
return block.getMetadata(metadataName);
|
||||
}
|
||||
|
||||
public int getTotal(UUID uuid) {
|
||||
List<blockLoc> list = blockOwnerShips.get(uuid);
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
YmlMaker f2 = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
if (!f.exists() && !f2.exists())
|
||||
return;
|
||||
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(f2.getConfigFile());
|
||||
}
|
||||
|
||||
public void load() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
YmlMaker f2 = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
if (!f.exists() && !f2.exists())
|
||||
return;
|
||||
f = f2;
|
||||
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(f2.getConfigFile());
|
||||
}
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
|
||||
f = f2;
|
||||
if (isReassignDisabled())
|
||||
return;
|
||||
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
|
||||
if (isReassignDisabled())
|
||||
return;
|
||||
|
||||
ConfigurationSection section = f.getConfig().getConfigurationSection(path);
|
||||
if (section == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(one);
|
||||
} catch (IllegalArgumentException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
block.setMetadata(metadataName, new FixedMetadataValue(plugin, one));
|
||||
|
||||
blist.add(bl);
|
||||
total++;
|
||||
}
|
||||
|
||||
if (!blist.isEmpty()) {
|
||||
blockOwnerShips.put(uuid, blist);
|
||||
}
|
||||
}
|
||||
|
||||
if (total > 0) {
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + total + " " + path.toLowerCase() + " for reassigning.");
|
||||
}
|
||||
ConfigurationSection section = f.getConfig().getConfigurationSection(path);
|
||||
if (section == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(new File(Jobs.getFolder(), "blockOwnerShips.yml"));
|
||||
}
|
||||
int total = 0;
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
|
||||
f = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
|
||||
if (blockOwnerShips.isEmpty() && f.getConfigFile().length() == 0L) {
|
||||
f.getConfigFile().delete();
|
||||
return;
|
||||
}
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(one);
|
||||
} catch (IllegalArgumentException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
f.createNewFile();
|
||||
f.saveDefaultConfig();
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
if (isReassignDisabled()) {
|
||||
return;
|
||||
}
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
block.setMetadata(metadataName, new FixedMetadataValue(plugin, one));
|
||||
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
f.getConfig().set(path, null);
|
||||
blist.add(bl);
|
||||
total++;
|
||||
}
|
||||
|
||||
for (Map.Entry<UUID, List<blockLoc>> one : blockOwnerShips.entrySet()) {
|
||||
String full = "";
|
||||
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
if (!full.isEmpty())
|
||||
full += ";";
|
||||
|
||||
full += oneL.toString();
|
||||
}
|
||||
|
||||
if (!full.isEmpty())
|
||||
f.getConfig().set(path + "." + one.getKey().toString(), full);
|
||||
}
|
||||
|
||||
f.saveConfig();
|
||||
if (!blist.isEmpty()) {
|
||||
blockOwnerShips.put(uuid, blist);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReassignDisabled() {
|
||||
return (type == BlockTypes.FURNACE && !Jobs.getGCManager().isFurnacesReassign())
|
||||
|| (type == BlockTypes.BLAST_FURNACE && !Jobs.getGCManager().BlastFurnacesReassign)
|
||||
|| (type == BlockTypes.BREWING_STAND && !Jobs.getGCManager().isBrewingStandsReassign())
|
||||
|| (type == BlockTypes.SMOKER && !Jobs.getGCManager().SmokerReassign);
|
||||
if (total > 0) {
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + total + " " + path.toLowerCase() + " for reassigning.");
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(new File(Jobs.getFolder(), "blockOwnerShips.yml"));
|
||||
}
|
||||
|
||||
public enum ownershipFeedback {
|
||||
invalid, tooMany, newReg, old, notOwn
|
||||
f = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
|
||||
if (blockOwnerShips.isEmpty() && f.getConfigFile().length() == 0L) {
|
||||
f.getConfigFile().delete();
|
||||
return;
|
||||
}
|
||||
|
||||
f.createNewFile();
|
||||
f.saveDefaultConfig();
|
||||
|
||||
if (isReassignDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
f.getConfig().set(path, null);
|
||||
|
||||
for (Map.Entry<UUID, List<blockLoc>> one : blockOwnerShips.entrySet()) {
|
||||
String full = "";
|
||||
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
if (!full.isEmpty())
|
||||
full += ";";
|
||||
|
||||
full += oneL.toString();
|
||||
}
|
||||
|
||||
if (!full.isEmpty())
|
||||
f.getConfig().set(path + "." + one.getKey().toString(), full);
|
||||
}
|
||||
|
||||
f.saveConfig();
|
||||
}
|
||||
|
||||
public boolean isReassignDisabled() {
|
||||
return (type == BlockTypes.FURNACE && !Jobs.getGCManager().isFurnacesReassign())
|
||||
|| (type == BlockTypes.BLAST_FURNACE && !Jobs.getGCManager().BlastFurnacesReassign)
|
||||
|| (type == BlockTypes.BREWING_STAND && !Jobs.getGCManager().isBrewingStandsReassign())
|
||||
|| (type == BlockTypes.SMOKER && !Jobs.getGCManager().SmokerReassign);
|
||||
}
|
||||
|
||||
public enum ownershipFeedback {
|
||||
invalid, tooMany, newReg, old, notOwn
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,37 @@
|
||||
package com.gamingmesh.jobs.container.blockOwnerShip;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public enum BlockTypes {
|
||||
|
||||
BREWING_STAND("BREWING_STAND", "LEGACY_BREWING_STAND"), FURNACE("FURNACE", "LEGACY_BURNING_FURNACE"), SMOKER,
|
||||
BLAST_FURNACE;
|
||||
BREWING_STAND("BREWING_STAND", "LEGACY_BREWING_STAND"),
|
||||
FURNACE("FURNACE", "LEGACY_BURNING_FURNACE"),
|
||||
SMOKER,
|
||||
BLAST_FURNACE;
|
||||
|
||||
private String[] names;
|
||||
private String[] names;
|
||||
|
||||
BlockTypes() {
|
||||
names = new String[] { toString() };
|
||||
}
|
||||
BlockTypes() {
|
||||
names = new String[] { toString() };
|
||||
}
|
||||
|
||||
BlockTypes(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
BlockTypes(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public String[] getNames() {
|
||||
return names;
|
||||
}
|
||||
public String[] getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
public static BlockTypes getFromCMIMaterial(CMIMaterial type) {
|
||||
for (BlockTypes b : values()) {
|
||||
for (String name : b.names) {
|
||||
if (name.equals(type.name())) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
public static BlockTypes getFromCMIMaterial(CMIMaterial type) {
|
||||
for (BlockTypes b : values()) {
|
||||
for (String name : b.names) {
|
||||
if (name.equals(type.name())) {
|
||||
return b;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package com.gamingmesh.jobs.dao;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
|
||||
public class JobsManager {
|
||||
private JobsDAO dao;
|
||||
|
@ -18,18 +18,6 @@
|
||||
|
||||
package com.gamingmesh.jobs.economy;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.api.JobsPaymentEvent;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -37,6 +25,20 @@ import java.util.UUID;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.api.JobsPaymentEvent;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class BufferedEconomy {
|
||||
|
||||
private Jobs plugin;
|
||||
@ -171,7 +173,7 @@ public class BufferedEconomy {
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().ActionBarsMessageByDefault && serverTaxesAccount.isOnline()) {
|
||||
ActionBarManager.send(Bukkit.getPlayer(serverAccountName),
|
||||
CMIActionBar.send(Bukkit.getPlayer(serverAccountName),
|
||||
Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (totalAmount * 100) / 100.0));
|
||||
}
|
||||
}
|
||||
@ -201,7 +203,7 @@ public class BufferedEconomy {
|
||||
payment.getPayment().putAll(jobsPaymentEvent.getPayment());
|
||||
|
||||
if (Jobs.getGCManager().UseServerAccount && !hasMoney) {
|
||||
ActionBarManager.send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney"));
|
||||
CMIActionBar.send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney"));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -271,7 +273,7 @@ public class BufferedEconomy {
|
||||
boolean showInActionbar = ToggleBarHandling.getActionBarToggle().getOrDefault(playerUUID.toString(),
|
||||
Jobs.getGCManager().ActionBarsMessageByDefault);
|
||||
if (showInActionbar) {
|
||||
ActionBarManager.send(abp, message);
|
||||
CMIActionBar.send(abp, message);
|
||||
} else {
|
||||
abp.sendMessage(message);
|
||||
}
|
||||
|
@ -27,9 +27,10 @@ import java.util.regex.Pattern;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
public class Language {
|
||||
|
||||
public FileConfiguration enlocale, customlocale;
|
||||
|
@ -66,10 +66,6 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.ActionBarManager;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.Signs.SignTopType;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.Signs.jobsSign;
|
||||
@ -81,9 +77,14 @@ import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsArmorChangeEvent;
|
||||
import com.gamingmesh.jobs.container.JobsArmorChangeEvent.EquipMethod;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class JobsListener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
@ -118,7 +119,7 @@ public class JobsListener implements Listener {
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (Util.getItemInMainHand(player).getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
|
||||
if (CMIItemStack.getItemInMainHand(player).getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()) || !player.hasPermission("jobs.area.select"))
|
||||
@ -370,7 +371,7 @@ public class JobsListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onLimitedItemInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ItemStack iih = Util.getItemInMainHand(player);
|
||||
ItemStack iih = CMIItemStack.getItemInMainHand(player);
|
||||
if (iih.getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
@ -411,7 +412,7 @@ public class JobsListener implements Listener {
|
||||
|
||||
if (meinOk != null) {
|
||||
event.setCancelled(true);
|
||||
ActionBarManager.send(player, Jobs.getLanguage().getMessage("limitedItem.error.levelup", "[jobname]", meinOk));
|
||||
CMIActionBar.send(player, Jobs.getLanguage().getMessage("limitedItem.error.levelup", "[jobname]", meinOk));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,24 +18,11 @@
|
||||
|
||||
package com.gamingmesh.jobs.listeners;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.*;
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.*;
|
||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||
import com.gamingmesh.jobs.container.*;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip.ownershipFeedback;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.hooks.JobsHook;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.base.Objects;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -45,7 +32,16 @@ import org.bukkit.block.BrewingStand;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Damageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -65,9 +61,9 @@ import org.bukkit.event.entity.SlimeSplitEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.BrewEvent;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
@ -89,10 +85,45 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.actions.BlockActionInfo;
|
||||
import com.gamingmesh.jobs.actions.BlockCollectInfo;
|
||||
import com.gamingmesh.jobs.actions.CustomKillInfo;
|
||||
import com.gamingmesh.jobs.actions.EnchantActionInfo;
|
||||
import com.gamingmesh.jobs.actions.EntityActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ExploreActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ItemNameActionInfo;
|
||||
import com.gamingmesh.jobs.actions.PotionItemActionInfo;
|
||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.ExploreRespond;
|
||||
import com.gamingmesh.jobs.container.FastPayment;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip;
|
||||
import com.gamingmesh.jobs.container.blockOwnerShip.BlockOwnerShip.ownershipFeedback;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.hooks.JobsHook;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import net.Zrips.CMILib.CMILib;
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Items.ItemManager;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public final class JobsPaymentListener implements Listener {
|
||||
|
||||
@ -100,13 +131,13 @@ public final class JobsPaymentListener implements Listener {
|
||||
private final String blockMetadata = "BlockOwner";
|
||||
|
||||
private final Cache<UUID, Double> damageDealtByPlayers = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.weakKeys()
|
||||
.build();
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.weakKeys()
|
||||
.build();
|
||||
private final Cache<UUID, Entity> punchedEndCrystals = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(10, TimeUnit.SECONDS)
|
||||
.weakKeys()
|
||||
.build();
|
||||
.expireAfterWrite(10, TimeUnit.SECONDS)
|
||||
.weakKeys()
|
||||
.build();
|
||||
private Cache<UUID, Long> cowMilkingTimer;
|
||||
|
||||
public JobsPaymentListener(Jobs plugin) {
|
||||
@ -114,9 +145,9 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
if (Jobs.getGCManager().CowMilkingTimer > 0) {
|
||||
cowMilkingTimer = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(Jobs.getGCManager().CowMilkingTimer, TimeUnit.MILLISECONDS)
|
||||
.weakKeys()
|
||||
.build();
|
||||
.expireAfterWrite(Jobs.getGCManager().CowMilkingTimer, TimeUnit.MILLISECONDS)
|
||||
.weakKeys()
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +207,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
||||
} else if (currentItem != null) {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.VTRADE));
|
||||
}
|
||||
@ -199,7 +230,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
newItemsCount--;
|
||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName())
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
||||
else
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.VTRADE));
|
||||
}
|
||||
@ -216,7 +247,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ItemStack itemInHand = Util.getItemInMainHand(player);
|
||||
ItemStack itemInHand = CMIItemStack.getItemInMainHand(player);
|
||||
if (itemInHand.getType() != Material.BUCKET && itemInHand.getType() != Material.BOWL) {
|
||||
return;
|
||||
}
|
||||
@ -399,7 +430,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
// Protection for block break with silktouch
|
||||
if (Jobs.getGCManager().useSilkTouchProtection) {
|
||||
ItemStack item = Util.getItemInMainHand(player);
|
||||
ItemStack item = CMIItemStack.getItemInMainHand(player);
|
||||
|
||||
if (item.getType() != Material.AIR && Jobs.getBpManager().isInBp(block)) {
|
||||
for (Enchantment one : item.getEnchantments().keySet()) {
|
||||
@ -438,7 +469,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_12_R1)
|
||||
&& ItemManager.getItem(event.getItemInHand()).isSimilar(CMIMaterial.BONE_MEAL.newCMIItemStack()))
|
||||
&& CMILib.getInstance().getItemManager().getItem(event.getItemInHand()).isSimilar(CMIMaterial.BONE_MEAL.newCMIItemStack()))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
@ -696,7 +727,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType()));
|
||||
} else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.CRAFT));
|
||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.CRAFT));
|
||||
} else if (currentItem != null) {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.CRAFT));
|
||||
}
|
||||
@ -723,7 +754,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
if (resultItemMeta != null && resultItemMeta.hasDisplayName())
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
||||
.getComplement().getDisplayName(resultItemMeta)), ActionType.CRAFT));
|
||||
.getComplement().getDisplayName(resultItemMeta)), ActionType.CRAFT));
|
||||
else
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||
}
|
||||
@ -1140,7 +1171,8 @@ public final class JobsPaymentListener implements Listener {
|
||||
try {
|
||||
// So lets remove meta in case some plugin removes entity in wrong way.
|
||||
lVictim.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
|
||||
} catch (Exception ignored) { }
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1155,7 +1187,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
damageDealtByPlayers.invalidate(lVictimUUID);
|
||||
|
||||
if (perc < Jobs.getGCManager().MonsterDamagePercentage)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1332,7 +1364,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
continue;
|
||||
|
||||
Player p = (Player) one;
|
||||
if (!Util.getItemInMainHand(p).getType().toString().equalsIgnoreCase("ARMOR_STAND"))
|
||||
if (!CMIItemStack.getItemInMainHand(p).getType().toString().equalsIgnoreCase("ARMOR_STAND"))
|
||||
continue;
|
||||
|
||||
double d = p.getLocation().distance(loc);
|
||||
@ -1477,7 +1509,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new ItemActionInfo(Util.getItemInMainHand(player), ActionType.EAT));
|
||||
Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), new ItemActionInfo(CMIItemStack.getItemInMainHand(player), ActionType.EAT));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@ -1558,7 +1590,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
CMIMaterial cmat = CMIMaterial.get(block);
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p);
|
||||
Material hand = Util.getItemInMainHand(p).getType();
|
||||
Material hand = CMIItemStack.getItemInMainHand(p).getType();
|
||||
|
||||
if (event.useInteractedBlock() != org.bukkit.event.Event.Result.DENY
|
||||
&& event.getAction() == Action.RIGHT_CLICK_BLOCK && jPlayer != null && !p.isSneaking()) {
|
||||
@ -1616,9 +1648,9 @@ public final class JobsPaymentListener implements Listener {
|
||||
report = true;
|
||||
|
||||
if (report)
|
||||
ActionBarManager.send(p, Jobs.getLanguage().getMessage("general.error.noRegistration", "[block]", name));
|
||||
CMIActionBar.send(p, Jobs.getLanguage().getMessage("general.error.noRegistration", "[block]", name));
|
||||
} else if (done == ownershipFeedback.newReg && jPlayer != null) {
|
||||
ActionBarManager.send(p, Jobs.getLanguage().getMessage("general.error.newRegistration", "[block]", name,
|
||||
CMIActionBar.send(p, Jobs.getLanguage().getMessage("general.error.newRegistration", "[block]", name,
|
||||
"[current]", blockOwner.getTotal(jPlayer.getUniqueId()),
|
||||
"[max]", jPlayer.getMaxOwnerShipAllowed(blockOwner.getType()) == 0 ? "-" : jPlayer.getMaxOwnerShipAllowed(blockOwner.getType())));
|
||||
}
|
||||
@ -1630,14 +1662,14 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
// Prevent item durability loss
|
||||
if (!Jobs.getGCManager().payItemDurabilityLoss && hand.getMaxDurability()
|
||||
- Util.getDurability(Util.getItemInMainHand(p)) != hand.getMaxDurability())
|
||||
- Util.getDurability(CMIItemStack.getItemInMainHand(p)) != hand.getMaxDurability())
|
||||
return;
|
||||
|
||||
// either it's version 1.13+ and we're trying to strip a normal log like oak,
|
||||
// or it's 1.16+ and we're trying to strip a fungi like warped stem
|
||||
if ((Version.isCurrentEqualOrHigher(Version.v1_13_R1) && (block.getType().toString().endsWith("_LOG") || block.getType().toString().endsWith("_WOOD"))) ||
|
||||
(Version.isCurrentEqualOrHigher(Version.v1_16_R1) && (block.getType().toString().endsWith("_STEM") || block.getType().toString().endsWith("_HYPHAE"))))
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block), 1);
|
||||
// either it's version 1.13+ and we're trying to strip a normal log like oak,
|
||||
// or it's 1.16+ and we're trying to strip a fungi like warped stem
|
||||
if ((Version.isCurrentEqualOrHigher(Version.v1_13_R1) && (block.getType().toString().endsWith("_LOG") || block.getType().toString().endsWith("_WOOD"))) ||
|
||||
(Version.isCurrentEqualOrHigher(Version.v1_16_R1) && (block.getType().toString().endsWith("_STEM") || block.getType().toString().endsWith("_HYPHAE"))))
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.STRIPLOGS), block), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1707,7 +1739,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (Jobs.getGCManager().payItemDurabilityLoss)
|
||||
return true;
|
||||
|
||||
ItemStack hand = Util.getItemInMainHand(p);
|
||||
ItemStack hand = CMIItemStack.getItemInMainHand(p);
|
||||
|
||||
java.util.Map<Enchantment, Integer> got = Jobs.getGCManager().whiteListedItems.get(CMIMaterial.get(hand));
|
||||
if (got == null)
|
||||
|
@ -13,11 +13,12 @@ import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIReflections;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.ScoreboardInfo;
|
||||
|
||||
import net.Zrips.CMILib.CMILib;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class CMIScoreboardManager {
|
||||
|
||||
private java.util.concurrent.ConcurrentMap<UUID, ScoreboardInfo> timerMap = new ConcurrentHashMap<>();
|
||||
@ -155,7 +156,7 @@ public class CMIScoreboardManager {
|
||||
}
|
||||
|
||||
private static Class<?> getNMSClass(String nmsClassString) throws ClassNotFoundException {
|
||||
return CMIReflections.getMinecraftClass(nmsClassString);
|
||||
return CMILib.getInstance().getReflectionManager().getMinecraftClass(nmsClassString);
|
||||
}
|
||||
|
||||
private static Object getConnection(Player player) throws Exception {
|
||||
|
@ -1,30 +0,0 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Debug {
|
||||
public static void D(Object... message) {
|
||||
Player player = Bukkit.getPlayer("Zrips");
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
|
||||
String FullMessage = "";
|
||||
int i = 1;
|
||||
ChatColor cl = ChatColor.GRAY;
|
||||
for (Object one : message) {
|
||||
i++;
|
||||
if (i >= 2) {
|
||||
i = 0;
|
||||
if (cl == ChatColor.GRAY)
|
||||
cl = ChatColor.WHITE;
|
||||
else
|
||||
cl = ChatColor.GRAY;
|
||||
FullMessage += cl;
|
||||
}
|
||||
FullMessage += String.valueOf(one) + " ";
|
||||
}
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "[CMID] " + ChatColor.DARK_AQUA + FullMessage);
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
||||
public class GiveItem {
|
||||
|
||||
|
@ -1,98 +0,0 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
public class PageInfo {
|
||||
|
||||
private int totalEntries = 0,
|
||||
totalPages = 0,
|
||||
start = 0,
|
||||
end = 0,
|
||||
currentPage = 0,
|
||||
currentEntry = 0,
|
||||
perPage = 6;
|
||||
|
||||
public PageInfo(int perPage, int totalEntries, int currentPage) {
|
||||
this.perPage = perPage;
|
||||
this.totalEntries = totalEntries;
|
||||
this.currentPage = currentPage < 1 ? 1 : currentPage;
|
||||
|
||||
calculate();
|
||||
}
|
||||
|
||||
public int getPositionForOutput() {
|
||||
return currentEntry;
|
||||
}
|
||||
|
||||
public int getPositionForOutput(int place) {
|
||||
return start + place + 1;
|
||||
}
|
||||
|
||||
private void calculate() {
|
||||
start = (currentPage - 1) * perPage;
|
||||
end = start + perPage - 1;
|
||||
|
||||
if (end + 1 > totalEntries)
|
||||
end = totalEntries - 1;
|
||||
|
||||
totalPages = (int) Math.ceil((double) totalEntries / (double) perPage);
|
||||
}
|
||||
|
||||
public boolean isInRange(int place) {
|
||||
return place >= start && place <= end;
|
||||
}
|
||||
|
||||
public boolean isEntryOk() {
|
||||
currentEntry++;
|
||||
return isContinueNoAdd();
|
||||
}
|
||||
|
||||
public boolean isContinue() {
|
||||
return !isEntryOk();
|
||||
}
|
||||
|
||||
public boolean isContinueNoAdd() {
|
||||
int entry = currentEntry - 1;
|
||||
return entry >= start && entry <= end;
|
||||
}
|
||||
|
||||
public boolean isBreak() {
|
||||
return currentEntry - 1 > end;
|
||||
}
|
||||
|
||||
public boolean isPageOk() {
|
||||
return isPageOk(currentPage);
|
||||
}
|
||||
|
||||
public boolean isPageOk(int page) {
|
||||
return (totalPages < page || page < 1) ? false : true;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public int getTotalPages() {
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
public int getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
public int getTotalEntries() {
|
||||
return totalEntries;
|
||||
}
|
||||
|
||||
public int getNextPageNumber() {
|
||||
int page = currentPage + 1;
|
||||
return page > totalPages ? totalPages : page;
|
||||
}
|
||||
|
||||
public int getPrevPageNumber() {
|
||||
int prev = currentPage - 1;
|
||||
return prev < 1 ? 1 : prev;
|
||||
}
|
||||
}
|
@ -34,10 +34,11 @@ import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
import com.gamingmesh.jobs.CMILib.Version;
|
||||
import com.gamingmesh.jobs.container.JobsWorld;
|
||||
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public class Util {
|
||||
|
||||
private static Map<UUID, String> jobsEditorMap = new HashMap<>(), questsEditorMap = new HashMap<>();
|
||||
@ -125,19 +126,6 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemInMainHand(Player player) {
|
||||
if (Version.isCurrentHigher(Version.v1_8_R3))
|
||||
return player.getInventory().getItemInMainHand();
|
||||
return player.getItemInHand();
|
||||
}
|
||||
|
||||
public static void setItemInMainHand(Player player, ItemStack item) {
|
||||
if (Version.isCurrentHigher(Version.v1_8_R3))
|
||||
player.getInventory().setItemInMainHand(item);
|
||||
else
|
||||
player.setItemInHand(item);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ItemStack getSkull(String skullOwner) {
|
||||
ItemStack item = CMIMaterial.PLAYER_HEAD.newItemStack();
|
||||
@ -181,11 +169,6 @@ public class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String firstToUpperCase(String name) {
|
||||
name = name.toLowerCase().replace('_', ' ');
|
||||
return name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
}
|
||||
|
||||
public static Map<UUID, String> getJobsEditorMap() {
|
||||
return jobsEditorMap;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.CMILib;
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
@ -9,7 +9,7 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
|
||||
public interface Complement {
|
||||
|
||||
|
@ -5,6 +5,7 @@ version: ${project.version}
|
||||
api-version: "1.13"
|
||||
website: https://www.spigotmc.org/resources/4216/
|
||||
authors: [Zrips, montlikadani]
|
||||
depend: [CMILib]
|
||||
softdepend: [Vault, Essentials, MythicMobs, McMMO, mcMMO, WorldGuard, MyPet, PlaceholderAPI, EcoEnchants]
|
||||
commands:
|
||||
jobs:
|
||||
|
Loading…
Reference in New Issue
Block a user