forked from Upstream/CommandPanels
3.20.2.0
This commit is contained in:
parent
fe32486b0b
commit
42dd8ee698
6
pom.xml
6
pom.xml
@ -126,7 +126,7 @@
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
<artifactId>item-nbt-api</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<version>2.12.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -150,7 +150,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -221,7 +221,7 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<version>1.0.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.essentialsx</groupId>
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 3.20.1.0
|
||||
version: 3.20.2.0
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -75,7 +75,7 @@ panels:
|
||||
'21':
|
||||
material: POTION
|
||||
name: '&fClick to heal the player'
|
||||
potion: INSTANT_HEAL
|
||||
potion: HEALING
|
||||
lore:
|
||||
- '&7Uses the /heal command so that'
|
||||
- '&7the player needs permission'
|
||||
|
@ -31,10 +31,6 @@ import me.rockyhawk.commandpanels.interactives.OutsideClickEvent;
|
||||
import me.rockyhawk.commandpanels.interactives.input.UserInputUtils;
|
||||
import me.rockyhawk.commandpanels.interactives.Commandpanelrefresher;
|
||||
import me.rockyhawk.commandpanels.interactives.OpenOnJoin;
|
||||
import me.rockyhawk.commandpanels.ioclasses.nbt.NBTManager;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.LegacyVersion;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.PlayerHeads;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.*;
|
||||
import me.rockyhawk.commandpanels.openwithitem.HotbarItemLoader;
|
||||
import me.rockyhawk.commandpanels.openwithitem.SwapItemEvent;
|
||||
@ -43,6 +39,7 @@ import me.rockyhawk.commandpanels.openwithitem.UtilsOpenWithItem;
|
||||
import me.rockyhawk.commandpanels.panelblocks.BlocksTabComplete;
|
||||
import me.rockyhawk.commandpanels.panelblocks.Commandpanelblocks;
|
||||
import me.rockyhawk.commandpanels.panelblocks.PanelBlockOnClick;
|
||||
import me.rockyhawk.commandpanels.nbt.NBTManager;
|
||||
import me.rockyhawk.commandpanels.playerinventoryhandler.InventorySaver;
|
||||
import me.rockyhawk.commandpanels.playerinventoryhandler.ItemStackSerializer;
|
||||
import me.rockyhawk.commandpanels.updater.Updater;
|
||||
@ -97,19 +94,17 @@ public class CommandPanels extends JavaPlugin{
|
||||
public HasSections has = new HasSections(this);
|
||||
public GetCustomHeads customHeads = new GetCustomHeads(this);
|
||||
public Updater updater = new Updater(this);
|
||||
public PlayerHeads getHeads = new PlayerHeads(this);
|
||||
public LegacyVersion legacy = new LegacyVersion(this);
|
||||
|
||||
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
|
||||
public OpenGUI createGUI = new OpenGUI(this);
|
||||
public PanelPermissions panelPerms = new PanelPermissions(this);
|
||||
public HotbarItemLoader hotbar = new HotbarItemLoader(this);
|
||||
public NBTManager nbt = new NBTManager(this);
|
||||
|
||||
public InventorySaver inventorySaver = new InventorySaver(this);
|
||||
public ItemStackSerializer itemSerializer = new ItemStackSerializer(this);
|
||||
public UserInputUtils inputUtils = new UserInputUtils(this);
|
||||
public OpenFloodgateGUI floodgateOpenGUI = new OpenFloodgateGUI(this);
|
||||
public NBTManager nbt = new NBTManager(this);
|
||||
|
||||
public File panelsf = new File(this.getDataFolder() + File.separator + "panels");
|
||||
public YamlConfiguration blockConfig; //where panel block locations are stored
|
||||
@ -184,6 +179,7 @@ public class CommandPanels extends JavaPlugin{
|
||||
this.getServer().getPluginManager().registerEvents(new ItemFallManager(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new OpenOnJoin(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new OutsideClickEvent(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new SwapItemEvent(this), this);
|
||||
|
||||
if (this.getServer().getPluginManager().isPluginEnabled("floodgate")) {
|
||||
this.getServer().getPluginManager().registerEvents(new OpenFloodgateGUI(this), this);
|
||||
@ -224,10 +220,6 @@ public class CommandPanels extends JavaPlugin{
|
||||
this.getServer().getPluginManager().registerEvents(new PanelBlockOnClick(this), this);
|
||||
}
|
||||
|
||||
//if 1.8 don't use this
|
||||
if (!Bukkit.getVersion().contains("1.8")) {
|
||||
this.getServer().getPluginManager().registerEvents(new SwapItemEvent(this), this);
|
||||
}
|
||||
//if VotingPlugin is enabled
|
||||
if (getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
|
||||
votingPlugin= VotingPluginHooks.getInstance();
|
||||
@ -240,10 +232,6 @@ public class CommandPanels extends JavaPlugin{
|
||||
//save the example_top.yml file and the template.yml file
|
||||
if (!this.panelsf.exists()) {
|
||||
try {
|
||||
if(legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
|
||||
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("exampleLegacy.yml")));
|
||||
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example.yml"));
|
||||
}else {
|
||||
//top
|
||||
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_top.yml")));
|
||||
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_top.yml"));
|
||||
@ -256,7 +244,7 @@ public class CommandPanels extends JavaPlugin{
|
||||
//bottom
|
||||
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_bottom.yml")));
|
||||
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_bottom.yml"));
|
||||
}
|
||||
|
||||
FileConfiguration templateFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("template.yml")));
|
||||
templateFileConfiguration.save(new File(this.panelsf + File.separator + "template.yml"));
|
||||
} catch (IOException var11) {
|
||||
@ -318,17 +306,10 @@ public class CommandPanels extends JavaPlugin{
|
||||
//hiding attributes will add an NBT tag
|
||||
if(hideAttributes) {
|
||||
renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
renamedMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
renamedMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
//HIDE_ARMOR_TRIM was added into 1.20 api
|
||||
if(legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20)){
|
||||
renamedMeta.addItemFlags(ItemFlag.HIDE_ARMOR_TRIM);
|
||||
}
|
||||
//HIDE_DYE was added into 1.17 api
|
||||
if(legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_17)){
|
||||
renamedMeta.addItemFlags(ItemFlag.HIDE_DYE);
|
||||
}
|
||||
}
|
||||
if (customName != null) {
|
||||
renamedMeta.setDisplayName(customName);
|
||||
}
|
||||
@ -460,7 +441,7 @@ public class CommandPanels extends JavaPlugin{
|
||||
p.sendMessage(ChatColor.GOLD + "/cpv " + ChatColor.WHITE + "Display the current version.");
|
||||
}
|
||||
if (p.hasPermission("commandpanel.refresh")) {
|
||||
p.sendMessage(ChatColor.GOLD + "/cpu [player] [position:all] " + ChatColor.WHITE + "Update a panel for a player while it is still open.");
|
||||
p.sendMessage(ChatColor.GOLD + "/cpu <player> [position:all] " + ChatColor.WHITE + "Update a panel for a player while it is still open.");
|
||||
}
|
||||
if (p.hasPermission("commandpanel.update")) {
|
||||
p.sendMessage(ChatColor.GOLD + "/cpv latest " + ChatColor.WHITE + "Download the latest update upon server reload/restart.");
|
||||
@ -470,7 +451,7 @@ public class CommandPanels extends JavaPlugin{
|
||||
p.sendMessage(ChatColor.GOLD + "/cpe <panel file> " + ChatColor.WHITE + "Export panel to the Online Editor.");
|
||||
}
|
||||
if (p.hasPermission("commandpanel.import")) {
|
||||
p.sendMessage(ChatColor.GOLD + "/cpi [file name] [URL] " + ChatColor.WHITE + "Downloads a panel from a raw link online.");
|
||||
p.sendMessage(ChatColor.GOLD + "/cpi <file name> <URL> " + ChatColor.WHITE + "Downloads a panel from a raw link online.");
|
||||
}
|
||||
if (p.hasPermission("commandpanel.list")) {
|
||||
p.sendMessage(ChatColor.GOLD + "/cpl " + ChatColor.WHITE + "Lists the currently loaded panels.");
|
||||
|
@ -99,7 +99,7 @@ public class Panel{
|
||||
}
|
||||
try {
|
||||
//add NBT to item and return the ItemStack
|
||||
return plugin.nbt.setNBT(s, "CommandPanelsHotbar", panelName + ":" + slot);
|
||||
return plugin.nbt.setData(s, "CommandPanelsHotbar", panelName + ":" + slot);
|
||||
}catch(Exception e) {
|
||||
//return air if null
|
||||
return new ItemStack(Material.AIR);
|
||||
|
@ -4,7 +4,6 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -32,7 +31,7 @@ public class GetCustomHeads {
|
||||
public HashMap<String, String> playerHeadTextures = new HashMap<>();
|
||||
|
||||
public String getHeadBase64(ItemStack head) {
|
||||
if (plugin.getHeads.ifSkullOrHead(head.getType().toString()) && head.hasItemMeta()) {
|
||||
if ((head.getType() == Material.PLAYER_HEAD) && head.hasItemMeta()) {
|
||||
try {
|
||||
SkullMeta meta = (SkullMeta) head.getItemMeta();
|
||||
assert meta != null;
|
||||
@ -71,18 +70,13 @@ public class GetCustomHeads {
|
||||
|
||||
//getting the head from a Player Name
|
||||
public ItemStack getPlayerHead(String name) {
|
||||
byte id = 0;
|
||||
if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
|
||||
id = 3;
|
||||
}
|
||||
|
||||
//get texture if already cached
|
||||
if(playerHeadTextures.containsKey(name)) {
|
||||
return getCustomHead(playerHeadTextures.get(name));
|
||||
}
|
||||
|
||||
//create ItemStack
|
||||
ItemStack itemStack = new ItemStack(Material.matchMaterial(plugin.getHeads.playerHeadString()), 1, id);
|
||||
ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||
|
||||
//Run fallback code, if API call fails, use legacy setOwner
|
||||
SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
|
||||
@ -144,11 +138,7 @@ public class GetCustomHeads {
|
||||
throw new IllegalStateException("Profile doesn't contain a property map");
|
||||
} else {
|
||||
propertyMap.put("textures", new Property("textures", b64stringtexture));
|
||||
byte id = 0;
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
|
||||
id = 3;
|
||||
}
|
||||
ItemStack head = new ItemStack(Material.matchMaterial(plugin.getHeads.playerHeadString()), 1,id);
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||
ItemMeta headMeta = head.getItemMeta();
|
||||
assert headMeta != null;
|
||||
|
||||
|
@ -106,16 +106,6 @@ public class HasSections {
|
||||
outputValue = false;
|
||||
}
|
||||
|
||||
//the original has sections as TinyTank800 wanted to keep them
|
||||
if(setName.startsWith("hasvalue")) {
|
||||
return compare.equals(value) == outputValue;
|
||||
}
|
||||
if(setName.startsWith("hasperm")) {
|
||||
return p.hasPermission(value) == outputValue;
|
||||
}
|
||||
if(setName.startsWith("hasgreater")) {
|
||||
return (Long.parseLong(compare) >= Long.parseLong(value)) == outputValue;
|
||||
}
|
||||
//the current has section with all the functions implemented inside it
|
||||
if(setName.startsWith("has")) {
|
||||
if(value.endsWith(" HASPERM")) {
|
||||
|
@ -1,15 +1,10 @@
|
||||
package me.rockyhawk.commandpanels.classresources;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBT;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
|
||||
import me.arcaniax.hdb.api.HeadDatabaseAPI;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.MMOItemsAPI;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.manager.ItemManager;
|
||||
import org.bukkit.*;
|
||||
@ -28,7 +23,6 @@ import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.inventory.meta.trim.ArmorTrim;
|
||||
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.*;
|
||||
@ -79,24 +73,14 @@ public class ItemCreation {
|
||||
boolean normalCreation = true;
|
||||
//name of head/skull if used
|
||||
skullname = "no skull";
|
||||
short id = 0;
|
||||
if(itemSection.contains("ID")){
|
||||
id = Short.parseShort(itemSection.getString("ID"));
|
||||
}
|
||||
if (matraw.split("\\s")[0].equalsIgnoreCase("cps=") || matraw.split("\\s")[0].toLowerCase().equals("cpo=")) {
|
||||
skullname = p.getUniqueId().toString();
|
||||
mat = plugin.getHeads.playerHeadString();
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
|
||||
id = 3;
|
||||
}
|
||||
mat = Material.PLAYER_HEAD.toString();
|
||||
}
|
||||
|
||||
if (matraw.split("\\s")[0].equalsIgnoreCase("hdb=")) {
|
||||
skullname = "hdb";
|
||||
mat = plugin.getHeads.playerHeadString();
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
|
||||
id = 3;
|
||||
}
|
||||
mat = Material.PLAYER_HEAD.toString();
|
||||
}
|
||||
|
||||
//creates custom MMOItems items
|
||||
@ -129,7 +113,7 @@ public class ItemCreation {
|
||||
}
|
||||
|
||||
if(normalCreation) {
|
||||
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1, id);
|
||||
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1);
|
||||
}
|
||||
|
||||
if (!skullname.equals("no skull") && !skullname.equals("hdb") && !matraw.split("\\s")[0].equalsIgnoreCase("cpo=")) {
|
||||
@ -138,7 +122,6 @@ public class ItemCreation {
|
||||
if (matraw.split("\\s")[1].equalsIgnoreCase("self")) {
|
||||
//if cps= self
|
||||
meta = (SkullMeta) s.getItemMeta();
|
||||
if(!plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
|
||||
try {
|
||||
assert meta != null;
|
||||
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
|
||||
@ -146,9 +129,6 @@ public class ItemCreation {
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self"));
|
||||
plugin.debug(var23,p);
|
||||
}
|
||||
}else{
|
||||
meta.setOwner(p.getName());
|
||||
}
|
||||
s.setItemMeta(meta);
|
||||
}else if (plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]).length() <= 16) {
|
||||
//if cps= username
|
||||
@ -203,7 +183,7 @@ public class ItemCreation {
|
||||
if(itemSection.isConfigurationSection("nbt." + key)){
|
||||
continue;
|
||||
}
|
||||
s = plugin.nbt.setNBT(s,key,plugin.tex.attachPlaceholders(panel, position, p, Objects.requireNonNull(itemSection.getString("nbt." + key)))); //itemSection.getString("nbt." + key));
|
||||
s = plugin.nbt.setData(s,key,plugin.tex.attachPlaceholders(panel, position, p, Objects.requireNonNull(itemSection.getString("nbt." + key))));
|
||||
}
|
||||
}
|
||||
if (itemSection.contains("enchanted")) {
|
||||
@ -290,22 +270,9 @@ public class ItemCreation {
|
||||
PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
|
||||
String[] effectType = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("potion")).split("\\s");
|
||||
assert potionMeta != null;
|
||||
boolean extended = false;
|
||||
boolean upgraded = false;
|
||||
//create data
|
||||
if(effectType.length >= 2){
|
||||
if(effectType[1].equalsIgnoreCase("true")){
|
||||
extended = true;
|
||||
}
|
||||
if(effectType.length == 3){
|
||||
if(effectType[2].equalsIgnoreCase("true")){
|
||||
upgraded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
PotionData newData = new PotionData(PotionType.valueOf(effectType[0].toUpperCase()),extended,upgraded);
|
||||
PotionType newData = PotionType.valueOf(effectType[0].toUpperCase());
|
||||
//set meta
|
||||
potionMeta.setBasePotionData(newData);
|
||||
potionMeta.setBasePotionType(newData);
|
||||
s.setItemMeta(potionMeta);
|
||||
} catch (Exception er) {
|
||||
//don't add the effect
|
||||
@ -316,14 +283,6 @@ public class ItemCreation {
|
||||
if (itemSection.contains("damage")) {
|
||||
//change the damage amount (placeholders accepted)
|
||||
//if the damage is not unbreakable and should be a value
|
||||
if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
|
||||
try {
|
||||
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p, itemSection.getString("damage")))));
|
||||
} catch (Exception e) {
|
||||
plugin.debug(e, p);
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
|
||||
}
|
||||
} else {
|
||||
if(itemSection.getString("damage").equalsIgnoreCase("-1")){
|
||||
//if the player wants the item to be unbreakable. Only works in non legacy versions
|
||||
ItemMeta unbreak = s.getItemMeta();
|
||||
@ -334,23 +293,22 @@ public class ItemCreation {
|
||||
try {
|
||||
Damageable itemDamage = (Damageable) s.getItemMeta();
|
||||
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p, itemSection.getString("damage")))));
|
||||
s.setItemMeta((ItemMeta) itemDamage);
|
||||
s.setItemMeta(itemDamage);
|
||||
} catch (Exception e) {
|
||||
plugin.debug(e, p);
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemSection.contains("nbt")) {
|
||||
for(String key : Objects.requireNonNull(itemSection.getConfigurationSection("nbt")).getKeys(true)){
|
||||
if(itemSection.isConfigurationSection("nbt." + key)){
|
||||
continue;
|
||||
}
|
||||
s = plugin.nbt.setNBT(s,key,plugin.tex.attachPlaceholders(panel, position, p, Objects.requireNonNull(itemSection.getString("nbt." + key)))); //itemSection.getString("nbt." + key));
|
||||
s = plugin.nbt.setData(s, key, plugin.tex.attachPlaceholders(panel, position, p, Objects.requireNonNull(itemSection.getString("nbt." + key))));
|
||||
}
|
||||
}
|
||||
// 1.20 Trim Feature for Player Armor
|
||||
if(plugin.legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && itemSection.contains("trim")){
|
||||
if(itemSection.contains("trim")){
|
||||
// trim: <Material> <Pattern>
|
||||
String trim = itemSection.getString("trim");
|
||||
String[] trimList = trim.split("\\s");
|
||||
@ -421,14 +379,9 @@ public class ItemCreation {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
|
||||
if (cont.getDurability() != 0 && !cont.getType().toString().equals("SKULL_ITEM")) {
|
||||
file.set("panels." + panelName + ".item." + i + ".ID", cont.getDurability());
|
||||
}
|
||||
}
|
||||
if(file.contains("panels." + panelName + ".item." + i + ".material")){
|
||||
if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){
|
||||
if(!plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
|
||||
if(!(Material.PLAYER_HEAD == cont.getType())){
|
||||
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
|
||||
}
|
||||
}else{
|
||||
@ -437,15 +390,11 @@ public class ItemCreation {
|
||||
}else{
|
||||
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
|
||||
}
|
||||
if(plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
|
||||
if(Material.PLAYER_HEAD == cont.getType()){
|
||||
if(!Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") && !Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")) {
|
||||
SkullMeta meta = (SkullMeta) cont.getItemMeta();
|
||||
if (plugin.customHeads.getHeadBase64(cont) != null && !plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
|
||||
//inject base64 here, disable for legacy as is not working
|
||||
if (plugin.customHeads.getHeadBase64(cont) != null) {
|
||||
//inject base64 here
|
||||
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.customHeads.getHeadBase64(cont));
|
||||
} else if (meta.hasOwner()) {
|
||||
//check for skull owner
|
||||
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + meta.getOwner());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -463,11 +412,8 @@ public class ItemCreation {
|
||||
try {
|
||||
PotionMeta potionMeta = (PotionMeta) cont.getItemMeta();
|
||||
assert potionMeta != null;
|
||||
PotionData potionData = potionMeta.getBasePotionData();
|
||||
PotionType potionType = potionData.getType(); // Gets the potion type as a string rather than bukkit type
|
||||
boolean level = potionData.isUpgraded(); // Check if the potion is level II
|
||||
boolean extended = potionData.isExtended(); // Check if the potion is extended
|
||||
file.set("panels." + panelName + ".item." + i + ".potion", potionType + " " + extended + " " + level);
|
||||
String potionType = potionMeta.getBasePotionType().toString(); // Gets the potion type as a string rather than bukkit type
|
||||
file.set("panels." + panelName + ".item." + i + ".potion", potionType);
|
||||
}catch(Exception ignore){
|
||||
//not a banner
|
||||
file.set("panels." + panelName + ".item." + i + ".potion", null);
|
||||
@ -483,9 +429,7 @@ public class ItemCreation {
|
||||
}
|
||||
file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
|
||||
file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
|
||||
if(plugin.legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
|
||||
file.set("panels." + panelName + ".item." + i + ".customdata", Objects.requireNonNull(cont.getItemMeta()).getCustomModelData());
|
||||
}
|
||||
}catch(Exception n){
|
||||
//skip over an item that spits an error
|
||||
}
|
||||
@ -534,42 +478,25 @@ public class ItemCreation {
|
||||
//check for nbt
|
||||
if(nbtCheck) {
|
||||
try {
|
||||
NBTItem nbtitem1 = new NBTItem(one);
|
||||
NBTItem nbtitem2 = new NBTItem(two);
|
||||
|
||||
if (!nbtitem1.equals(nbtitem2)) {
|
||||
if(!plugin.nbt.hasSameNBT(one, two)){
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
//check for damage
|
||||
try {
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
|
||||
if(one.getDurability() != two.getDurability()) {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
Damageable tempOne = (Damageable) one.getItemMeta();
|
||||
Damageable tempTwo = (Damageable) two.getItemMeta();
|
||||
if(tempOne.getDamage() != tempTwo.getDamage()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
//check for potions
|
||||
try {
|
||||
PotionMeta meta1 = (PotionMeta) one.getItemMeta();
|
||||
PotionMeta meta2 = (PotionMeta) two.getItemMeta();
|
||||
//different duration
|
||||
if(meta1.getBasePotionData().isExtended() != meta2.getBasePotionData().isExtended()){
|
||||
return false;
|
||||
}
|
||||
//different upgrade
|
||||
if(meta1.getBasePotionData().isUpgraded() != meta2.getBasePotionData().isUpgraded()){
|
||||
return false;
|
||||
}
|
||||
//different potion type
|
||||
if (meta1.getBasePotionData().getType().compareTo(meta2.getBasePotionData().getType()) != 0){
|
||||
if (meta1.getBasePotionType().toString().compareTo(meta2.getBasePotionType().toString()) != 0){
|
||||
return false;
|
||||
}
|
||||
}catch(Exception ignore){}
|
||||
|
@ -5,14 +5,12 @@ import com.earth2me.essentials.Essentials;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -141,18 +139,18 @@ public class Placeholders {
|
||||
}
|
||||
}
|
||||
|
||||
//placeholder to check if an item has NBT %cp-nbt-slot:key%
|
||||
//placeholder to check if an item has a container %cp-container-slot:key%
|
||||
if(identifier.startsWith("nbt-")) {
|
||||
try {
|
||||
String slot_key = identifier.replace("nbt-", "");
|
||||
String value;
|
||||
value = plugin.nbt.getNBT(p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(slot_key.split(":")[0])),slot_key.split(":")[1]);
|
||||
value = plugin.nbt.getData(p.getOpenInventory().getTopInventory().getItem((int) Double.parseDouble(slot_key.split(":")[0])), slot_key.split(":")[1]);
|
||||
if(value.isEmpty()){
|
||||
value = "empty";
|
||||
value = "";
|
||||
}
|
||||
return value;
|
||||
}catch (Exception ex){
|
||||
plugin.debug(ex,p);
|
||||
//nbt does not exist or slot does not exist
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@ -170,8 +168,8 @@ public class Placeholders {
|
||||
if (item != null && item.hasItemMeta() && item.getItemMeta() instanceof PotionMeta) {
|
||||
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
|
||||
|
||||
//Returns the value like this <Type>:<Extended>:<Upgraded> Example SLOWNESS:true:false
|
||||
return potionMeta.getBasePotionData().getType() + ":" + potionMeta.getBasePotionData().isExtended() + ":" + potionMeta.getBasePotionData().isUpgraded();
|
||||
//Returns the value like this <Type> Example SLOWNESS
|
||||
return potionMeta.getBasePotionType().toString();
|
||||
} else {
|
||||
return "empty"; // Item is either null or doesn't have potion meta
|
||||
}
|
||||
@ -189,10 +187,6 @@ public class Placeholders {
|
||||
String material;
|
||||
try {
|
||||
material = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getType().toString();
|
||||
if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
|
||||
//add the ID to the end if it is legacy (eg, material:id)
|
||||
material = material + ":" + p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getData().getData();
|
||||
}
|
||||
} catch (NullPointerException er) {
|
||||
material = "AIR";
|
||||
}
|
||||
@ -238,17 +232,11 @@ public class Placeholders {
|
||||
if(identifier.startsWith("damaged-")) {
|
||||
try {
|
||||
String matNumber = identifier.replace("damaged-", "");
|
||||
boolean damaged = false;
|
||||
boolean damaged;
|
||||
ItemStack itm = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber));
|
||||
try {
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
|
||||
if(itm.getType().getMaxDurability() != 0) {
|
||||
damaged = (itm.getType().getMaxDurability() - itm.getDurability()) < itm.getType().getMaxDurability();
|
||||
}
|
||||
}else {
|
||||
Damageable itemDamage = (Damageable) itm.getItemMeta();
|
||||
damaged = itemDamage.hasDamage();
|
||||
}
|
||||
} catch (NullPointerException er) {
|
||||
damaged = false;
|
||||
}
|
||||
|
@ -20,9 +20,6 @@ public class Commandpanelsupdate implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (label.equalsIgnoreCase("cpu") || label.equalsIgnoreCase("commandpanelupdate") || label.equalsIgnoreCase("cpanelu")) {
|
||||
if (sender.hasPermission("commandpanel.refresh")) {
|
||||
//command /cpu (uses .refresh permission node)
|
||||
// /cpu <Playername> <Position/ALL>
|
||||
|
||||
String name;
|
||||
Player targetPlayer;
|
||||
try {
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class Commandpanelversion implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
|
@ -3,7 +3,6 @@ package me.rockyhawk.commandpanels.commandtags.tags.economy;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -73,18 +72,7 @@ public class BuyItemTags implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void giveItem(Player p, String[] args){
|
||||
//legacy ID
|
||||
byte id = 0;
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
|
||||
for (String argsTemp : args) {
|
||||
if (argsTemp.startsWith("id:")) {
|
||||
id = Byte.parseByte(argsTemp.replace("id:", ""));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.inventorySaver.addItem(p,new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2]),id));
|
||||
plugin.inventorySaver.addItem(p,new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2])));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package me.rockyhawk.commandpanels.commandtags.tags.economy;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -130,7 +129,7 @@ public class SellItemTags implements Listener {
|
||||
if (!potion.equals("false")) {
|
||||
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
|
||||
assert potionMeta != null;
|
||||
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
|
||||
if (!potionMeta.getBasePotionType().name().equalsIgnoreCase(potion)) {
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.PanelCommandEvent;
|
||||
import me.rockyhawk.commandpanels.classresources.SerializerUtils;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
@ -138,11 +137,10 @@ public class BasicTags implements Listener {
|
||||
if(e.name.equalsIgnoreCase("minimessage=")){
|
||||
e.commandTagUsed();
|
||||
//get checks
|
||||
boolean isVersionCompatible = plugin.legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18);
|
||||
boolean isPaper = Bukkit.getServer().getVersion().contains("Paper");
|
||||
boolean allowUnsafeMiniMessage = plugin.config.getBoolean("config.allow-unsafe-mini-message");
|
||||
//do mini message if conditions are met
|
||||
if (isVersionCompatible && (isPaper || allowUnsafeMiniMessage)) {
|
||||
if (isPaper || allowUnsafeMiniMessage) {
|
||||
Audience player = (Audience) e.p; // Needed because the basic Player from the Event can't send Paper's Components
|
||||
Component parsedText = SerializerUtils.serializeText(String.join(" ", e.args));
|
||||
player.sendMessage(parsedText);
|
||||
|
@ -2,7 +2,6 @@ package me.rockyhawk.commandpanels.generatepanels;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -93,12 +92,7 @@ public class GenUtils implements Listener {
|
||||
|
||||
file.set("panels." + date + ".title", "&8Generated " + date);
|
||||
file.addDefault("panels." + date + ".command", date);
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
|
||||
file.set("panels." + date + ".empty", "STAINED_GLASS_PANE");
|
||||
file.set("panels." + date + ".emptyID", "15");
|
||||
}else{
|
||||
file.set("panels." + date + ".empty", "BLACK_STAINED_GLASS_PANE");
|
||||
}
|
||||
//add items
|
||||
file = plugin.itemCreate.generatePanelFile(date,inv,file);
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class Commandpanelrefresher implements Listener {
|
||||
if(plugin.inventorySaver.hasNormalInventory(p)) {
|
||||
for (ItemStack itm : p.getInventory().getContents()) {
|
||||
if (itm != null) {
|
||||
if (plugin.nbt.hasNBT(itm)) {
|
||||
if (plugin.nbt.hasData(itm,"CommandPanelsItem")) {
|
||||
p.getInventory().remove(itm);
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GetItemInHand {
|
||||
CommandPanels plugin;
|
||||
public GetItemInHand(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public ItemStack itemInHand(Player p){
|
||||
return p.getInventory().getItemInMainHand();
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GetItemInHand_Legacy {
|
||||
CommandPanels plugin;
|
||||
public GetItemInHand_Legacy(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack itemInHand(Player p){
|
||||
return p.getInventory().getItemInHand();
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
//get contents
|
||||
public class GetStorageContents {
|
||||
CommandPanels plugin;
|
||||
public GetStorageContents(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public ItemStack[] getStorageContents(Inventory i){
|
||||
return i.getContents();
|
||||
}
|
||||
|
||||
public void setStorageContents(Player p, ItemStack[] i){
|
||||
p.getOpenInventory().getTopInventory().setContents(i);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
//get contents legacy
|
||||
public class GetStorageContents_Legacy {
|
||||
CommandPanels plugin;
|
||||
public GetStorageContents_Legacy(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public ItemStack[] getStorageContents(Inventory i){
|
||||
return i.getContents();
|
||||
}
|
||||
|
||||
public void setStorageContents(Player p, ItemStack[] i){
|
||||
p.getOpenInventory().getTopInventory().setContents(i);
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses.legacy;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.ioclasses.GetStorageContents;
|
||||
import me.rockyhawk.commandpanels.ioclasses.GetStorageContents_Legacy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class LegacyVersion {
|
||||
CommandPanels plugin;
|
||||
public MinecraftVersions LOCAL_VERSION;
|
||||
public LegacyVersion(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
String VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
LOCAL_VERSION = MinecraftVersions.get(VERSION);
|
||||
}
|
||||
|
||||
public ItemStack[] getStorageContents(Inventory i){
|
||||
if(LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
|
||||
return new GetStorageContents_Legacy(plugin).getStorageContents(i);
|
||||
}else{
|
||||
return new GetStorageContents(plugin).getStorageContents(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStorageContents(Player p, ItemStack[] i){
|
||||
if(LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
|
||||
new GetStorageContents_Legacy(plugin).setStorageContents(p,i);
|
||||
}else{
|
||||
new GetStorageContents(plugin).setStorageContents(p,i);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses.legacy;
|
||||
|
||||
public enum MinecraftVersions {
|
||||
v1_8( "1_8", 0 ),
|
||||
v1_9( "1_9", 1 ),
|
||||
v1_10( "1_10", 2 ),
|
||||
v1_11( "1_11", 3 ),
|
||||
v1_12( "1_12", 4 ),
|
||||
v1_13( "1_13", 5 ),
|
||||
v1_14( "1_14", 6 ),
|
||||
v1_15( "1_15", 7 ),
|
||||
v1_16( "1_16", 8 ),
|
||||
v1_17( "1_17", 9 ),
|
||||
v1_18( "1_18", 10 ),
|
||||
v1_19( "1_19", 11 ),
|
||||
v1_20( "1_20", 12 ),
|
||||
v1_21( "1_21", 13 ),
|
||||
v1_22( "1_22", 14 ),
|
||||
v1_23( "1_23", 15 ),
|
||||
v1_24( "1_24", 16 ),
|
||||
v1_25( "1_25", 17 ),
|
||||
v1_26( "1_26", 18 );
|
||||
|
||||
|
||||
private int order;
|
||||
private String key;
|
||||
|
||||
MinecraftVersions( String key, int v ) {
|
||||
this.key = key;
|
||||
order = v;
|
||||
}
|
||||
|
||||
public boolean greaterThanOrEqualTo( MinecraftVersions other ) {
|
||||
return order >= other.order;
|
||||
}
|
||||
|
||||
public boolean lessThanOrEqualTo( MinecraftVersions other ) {
|
||||
return order <= other.order;
|
||||
}
|
||||
|
||||
public static MinecraftVersions get(String v ) {
|
||||
for ( MinecraftVersions k : MinecraftVersions.values() ) {
|
||||
if ( v.contains( k.key ) ) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses.legacy;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
|
||||
public class PlayerHeads {
|
||||
CommandPanels plugin;
|
||||
public PlayerHeads(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public boolean ifSkullOrHead(String material) {
|
||||
return material.equalsIgnoreCase("PLAYER_HEAD") || material.equalsIgnoreCase("SKULL_ITEM");
|
||||
}
|
||||
|
||||
public String playerHeadString() {
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
|
||||
return "SKULL_ITEM";
|
||||
}else{
|
||||
return "PLAYER_HEAD";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.rockyhawk.commandpanels.ioclasses.nbt;
|
||||
package me.rockyhawk.commandpanels.nbt;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBT;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
@ -11,30 +11,28 @@ public class NBTManager {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
//commandpanel item NBT
|
||||
public boolean hasNBT(ItemStack item){
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
return nbti.hasTag("CommandPanelsItem");
|
||||
public boolean hasSameNBT(ItemStack one, ItemStack two){
|
||||
NBTItem nbtitem1 = new NBTItem(one);
|
||||
NBTItem nbtitem2 = new NBTItem(two);
|
||||
|
||||
return nbtitem1.equals(nbtitem2);
|
||||
}
|
||||
|
||||
public ItemStack setNBT(ItemStack item){
|
||||
NBT.modify(item, nbt -> {
|
||||
nbt.setString("CommandPanelsItem", "1");
|
||||
});
|
||||
return item;
|
||||
}
|
||||
|
||||
//custom key NBT
|
||||
public String getNBT(ItemStack item, String key){
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
if(!nbti.hasNBTData()) return "";
|
||||
return nbti.getString(key);
|
||||
}
|
||||
|
||||
public ItemStack setNBT(ItemStack item, String key, String value){
|
||||
public ItemStack setData(ItemStack item, String key, String value){
|
||||
NBT.modify(item, nbt -> {
|
||||
nbt.setString(key, value);
|
||||
});
|
||||
return item;
|
||||
}
|
||||
|
||||
public boolean hasData(ItemStack item, String key){
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
return nbti.hasTag(key);
|
||||
}
|
||||
|
||||
public String getData(ItemStack item, String key){
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
if(!nbti.hasNBTData()) return "";
|
||||
return nbti.getString(key);
|
||||
}
|
||||
}
|
@ -141,7 +141,7 @@ public class OpenGUI {
|
||||
empty = plugin.itemCreate.makeItemFromConfig(panel,position,pconfig.getConfigurationSection("custom-item." + pconfig.getString("empty")),p,true,true,true);
|
||||
}else{
|
||||
empty = new ItemStack(Objects.requireNonNull(Material.matchMaterial(pconfig.getString("empty").toUpperCase())), 1,id);
|
||||
empty = plugin.nbt.setNBT(empty);
|
||||
empty = plugin.nbt.setData(empty, "CommandPanelsItem", "true");
|
||||
ItemMeta renamedMeta = empty.getItemMeta();
|
||||
assert renamedMeta != null;
|
||||
renamedMeta.setDisplayName(" ");
|
||||
@ -175,7 +175,7 @@ public class OpenGUI {
|
||||
} else if (openType == PanelOpenType.Refresh) {
|
||||
//openType 0 will just refresh the panel
|
||||
if(position == PanelPosition.Top) {
|
||||
plugin.legacy.setStorageContents(p, plugin.legacy.getStorageContents(i));
|
||||
p.getOpenInventory().getTopInventory().setContents(i.getContents());
|
||||
}
|
||||
} else if (openType == PanelOpenType.Return) {
|
||||
//will return the inventory, not opening it at all
|
||||
|
@ -130,9 +130,9 @@ public class OpenPanelsLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNBTInjected(ItemStack itm){
|
||||
public boolean isContainerInjected(ItemStack itm){
|
||||
if(itm != null){
|
||||
return plugin.nbt.hasNBT(itm);
|
||||
return plugin.nbt.hasData(itm,"CommandPanelsItem");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class UtilsPanelsLoader implements Listener {
|
||||
p.updateInventory();
|
||||
for(ItemStack itm : p.getInventory().getContents()){
|
||||
if(itm != null){
|
||||
if (plugin.nbt.hasNBT(itm)) {
|
||||
if (plugin.nbt.hasData(itm, "CommandPanelsItem")) {
|
||||
p.getInventory().remove(itm);
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class UtilsPanelsLoader implements Listener {
|
||||
Player p = (Player)e.getWhoClicked();
|
||||
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
|
||||
for(ItemStack itm : p.getInventory().getContents()){
|
||||
if(plugin.openPanels.isNBTInjected(itm)){
|
||||
if(plugin.openPanels.isContainerInjected(itm)){
|
||||
p.getInventory().remove(itm);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class HotbarItemLoader {
|
||||
if(stationaryItems.get(p.getUniqueId()).list.containsKey(String.valueOf(slot))){
|
||||
if(openPanel) {
|
||||
try {
|
||||
if (!plugin.nbt.getNBT(p.getInventory().getItem(slot), "CommandPanelsHotbar").split(":")[1].equals(String.valueOf(slot))) {
|
||||
if (!plugin.nbt.getData(p.getInventory().getItem(slot), "CommandPanelsHotbar").split(":")[1].equals(String.valueOf(slot))) {
|
||||
return false;
|
||||
}
|
||||
}catch(Exception ex){
|
||||
@ -64,7 +64,7 @@ public class HotbarItemLoader {
|
||||
//return true if found
|
||||
public boolean itemCheckExecute(ItemStack invItem, Player p, boolean openPanel, boolean stationaryOnly){
|
||||
try {
|
||||
if (Objects.equals(plugin.nbt.getNBT(invItem, "CommandPanelsHotbar"), "")) {
|
||||
if (Objects.equals(plugin.nbt.getData(invItem, "CommandPanelsHotbar"), "")) {
|
||||
return false;
|
||||
}
|
||||
}catch(IllegalArgumentException | NullPointerException nu){
|
||||
@ -73,13 +73,13 @@ public class HotbarItemLoader {
|
||||
for(Panel panel : plugin.panelList) {
|
||||
if(stationaryOnly){
|
||||
try {
|
||||
if (plugin.nbt.getNBT(invItem, "CommandPanelsHotbar").split(":")[1].equals("-1")) {
|
||||
if (plugin.nbt.getData(invItem, "CommandPanelsHotbar").split(":")[1].equals("-1")) {
|
||||
continue;
|
||||
}
|
||||
}catch(NullPointerException | IllegalArgumentException ignore){}
|
||||
}
|
||||
if(panel.hasHotbarItem()){
|
||||
if(plugin.nbt.getNBT(invItem,"CommandPanelsHotbar").split(":")[0].equals(panel.getName())){
|
||||
if(plugin.nbt.getData(invItem,"CommandPanelsHotbar").split(":")[0].equals(panel.getName())){
|
||||
if(openPanel) {
|
||||
//only open panel automatically if there are no commands and if world is not disabled
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
@ -120,9 +120,9 @@ public class HotbarItemLoader {
|
||||
stationaryItems.put(p.getUniqueId(),new HotbarPlayerManager());
|
||||
for(int i = 0; i <= 35; i++){
|
||||
try {
|
||||
if (!Objects.equals(plugin.nbt.getNBT(p.getInventory().getItem(i), "CommandPanelsHotbar"), "")) {
|
||||
if (!Objects.equals(plugin.nbt.getData(p.getInventory().getItem(i), "CommandPanelsHotbar"), "")) {
|
||||
//do not remove items that are not stationary
|
||||
if(!plugin.nbt.getNBT(p.getInventory().getItem(i), "CommandPanelsHotbar").endsWith("-1")) {
|
||||
if(!plugin.nbt.getData(p.getInventory().getItem(i), "CommandPanelsHotbar").endsWith("-1")) {
|
||||
p.getInventory().setItem(i, new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package me.rockyhawk.commandpanels.openwithitem;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.ioclasses.GetItemInHand;
|
||||
import me.rockyhawk.commandpanels.ioclasses.GetItemInHand_Legacy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -110,17 +108,15 @@ public class UtilsOpenWithItem implements Listener {
|
||||
try {
|
||||
for (ItemStack s : new ArrayList<>(e.getDrops())) {
|
||||
try {
|
||||
if (!plugin.nbt.getNBT(s, "CommandPanelsHotbar").isEmpty()) {
|
||||
if (!plugin.nbt.getData(s, "CommandPanelsHotbar").isEmpty()) {
|
||||
//do not remove items that are not stationary
|
||||
if (!plugin.nbt.getNBT(s, "CommandPanelsHotbar").endsWith("-1")) {
|
||||
if (!plugin.nbt.getData(s, "CommandPanelsHotbar").endsWith("-1")) {
|
||||
e.getDrops().remove(s);
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException | IllegalArgumentException ignore) {}
|
||||
}
|
||||
}catch (NullPointerException ignore){
|
||||
System.out.println("crapped out");
|
||||
}
|
||||
}catch (NullPointerException ignore){}
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e){
|
||||
@ -152,11 +148,7 @@ public class UtilsOpenWithItem implements Listener {
|
||||
//cancel everything if holding item (item frames eg)
|
||||
Player p = e.getPlayer();
|
||||
ItemStack clicked;
|
||||
if(Bukkit.getVersion().contains("1.8")){
|
||||
clicked = new GetItemInHand_Legacy(plugin).itemInHand(p);
|
||||
}else{
|
||||
clicked = new GetItemInHand(plugin).itemInHand(p);
|
||||
}
|
||||
clicked = p.getInventory().getItemInMainHand();
|
||||
if(plugin.hotbar.itemCheckExecute(clicked,p,true,false)){
|
||||
e.setCancelled(true);
|
||||
p.updateInventory();
|
||||
|
Loading…
Reference in New Issue
Block a user