Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/me/rockyhawk/commandpanels/commandtags/tags/economy/BuyItemTags.java
#	src/me/rockyhawk/commandpanels/commandtags/tags/economy/SellItemTags.java
This commit is contained in:
TinyTank800 2024-05-04 10:57:45 -07:00
commit 1f7db8a1d7
32 changed files with 256 additions and 675 deletions

View File

@ -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>

View File

@ -48,7 +48,6 @@ placeholders:
start: '{'
end: '}'
updater:
auto-update: false
update-checks: true
purchase:
currency:

View File

@ -1,10 +1,10 @@
version: 3.20.1.0
version: 3.21.0.0
main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels
author: RockyHawk
api-version: '1.13'
description: Fully Custom GUIs. Make your Server Professional.
softdepend: [Essentials, PlaceholderAPI, Vault, HeadDatabase, TokenManager, VotingPlugin, MMOItems, ChestSort]
softdepend: [Essentials, PlaceholderAPI, Vault, HeadDatabase, TokenManager, VotingPlugin, MMOItems, ChestSort, floodgate]
commands:
commandpanel:
description: Open a command panel.

View File

@ -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'

View File

@ -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,7 +179,11 @@ 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 OpenFloodgateGUI(this), this);
this.getServer().getPluginManager().registerEvents(new SwapItemEvent(this), this);
if (this.getServer().getPluginManager().isPluginEnabled("floodgate")) {
this.getServer().getPluginManager().registerEvents(new OpenFloodgateGUI(this), this);
}
//load in the updater if requested
if (Objects.requireNonNull(config.getString("updater.update-checks")).equalsIgnoreCase("true")) {
@ -221,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();
@ -237,23 +232,19 @@ 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"));
//middle one
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_one.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_one.yml"));
//middle two
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_two.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_two.yml"));
//bottom
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_bottom.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_bottom.yml"));
}
//top
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_top.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_top.yml"));
//middle one
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_one.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_one.yml"));
//middle two
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_two.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_two.yml"));
//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) {
@ -292,7 +283,7 @@ public class CommandPanels extends JavaPlugin{
//save files
panelData.saveDataFile();
inventorySaver.saveInventoryFile();
updater.autoUpdatePlugin(this.getFile().getName());
updater.updatePlugin(this.getFile().getName());
Bukkit.getLogger().info("RockyHawk's CommandPanels Plugin Disabled, aww man.");
}
@ -315,16 +306,9 @@ 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);
}
renamedMeta.addItemFlags(ItemFlag.HIDE_ARMOR_TRIM);
renamedMeta.addItemFlags(ItemFlag.HIDE_DYE);
}
if (customName != null) {
renamedMeta.setDisplayName(customName);
@ -457,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.");
@ -467,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.");

View File

@ -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);

View File

@ -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;

View File

@ -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")) {

View File

@ -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,16 +122,12 @@ 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)));
} catch (Exception var23) {
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());
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
} catch (Exception var23) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self"));
plugin.debug(var23,p);
}
s.setItemMeta(meta);
}else if (plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]).length() <= 16) {
@ -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,29 +283,20 @@ 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();
unbreak.setUnbreakable(true);
s.setItemMeta(unbreak);
}
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();
unbreak.setUnbreakable(true);
s.setItemMeta(unbreak);
}
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);
} catch (Exception e) {
plugin.debug(e, p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
}
try {
Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p, itemSection.getString("damage")))));
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")) {
@ -346,11 +304,11 @@ 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))));
}
}
// 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());
}
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;
}
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){}

View File

@ -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();
}
Damageable itemDamage = (Damageable) itm.getItemMeta();
damaged = itemDamage.hasDamage();
} catch (NullPointerException er) {
damaged = false;
}

View File

