forked from Upstream/CommandPanels
Placeholder API fixes build 2
This commit is contained in:
parent
1ea62d8c12
commit
c48f41f1c3
@ -626,10 +626,14 @@ public class commandpanels extends JavaPlugin {
|
||||
|
||||
//regular string papi
|
||||
public String papi(Player p, String setpapi) {
|
||||
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
setpapi = PlaceholderAPI.setPlaceholders(p, setpapi);
|
||||
try {
|
||||
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
setpapi = PlaceholderAPI.setPlaceholders(p, setpapi);
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', setpapi);
|
||||
}catch(NullPointerException e){
|
||||
return setpapi;
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&',setpapi);
|
||||
}
|
||||
|
||||
//papi except if it is a String List
|
||||
@ -645,7 +649,11 @@ public class commandpanels extends JavaPlugin {
|
||||
int tempInt = 0;
|
||||
//change colour
|
||||
for(String temp : setpapi){
|
||||
setpapi.set(tempInt,ChatColor.translateAlternateColorCodes('&',temp));
|
||||
try {
|
||||
setpapi.set(tempInt, ChatColor.translateAlternateColorCodes('&', temp));
|
||||
}catch(NullPointerException ignore){
|
||||
|
||||
}
|
||||
tempInt += 1;
|
||||
}
|
||||
return setpapi;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.rockyhawk.commandPanels.commands;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.rockyhawk.commandPanels.commandpanels;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -92,10 +91,10 @@ public class commandpanel implements CommandExecutor {
|
||||
if(sender.hasPermission("commandpanel.other")) {
|
||||
try {
|
||||
if (cf.contains("panels." + panels + ".disabled-worlds")) {
|
||||
List<String> disabledWorlds = (List<String>) cf.getList("panels." + panels + ".disabled-worlds");
|
||||
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
|
||||
if (disabledWorlds.contains(sp.getWorld().getName())) {
|
||||
//panel cannot be used in the players world!
|
||||
if (plugin.config.getString("config.disabled-world-message").equalsIgnoreCase("true")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Panel is disabled in players world!"));
|
||||
}
|
||||
return true;
|
||||
@ -109,9 +108,9 @@ public class commandpanel implements CommandExecutor {
|
||||
try {
|
||||
if (cf.contains("panels." + panels + ".sound-on-open")) {
|
||||
//play sound when panel is opened
|
||||
if(!cf.getString("panels." + panels + ".sound-on-open").equalsIgnoreCase("off")) {
|
||||
if(!Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).equalsIgnoreCase("off")) {
|
||||
try {
|
||||
sp.playSound(sp.getLocation(), Sound.valueOf(cf.getString("panels." + panels + ".sound-on-open").toUpperCase()), 1F, 1F);
|
||||
sp.playSound(sp.getLocation(), Sound.valueOf(Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).toUpperCase()), 1F, 1F);
|
||||
} catch (Exception s) {
|
||||
sp.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(sp, plugin.config.getString("config.format.error") + " " + "sound-on-open: " + cf.getString("panels." + panels + ".sound-on-open"))));
|
||||
}
|
||||
@ -120,7 +119,7 @@ public class commandpanel implements CommandExecutor {
|
||||
if (cf.contains("panels." + panels + ".commands-on-open")) {
|
||||
//execute commands on panel open
|
||||
try {
|
||||
List<String> commands = (List<String>) cf.getList("panels." + panels + ".commands-on-open");
|
||||
List<String> commands = cf.getStringList("panels." + panels + ".commands-on-open");
|
||||
for (int i = 0; commands.size() - 1 >= i; i++) {
|
||||
int val = plugin.commandPayWall(sp,commands.get(i));
|
||||
if(val == 0){
|
||||
@ -183,7 +182,7 @@ public class commandpanel implements CommandExecutor {
|
||||
|
||||
if (sender.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
|
||||
if(cf.contains("panels." + panels + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) cf.getList("panels." + panels + ".disabled-worlds");
|
||||
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
|
||||
if(disabledWorlds.contains(sp.getWorld().getName())){
|
||||
//panel cannot be used in the players world!
|
||||
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
|
||||
@ -302,10 +301,10 @@ public class commandpanel implements CommandExecutor {
|
||||
}
|
||||
if (p.hasPermission("commandpanel.panel." + cf.getString("panels." + panels + ".perm"))) {
|
||||
if(cf.contains("panels." + panels + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) cf.getList("panels." + panels + ".disabled-worlds");
|
||||
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
//panel cannot be used in the players world!
|
||||
if(plugin.config.getString("config.disabled-world-message").equalsIgnoreCase("true")){
|
||||
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
|
||||
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
|
||||
}
|
||||
return true;
|
||||
@ -313,9 +312,9 @@ public class commandpanel implements CommandExecutor {
|
||||
}
|
||||
if (cf.contains("panels." + panels + ".sound-on-open")) {
|
||||
//play sound when panel is opened
|
||||
if(!cf.getString("panels." + panels + ".sound-on-open").equalsIgnoreCase("off")) {
|
||||
if(!Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).equalsIgnoreCase("off")) {
|
||||
try {
|
||||
p.playSound(p.getLocation(), Sound.valueOf(cf.getString("panels." + panels + ".sound-on-open").toUpperCase()), 1F, 1F);
|
||||
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).toUpperCase()), 1F, 1F);
|
||||
} catch (Exception s) {
|
||||
plugin.debug(s);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + " " + "sound-on-open: " + cf.getString("panels." + panels + ".sound-on-open"))));
|
||||
@ -325,7 +324,7 @@ public class commandpanel implements CommandExecutor {
|
||||
if (cf.contains("panels." + panels + ".commands-on-open")) {
|
||||
//execute commands on panel open
|
||||
try {
|
||||
List<String> commands = (List<String>) cf.getList("panels." + panels + ".commands-on-open");
|
||||
List<String> commands = cf.getStringList("panels." + panels + ".commands-on-open");
|
||||
for (int i = 0; commands.size() - 1 >= i; i++) {
|
||||
int val = plugin.commandPayWall(p,commands.get(i));
|
||||
if(val == 0){
|
||||
@ -374,10 +373,10 @@ public class commandpanel implements CommandExecutor {
|
||||
|
||||
if (p.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
|
||||
if(cf.contains("panels." + panels + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) cf.getList("panels." + panels + ".disabled-worlds");
|
||||
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
//panel cannot be used in the players world!
|
||||
if(plugin.config.getString("config.disabled-world-message").equalsIgnoreCase("true")){
|
||||
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
|
||||
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
|
||||
}
|
||||
return true;
|
||||
@ -385,7 +384,7 @@ public class commandpanel implements CommandExecutor {
|
||||
}
|
||||
ItemStack s;
|
||||
try {
|
||||
s = new ItemStack(Material.matchMaterial(cf.getString("panels." + panels + ".open-with-item.material")), 1);
|
||||
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(cf.getString("panels." + panels + ".open-with-item.material"))), 1);
|
||||
}catch(Exception n){
|
||||
plugin.debug(n);
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
@ -426,6 +425,7 @@ public class commandpanel implements CommandExecutor {
|
||||
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
|
||||
panels = args[0];
|
||||
nfound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nfound) {
|
||||
@ -442,10 +442,10 @@ public class commandpanel implements CommandExecutor {
|
||||
if (p.hasPermission("commandpanel.panel." + cf.getString("panels." + panels + ".perm"))) {
|
||||
if(p.hasPermission("commandpanel.other")) {
|
||||
if(cf.contains("panels." + panels + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) cf.getList("panels." + panels + ".disabled-worlds");
|
||||
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
//panel cannot be used in the players world!
|
||||
if(plugin.config.getString("config.disabled-world-message").equalsIgnoreCase("true")){
|
||||
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
|
||||
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
|
||||
}
|
||||
return true;
|
||||
@ -495,10 +495,10 @@ public class commandpanel implements CommandExecutor {
|
||||
|
||||
if (p.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
|
||||
if(cf.contains("panels." + panels + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) cf.getList("panels." + panels + ".disabled-worlds");
|
||||
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
//panel cannot be used in the players world!
|
||||
if(plugin.config.getString("config.disabled-world-message").equalsIgnoreCase("true")){
|
||||
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
|
||||
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
|
||||
}
|
||||
return true;
|
||||
@ -506,7 +506,7 @@ public class commandpanel implements CommandExecutor {
|
||||
}
|
||||
ItemStack s;
|
||||
try {
|
||||
s = new ItemStack(Material.matchMaterial(cf.getString("panels." + panels + ".open-with-item.material")), 1);
|
||||
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(cf.getString("panels." + panels + ".open-with-item.material"))), 1);
|
||||
}catch(Exception n){
|
||||
plugin.debug(n);
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
@ -520,7 +520,7 @@ public class commandpanel implements CommandExecutor {
|
||||
if(p.hasPermission("commandpanel.other")) {
|
||||
try {
|
||||
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
|
||||
p.getInventory().setItem(Integer.parseInt(cf.getString("panels." + panels + ".open-with-item.stationary")), s);
|
||||
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
|
||||
}else{
|
||||
p.getInventory().addItem(s);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.rockyhawk.commandPanels.commands;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.rockyhawk.commandPanels.commandpanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -1,18 +1,14 @@
|
||||
package me.rockyhawk.commandPanels.commands;
|
||||
|
||||
import me.rockyhawk.commandPanels.commandpanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
public class commandpanelsreload implements CommandExecutor {
|
||||
commandpanels plugin;
|
||||
|
@ -39,7 +39,7 @@ public class cpTabComplete implements TabCompleter {
|
||||
}
|
||||
if(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) temp.getList("panels." + key + ".disabled-worlds");
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
if(!disabledWorlds.contains(p.getWorld().getName())){
|
||||
apanels.add(key);
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ public class newGenUtils implements Listener {
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
//reload panel files to avoid conflicts
|
||||
plugin.reloadPanelFiles();
|
||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||
Player p = (Player)e.getPlayer();
|
||||
if (!ChatColor.stripColor(e.getView().getTitle()).equals("Generate New Panel")){
|
||||
return;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.rockyhawk.commandPanels.ingameEditor;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.rockyhawk.commandPanels.commandpanels;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -40,7 +40,7 @@ public class cpTabCompleteIngame implements TabCompleter {
|
||||
}
|
||||
if(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) temp.getList("panels." + key + ".disabled-worlds");
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
assert p != null;
|
||||
assert disabledWorlds != null;
|
||||
if(!disabledWorlds.contains(p.getWorld().getName())){
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.rockyhawk.commandPanels.ingameEditor;
|
||||
|
||||
import me.rockyhawk.commandPanels.commandpanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
|
@ -148,7 +148,7 @@ public class utilsOpenWithItem implements Listener {
|
||||
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) temp.getList("panels." + key + ".disabled-worlds");
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
assert disabledWorlds != null;
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
continue;
|
||||
@ -197,7 +197,7 @@ public class utilsOpenWithItem implements Listener {
|
||||
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) temp.getList("panels." + key + ".disabled-worlds");
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
assert disabledWorlds != null;
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
continue;
|
||||
@ -286,7 +286,7 @@ public class utilsOpenWithItem implements Listener {
|
||||
key = (String) var10.next();
|
||||
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = (List<String>) temp.getList("panels." + key + ".disabled-worlds");
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
assert disabledWorlds != null;
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
continue;
|
||||
|
@ -42,7 +42,7 @@ public class blocksTabComplete implements TabCompleter {
|
||||
}
|
||||
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
|
||||
if (temp.contains("panels." + key + ".disabled-worlds")) {
|
||||
List<String> disabledWorlds = (List<String>) temp.getList("panels." + key + ".disabled-worlds");
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
if (!disabledWorlds.contains(p.getWorld().getName())) {
|
||||
apanels.add(key);
|
||||
}
|
||||
|
@ -1,13 +1,9 @@
|
||||
package me.rockyhawk.commandPanels.panelBlocks;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.rockyhawk.commandPanels.commandpanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
Loading…
Reference in New Issue
Block a user