forked from Upstream/CommandPanels
3.16.0.0
This commit is contained in:
parent
87a5765fd6
commit
7cd8d6b49c
@ -1,7 +1,7 @@
|
|||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="PlaceholderAPI-2.10.8">
|
<library name="PlaceholderAPI-2.10.9">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.8.jar!/" />
|
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.9.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
@ -11,7 +11,6 @@
|
|||||||
<orderEntry type="library" name="HeadDatabaseAPI" level="project" />
|
<orderEntry type="library" name="HeadDatabaseAPI" level="project" />
|
||||||
<orderEntry type="library" name="TokenManager-3.2.4" level="project" />
|
<orderEntry type="library" name="TokenManager-3.2.4" level="project" />
|
||||||
<orderEntry type="library" name="Vault" level="project" />
|
<orderEntry type="library" name="Vault" 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" />
|
<orderEntry type="library" name="MMOItems-6.5.1" level="project" />
|
||||||
<orderEntry type="library" name="spigot-1.16.4" level="project" />
|
<orderEntry type="library" name="spigot-1.16.4" level="project" />
|
||||||
@ -19,5 +18,6 @@
|
|||||||
<orderEntry type="library" name="CustomItemsAPI_PLACEHOLDER" level="project" />
|
<orderEntry type="library" name="CustomItemsAPI_PLACEHOLDER" level="project" />
|
||||||
<orderEntry type="library" name="ChestSort" level="project" />
|
<orderEntry type="library" name="ChestSort" level="project" />
|
||||||
<orderEntry type="library" name="MythicLib-1.0.16" level="project" />
|
<orderEntry type="library" name="MythicLib-1.0.16" level="project" />
|
||||||
|
<orderEntry type="library" name="PlaceholderAPI-2.10.9" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -7,13 +7,13 @@
|
|||||||
# |------------------------------------------------------------------------
|
# |------------------------------------------------------------------------
|
||||||
config:
|
config:
|
||||||
refresh-panels: true
|
refresh-panels: true
|
||||||
|
refresh-delay: 20
|
||||||
panel-blocks: true
|
panel-blocks: true
|
||||||
ingame-editor: true
|
ingame-editor: true
|
||||||
hotbar-items: true
|
hotbar-items: true
|
||||||
custom-commands: true
|
custom-commands: true
|
||||||
auto-register-commands: false
|
auto-register-commands: false
|
||||||
auto-update-panels: false
|
auto-update-panels: false
|
||||||
refresh-delay: 20
|
|
||||||
server-ping-timeout: 10
|
server-ping-timeout: 10
|
||||||
stop-sound: true
|
stop-sound: true
|
||||||
disabled-world-message: true
|
disabled-world-message: true
|
||||||
@ -37,6 +37,13 @@ config:
|
|||||||
hexcodes:
|
hexcodes:
|
||||||
start_tag: '#'
|
start_tag: '#'
|
||||||
end_tag: ''
|
end_tag: ''
|
||||||
|
placeholders:
|
||||||
|
primary:
|
||||||
|
start: '%'
|
||||||
|
end: '%'
|
||||||
|
secondary:
|
||||||
|
start: '{'
|
||||||
|
end: '}'
|
||||||
updater:
|
updater:
|
||||||
auto-update: true
|
auto-update: true
|
||||||
minor-updates-only: true
|
minor-updates-only: true
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 3.15.7.1
|
version: 3.16.0.0
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -287,7 +287,7 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
}else{
|
}else{
|
||||||
clore = lore;
|
clore = lore;
|
||||||
}
|
}
|
||||||
renamedMeta.setLore(clore);
|
renamedMeta.setLore(splitListWithEscape(clore));
|
||||||
}
|
}
|
||||||
renamed.setItemMeta(renamedMeta);
|
renamed.setItemMeta(renamedMeta);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
@ -456,6 +456,15 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//split lists using \n escape character
|
||||||
|
public List<String> splitListWithEscape(List<String> list){
|
||||||
|
List<String> output = new ArrayList<>();
|
||||||
|
for(String str : list){
|
||||||
|
output.addAll(Arrays.asList(str.split("\\\\n")));
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
public int getRandomNumberInRange(int min, int max) {
|
public int getRandomNumberInRange(int min, int max) {
|
||||||
|
|
||||||
if (min >= max) {
|
if (min >= max) {
|
||||||
|
@ -42,6 +42,11 @@ public class Utils implements Listener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
if(e.getClickedInventory().getType() == InventoryType.PLAYER){
|
if(e.getClickedInventory().getType() == InventoryType.PLAYER){
|
||||||
|
if(panel.getConfig().isSet("panelType")){
|
||||||
|
if(panel.getConfig().getStringList("panelType").contains("unmovable")){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +65,4 @@ public class CommandPanelsAPI {
|
|||||||
public ItemStack makeItem(Player p, ConfigurationSection itemSection){
|
public ItemStack makeItem(Player p, ConfigurationSection itemSection){
|
||||||
return plugin.itemCreate.makeCustomItemFromConfig(null,itemSection, p, true, true, false);
|
return plugin.itemCreate.makeCustomItemFromConfig(null,itemSection, p, true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//will return item slots of hotbar stationary items
|
|
||||||
public Set<Integer> getHotbarItems(){
|
|
||||||
return plugin.hotbar.getStationaryItemSlots();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Panel{
|
public class Panel{
|
||||||
CommandPanels plugin = JavaPlugin.getPlugin(CommandPanels.class);
|
CommandPanels plugin = JavaPlugin.getPlugin(CommandPanels.class);
|
||||||
@ -68,19 +69,28 @@ public class Panel{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem(Player p, int slot){
|
public ItemStack getItem(Player p, int slot){
|
||||||
ConfigurationSection itemSection = panelConfig.getConfigurationSection("item." + slot);
|
String section = plugin.itemCreate.hasSection(this,panelConfig.getConfigurationSection("item." + slot), p);
|
||||||
|
ConfigurationSection itemSection = panelConfig.getConfigurationSection("item." + slot + section);
|
||||||
return plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false);
|
return plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getCustomItem(Player p, String itemName){
|
public ItemStack getCustomItem(Player p, String itemName){
|
||||||
ConfigurationSection itemSection = panelConfig.getConfigurationSection("custom-item." + itemName);
|
String section = plugin.itemCreate.hasSection(this,panelConfig.getConfigurationSection("custom-item." + itemName), p);
|
||||||
|
ConfigurationSection itemSection = panelConfig.getConfigurationSection("custom-item." + itemName + section);
|
||||||
return plugin.itemCreate.makeCustomItemFromConfig(this,itemSection, p, true, true, false);
|
return plugin.itemCreate.makeCustomItemFromConfig(this,itemSection, p, true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getHotbarItem(Player p){
|
public ItemStack getHotbarItem(Player p){
|
||||||
ConfigurationSection itemSection = panelConfig.getConfigurationSection("open-with-item");
|
ItemStack s = plugin.itemCreate.makeItemFromConfig(this,getHotbarSection(p), p, true, true, false);
|
||||||
ItemStack s = plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false);
|
int slot = -1;
|
||||||
return plugin.nbt.setNBT(s,"CommandPanelsHotbar",panelName);
|
if(getHotbarSection(p).isSet("stationary")){
|
||||||
|
slot = getHotbarSection(p).getInt("stationary");
|
||||||
|
}
|
||||||
|
return plugin.nbt.setNBT(s,"CommandPanelsHotbar",panelName + ":" + slot);
|
||||||
|
}
|
||||||
|
public ConfigurationSection getHotbarSection(Player p){
|
||||||
|
String section = plugin.itemCreate.hasSection(this,panelConfig.getConfigurationSection("open-with-item"), p);
|
||||||
|
return panelConfig.getConfigurationSection("open-with-item" + section);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasHotbarItem(){
|
public boolean hasHotbarItem(){
|
||||||
|
@ -41,13 +41,9 @@ public class CreateText {
|
|||||||
try {
|
try {
|
||||||
int tempInt = 0;
|
int tempInt = 0;
|
||||||
for (String temp : setpapi) {
|
for (String temp : setpapi) {
|
||||||
setpapi.set(tempInt, plugin.placeholders.setCpPlaceholders(panel, p, temp));
|
setpapi.set(tempInt, attachPlaceholders(panel, p, temp));
|
||||||
tempInt += 1;
|
tempInt += 1;
|
||||||
}
|
}
|
||||||
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
|
||||||
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
|
|
||||||
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
|
|
||||||
}
|
|
||||||
}catch(Exception ignore){
|
}catch(Exception ignore){
|
||||||
//this will be ignored as it is probably a null
|
//this will be ignored as it is probably a null
|
||||||
return null;
|
return null;
|
||||||
@ -61,13 +57,9 @@ public class CreateText {
|
|||||||
if(placeholder) {
|
if(placeholder) {
|
||||||
int tempInt = 0;
|
int tempInt = 0;
|
||||||
for (String temp : setpapi) {
|
for (String temp : setpapi) {
|
||||||
setpapi.set(tempInt, plugin.placeholders.setCpPlaceholders(panel, p, temp));
|
setpapi.set(tempInt, attachPlaceholders(panel, p, temp));
|
||||||
tempInt += 1;
|
tempInt += 1;
|
||||||
}
|
}
|
||||||
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
|
||||||
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
|
|
||||||
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}catch(Exception ignore){
|
}catch(Exception ignore){
|
||||||
//this will be ignored as it is probably a null
|
//this will be ignored as it is probably a null
|
||||||
@ -98,11 +90,7 @@ public class CreateText {
|
|||||||
//string papi with no colours
|
//string papi with no colours
|
||||||
public String placeholdersNoColour(Panel panel, Player p, String setpapi) {
|
public String placeholdersNoColour(Panel panel, Player p, String setpapi) {
|
||||||
try {
|
try {
|
||||||
setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi);
|
setpapi = attachPlaceholders(panel, p,setpapi);
|
||||||
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
|
||||||
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
|
|
||||||
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
|
|
||||||
}
|
|
||||||
return setpapi;
|
return setpapi;
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
return setpapi;
|
return setpapi;
|
||||||
@ -112,15 +100,22 @@ public class CreateText {
|
|||||||
//regular string papi
|
//regular string papi
|
||||||
public String placeholders(Panel panel, Player p, String setpapi) {
|
public String placeholders(Panel panel, Player p, String setpapi) {
|
||||||
try {
|
try {
|
||||||
setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi);
|
setpapi = attachPlaceholders(panel, p,setpapi);
|
||||||
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
|
||||||
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
|
|
||||||
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
|
|
||||||
}
|
|
||||||
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
|
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
|
||||||
return setpapi;
|
return setpapi;
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
return setpapi;
|
return setpapi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String attachPlaceholders(Panel panel, Player p, String input){
|
||||||
|
//do all the placeholders in order to fill into text
|
||||||
|
input = plugin.placeholders.setPlaceholders(panel, p, input, false);
|
||||||
|
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||||
|
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
|
||||||
|
input = PlaceholderAPI.setPlaceholders(offp, input);
|
||||||
|
}
|
||||||
|
input = plugin.placeholders.setPlaceholders(panel, p, input, true);
|
||||||
|
return input;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ public class HexColours {
|
|||||||
|
|
||||||
//used to translate hex colours into ChatColors
|
//used to translate hex colours into ChatColors
|
||||||
private String doTranslation(String message, String startTag, String endTag) {
|
private String doTranslation(String message, String startTag, String endTag) {
|
||||||
//final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
|
|
||||||
final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
|
final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
|
||||||
Matcher matcher = hexPattern.matcher(message);
|
Matcher matcher = hexPattern.matcher(message);
|
||||||
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
||||||
|
@ -23,17 +23,60 @@ public class Placeholders {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String setPlaceholders(Panel panel, Player p, String str, boolean primary){
|
||||||
|
String[] HOLDERS = getPlaceholderEnds(panel,primary);
|
||||||
|
while (str.contains(HOLDERS[0] + "cp-")) {
|
||||||
|
try {
|
||||||
|
int start = str.indexOf(HOLDERS[0] + "cp-");
|
||||||
|
int end = str.indexOf(HOLDERS[1], str.indexOf(HOLDERS[0] + "cp-") + 1);
|
||||||
|
String identifier = str.substring(start, end).replace(HOLDERS[0] + "cp-", "").replace(HOLDERS[1], "");
|
||||||
|
String value;
|
||||||
|
try {
|
||||||
|
value = doCpPlaceholders(panel,p,identifier, str);
|
||||||
|
} catch (NullPointerException er) {
|
||||||
|
value = "";
|
||||||
|
}
|
||||||
|
str = str.replace(str.substring(start, end) + HOLDERS[1], value);
|
||||||
|
}catch(Exception ex){
|
||||||
|
plugin.debug(ex,p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//returns primary then secondary {[start,end],[start,end]}
|
||||||
|
public String[] getPlaceholderEnds(Panel panel, boolean primary){
|
||||||
|
List<String[]> values = new ArrayList<>();
|
||||||
|
values.add(new String[]{plugin.config.getString("placeholders.primary.start"),plugin.config.getString("placeholders.primary.end")});
|
||||||
|
values.add(new String[]{plugin.config.getString("placeholders.secondary.start"),plugin.config.getString("placeholders.secondary.end")});
|
||||||
|
if(panel.getConfig().isSet("placeholders")){
|
||||||
|
if(panel.getConfig().isSet("placeholders.primary")){
|
||||||
|
values.set(0,new String[]{panel.getConfig().getString("placeholders.primary.start"),panel.getConfig().getString("placeholders.primary.end")});
|
||||||
|
}
|
||||||
|
if(panel.getConfig().isSet("placeholders.secondary")){
|
||||||
|
values.set(1,new String[]{panel.getConfig().getString("placeholders.secondary.start"),panel.getConfig().getString("placeholders.secondary.end")});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(primary){
|
||||||
|
return values.get(0);
|
||||||
|
}else{
|
||||||
|
return values.get(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public String setCpPlaceholders(Panel panel, Player p, String str){
|
private String doCpPlaceholders(Panel panel, Player p, String identifier, String string){
|
||||||
|
|
||||||
//do player input placeholder first
|
//do player input placeholder first
|
||||||
if (str.contains("%cp-player-input%")) {
|
if (identifier.equals("player-input")) {
|
||||||
for (String[] key : plugin.userInputStrings) {
|
for (String[] key : plugin.userInputStrings) {
|
||||||
if (key[0].equals(p.getName())) {
|
if (key[0].equals(p.getName())) {
|
||||||
plugin.userInputStrings.add(new String[]{p.getName(), str});
|
plugin.userInputStrings.add(new String[]{p.getName(), string});
|
||||||
return "cpc";
|
return "cpc";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.userInputStrings.add(new String[]{p.getName(), str});
|
plugin.userInputStrings.add(new String[]{p.getName(), string});
|
||||||
List<String> inputMessages = new ArrayList<String>(plugin.config.getStringList("config.input-message"));
|
List<String> inputMessages = new ArrayList<String>(plugin.config.getStringList("config.input-message"));
|
||||||
for (String temp : inputMessages) {
|
for (String temp : inputMessages) {
|
||||||
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("config.input-cancel")));
|
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("config.input-cancel")));
|
||||||
@ -43,23 +86,39 @@ public class Placeholders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//replace nodes with PlaceHolders
|
//replace nodes with PlaceHolders
|
||||||
str = str.replaceAll("%cp-player-displayname%", p.getDisplayName());
|
switch(identifier){
|
||||||
str = str.replaceAll("%cp-player-name%", p.getName());
|
case("player-displayname"): {
|
||||||
str = str.replaceAll("%cp-player-world%", p.getWorld().getName());
|
return p.getDisplayName();
|
||||||
str = str.replaceAll("%cp-player-x%", String.valueOf(Math.round(p.getLocation().getX())));
|
}
|
||||||
str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY())));
|
case("player-name"): {
|
||||||
str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ())));
|
return p.getName();
|
||||||
str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
|
}
|
||||||
str = str.replaceAll("%cp-tag%", plugin.tex.colour(plugin.tag));
|
case("player-world"): {
|
||||||
|
return p.getWorld().getName();
|
||||||
|
}
|
||||||
|
case("player-x"): {
|
||||||
|
return String.valueOf(Math.round(p.getLocation().getX()));
|
||||||
|
}
|
||||||
|
case("player-y"): {
|
||||||
|
return String.valueOf(Math.round(p.getLocation().getY()));
|
||||||
|
}
|
||||||
|
case("player-z"): {
|
||||||
|
return String.valueOf(Math.round(p.getLocation().getZ()));
|
||||||
|
}
|
||||||
|
case("online-players"): {
|
||||||
|
return Integer.toString(Bukkit.getServer().getOnlinePlayers().size());
|
||||||
|
}
|
||||||
|
case("tag"): {
|
||||||
|
return plugin.tex.colour(plugin.tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//set custom placeholders to their values
|
//set custom placeholders to their values
|
||||||
if(panel != null) {
|
if(panel != null) {
|
||||||
for (String placeholder : panel.placeholders.keys.keySet()) {
|
for (String placeholder : panel.placeholders.keys.keySet()) {
|
||||||
while (str.contains(placeholder)) {
|
if(identifier.equals(placeholder)) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf(placeholder);
|
return panel.placeholders.keys.get(placeholder);
|
||||||
int end = start + placeholder.length() - 1;
|
|
||||||
str = str.replace(str.substring(start, end) + "%", panel.placeholders.keys.get(placeholder));
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.debug(ex, p);
|
plugin.debug(ex, p);
|
||||||
break;
|
break;
|
||||||
@ -69,103 +128,91 @@ public class Placeholders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//placeholder to check for server availability %cp-server-IP:PORT%
|
//placeholder to check for server availability %cp-server-IP:PORT%
|
||||||
while (str.contains("%cp-server-")) {
|
if(identifier.startsWith("server-")) {
|
||||||
int start = str.indexOf("%cp-server-");
|
String ip_port = identifier.replace("server-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-server-")+1);
|
|
||||||
String ip_port = str.substring(start, end).replace("%cp-server-", "").replace("%","");
|
|
||||||
Socket s = new Socket();
|
Socket s = new Socket();
|
||||||
try {
|
try {
|
||||||
s.connect(new InetSocketAddress(ip_port.split(":")[0], Integer.parseInt(ip_port.split(":")[1])), plugin.config.getInt("config.server-ping-timeout"));
|
s.connect(new InetSocketAddress(ip_port.split(":")[0], Integer.parseInt(ip_port.split(":")[1])), plugin.config.getInt("config.server-ping-timeout"));
|
||||||
str = str.replace(str.substring(start, end) + "%", "true");
|
|
||||||
s.close();
|
s.close();
|
||||||
|
return "true";
|
||||||
}catch (IOException ex){
|
}catch (IOException ex){
|
||||||
str = str.replace(str.substring(start, end) + "%", "false");
|
return "false";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//placeholder to check if an item has NBT %cp-nbt-slot:key%
|
//placeholder to check if an item has NBT %cp-nbt-slot:key%
|
||||||
while (str.contains("%cp-nbt-")) {
|
if(identifier.startsWith("nbt-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-nbt-");
|
String slot_key = identifier.replace("nbt-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-nbt-")+1);
|
|
||||||
String slot_key = str.substring(start, end).replace("%cp-nbt-", "").replace("%","");
|
|
||||||
String value;
|
String value;
|
||||||
value = plugin.nbt.getNBT(p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(slot_key.split(":")[0])),slot_key.split(":")[1]);
|
value = plugin.nbt.getNBT(p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(slot_key.split(":")[0])),slot_key.split(":")[1]);
|
||||||
if(value == null){
|
if(value == null){
|
||||||
value = "empty";
|
value = "empty";
|
||||||
}
|
}
|
||||||
str = str.replace(str.substring(start, end) + "%", value);
|
return value;
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//DO placeholders for detection of other items in a panel
|
//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-")) {
|
if(identifier.startsWith("material-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-material-");
|
String matNumber = identifier.replace("material-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-material-") + 1);
|
|
||||||
String matNumber = str.substring(start, end).replace("%cp-material-", "").replace("%", "");
|
|
||||||
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 (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
|
if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
|
||||||
//add the ID to the end if it is legacy (eg, material:id)
|
//add the ID to the end if it is legacy (eg, material:id)
|
||||||
material = material + ":" + p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().getId();
|
material = material + ":" + p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().getId();
|
||||||
}
|
}
|
||||||
} catch (NullPointerException er) {
|
} catch (NullPointerException er) {
|
||||||
material = "AIR";
|
material = "AIR";
|
||||||
}
|
}
|
||||||
str = str.replace(str.substring(start, end) + "%", material);
|
return material;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//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-")) {
|
if(identifier.startsWith("stack-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-stack-");
|
String matNumber = identifier.replace("stack-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-stack-") + 1);
|
|
||||||
String matNumber = str.substring(start, end).replace("%cp-stack-", "").replace("%", "");
|
|
||||||
int amount;
|
int amount;
|
||||||
try {
|
try {
|
||||||
amount = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getAmount();
|
amount = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getAmount();
|
||||||
} catch (NullPointerException er) {
|
} catch (NullPointerException er) {
|
||||||
amount = 0;
|
amount = 0;
|
||||||
}
|
}
|
||||||
str = str.replace(str.substring(start, end) + "%", String.valueOf(amount));
|
return String.valueOf(amount);
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//get stack amount from slot in current open inventory (panel)
|
//get stack amount from slot in current open inventory (panel)
|
||||||
while (str.contains("%cp-modeldata-")) {
|
if(identifier.startsWith("modeldata-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-modeldata-");
|
String matNumber = identifier.replace("modeldata-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-modeldata-") + 1);
|
|
||||||
String matNumber = str.substring(start, end).replace("%cp-modeldata-", "").replace("%", "");
|
|
||||||
int modelData;
|
int modelData;
|
||||||
try {
|
try {
|
||||||
modelData = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getItemMeta().getCustomModelData();
|
modelData = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getItemMeta().getCustomModelData();
|
||||||
} catch (NullPointerException er) {
|
} catch (NullPointerException er) {
|
||||||
modelData = 0;
|
modelData = 0;
|
||||||
}
|
}
|
||||||
str = str.replace(str.substring(start, end) + "%", String.valueOf(modelData));
|
return String.valueOf(modelData);
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//is an item damaged
|
//is an item damaged
|
||||||
while (str.contains("%cp-damaged-")) {
|
if(identifier.startsWith("damaged-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-damaged-");
|
String matNumber = identifier.replace("damaged-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-damaged-") + 1);
|
|
||||||
String matNumber = str.substring(start, end).replace("%cp-damaged-", "").replace("%", "");
|
|
||||||
boolean damaged = false;
|
boolean damaged = false;
|
||||||
ItemStack itm = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber));
|
ItemStack itm = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber));
|
||||||
try {
|
try {
|
||||||
@ -180,18 +227,16 @@ public class Placeholders {
|
|||||||
} catch (NullPointerException er) {
|
} catch (NullPointerException er) {
|
||||||
damaged = false;
|
damaged = false;
|
||||||
}
|
}
|
||||||
str = str.replace(str.substring(start, end) + "%", String.valueOf(damaged));
|
return String.valueOf(damaged);
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//is an item identical, uses custom-items (custom item, slot)
|
//is an item identical, uses custom-items (custom item, slot)
|
||||||
while (str.contains("%cp-identical-")) {
|
if(identifier.startsWith("identical-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-identical-");
|
String matLocSlot = identifier.replace("identical-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-identical-") + 1);
|
|
||||||
String matLocSlot = str.substring(start, end).replace("%cp-identical-", "").replace("%", "");
|
|
||||||
String matLoc = matLocSlot.split(",")[0];
|
String matLoc = matLocSlot.split(",")[0];
|
||||||
int matSlot = Integer.parseInt(matLocSlot.split(",")[1]);
|
int matSlot = Integer.parseInt(matLocSlot.split(",")[1]);
|
||||||
boolean isIdentical = false;
|
boolean isIdentical = false;
|
||||||
@ -199,8 +244,7 @@ public class Placeholders {
|
|||||||
|
|
||||||
if(itm == null){
|
if(itm == null){
|
||||||
//continue if material is null
|
//continue if material is null
|
||||||
str = str.replace(str.substring(start, end) + "%", String.valueOf(false));
|
return "false";
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -224,96 +268,88 @@ public class Placeholders {
|
|||||||
isIdentical = false;
|
isIdentical = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
str = str.replace(str.substring(start, end) + "%", String.valueOf(isIdentical));
|
return String.valueOf(isIdentical);
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//does %cp-random-MIN,MAX%
|
//does %cp-random-MIN,MAX%
|
||||||
while (str.contains("%cp-random-")) {
|
if(identifier.startsWith("random-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-random-");
|
String min_max = identifier.replace("random-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-random-") + 1);
|
|
||||||
String min_max = str.substring(start, end).replace("%cp-random-", "").replace("%", "");
|
|
||||||
int min = Integer.parseInt(min_max.split(",")[0]);
|
int min = Integer.parseInt(min_max.split(",")[0]);
|
||||||
int max = Integer.parseInt(min_max.split(",")[1]);
|
int max = Integer.parseInt(min_max.split(",")[1]);
|
||||||
str = str.replace(str.substring(start, end) + "%", String.valueOf(plugin.getRandomNumberInRange(min, max)));
|
return String.valueOf(plugin.getRandomNumberInRange(min, max));
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//returns value of stored data
|
//returns value of stored data
|
||||||
while (str.contains("%cp-data-")) {
|
if(identifier.startsWith("data-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-data-");
|
String dataPoint = identifier.replace("data-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-data-") + 1);
|
|
||||||
String dataPoint = str.substring(start, end).replace("%cp-data-", "").replace("%", "");
|
|
||||||
//get data from other user
|
//get data from other user
|
||||||
if(dataPoint.contains(",")){
|
if(dataPoint.contains(",")){
|
||||||
String dataName = dataPoint.split(",")[0];
|
String dataName = dataPoint.split(",")[0];
|
||||||
String playerName = dataPoint.split(",")[1];
|
String playerName = dataPoint.split(",")[1];
|
||||||
str = str.replace(str.substring(start, end) + "%", plugin.panelData.getUserData(Bukkit.getOfflinePlayer(playerName).getUniqueId(),dataName));
|
return plugin.panelData.getUserData(Bukkit.getOfflinePlayer(playerName).getUniqueId(),dataName);
|
||||||
}else{
|
}else{
|
||||||
str = str.replace(str.substring(start, end) + "%", plugin.panelData.getUserData(p.getUniqueId(),dataPoint));
|
return plugin.panelData.getUserData(p.getUniqueId(),dataPoint);
|
||||||
}
|
}
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//edits data via placeholder execution (will return empty output)
|
//edits data via placeholder execution (will return empty output)
|
||||||
while (str.contains("%cp-setdata-")) {
|
if(identifier.startsWith("setdata-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-setdata-");
|
String point_value = identifier.replace("cp-setdata-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-setdata-") + 1);
|
|
||||||
String point_value = str.substring(start, end).replace("%cp-setdata-", "").replace("%", "");
|
|
||||||
String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
|
String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
|
||||||
plugin.commandTags.runCommand(panel,p, command);
|
plugin.commandTags.runCommand(panel,p, command);
|
||||||
str = str.replace(str.substring(start, end) + "%", "");
|
return "";
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//math data via placeholder execution (will return empty output)
|
//math data via placeholder execution (will return empty output)
|
||||||
while (str.contains("%cp-mathdata-")) {
|
if(identifier.startsWith("mathdata-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-mathdata-");
|
String point_value = identifier.replace("mathdata-", "");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-mathdata-") + 1);
|
|
||||||
String point_value = str.substring(start, end).replace("%cp-mathdata-", "").replace("%", "");
|
|
||||||
String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
|
String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
|
||||||
plugin.commandTags.runCommand(panel,p,command);
|
plugin.commandTags.runCommand(panel,p,command);
|
||||||
str = str.replace(str.substring(start, end) + "%", "");
|
return "";
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//checks for players online
|
//checks for players online
|
||||||
while (str.contains("%cp-player-online-")) {
|
if(identifier.startsWith("player-online-")) {
|
||||||
try {
|
try {
|
||||||
int start = str.indexOf("%cp-player-online-");
|
String playerLocation = identifier.replace("player-online-", "");
|
||||||
int end = str.indexOf("-find%", str.indexOf("%cp-player-online-") + 1);
|
|
||||||
String playerLocation = str.substring(start, end).replace("%cp-player-online-", "");
|
|
||||||
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
|
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
|
||||||
if (Integer.parseInt(playerLocation) > playerFind.length) {
|
if (Integer.parseInt(playerLocation) > playerFind.length) {
|
||||||
str = str.replace(str.substring(start, end) + "-find%", plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline"))));
|
return plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")));
|
||||||
} else {
|
} else {
|
||||||
str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName());
|
return playerFind[Integer.parseInt(playerLocation) - 1].getName();
|
||||||
}
|
}
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
plugin.debug(ex,p);
|
plugin.debug(ex,p);
|
||||||
break;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (plugin.econ != null) {
|
if (plugin.econ != null) {
|
||||||
str = str.replaceAll("%cp-player-balance%", String.valueOf(Math.round(plugin.econ.getBalance(p))));
|
if(identifier.equals("player-balance")) {
|
||||||
|
return String.valueOf(Math.round(plugin.econ.getBalance(p)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception place) {
|
} catch (Exception place) {
|
||||||
//skip
|
//skip
|
||||||
@ -321,12 +357,16 @@ public class Placeholders {
|
|||||||
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
|
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
|
||||||
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
|
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
|
||||||
assert api != null;
|
assert api != null;
|
||||||
str = str.replaceAll("%cp-tokenmanager-balance%", Long.toString(api.getTokens(p).orElse(0)));
|
if(identifier.equals("tokenmanager-balance")) {
|
||||||
|
return Long.toString(api.getTokens(p).orElse(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (plugin.getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
|
if (plugin.getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
|
||||||
str = str.replaceAll("%cp-votingplugin-points%", String.valueOf(UserManager.getInstance().getVotingPluginUser(p).getPoints()));
|
if(identifier.equals("votingplugin-points")) {
|
||||||
|
return String.valueOf(UserManager.getInstance().getVotingPluginUser(p).getPoints());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//end nodes with PlaceHolders
|
//end nodes with PlaceHolders
|
||||||
return str;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,10 @@ public class CommandTagEvent extends Event {
|
|||||||
this.name = split[0].trim();
|
this.name = split[0].trim();
|
||||||
this.raw = split[1].trim().split("\\s");
|
this.raw = split[1].trim().split("\\s");
|
||||||
if(doApiPlaceholders) {
|
if(doApiPlaceholders) {
|
||||||
this.args = plugin.tex.placeholders(panel1, player, split[1].trim()).split("\\s");
|
this.args = plugin.tex.attachPlaceholders(panel1, player, split[1].trim()).split("\\s");
|
||||||
}else{
|
}else{
|
||||||
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setCpPlaceholders(panel, p,split[1].trim())).split("\\s");
|
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, p,split[1].trim(),false)).split("\\s");
|
||||||
|
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, p,split[1].trim(),true)).split("\\s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,16 +29,18 @@ public class Commandpanelcustom implements Listener {
|
|||||||
|
|
||||||
boolean correctCommand = true;
|
boolean correctCommand = true;
|
||||||
ArrayList<String[]> placeholders = new ArrayList<>(); //should read placeholder,argument
|
ArrayList<String[]> placeholders = new ArrayList<>(); //should read placeholder,argument
|
||||||
String[] args = cmd.split("\\s");
|
String[] phEnds = plugin.placeholders.getPlaceholderEnds(panel,true); //start and end of placeholder
|
||||||
String[] executedCommand = e.getMessage().replace("/", "").split("\\s"); //command split into args
|
String[] command = cmd.split("\\s");
|
||||||
if(args.length != executedCommand.length){
|
String[] message = e.getMessage().replace("/", "").split("\\s"); //command split into args
|
||||||
|
|
||||||
|
if(command.length != message.length){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < cmd.split("\\s").length; i++){
|
for(int i = 0; i < cmd.split("\\s").length; i++){
|
||||||
if(args[i].startsWith("%cp-")){
|
if(command[i].startsWith(phEnds[0])){
|
||||||
placeholders.add(new String[]{args[i], executedCommand[i]});
|
placeholders.add(new String[]{command[i].replace(phEnds[0],"").replace(phEnds[1],""), message[i]});
|
||||||
}else if(!args[i].equals(executedCommand[i])){
|
}else if(!command[i].equals(message[i])){
|
||||||
correctCommand = false;
|
correctCommand = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package me.rockyhawk.commandpanels.ingameeditor;
|
|||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import me.rockyhawk.commandpanels.api.Panel;
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
@ -96,8 +96,7 @@ public final class NBT_1_13 {
|
|||||||
classCache.put( "GameProfile", Class.forName( "com.mojang.authlib.GameProfile" ) );
|
classCache.put( "GameProfile", Class.forName( "com.mojang.authlib.GameProfile" ) );
|
||||||
classCache.put( "Property", Class.forName( "com.mojang.authlib.properties.Property" ) );
|
classCache.put( "Property", Class.forName( "com.mojang.authlib.properties.Property" ) );
|
||||||
classCache.put( "PropertyMap", Class.forName( "com.mojang.authlib.properties.PropertyMap" ) );
|
classCache.put( "PropertyMap", Class.forName( "com.mojang.authlib.properties.PropertyMap" ) );
|
||||||
} catch ( ClassNotFoundException e ) {
|
} catch ( ClassNotFoundException ignore ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTClasses = new HashMap< Class< ? >, Class< ? > >();
|
NBTClasses = new HashMap< Class< ? >, Class< ? > >();
|
||||||
@ -126,7 +125,6 @@ public final class NBT_1_13 {
|
|||||||
NBTClasses.put( Class.forName( "[I" ), Class.forName( "net.minecraft.nbt.NBTTagIntArray" ) );
|
NBTClasses.put( Class.forName( "[I" ), Class.forName( "net.minecraft.nbt.NBTTagIntArray" ) );
|
||||||
}
|
}
|
||||||
} catch ( ClassNotFoundException e ) {
|
} catch ( ClassNotFoundException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
methodCache = new HashMap< String, Method >();
|
methodCache = new HashMap< String, Method >();
|
||||||
@ -210,7 +208,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
methodCache.put( "loadNBTTagCompound", getNMSClass( "MojangsonParser" ).getMethod( "parse", String.class ) );
|
methodCache.put( "loadNBTTagCompound", getNMSClass( "MojangsonParser" ).getMethod( "parse", String.class ) );
|
||||||
} catch( Exception e ) {
|
} catch( Exception e ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -246,8 +243,7 @@ public final class NBT_1_13 {
|
|||||||
if ( LOCAL_VERSION == MinecraftVersion.v1_11 || LOCAL_VERSION == MinecraftVersion.v1_12 ) {
|
if ( LOCAL_VERSION == MinecraftVersion.v1_11 || LOCAL_VERSION == MinecraftVersion.v1_12 ) {
|
||||||
constructorCache.put( getNMSClass( "ItemStack" ), getNMSClass( "ItemStack" ).getConstructor( getNMSClass( "NBTTagCompound" ) ) );
|
constructorCache.put( getNMSClass( "ItemStack" ), getNMSClass( "ItemStack" ).getConstructor( getNMSClass( "NBTTagCompound" ) ) );
|
||||||
}
|
}
|
||||||
} catch( Exception e ) {
|
} catch( Exception ignore ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagFieldCache = new HashMap< Class< ? >, Field >();
|
NBTTagFieldCache = new HashMap< Class< ? >, Field >();
|
||||||
@ -274,8 +270,7 @@ public final class NBT_1_13 {
|
|||||||
field.setAccessible( true );
|
field.setAccessible( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch( Exception e ) {
|
} catch( Exception ignore ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -288,8 +283,7 @@ public final class NBT_1_13 {
|
|||||||
}
|
}
|
||||||
NBTListData.setAccessible( true );
|
NBTListData.setAccessible( true );
|
||||||
NBTCompoundMap.setAccessible( true );
|
NBTCompoundMap.setAccessible( true );
|
||||||
} catch( Exception e ) {
|
} catch( Exception ignore ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +303,6 @@ public final class NBT_1_13 {
|
|||||||
return NBTTagFieldCache.get( clazz ).get( object );
|
return NBTTagFieldCache.get( clazz ).get( object );
|
||||||
}
|
}
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -330,7 +323,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return Class.forName("net.minecraft.server." + VERSION + "." + name);
|
return Class.forName("net.minecraft.server." + VERSION + "." + name);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,27 +384,23 @@ public final class NBT_1_13 {
|
|||||||
Object textureProperty = getConstructor( getNMSClass( "Property" ) ).newInstance( "textures", new String( Base64.getEncoder().encode( String.format( "{textures:{SKIN:{\"url\":\"%s\"}}}", skinURL ).getBytes() ) ) );
|
Object textureProperty = getConstructor( getNMSClass( "Property" ) ).newInstance( "textures", new String( Base64.getEncoder().encode( String.format( "{textures:{SKIN:{\"url\":\"%s\"}}}", skinURL ).getBytes() ) ) );
|
||||||
getMethod( "put" ).invoke( propertyMap, "textures", textureProperty );
|
getMethod( "put" ).invoke( propertyMap, "textures", textureProperty );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e1 ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e1 ) {
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( methodCache.containsKey( "setProfile" ) ) {
|
if ( methodCache.containsKey( "setProfile" ) ) {
|
||||||
try {
|
try {
|
||||||
getMethod( "setProfile" ).invoke( headMeta, profile );
|
getMethod( "setProfile" ).invoke( headMeta, profile );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Field profileField = null;
|
Field profileField = null;
|
||||||
try {
|
try {
|
||||||
profileField = headMeta.getClass().getDeclaredField("profile");
|
profileField = headMeta.getClass().getDeclaredField("profile");
|
||||||
} catch ( NoSuchFieldException | SecurityException e ) {
|
} catch ( NoSuchFieldException | SecurityException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
try {
|
try {
|
||||||
profileField.set(headMeta, profile);
|
profileField.set(headMeta, profile);
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
head.setItemMeta(headMeta);
|
head.setItemMeta(headMeta);
|
||||||
@ -433,7 +421,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
profileField = meta.getClass().getDeclaredField("profile");
|
profileField = meta.getClass().getDeclaredField("profile");
|
||||||
} catch ( NoSuchFieldException | SecurityException e ) {
|
} catch ( NoSuchFieldException | SecurityException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
throw new IllegalArgumentException( "Item is not a player skull!" );
|
throw new IllegalArgumentException( "Item is not a player skull!" );
|
||||||
}
|
}
|
||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
@ -452,7 +439,6 @@ public final class NBT_1_13 {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch ( IllegalArgumentException | IllegalAccessException | SecurityException | InvocationTargetException e) {
|
} catch ( IllegalArgumentException | IllegalAccessException | SecurityException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,7 +458,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return getTag( getCompound( item ), keys );
|
return getTag( getCompound( item ), keys );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -496,7 +481,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -525,7 +509,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
return getNBTTag( tag, keys );
|
return getNBTTag( tag, keys );
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,7 +550,6 @@ public final class NBT_1_13 {
|
|||||||
getMethod( "setTag" ).invoke( stack, tag );
|
getMethod( "setTag" ).invoke( stack, tag );
|
||||||
return ( ItemStack ) getMethod( "asBukkitCopy" ).invoke( null, stack );
|
return ( ItemStack ) getMethod( "asBukkitCopy" ).invoke( null, stack );
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -596,7 +578,6 @@ public final class NBT_1_13 {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -616,7 +597,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return getTag( getCompound( entity ), keys );
|
return getTag( getCompound( entity ), keys );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -635,7 +615,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -663,7 +642,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
return getNBTTag( tag, keys );
|
return getNBTTag( tag, keys );
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -698,7 +676,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
getMethod( "setEntityTag" ).invoke( NMSEntity, tag );
|
getMethod( "setEntityTag" ).invoke( NMSEntity, tag );
|
||||||
} catch ( Exception exception ) {
|
} catch ( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -718,7 +695,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return getTag( getCompound( block ), keys );
|
return getTag( getCompound( block ), keys );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -743,7 +719,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
} catch( Exception exception ) {
|
} catch( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -777,7 +752,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
return getNBTTag( tag, keys );
|
return getNBTTag( tag, keys );
|
||||||
} catch( Exception exception ) {
|
} catch( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -822,7 +796,6 @@ public final class NBT_1_13 {
|
|||||||
getMethod( "setTileTag" ).invoke( tileEntity, tag );
|
getMethod( "setTileTag" ).invoke( tileEntity, tag );
|
||||||
}
|
}
|
||||||
} catch( Exception exception ) {
|
} catch( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -852,7 +825,6 @@ public final class NBT_1_13 {
|
|||||||
|
|
||||||
getMethod( "setGameProfile" ).invoke( tileEntity, profile );
|
getMethod( "setGameProfile" ).invoke( tileEntity, profile );
|
||||||
} catch( Exception exception ) {
|
} catch( Exception exception ) {
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +839,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return getTag( ( ( NBTCompound ) object ).tag, keys );
|
return getTag( ( ( NBTCompound ) object ).tag, keys );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -896,14 +867,12 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return getNBTTag( ( ( NBTCompound ) object ).tag, keys );
|
return getNBTTag( ( ( NBTCompound ) object ).tag, keys );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if ( getNMSClass( "NBTTagCompound" ).isInstance( object ) ) {
|
} else if ( getNMSClass( "NBTTagCompound" ).isInstance( object ) ) {
|
||||||
try {
|
try {
|
||||||
return getNBTTag( object, keys );
|
return getNBTTag( object, keys );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1109,8 +1078,7 @@ public final class NBT_1_13 {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -1148,7 +1116,6 @@ public final class NBT_1_13 {
|
|||||||
return ( int ) getMethod( "size" ).invoke( nbtCompound.tag );
|
return ( int ) getMethod( "size" ).invoke( nbtCompound.tag );
|
||||||
}
|
}
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1179,8 +1146,7 @@ public final class NBT_1_13 {
|
|||||||
} else if ( object instanceof NBTCompound ) {
|
} else if ( object instanceof NBTCompound ) {
|
||||||
try {
|
try {
|
||||||
setTag( ( ( NBTCompound ) object ).tag, value, keys );
|
setTag( ( ( NBTCompound ) object ).tag, value, keys );
|
||||||
} catch ( InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException( "Object provided must be of type ItemStack, Entity, Block, or NBTCompound!" );
|
throw new IllegalArgumentException( "Object provided must be of type ItemStack, Entity, Block, or NBTCompound!" );
|
||||||
@ -1210,7 +1176,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return new NBTCompound( getNMSClass( "NBTTagCompound" ).newInstance() );
|
return new NBTCompound( getNMSClass( "NBTTagCompound" ).newInstance() );
|
||||||
} catch ( InstantiationException | IllegalAccessException e ) {
|
} catch ( InstantiationException | IllegalAccessException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1368,7 +1333,6 @@ public final class NBT_1_13 {
|
|||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1386,8 +1350,7 @@ public final class NBT_1_13 {
|
|||||||
public void set( Object value, Object... keys ) {
|
public void set( Object value, Object... keys ) {
|
||||||
try {
|
try {
|
||||||
new NBT_1_13().setTag( tag, value, keys );
|
new NBT_1_13().setTag( tag, value, keys );
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception ignore ) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1405,7 +1368,6 @@ public final class NBT_1_13 {
|
|||||||
try {
|
try {
|
||||||
return new NBTCompound( new NBT_1_13().getMethod( "loadNBTTagCompound" ).invoke( null, json ) );
|
return new NBTCompound( new NBT_1_13().getMethod( "loadNBTTagCompound" ).invoke( null, json ) );
|
||||||
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
} catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,7 @@ public class OpenPanelsLoader {
|
|||||||
|
|
||||||
public boolean isNBTInjected(ItemStack itm){
|
public boolean isNBTInjected(ItemStack itm){
|
||||||
if(itm != null){
|
if(itm != null){
|
||||||
if (plugin.nbt.hasNBT(itm)) {
|
return plugin.nbt.hasNBT(itm);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class HotbarItemLoader {
|
public class HotbarItemLoader {
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
@ -17,37 +17,31 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//stationary slots 0-8 are the hotbar, using 9-35 for inside the inventory
|
//stationary slots 0-8 are the hotbar, using 9-35 for inside the inventory
|
||||||
HashMap<Integer,Panel> stationaryItems = new HashMap<>();
|
HashMap<UUID,HotbarPlayerManager> stationaryItems = new HashMap<>();
|
||||||
|
|
||||||
//will compile the ArrayList {slot 0-4, index of panelNames}
|
//will compile the ArrayList {slot 0-4, index of panelNames}
|
||||||
public void reloadHotbarSlots() {
|
public void reloadHotbarSlots() {
|
||||||
stationaryItems.clear();
|
stationaryItems.clear();
|
||||||
for (Panel panel : plugin.panelList) {
|
|
||||||
if(panel.getConfig().contains("open-with-item.stationary")){
|
|
||||||
stationaryItems.put(panel.getConfig().getInt("open-with-item.stationary"), panel.copy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//update hotbar items for all players when reloaded
|
//update hotbar items for all players when reloaded
|
||||||
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
||||||
plugin.hotbar.updateHotbarItems(p);
|
plugin.hotbar.updateHotbarItems(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> getStationaryItemSlots(){
|
|
||||||
return stationaryItems.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
//return true if found
|
//return true if found
|
||||||
public boolean stationaryExecute(int slot, Player p, boolean openPanel){
|
public boolean stationaryExecute(int slot, Player p, boolean openPanel){
|
||||||
for(int temp : stationaryItems.keySet()){
|
if(stationaryItems.get(p.getUniqueId()).list.containsKey(slot)){
|
||||||
if(slot == temp){
|
|
||||||
if(openPanel) {
|
if(openPanel) {
|
||||||
Panel panel = stationaryItems.get(temp);
|
try {
|
||||||
//only open panel automatically if there are no commands and player world is not disabled
|
if (!plugin.nbt.getNBT(p.getInventory().getItem(slot), "CommandPanelsHotbar").split(":")[1].equals(String.valueOf(slot))) {
|
||||||
if(!p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))){
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
}catch(Exception ex){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Panel panel = stationaryItems.get(p.getUniqueId()).getPanel(slot);
|
||||||
|
//only open panel automatically if there are no commands and player world is not disabled
|
||||||
|
if(!p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!itemCheckExecute(p.getInventory().getItem(slot),p,false,false)){
|
if(!itemCheckExecute(p.getInventory().getItem(slot),p,false,false)){
|
||||||
@ -63,7 +57,6 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,12 +71,14 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
for(Panel panel : plugin.panelList) {
|
for(Panel panel : plugin.panelList) {
|
||||||
if(stationaryOnly){
|
if(stationaryOnly){
|
||||||
if(!panel.getConfig().contains("open-with-item.stationary")){
|
try {
|
||||||
|
if (plugin.nbt.getNBT(invItem, "CommandPanelsHotbar").split(":")[1].equals("-1")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}catch(NullPointerException | IllegalArgumentException ignore){}
|
||||||
}
|
}
|
||||||
if(panel.hasHotbarItem()){
|
if(panel.hasHotbarItem()){
|
||||||
if(plugin.nbt.getNBT(invItem,"CommandPanelsHotbar").equals(panel.getName())){
|
if(plugin.nbt.getNBT(invItem,"CommandPanelsHotbar").split(":")[0].equals(panel.getName())){
|
||||||
if(openPanel) {
|
if(openPanel) {
|
||||||
//only open panel automatically if there are no commands and if world is not disabled
|
//only open panel automatically if there are no commands and if world is not disabled
|
||||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||||
@ -121,6 +116,7 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//remove any old hotbar items
|
//remove any old hotbar items
|
||||||
|
stationaryItems.put(p.getUniqueId(),new HotbarPlayerManager());
|
||||||
for(int i = 0; i <= 35; i++){
|
for(int i = 0; i <= 35; i++){
|
||||||
try {
|
try {
|
||||||
if (plugin.nbt.getNBT(p.getInventory().getItem(i), "CommandPanelsHotbar") != null) {
|
if (plugin.nbt.getNBT(p.getInventory().getItem(i), "CommandPanelsHotbar") != null) {
|
||||||
@ -136,8 +132,9 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
||||||
ItemStack s = panel.getHotbarItem(p);
|
ItemStack s = panel.getHotbarItem(p);
|
||||||
if(panel.getConfig().contains("open-with-item.stationary")) {
|
if(panel.getHotbarSection(p).contains("stationary")) {
|
||||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"),s);
|
p.getInventory().setItem(panel.getHotbarSection(p).getInt("stationary"),s);
|
||||||
|
stationaryItems.get(p.getUniqueId()).addSlot(panel.getHotbarSection(p).getInt("stationary"),panel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package me.rockyhawk.commandpanels.openwithitem;
|
||||||
|
|
||||||
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class HotbarPlayerManager {
|
||||||
|
public HashMap<Integer,Panel> list = new HashMap<>();
|
||||||
|
|
||||||
|
public HotbarPlayerManager(){
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSlot(int slot, Panel panel){
|
||||||
|
list.put(slot,panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Panel getPanel(int slot){
|
||||||
|
return list.get(slot);
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,7 @@ public class UtilsChestSortEvent implements Listener {
|
|||||||
}
|
}
|
||||||
//If the ChestSort plugin triggers an event
|
//If the ChestSort plugin triggers an event
|
||||||
if(e.getInventory().getType() == InventoryType.PLAYER){
|
if(e.getInventory().getType() == InventoryType.PLAYER){
|
||||||
for(int slot : plugin.hotbar.getStationaryItemSlots()){
|
for(int slot : plugin.hotbar.stationaryItems.get(e.getPlayer().getUniqueId()).list.keySet()){
|
||||||
e.setUnmovable(slot);
|
e.setUnmovable(slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,10 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
plugin.hotbar.updateHotbarItems(e.getPlayer());
|
plugin.hotbar.updateHotbarItems(e.getPlayer());
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent e){
|
||||||
|
plugin.hotbar.stationaryItems.remove(e.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
@EventHandler
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent e){
|
public void onPlayerDropItem(PlayerDropItemEvent e){
|
||||||
if(!plugin.openWithItem){
|
if(!plugin.openWithItem){
|
||||||
//if none of the panels have open-with-item
|
//if none of the panels have open-with-item
|
||||||
|
Loading…
Reference in New Issue
Block a user