@ -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 {

View File

@ -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;

View File

@ -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;
@ -13,7 +12,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.*;
import java.util.Objects;
public class BuyItemTags implements Listener {
CommandPanels plugin;
@ -25,13 +24,13 @@ public class BuyItemTags implements Listener {
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("buy=")){
e.commandTagUsed();
//if player uses buy= it will be eg. buy= <price> <item> <amount of item> [id:#]
//if player uses buy= it will be eg. buy= <price> <item> <amount of item> <ID>
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(e.p) >= Double.parseDouble(e.args[0])) {
plugin.econ.withdrawPlayer(e.p, Double.parseDouble(e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p, e);
giveItem(e.p, e.args);
} else {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.failure")));
@ -47,7 +46,7 @@ public class BuyItemTags implements Listener {
}
if(e.name.equalsIgnoreCase("tokenbuy=")) {
e.commandTagUsed();
//if player uses tokenbuy= it will be eg. tokenbuy= <price> <item> <amount of item> [id:#]
//if player uses tokenbuy= it will be eg. tokenbuy= <price> <item> <amount of item> <ID>
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
final TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
@ -58,7 +57,7 @@ public class BuyItemTags implements Listener {
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p, e);
giveItem(e.p,e.args);
} else {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.failure")));
@ -73,28 +72,7 @@ public class BuyItemTags implements Listener {
}
}
@SuppressWarnings("deprecation")
private void giveItem(Player p, CommandTagEvent e){
String[] args = e.args;
//legacy ID
byte id = 0;
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
for (String arg : args) {
if (arg.startsWith("id:")) {
id = Byte.parseByte(arg.replace("id:", ""));
break;
}
}
}
ItemStack buyItem;
if (Material.matchMaterial(args[1]) == null) {
buyItem = plugin.itemCreate.makeCustomItemFromConfig(e.panel, PanelPosition.Top, e.panel.getConfig().getConfigurationSection("custom-item." + args[1]), e.p, true, true, false);
buyItem.setAmount(Integer.parseInt(args[2]));
} else {
buyItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2]), id);
}
plugin.inventorySaver.addItem(p,buyItem);
private void giveItem(Player p, String[] args){
plugin.inventorySaver.addItem(p,new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2])));
}
}

View File

