v3.14.3.0

This commit is contained in:
rockyhawk64 2020-12-23 20:38:46 +11:00
parent 39ae5ff9fe
commit f6aec68a1b
7 changed files with 94 additions and 28 deletions

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="MMOItems-6.5.1">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/MMOItems-6.5.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -15,5 +15,6 @@
<orderEntry type="library" name="spigot-1.13.2" level="project" /> <orderEntry type="library" name="spigot-1.13.2" level="project" />
<orderEntry type="library" name="PlaceholderAPI-2.10.8" level="project" /> <orderEntry type="library" name="PlaceholderAPI-2.10.8" level="project" />
<orderEntry type="library" name="VotingPlugin" level="project" /> <orderEntry type="library" name="VotingPlugin" level="project" />
<orderEntry type="library" name="MMOItems-6.5.1" level="project" />
</component> </component>
</module> </module>

View File

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

View File

@ -85,15 +85,13 @@ public class CommandPanels extends JavaPlugin {
public File panelsf; public File panelsf;
public YamlConfiguration blockConfig; //where panel block locations are stored public YamlConfiguration blockConfig; //where panel block locations are stored
public CommandPanels() {
this.panelsf = new File(this.getDataFolder() + File.separator + "panels");
this.blockConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "blocks.yml"));
}
public void onEnable() { public void onEnable() {
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loading..."); Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loading...");
this.panelsf = new File(this.getDataFolder() + File.separator + "panels");
this.blockConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "blocks.yml"));
this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml")); this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml"));
//save the config.yml file //save the config.yml file
File configFile = new File(this.getDataFolder() + File.separator + "config.yml"); File configFile = new File(this.getDataFolder() + File.separator + "config.yml");
if (!configFile.exists()) { if (!configFile.exists()) {
@ -361,6 +359,7 @@ public class CommandPanels extends JavaPlugin {
return setpapi; return setpapi;
} }
@SuppressWarnings("deprecation")
public String setCpPlaceholders(Player p, String str) { public String setCpPlaceholders(Player p, String str) {
//replace nodes with PlaceHolders //replace nodes with PlaceHolders
str = str.replaceAll("%cp-player-displayname%", p.getDisplayName()); str = str.replaceAll("%cp-player-displayname%", p.getDisplayName());
@ -395,6 +394,7 @@ public class CommandPanels extends JavaPlugin {
} }
} }
//DO placeholders for detection of other items in a panel
//get material value from slot in current open inventory (panel) //get material value from slot in current open inventory (panel)
while (str.contains("%cp-material-")) { while (str.contains("%cp-material-")) {
try { try {
@ -404,6 +404,10 @@ public class CommandPanels extends JavaPlugin {
String material; String material;
try { try {
material = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().toString(); material = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().toString();
if(legacy.isLegacy()){
//add the ID to the end if it is legacy (eg, material:id)
material = material + ":" + p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().getId();
}
} catch (NullPointerException er) { } catch (NullPointerException er) {
material = "AIR"; material = "AIR";
} }
@ -412,7 +416,6 @@ public class CommandPanels extends JavaPlugin {
debug(ex); debug(ex);
} }
} }
//get stack amount from slot in current open inventory (panel) //get stack amount from slot in current open inventory (panel)
while (str.contains("%cp-stack-")) { while (str.contains("%cp-stack-")) {
try { try {
@ -430,6 +433,31 @@ public class CommandPanels extends JavaPlugin {
debug(ex); debug(ex);
} }
} }
//is an item damaged
while (str.contains("%cp-damaged-")) {
try {
int start = str.indexOf("%cp-damaged-");
int end = str.indexOf("%", str.indexOf("%cp-damaged-") + 1);
String matNumber = str.substring(start, end).replace("%cp-damaged-", "").replace("%", "");
boolean damaged = false;
ItemStack itm = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber));
try {
if(legacy.isLegacy()){
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;
}
str = str.replace(str.substring(start, end) + "%", String.valueOf(damaged));
}catch(Exception ex){
debug(ex);
}
}
//does %cp-random-MIN,MAX% //does %cp-random-MIN,MAX%
while (str.contains("%cp-random-")) { while (str.contains("%cp-random-")) {

View File

@ -2,6 +2,9 @@ package me.rockyhawk.commandpanels.classresources;
import me.arcaniax.hdb.api.HeadDatabaseAPI; import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.manager.ItemManager;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType; import org.bukkit.block.banner.PatternType;
@ -44,9 +47,9 @@ public class ItemCreation {
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!")); p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
return null; return null;
} }
ItemStack s; ItemStack s = null;
String mat; String mat;
String matskull; String matraw;
String skullname; String skullname;
//this will convert the %cp-player-online-1-find% into cps= NAME //this will convert the %cp-player-online-1-find% into cps= NAME
if (material.contains("%cp-player-online-")) { if (material.contains("%cp-player-online-")) {
@ -62,14 +65,19 @@ public class ItemCreation {
} }
} }
try { try {
//can be changed
mat = material.toUpperCase(); mat = material.toUpperCase();
matskull = material; //cannot be changed (raw)
matraw = material;
//generate item stack normally
boolean normalCreation = true;
//name of head/skull if used
skullname = "no skull"; skullname = "no skull";
short id = 0; short id = 0;
if(itemSection.contains("ID")){ if(itemSection.contains("ID")){
id = Short.parseShort(itemSection.getString("ID")); id = Short.parseShort(itemSection.getString("ID"));
} }
if (matskull.split("\\s")[0].toLowerCase().equals("cps=") || matskull.split("\\s")[0].toLowerCase().equals("cpo=")) { if (matraw.split("\\s")[0].toLowerCase().equals("cps=") || matraw.split("\\s")[0].toLowerCase().equals("cpo=")) {
skullname = p.getUniqueId().toString(); skullname = p.getUniqueId().toString();
mat = plugin.getHeads.playerHeadString(); mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.isLegacy()){ if(plugin.legacy.isLegacy()){
@ -77,7 +85,7 @@ public class ItemCreation {
} }
} }
if (matskull.split("\\s")[0].toLowerCase().equals("hdb=")) { if (matraw.split("\\s")[0].toLowerCase().equals("hdb=")) {
skullname = "hdb"; skullname = "hdb";
mat = plugin.getHeads.playerHeadString(); mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.isLegacy()){ if(plugin.legacy.isLegacy()){
@ -85,12 +93,24 @@ public class ItemCreation {
} }
} }
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1,id); //create custom MMOItems item
if(matraw.split("\\s")[0].toLowerCase().equals("mmo=") && plugin.getServer().getPluginManager().isPluginEnabled("MMOItems")){
String itemType = matraw.split("\\s")[1];
String itemID = matraw.split("\\s")[2];
ItemManager itemManager = MMOItems.plugin.getItems();
MMOItem mmoitem = itemManager.getMMOItem(MMOItems.plugin.getTypes().get(itemType), itemID);
s = mmoitem.newBuilder().build();
normalCreation = false;
}
if (!skullname.equals("no skull") && !skullname.equals("hdb") && !matskull.split("\\s")[0].equalsIgnoreCase("cpo=")) { if(normalCreation) {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1, id);
}
if (!skullname.equals("no skull") && !skullname.equals("hdb") && !matraw.split("\\s")[0].equalsIgnoreCase("cpo=")) {
try { try {
SkullMeta meta; SkullMeta meta;
if (matskull.split("\\s")[1].equalsIgnoreCase("self")) { if (matraw.split("\\s")[1].equalsIgnoreCase("self")) {
//if cps= self //if cps= self
meta = (SkullMeta) s.getItemMeta(); meta = (SkullMeta) s.getItemMeta();
if(!plugin.legacy.isLegacy()) { if(!plugin.legacy.isLegacy()) {
@ -105,22 +125,22 @@ public class ItemCreation {
meta.setOwner(p.getName()); meta.setOwner(p.getName());
} }
s.setItemMeta(meta); s.setItemMeta(meta);
}else if (plugin.papiNoColour(p,matskull.split("\\s")[1]).length() <= 16) { }else if (plugin.papiNoColour(p,matraw.split("\\s")[1]).length() <= 16) {
//if cps= username //if cps= username
s = plugin.customHeads.getPlayerHead(plugin.papiNoColour(p,matskull.split("\\s")[1])); s = plugin.customHeads.getPlayerHead(plugin.papiNoColour(p,matraw.split("\\s")[1]));
} else { } else {
//custom data cps= base64 //custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.papiNoColour(p,matskull.split("\\s")[1])); s = plugin.customHeads.getCustomHead(plugin.papiNoColour(p,matraw.split("\\s")[1]));
} }
} catch (Exception var32) { } catch (Exception var32) {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull")); p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32); plugin.debug(var32);
} }
} }
if (!skullname.equals("no skull") && matskull.split("\\s")[0].equalsIgnoreCase("cpo=")) { if (!skullname.equals("no skull") && matraw.split("\\s")[0].equalsIgnoreCase("cpo=")) {
SkullMeta cpoMeta = (SkullMeta) s.getItemMeta(); SkullMeta cpoMeta = (SkullMeta) s.getItemMeta();
assert cpoMeta != null; assert cpoMeta != null;
cpoMeta.setOwningPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(matskull.split("\\s")[1])).getUniqueId())); cpoMeta.setOwningPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(matraw.split("\\s")[1])).getUniqueId()));
s.setItemMeta(cpoMeta); s.setItemMeta(cpoMeta);
} }
if (skullname.equals("hdb")) { if (skullname.equals("hdb")) {
@ -129,7 +149,7 @@ public class ItemCreation {
api = new HeadDatabaseAPI(); api = new HeadDatabaseAPI();
try { try {
s = api.getItemHead(matskull.split("\\s")[1].trim()); s = api.getItemHead(matraw.split("\\s")[1].trim());
} catch (Exception var22) { } catch (Exception var22) {
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!")); p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!"));
plugin.debug(var22); plugin.debug(var22);
@ -138,6 +158,7 @@ public class ItemCreation {
p.sendMessage(plugin.papi(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!")); p.sendMessage(plugin.papi(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
} }
} }
if (itemSection.contains("map")) { if (itemSection.contains("map")) {
/* /*
This will do maps from custom images This will do maps from custom images

View File

@ -77,18 +77,24 @@ public class Commandpanelsreload implements CommandExecutor {
for (String[] panelName : plugin.panelNames) { for (String[] panelName : plugin.panelNames) {
tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]); tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
if(tempFile.contains("panelType")){
if(tempFile.getStringList("panelType").contains("nocommandregister")){
continue;
}
}
if(tempFile.contains("commands")){ if(tempFile.contains("commands")){
List<String> panelCommands = tempFile.getStringList("commands"); List<String> panelCommands = tempFile.getStringList("commands");
for(String command : panelCommands){ for(String command : panelCommands){
cmdCF.set("aliases." + command.split("\\s")[0],temp); cmdCF.set("aliases." + command.split("\\s")[0],temp);
} }
} }
}
try { try {
cmdCF.save(commandsLoc); cmdCF.save(commandsLoc);
} catch (IOException var10) { } catch (IOException var10) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not register custom commands!"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not register custom commands!");
}
} }
} }
} }

View File

@ -59,8 +59,9 @@ public class OpenGUI {
} }
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(pconfig.getConfigurationSection("item." + item.split("\\s")[c] + section)), p, onOpen != 3, onOpen != 3); ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(pconfig.getConfigurationSection("item." + item.split("\\s")[c] + section)), p, onOpen != 3, onOpen != 3);
//do itemType for placeable //This is for CUSTOM ITEMS
if(pconfig.contains("item." + item.split("\\s")[c] + section + ".itemType")) { if(pconfig.contains("item." + item.split("\\s")[c] + section + ".itemType")) {
//this is for contents in the itemType section
if (pconfig.getStringList("item." + item.split("\\s")[c] + section + ".itemType").contains("placeable") && onOpen == 0) { if (pconfig.getStringList("item." + item.split("\\s")[c] + section + ".itemType").contains("placeable") && onOpen == 0) {
//keep item the same, onOpen == 0 meaning panel is refreshing //keep item the same, onOpen == 0 meaning panel is refreshing
i.setItem(Integer.parseInt(item.split("\\s")[c]), p.getOpenInventory().getItem(Integer.parseInt(item.split("\\s")[c]))); i.setItem(Integer.parseInt(item.split("\\s")[c]), p.getOpenInventory().getItem(Integer.parseInt(item.split("\\s")[c])));