3.9.1 Fixes

This commit is contained in:
rockyhawk64 2020-08-17 18:44:11 +10:00
parent 16603f56ca
commit f6f3ff0313
13 changed files with 63 additions and 66 deletions

View File

@ -6,7 +6,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resource" type="java-resource" />
</content>
<orderEntry type="jdk" jdkName="adopt-openjdk-1.8" jdkType="JavaSDK" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="HeadDatabaseAPI" level="project" />
<orderEntry type="library" name="TokenManager-3.2.4" level="project" />

View File

@ -1,4 +1,4 @@
version: 3.9.0
version: 3.9.1
main: me.rockyhawk.commandPanels.commandpanels
name: CommandPanels
author: RockyHawk

View File

@ -354,7 +354,8 @@ public class commandpanels extends JavaPlugin {
}
public ItemStack getItem(String b64stringtexture) {
GameProfile profile = new GameProfile(UUID.randomUUID(), (String) null);
//get head from base64
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
PropertyMap propertyMap = profile.getProperties();
if (propertyMap == null) {
throw new IllegalStateException("Profile doesn't contain a property map");
@ -378,7 +379,6 @@ public class commandpanels extends JavaPlugin {
private <T> Field getField(Class<?> target, String name, Class<T> fieldType, int index) {
Field[] var4 = target.getDeclaredFields();
int var5 = var4.length;
for (Field field : var4) {
if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType()) && index-- <= 0) {
@ -1005,6 +1005,11 @@ public class commandpanels extends JavaPlugin {
if(!fileName.substring(ind).equalsIgnoreCase(".yml") && !fileName.substring(ind).equalsIgnoreCase(".yaml")){
continue;
}
//check before adding the file to commandpanels
if(!checkPanels(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)))){
this.getServer().getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error in: " + fileName);
continue;
}
panelFiles.add((directory + File.separator + fileName).replace(panelsf.toString() + File.separator,""));
for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) {
panelNames.add(new String[]{tempName, Integer.toString(count)});
@ -1014,24 +1019,25 @@ public class commandpanels extends JavaPlugin {
}
public void reloadPanelFiles() {
try {
panelFiles.clear();
panelNames.clear();
//load panel files
fileNamesFromDirectory(panelsf);
//this bit will set openWithItem to false/true upson reload
YamlConfiguration tempFile;
String tempName;
openWithItem = false;
for(String[] panelName : panelNames){
tempFile = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + panelFiles.get(Integer.parseInt(panelName[1]))));
tempName = panelName[0];
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
openWithItem = true;
}
panelFiles.clear();
panelNames.clear();
//load panel files
fileNamesFromDirectory(panelsf);
//this bit will set openWithItem to false/true upson reload
YamlConfiguration tempFile;
String tempName;
openWithItem = false;
for(String[] panelName : panelNames){
tempFile = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + panelFiles.get(Integer.parseInt(panelName[1]))));
if(!checkPanels(tempFile)){
this.getServer().getConsoleSender().sendMessage("[CommandPanels] Error in: " + panelFiles.get(Integer.parseInt(panelName[1])));
continue;
}
tempName = panelName[0];
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
openWithItem = true;
break;
}
} catch (NullPointerException noPanels) {
this.getServer().getConsoleSender().sendMessage("[CommandPanels] No panels found to load!");
}
}
@ -1096,7 +1102,6 @@ public class commandpanels extends JavaPlugin {
}};
public void openEditorGui(Player p, int pageChange) {
reloadPanelFiles();
Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor");
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)
@ -1106,7 +1111,7 @@ public class commandpanels extends JavaPlugin {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName));
String key;
if (!checkPanels(temp)) {
return;
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
@ -1185,7 +1190,6 @@ public class commandpanels extends JavaPlugin {
}
public void openPanelSettings(Player p, String panelName, YamlConfiguration cf) {
reloadPanelFiles();
Inventory i = Bukkit.createInventory(null, 45, "Panel Settings: " + panelName);
List<String> lore = new ArrayList();
ItemStack temp;
@ -1370,7 +1374,6 @@ public class commandpanels extends JavaPlugin {
}
public void openItemSettings(Player p, String panelName, YamlConfiguration cf, int itemNumber) {
reloadPanelFiles();
Inventory i = Bukkit.createInventory(null, 36, "Item Settings: " + panelName);
List<String> lore = new ArrayList();
ItemStack temp;

View File

@ -33,8 +33,7 @@ public class commandpanel implements CommandExecutor {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if(!plugin.checkPanels(temp)){
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Panel with syntax error found!"));
return true;
continue;
}
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
apanels.add(temp.getString("panels." + key + ".title"));

View File

@ -40,8 +40,7 @@ public class commandpanelcustom implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
return;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();

View File

@ -42,8 +42,8 @@ public class commandpanelslist implements CommandExecutor {
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(f)));
apanels.add("%file%" + plugin.panelFiles.get(f));
if(!plugin.checkPanels(temp)){
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
return true;
apanels.add("Error Reading File!");
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
@ -74,7 +74,7 @@ public class commandpanelslist implements CommandExecutor {
sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page");
break;
}
sender.sendMessage(ChatColor.DARK_GREEN + apanels.get(f).replaceAll("%file%","").replaceAll(".yml",""));
sender.sendMessage(ChatColor.DARK_GREEN + apanels.get(f).replaceAll("%file%",""));
}else{
sender.sendMessage(ChatColor.GREEN + "- " + apanels.get(f));
}

View File

@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.yaml.snakeyaml.scanner.ScannerException;
import java.io.File;
import java.util.ArrayList;
@ -23,35 +24,35 @@ public class cpTabComplete implements TabCompleter {
if(label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")){
ArrayList<String> apanels = new ArrayList<String>(); //all panels
String tpanels; //tpanels is the temp to check through the files
try {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
try {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return null;
if (!plugin.checkPanels(temp)) {
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if(!key.startsWith(args[0])){
if (!key.startsWith(args[0])) {
//this will narrow down the panels to what the user types
continue;
}
if(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if(temp.contains("panels." + key + ".disabled-worlds")){
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if (temp.contains("panels." + key + ".disabled-worlds")) {
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
if(!disabledWorlds.contains(p.getWorld().getName())){
if (!disabledWorlds.contains(p.getWorld().getName())) {
apanels.add(key);
}
}else{
} else {
apanels.add(key);
}
}
}
//if file contains opened panel then start
}catch(Exception skip){
//ignore panel
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
//if file contains opened panel then start
}
return apanels;
}

View File

@ -49,8 +49,7 @@ public class cpIngameEditCommand implements CommandExecutor {
tpanels = "";
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
if (!plugin.checkPanels(temp)) {
sender.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
return true;
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();

View File

@ -30,7 +30,7 @@ public class cpTabCompleteIngame implements TabCompleter {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return null;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();

View File

@ -49,7 +49,7 @@ public class editorUtils implements Listener {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
@ -146,7 +146,7 @@ public class editorUtils implements Listener {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
@ -213,7 +213,7 @@ public class editorUtils implements Listener {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempName));
String key;
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
@ -332,7 +332,7 @@ public class editorUtils implements Listener {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
if(e.getView().getTitle().equals("Panel Settings: " + key)){
@ -459,7 +459,7 @@ public class editorUtils implements Listener {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
if(e.getView().getTitle().equals("Item Settings: " + key)){
@ -594,7 +594,7 @@ public class editorUtils implements Listener {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile));
String key;
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;

View File

@ -141,7 +141,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
@ -184,7 +184,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
@ -225,7 +225,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
@ -259,8 +259,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Missing required component in panel!"));
return;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
@ -312,7 +311,6 @@ public class utilsOpenWithItem implements Listener {
}catch(Exception b){
return;
}
YamlConfiguration cf; //this is the file to use for any panel.* requests
String tpanels; //tpanels is the temp to check through the files
ItemStack clicked = e.getItemDrop().getItemStack();
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
@ -320,7 +318,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
@ -371,7 +369,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
@ -423,7 +421,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
return;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();

View File

@ -32,7 +32,7 @@ public class blocksTabComplete implements TabCompleter {
String key;
tpanels = "";
if (!plugin.checkPanels(temp)) {
return null;
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();

View File

@ -48,9 +48,7 @@ public class commandpanelrefresher implements Listener {
String key;
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if (!plugin.checkPanels(temp)) {
assert p != null;
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found or Panel with syntax error Found!"));
return;
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;