@ -11,8 +11,12 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class SellItemTags implements Listener {
CommandPanels plugin;
@ -24,15 +28,15 @@ public class SellItemTags implements Listener {
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("sell=")){
e.commandTagUsed();
//if player uses sell= it will be eg. sell= <total cashback> <item> <amount of item> [IGNORENBT]
//if player uses sell= it will be eg. sell= <total cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP] [custom-data:#]
try {
if (plugin.econ != null) {
int sold = removeItem(e.p, e, false);
int sold = removeItem(e.p, e.args, false);
if (sold <= 0) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")));
} else {
plugin.econ.depositPlayer(e.p, Double.parseDouble(e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", sold + " " + e.args[1]).replaceAll("%cp-args2%", "$" + e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", e.args[1]).replaceAll("%cp-args2%", "$" + e.args[0]));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires Vault and an Economy to work!");
@ -45,15 +49,15 @@ public class SellItemTags implements Listener {
}
if(e.name.equalsIgnoreCase("sellall=")){
e.commandTagUsed();
//if player uses sell-all= it will be eg. sell-all= <Per Item Cashback> <item> [IGNORENBT]
//if player uses sell-all= it will be eg. sell-all= <Per Item Cashback> <item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.econ != null) {
int sold = removeItem(e.p, e, true);
int sold = removeItem(e.p, e.args, true);
if (sold <= 0) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")));
} else {
plugin.econ.depositPlayer(e.p, Double.parseDouble(e.args[0]) * sold);
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", sold + " " + e.args[1]).replaceAll("%cp-args2%", String.valueOf(Double.parseDouble(e.args[0]) * sold)));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", e.args[1]).replaceAll("%cp-args2%", "$" + Double.parseDouble(e.args[0]) * sold));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires Vault and an Economy to work!");
@ -66,17 +70,17 @@ public class SellItemTags implements Listener {
}
if(e.name.equalsIgnoreCase("tokensell=")) {
e.commandTagUsed();
//if player uses tokensell= it will be eg. tokensell= <cashback> <item> <amount of item> [IGNORENBT]
//if player uses tokensell= it will be eg. tokensell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
final TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
int sold = removeItem(e.p, e, false);
int sold = removeItem(e.p, e.args, false);
if (sold <= 0) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")));
} else {
assert api != null;
api.addTokens(e.p, Long.parseLong(e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", sold + " " + e.args[1]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", e.args[1]));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires TokenManager to work!");
@ -86,194 +90,115 @@ public class SellItemTags implements Listener {
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
}
if(e.name.equalsIgnoreCase("tokensellall=")){
e.commandTagUsed();
//if player uses tokensellall= it will be eg. tokensellall= <cashback> <item> [IGNORENBT]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
final TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
int sold = removeItem(e.p, e, true);
if (sold <= 0) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")));
} else {
assert api != null;
api.addTokens(e.p, Long.parseLong(e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", sold + " " + e.args[1]));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires TokenManager to work!");
}
} catch (Exception sell) {
plugin.debug(sell,e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
return;
}
}
//returns false if player does not have item
private int removeItem(Player p, CommandTagEvent e, boolean removeAll){
String[] args = e.args;
private int removeItem(Player p, String[] args, boolean removeAll){
//get inventory slots and then an empty list to store slots that have the item to sell
List<ItemStack> cont = new ArrayList<>(Arrays.asList(plugin.inventorySaver.getNormalInventory(p)));
HashMap<Integer, ItemStack> remCont = new HashMap<>();
int count = 0;
try {
int id = -1;
for (String val : args) {
if (val.startsWith("id:")) {
id = Integer.parseInt(val.substring(3));
}
List<ItemStack> remCont = new ArrayList<>();
byte id = -1;
String potion = "false";
int customData = 0;
boolean noCustom = false;
for(String argsTemp : args){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
}
ItemStack sellItem;
if (Material.matchMaterial(args[1]) == null) {
sellItem = plugin.itemCreate.makeCustomItemFromConfig(e.panel, PanelPosition.Top, e.panel.getConfig().getConfigurationSection("custom-item." + args[1]), e.p, true, true, false);
if(!removeAll){
sellItem.setAmount(Integer.parseInt(args[2]));
} else {
sellItem.setAmount(1);
}
} else {
if(!removeAll){
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2]));
} else {
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])));
}
if (argsTemp.startsWith("id:")) {
id = Byte.parseByte(argsTemp.replace("id:", ""));
}
//This is here for when people want to take nbt items like spawners with types in a check for spawners.
boolean ignoreNBT = false;
for(String arg : args){
if (arg.equalsIgnoreCase("IGNORENBT")) {
ignoreNBT = true;
break;
}
if (argsTemp.startsWith("custom-data:")) {
customData = Integer.parseInt(argsTemp.replace("custom-data:", ""));
}
if (argsTemp.contains("NOCUSTOMDATA")) {
noCustom = true;
}
}
int remainingAmount = removeAll ? 0 : sellItem.getAmount();
//loop through items in the inventory
for (int f = 0; f < 36; f++) {
if (cont.get(f) == null) {
//skip slot if empty
continue;
}
ItemStack itm = cont.get(f);
if (Material.matchMaterial(args[1]) == null) {
//if custom item is a mmo item (1.14+ for the API)
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("MMOItems") && e.panel.getConfig().getString("custom-item." + args[1] + ".material").startsWith("mmo=")) {
String customItemMaterial = e.panel.getConfig().getString("custom-item." + args[1] + ".material");
String mmoType = customItemMaterial.split("\\s")[1];
String mmoID = customItemMaterial.split("\\s")[2];
if (plugin.isMMOItem(itm, mmoType, mmoID)) {
ItemStack add = new ItemStack(p.getInventory().getItem(f).getType(), p.getInventory().getItem(f).getAmount());
remainingAmount -= add.getAmount();
remCont.put(f,add);
if (remainingAmount <= 0 && !removeAll) {
break;
}
//create an itemstack of the item to sell and the amount to sell (0 if all as args[2] will not be an amount)
ItemStack sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), removeAll ? 0 : Integer.parseInt(args[2]));
int remainingAmount = removeAll ? 0 : sellItem.getAmount();
for (int f = 0; f < 36; f++) {
ItemStack itm = cont.get(f);
ItemStack remItm;
if (itm != null && itm.getType().equals(sellItem.getType())) {
remItm = new ItemStack(itm.getType(), itm.getAmount(), (short)f);
//check to ensure any extensions are checked
try {
if (!potion.equals("false")) {
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
assert potionMeta != null;
if (!potionMeta.getBasePotionType().name().equalsIgnoreCase(potion)) {
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect"));
return 0;
}
}
//Check if the item matches the id set. If not continue to next in loop.
if(id != -1 && itm.getDurability() != id){
continue;
}
//Check if noCustom is set and if the item has custom data. If so continue to next in loop.
if(noCustom && cont.get(f).hasItemMeta()){
if(Objects.requireNonNull(cont.get(f).getItemMeta()).hasCustomModelData()){
continue;
}
}
//Check if custom model data is set and if the item has that data. If not continue to next in loop.
if (customData != 0) {
if (!itm.hasItemMeta()) {
continue;
} else {
if(Objects.requireNonNull(itm.getItemMeta()).getCustomModelData() != customData){
continue;
}
continue; //This stops the other custom item section from reading and adding false numbers.
}
} catch (Exception ex) {
plugin.debug(ex, p);
}
//item-paywall is a custom item as it is not a material
if (plugin.itemCreate.isIdentical(sellItem, itm, Objects.requireNonNull(e.panel.getConfig().getConfigurationSection("custom-item." + args[1])).contains("nbt"))) {
ItemStack add = new ItemStack(p.getInventory().getItem(f).getType(), p.getInventory().getItem(f).getAmount());
remainingAmount -= add.getAmount();
remCont.put(f,add);
if (remainingAmount <= 0 && !removeAll) {
break;
}
}
}catch(Exception exc){
//skip if it cannot do unless plugin.debug is enabled
plugin.debug(exc,p);
}
remCont.add(remItm);
//if the remaining amount has been reached, break otherwise sell all
if (!removeAll) {
remainingAmount -= remItm.getAmount();
if (remainingAmount <= 0) {
break;
}
} else {
//if the item is a standard material
if (itm.getType() == sellItem.getType()) {
//If item has custom meta continue to next item.
if(itm.hasItemMeta() && !ignoreNBT){
continue;
}
//Check if the item matches the id set. If not continue to next in loop.
if (id != -1 && itm.getDurability() != id) {
continue;
}
//Adding item to the remove list then checking if we have reached the required amount.
ItemStack add = new ItemStack(itm.getType(), itm.getAmount());
remainingAmount -= add.getAmount();
remCont.put(f,add);
if (remainingAmount <= 0 && !removeAll) {
break;
}
}
sellItem.setAmount(sellItem.getAmount() + remItm.getAmount());
}
}
}
if (remainingAmount <= 0 && !removeAll) {
//Only remove if passed requirement
for(Map.Entry<Integer, ItemStack> entry : remCont.entrySet()) {
ItemStack remItem = entry.getValue();
//Check if its the last item in the loop and only subtract the remaining amount.
if (sellItem.getAmount() < remItem.getAmount()) {
if (plugin.inventorySaver.hasNormalInventory(p)) {
p.getInventory().getItem(entry.getKey()).setAmount(remItem.getAmount() - sellItem.getAmount());
count += remItem.getAmount();
p.updateInventory();
} else {
cont.get(entry.getKey()).setAmount(remItem.getAmount() - sellItem.getAmount());
count += remItem.getAmount();
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
} else { //If its anywhere but the last in loop just get rid of the items.
if (plugin.inventorySaver.hasNormalInventory(p)) {
p.getInventory().setItem(entry.getKey(), null);
count += remItem.getAmount();
p.updateInventory();
} else {
cont.remove(entry.getValue());
count += remItem.getAmount();
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
}
sellItem.setAmount(sellItem.getAmount() - remItem.getAmount());
}
} else if(remainingAmount <= 0){
//Remove all. Used for sellall=
for(Map.Entry<Integer, ItemStack> entry : remCont.entrySet()) {
ItemStack remItem = entry.getValue();
if (plugin.inventorySaver.hasNormalInventory(p)) {
p.getInventory().setItem(entry.getKey(), null);
count += remItem.getAmount();
if(remainingAmount <= 0){
int removedItems = 0;
for (int f = 0; f <= remCont.size() - 1; f++) {
ItemStack remItm = remCont.get(f);
if(f == remCont.size() - 1){
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().getItem(remItm.getDurability()).setAmount(remItm.getAmount() - sellItem.getAmount());
p.updateInventory();
} else {
cont.remove(entry.getValue());
count += remItem.getAmount();
}else{
cont.get(remItm.getDurability()).setAmount(remItm.getAmount() - sellItem.getAmount());
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
} else {
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().getItem(remItm.getDurability()).setAmount(0);
p.updateInventory();
}else{
cont.get(remItm.getDurability()).setAmount(0);
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
}
removedItems += remItm.getAmount();
sellItem.setAmount(sellItem.getAmount() - remItm.getAmount());
}
//Return how many were sold.
return count;
} catch (Exception buyc) {
//Error somewhere in sell= process.
plugin.debug(buyc, p);
plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: sell=/sellall=");
return 0; //Return 0 showing failure.
return removedItems;
}
return 0;
}
}

View File

@ -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);

View File

@ -52,18 +52,26 @@ public class CommandPanelsEditor implements CommandExecutor {
// Prepend "fileName: {name}" and "filePath: {relativePath}" to the YAML content
String yamlWithFileNameAndPath = "fileName: " + (relativePath.replaceFirst("[.][^.]+$", "")) + "\n" + fileContents;
byte[] contentBytes = yamlWithFileNameAndPath.getBytes(StandardCharsets.UTF_8);
// Create a clickable text component with the modified YAML content
BaseComponent[] components = new ComponentBuilder(plugin.tag +
net.md_5.bungee.api.ChatColor.GREEN + "Click here to copy " +
net.md_5.bungee.api.ChatColor.WHITE + panel.getFile().getName() +
net.md_5.bungee.api.ChatColor.GREEN + " to the clipboard!")
.event(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, yamlWithFileNameAndPath))
.create();
//65535 is maximum value that can be represented by an unsigned 16-bit binary number
if (contentBytes.length > 65535) {
// If the content is too large, notify the player to use a different method
sender.sendMessage(plugin.tag + ChatColor.RED +
"Content too long to paste in chat. Please copy and paste the panel file into the editor manually.");
} else {
// Safe to send
BaseComponent[] components = new ComponentBuilder(plugin.tag +
net.md_5.bungee.api.ChatColor.GREEN + "Click here to copy " +
net.md_5.bungee.api.ChatColor.WHITE + panel.getFile().getName() +
net.md_5.bungee.api.ChatColor.GREEN + " to the clipboard!")
.event(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, yamlWithFileNameAndPath))
.create();
Player player = (Player) sender;
player.spigot().sendMessage(components);
}
// Send the clickable text to the player
Player player = (Player) sender;
player.spigot().sendMessage(components);
return true;
}
}

View File

@ -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");
}
file.set("panels." + date + ".empty", "BLACK_STAINED_GLASS_PANE");
//add items
file = plugin.itemCreate.generatePanelFile(date,inv,file);

View 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);
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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";
}
}
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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();

