forked from Upstream/CommandPanels
3.10.2 Fixes
This commit is contained in:
parent
b1b5248249
commit
d35e45ea3e
@ -1,4 +1,4 @@
|
|||||||
version: 3.10.1
|
version: 3.10.2
|
||||||
main: me.rockyhawk.commandPanels.commandpanels
|
main: me.rockyhawk.commandPanels.commandpanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -1067,7 +1067,7 @@ public class commandpanels extends JavaPlugin {
|
|||||||
Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor");
|
Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor");
|
||||||
ArrayList<String> panelNames = new ArrayList<String>(); //all panels from ALL files (panel names)
|
ArrayList<String> panelNames = new ArrayList<String>(); //all panels from ALL files (panel names)
|
||||||
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
|
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
|
||||||
ArrayList<Material> panelItems = new ArrayList<Material>(); //all panels from ALL files (panel materials)
|
ArrayList<ItemStack> panelItems = new ArrayList<ItemStack>(); //all panels from ALL files (panel materials)
|
||||||
try {
|
try {
|
||||||
for(String fileName : panelFiles) { //will loop through all the files in folder
|
for(String fileName : panelFiles) { //will loop through all the files in folder
|
||||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName));
|
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName));
|
||||||
@ -1080,9 +1080,9 @@ public class commandpanels extends JavaPlugin {
|
|||||||
panelNames.add(papi( key));
|
panelNames.add(papi( key));
|
||||||
panelTitles.add(papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
|
panelTitles.add(papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
|
||||||
if (temp.contains("panels." + key + ".open-with-item.material")) {
|
if (temp.contains("panels." + key + ".open-with-item.material")) {
|
||||||
panelItems.add(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material"))));
|
panelItems.add(makeItemFromConfig(temp.getConfigurationSection("panels." + key + ".open-with-item"), p, false, true));
|
||||||
} else {
|
} else {
|
||||||
panelItems.add(Material.FILLED_MAP);
|
panelItems.add(new ItemStack(Material.FILLED_MAP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1141,8 +1141,8 @@ public class commandpanels extends JavaPlugin {
|
|||||||
for (String panelName : panelNames) {
|
for (String panelName : panelNames) {
|
||||||
//count is +1 because count starts at 0 not 1
|
//count is +1 because count starts at 0 not 1
|
||||||
if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) {
|
if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) {
|
||||||
temp = new ItemStack(panelItems.get(count), 1);
|
temp = panelItems.get(count);
|
||||||
setName(temp, ChatColor.WHITE + panelName, null, p, true, true);
|
setName(temp, ChatColor.WHITE + panelName, null, p, false, true);
|
||||||
i.setItem(slot, temp);
|
i.setItem(slot, temp);
|
||||||
slot += 1;
|
slot += 1;
|
||||||
}
|
}
|
||||||
@ -1266,7 +1266,7 @@ public class commandpanels extends JavaPlugin {
|
|||||||
|
|
||||||
if(cf.contains("panels." + panelName + ".open-with-item.material")){
|
if(cf.contains("panels." + panelName + ".open-with-item.material")){
|
||||||
hotbarItems = true;
|
hotbarItems = true;
|
||||||
temp = new ItemStack((Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(cf.getString("panels." + panelName + ".open-with-item.material"))))), 1);
|
temp = makeItemFromConfig(cf.getConfigurationSection("panels." + panelName + ".open-with-item"), p, false, true);
|
||||||
}else{
|
}else{
|
||||||
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
|
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class commandpanelsreload implements CommandExecutor {
|
public class commandpanelsreload implements CommandExecutor {
|
||||||
commandpanels plugin;
|
commandpanels plugin;
|
||||||
@ -20,6 +21,11 @@ public class commandpanelsreload implements CommandExecutor {
|
|||||||
if (label.equalsIgnoreCase("cpr") || label.equalsIgnoreCase("commandpanelreload") || label.equalsIgnoreCase("cpanelr")) {
|
if (label.equalsIgnoreCase("cpr") || label.equalsIgnoreCase("commandpanelreload") || label.equalsIgnoreCase("cpanelr")) {
|
||||||
if (sender.hasPermission("commandpanel.reload")) {
|
if (sender.hasPermission("commandpanel.reload")) {
|
||||||
plugin.reloadPanelFiles();
|
plugin.reloadPanelFiles();
|
||||||
|
try {
|
||||||
|
YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml")).save(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
//skip clearing temp
|
||||||
|
}
|
||||||
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
|
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
|
||||||
tag = plugin.config.getString("config.format.tag") + " ";
|
tag = plugin.config.getString("config.format.tag") + " ";
|
||||||
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.reload")));
|
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.reload")));
|
||||||
|
@ -249,13 +249,12 @@ public class editorUserInput implements Listener {
|
|||||||
plugin.reloadPanelFiles();
|
plugin.reloadPanelFiles();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Material temp = Material.matchMaterial(e.getMessage());
|
cf.set("panels." + panelName + ".open-with-item.material", e.getMessage());
|
||||||
cf.set("panels." + panelName + ".open-with-item.material", temp.toString());
|
|
||||||
if(!cf.contains("panels." + panelName + ".open-with-item.name")){
|
if(!cf.contains("panels." + panelName + ".open-with-item.name")){
|
||||||
cf.set("panels." + panelName + ".open-with-item.name", panelName + " Item");
|
cf.set("panels." + panelName + ".open-with-item.name", panelName + " Item");
|
||||||
}
|
}
|
||||||
savePanelFile(cf, panelFile);
|
savePanelFile(cf, panelFile);
|
||||||
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + temp.toString()));
|
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage()));
|
||||||
//after an open-with-item has been altered, reload after changes
|
//after an open-with-item has been altered, reload after changes
|
||||||
plugin.reloadPanelFiles();
|
plugin.reloadPanelFiles();
|
||||||
break;
|
break;
|
||||||
|
@ -652,16 +652,7 @@ public class editorUtils implements Listener {
|
|||||||
if(!cont.getEnchantments().isEmpty()){
|
if(!cont.getEnchantments().isEmpty()){
|
||||||
file.set("panels." + panelName + ".item." + i + ".enchanted", "true");
|
file.set("panels." + panelName + ".item." + i + ".enchanted", "true");
|
||||||
}
|
}
|
||||||
if(file.contains("panels." + panelName + ".item." + i + ".name")){
|
file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
|
||||||
//these will ensure &f items (blank items) will be set to &f to stay blank
|
|
||||||
if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".name")).equalsIgnoreCase("&f") || file.getString("panels." + panelName + ".item." + i + ".name").equalsIgnoreCase("§f")){
|
|
||||||
file.set("panels." + panelName + ".item." + i + ".name", "&f");
|
|
||||||
}else{
|
|
||||||
file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
|
|
||||||
}
|
|
||||||
file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
|
file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
|
||||||
}catch(Exception n){
|
}catch(Exception n){
|
||||||
//skip over an item that spits an error
|
//skip over an item that spits an error
|
||||||
@ -669,7 +660,6 @@ public class editorUtils implements Listener {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
file.save(new File(plugin.panelsf + File.separator + fileName));
|
file.save(new File(plugin.panelsf + File.separator + fileName));
|
||||||
tempEdit.save(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
|
|
||||||
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Saved Changes!"));
|
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Saved Changes!"));
|
||||||
} catch (IOException s) {
|
} catch (IOException s) {
|
||||||
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Could Not Save Changes!"));
|
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Could Not Save Changes!"));
|
||||||
|
@ -307,38 +307,26 @@ public class utilsOpenWithItem implements Listener {
|
|||||||
}catch(Exception b){
|
}catch(Exception b){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String tpanels; //tpanels is the temp to check through the files
|
|
||||||
ItemStack clicked = e.getItemDrop().getItemStack();
|
ItemStack clicked = e.getItemDrop().getItemStack();
|
||||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
for(String[] panelName : plugin.panelNames){
|
||||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
YamlConfiguration tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1]))));
|
||||||
String key;
|
String tempName = panelName[0];
|
||||||
tpanels = "";
|
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
|
||||||
if(!plugin.checkPanels(temp)){
|
try{
|
||||||
continue;
|
assert clicked != null;
|
||||||
}
|
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
|
||||||
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
|
||||||
key = (String) var10.next();
|
//cancel the click item event
|
||||||
for(String ekey : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
|
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
|
||||||
if(temp.contains("panels." + key + ".open-with-item")){
|
e.setCancelled(true);
|
||||||
if(clicked.getType() != Material.AIR) {
|
p.updateInventory();
|
||||||
//try and catch loop to stop errors with the same material type but different name
|
return;
|
||||||
try {
|
|
||||||
if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + ekey + ".open-with-item.material")))), 1).getType()) {
|
|
||||||
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + ekey + ".open-with-item.name")))))) {
|
|
||||||
//cancel the click item event
|
|
||||||
if(temp.contains("panels." + key + ".open-with-item.stationary")){
|
|
||||||
if(p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch(Exception n){
|
|
||||||
//do nothing
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch(NullPointerException cancel){
|
||||||
|
//do nothing skip item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user