forked from Upstream/CommandPanels
fixes v3.10.5
This commit is contained in:
parent
41a2e29777
commit
44dc044fe5
@ -1,4 +1,4 @@
|
||||
version: 3.10.4
|
||||
version: 3.10.5
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -6,10 +6,8 @@ import com.mojang.authlib.properties.Property;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -34,8 +32,9 @@ import me.rockyhawk.commandpanels.openwithitem.UtilsOpenWithItem;
|
||||
import me.rockyhawk.commandpanels.panelblocks.BlocksTabComplete;
|
||||
import me.rockyhawk.commandpanels.panelblocks.Commandpanelblocks;
|
||||
import me.rockyhawk.commandpanels.panelblocks.PanelBlockOnClick;
|
||||
import me.rockyhawk.commandpanels.premium.CommandpanelUserInput;
|
||||
import me.rockyhawk.commandpanels.premium.Commandpanelrefresher;
|
||||
import me.rockyhawk.commandpanels.interactives.CommandpanelUserInput;
|
||||
import me.rockyhawk.commandpanels.interactives.Commandpanelrefresher;
|
||||
import me.rockyhawk.commandpanels.updater.Updater;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -69,6 +68,7 @@ public class CommandPanels extends JavaPlugin {
|
||||
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
|
||||
public ItemCreation itemCreate = new ItemCreation(this);
|
||||
public GetCustomHeads customHeads = new GetCustomHeads(this);
|
||||
public Updater updater = new Updater(this);
|
||||
|
||||
public File panelsf;
|
||||
public YamlConfiguration blockConfig; //where panel block locations are stored
|
||||
@ -142,7 +142,7 @@ public class CommandPanels extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (Objects.requireNonNull(this.config.getString("config.update-notifications")).equalsIgnoreCase("true")) {
|
||||
githubNewUpdate(true);
|
||||
updater.githubNewUpdate(true);
|
||||
}
|
||||
|
||||
//load panelFiles
|
||||
@ -614,44 +614,6 @@ public class CommandPanels extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public String githubNewUpdate(boolean sendMessages){
|
||||
HttpURLConnection connection;
|
||||
String gitVersion;
|
||||
if(this.getDescription().getVersion().contains("-")){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running a custom version.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
connection = (HttpURLConnection) new URL("https://raw.githubusercontent.com/rockyhawk64/CommandPanels/master/resource/plugin.yml").openConnection();
|
||||
connection.connect();
|
||||
gitVersion = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine().split("\\s")[1];
|
||||
if(gitVersion.contains("-")){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if(!this.getDescription().getVersion().equals(gitVersion)){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " ================================================");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " An update for CommandPanels is available.");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download version " + gitVersion + " here:");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " https://www.spigotmc.org/resources/command-panels-custom-guis.67788/");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " ================================================");
|
||||
}
|
||||
return gitVersion;
|
||||
}
|
||||
}catch(IOException e){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error checking for updates online.");
|
||||
}
|
||||
debug(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//used to translate hex colours into ChatColors
|
||||
public String translateHexColorCodes(String message) {
|
||||
final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
|
||||
|
@ -57,7 +57,7 @@ public class Utils implements Listener {
|
||||
}
|
||||
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
|
||||
key = s;
|
||||
if (ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) {
|
||||
if (plugin.papi(Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) {
|
||||
panel = key;
|
||||
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
|
||||
foundPanel = true;
|
||||
@ -106,7 +106,7 @@ public class Utils implements Listener {
|
||||
List<String> commandsAfterSequence = commands;
|
||||
for (int i = 0; commands.size() - 1 >= i; i++) {
|
||||
if(commands.get(i).startsWith("sequence=")){
|
||||
String locationOfSequence = commands.get(i).split("\\s")[1];
|
||||
String locationOfSequence = plugin.papiNoColour(p,commands.get(i).split("\\s")[1]);
|
||||
List<String> commandsSequence = cf.getStringList(locationOfSequence);
|
||||
commandsAfterSequence.remove(i);
|
||||
commandsAfterSequence.addAll(i,commandsSequence);
|
||||
|
@ -326,9 +326,9 @@ public class ItemCreation {
|
||||
//this will do hasperm with no numbers
|
||||
boolean outputValue = true;
|
||||
//outputValue will default to true
|
||||
if (cf.contains("output")) {
|
||||
if (cf.contains("hasperm.output")) {
|
||||
//if output is true, and values match it will be this item, vice versa
|
||||
outputValue = cf.getBoolean("output");
|
||||
outputValue = cf.getBoolean("hasperm.output");
|
||||
}
|
||||
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) {
|
||||
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.rockyhawk.commandpanels.premium;
|
||||
package me.rockyhawk.commandpanels.interactives;
|
||||
|
||||
import me.rockyhawk.commandpanels.classresources.CommandTags;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
@ -1,4 +1,4 @@
|
||||
package me.rockyhawk.commandpanels.premium;
|
||||
package me.rockyhawk.commandpanels.interactives;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.*;
|
81
src/me/rockyhawk/commandpanels/updater/Updater.java
Normal file
81
src/me/rockyhawk/commandpanels/updater/Updater.java
Normal file
@ -0,0 +1,81 @@
|
||||
package me.rockyhawk.commandpanels.updater;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Updater {
|
||||
CommandPanels plugin;
|
||||
public Updater(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public String githubNewUpdate(boolean sendMessages){
|
||||
HttpURLConnection connection;
|
||||
String gitVersion;
|
||||
if(plugin.getDescription().getVersion().contains("-")){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running a custom version.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
connection = (HttpURLConnection) new URL("https://raw.githubusercontent.com/rockyhawk64/CommandPanels/master/resource/plugin.yml").openConnection();
|
||||
connection.connect();
|
||||
gitVersion = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine().split("\\s")[1];
|
||||
if(gitVersion.contains("-")){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//major.minor.patch for variables
|
||||
ArrayList<Integer> updateOnlineVersion = new ArrayList<>();
|
||||
ArrayList<Integer> updateCurrentVersion = new ArrayList<>();
|
||||
for(String key : plugin.getDescription().getVersion().split("\\.")){
|
||||
updateCurrentVersion.add(Integer.parseInt(key));
|
||||
}
|
||||
for(String key : gitVersion.split("\\.")){
|
||||
updateOnlineVersion.add(Integer.parseInt(key));
|
||||
}
|
||||
|
||||
//if update is true there is a new update
|
||||
boolean update = false;
|
||||
if(updateOnlineVersion.get(0) > updateCurrentVersion.get(0)){
|
||||
update = true;
|
||||
}else {
|
||||
if (updateOnlineVersion.get(1) > updateCurrentVersion.get(1)) {
|
||||
update = true;
|
||||
}else{
|
||||
if (updateOnlineVersion.get(2) > updateCurrentVersion.get(2)) {
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(update){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.AQUA + " An update for CommandPanels is available.");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download CommandPanels " + ChatColor.GOLD + gitVersion + ChatColor.WHITE + " here:");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.AQUA + " https://www.spigotmc.org/resources/command-panels-custom-guis.67788/");
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================");
|
||||
}
|
||||
return gitVersion;
|
||||
}
|
||||
}catch(IOException e){
|
||||
if(sendMessages) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error checking for updates online.");
|
||||
}
|
||||
plugin.debug(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user