View File

@ -104,7 +104,7 @@ public class Updater implements Listener {
}
//the pluginFileName can only be obtained from the main class
public void autoUpdatePlugin(String pluginFileName){
public void updatePlugin(String pluginFileName){
if (Objects.requireNonNull(plugin.config.getString("updater.update-checks")).equalsIgnoreCase("false")) {
return;
}
@ -113,23 +113,20 @@ public class Updater implements Listener {
String thisVersion = plugin.getDescription().getVersion();
//manual download, only if it was requested
if(downloadVersionManually != null) {
if (downloadVersionManually.equals("latest")) {
downloadFile(latestVersion, pluginFileName);
}else{
downloadFile(downloadVersionManually, pluginFileName);
}
if(downloadVersionManually == null) {
return;
}
if (downloadVersionManually.equals("latest")) {
downloadFile(latestVersion, pluginFileName);
}else{
downloadFile(downloadVersionManually, pluginFileName);
}
if(latestVersion.equals(thisVersion) || thisVersion.contains("-")){
//no need to update or running custom version
return;
}
if (Objects.requireNonNull(plugin.config.getString("updater.auto-update")).equalsIgnoreCase("false")) {
//return if auto-update is false
return;
}
if(thisVersion.split("\\.")[1].equals(latestVersion.split("\\.")[1]) && thisVersion.split("\\.")[0].equals(latestVersion.split("\\.")[0])){
//only update if the latest version is a minor update
//the first and second number of the version is the same, updates: [major.major.minor.minor]