mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2024-09-27 04:13:17 +02:00
Refactored some old code
This commit is contained in:
parent
9e622ba2b4
commit
74c346924b
@ -7,6 +7,6 @@ import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
|
||||
public interface DependListener {
|
||||
|
||||
public ItemStack getItemStack(Player p, WorldPlayer wp);
|
||||
ItemStack getItemStack(Player p, WorldPlayer wp);
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public interface OrcClickListener {
|
||||
|
||||
public void onClick(Player p, OrcInventory inv, OrcItem item);
|
||||
void onClick(Player p, OrcInventory inv, OrcItem item);
|
||||
|
||||
}
|
||||
|
@ -14,9 +14,8 @@ public abstract class OrcInventory {
|
||||
protected String title;
|
||||
private int rows;
|
||||
private InventoryType type;
|
||||
private boolean fill = false;
|
||||
|
||||
protected HashMap<Integer, OrcItem> items = new HashMap<>();
|
||||
protected HashMap<Integer, OrcItem> items = new HashMap<>();
|
||||
|
||||
public OrcInventory(String title) {
|
||||
Objects.requireNonNull(title, "title cannot be null");
|
||||
@ -32,8 +31,7 @@ public abstract class OrcInventory {
|
||||
|
||||
public OrcInventory(String title, int rows, boolean fill) {
|
||||
this(title, rows);
|
||||
this.fill = fill;
|
||||
if(this.fill) {
|
||||
if(fill) {
|
||||
for (int i = 0; i < rows * 9; i++) {
|
||||
items.put(i, OrcItem.fill);
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ import de.butzlabben.inventory.OrcItem;
|
||||
*/
|
||||
public interface ItemConverter<T> {
|
||||
|
||||
public OrcItem convert(T element);
|
||||
OrcItem convert(T element);
|
||||
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class GameProfileBuilder {
|
||||
synchronized (sync) {
|
||||
connection = (HttpURLConnection) new URL(
|
||||
String.format("https://sessionserver.mojang.com/session/minecraft/profile/%s?unsigned=false",
|
||||
new Object[] { UUIDTypeAdapter.fromUUID(uuid) })).openConnection();
|
||||
UUIDTypeAdapter.fromUUID(uuid))).openConnection();
|
||||
connection.setReadTimeout(5000);
|
||||
}
|
||||
if (connection.getResponseCode() == 200) {
|
||||
|
@ -31,7 +31,6 @@ public class WorldSystem extends JavaPlugin {
|
||||
final private String version = this.getDescription().getVersion();
|
||||
|
||||
private CreatorAdapter creator;
|
||||
private CommandFramework framework;
|
||||
|
||||
private static boolean is1_13 = false;
|
||||
|
||||
@ -76,7 +75,7 @@ public class WorldSystem extends JavaPlugin {
|
||||
}, 20 * 60 * 2, 20 * 60 * 2);
|
||||
|
||||
//COMMANDS
|
||||
framework = new CommandFramework(this);
|
||||
CommandFramework framework = new CommandFramework(this);
|
||||
framework.setNoPermissionMessage(MessageConfig.getNoPermission());
|
||||
|
||||
framework.registerCommands(new WSCommand());
|
||||
|
@ -16,7 +16,7 @@ public class AutoUpdate implements Runnable {
|
||||
private UpdateInformations ui;
|
||||
private String jar;
|
||||
|
||||
public AutoUpdate(UpdateInformations ui, String jar) {
|
||||
protected AutoUpdate(UpdateInformations ui, String jar) {
|
||||
this.ui = ui;
|
||||
this.jar = jar;
|
||||
}
|
||||
|
@ -19,11 +19,10 @@ public class UpdateInformations {
|
||||
private final String version, url, plugin;
|
||||
private final boolean silent;
|
||||
|
||||
public static synchronized UpdateInformations getInformations() {
|
||||
protected static synchronized UpdateInformations getInformations() {
|
||||
String json = callURL("https://zendilu.net/butzlabben/worldsystem/info.php?version=" + WorldSystem.getInstance().getDescription().getVersion());
|
||||
Gson gson = new GsonBuilder().create();
|
||||
UpdateInformations ui = gson.fromJson(json, UpdateInformations.class);
|
||||
return ui;
|
||||
return gson.fromJson(json, UpdateInformations.class);
|
||||
}
|
||||
|
||||
public static String callURL(String URL) {
|
||||
|
@ -22,7 +22,7 @@ public class DependenceConfig {
|
||||
OfflinePlayer op = null;
|
||||
try {
|
||||
op = Bukkit.getOfflinePlayer(UUID.fromString(s));
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (op == null) {
|
||||
op = Bukkit.getOfflinePlayer(s);
|
||||
@ -86,18 +86,15 @@ public class DependenceConfig {
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(dconfig);
|
||||
String uuid = op.getUniqueId().toString();
|
||||
//Fix for #40
|
||||
if (cfg.isInt("Dependences." + uuid + ".ID"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return cfg.isInt("Dependences." + uuid + ".ID");
|
||||
}
|
||||
|
||||
public String getWorldname() {
|
||||
File dconfig = new File("plugins//WorldSystem//dependence.yml");
|
||||
YamlConfiguration dcfg = YamlConfiguration.loadConfiguration(dconfig);
|
||||
String uuid = op.getUniqueId().toString();
|
||||
int id = dcfg.getInt("Dependences." + uuid + ".ID");
|
||||
String worldname = "ID" + id + "-" + uuid;
|
||||
return worldname;
|
||||
return "ID" + id + "-" + uuid;
|
||||
}
|
||||
|
||||
public String getWorldNamebyOfflinePlayer() {
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
public class Entry {
|
||||
|
||||
private OfflinePlayer op;
|
||||
private String uuid;
|
||||
private int id;
|
||||
private String worldname;
|
||||
|
||||
@ -36,13 +35,11 @@ public class Entry {
|
||||
}
|
||||
|
||||
protected boolean hasWorld() {
|
||||
if(worldname.equals("n"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return !worldname.equals("n");
|
||||
}
|
||||
|
||||
protected Entry(OfflinePlayer op) {
|
||||
uuid = op.getUniqueId().toString();
|
||||
String uuid = op.getUniqueId().toString();
|
||||
this.op = op;
|
||||
File dconfig = new File("plugins//WorldSystem//dependence.yml");
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(dconfig);
|
||||
|
@ -114,11 +114,11 @@ public class GuiConfig {
|
||||
YamlConfiguration cfg = getConfig();
|
||||
try {
|
||||
return new OrcItem(getMaterial(cfg, path), getData(cfg, path), getDisplay(cfg, path), getLore(cfg, path));
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
return new OrcItem(getMaterial(cfg, path), getDisplay(cfg, path), getLore(cfg, path));
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return OrcItem.error.clone().setDisplay("§c" + path);
|
||||
}
|
||||
|
@ -17,8 +17,7 @@ public class CommandExecutorClickListener implements OrcClickListener {
|
||||
@Override
|
||||
public void onClick(Player p, OrcInventory inv, OrcItem item) {
|
||||
p.closeInventory();
|
||||
String msg = message;
|
||||
p.chat(msg);
|
||||
p.chat(message);
|
||||
// Fix for #9
|
||||
inv.redraw(p);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class MoneyUtil {
|
||||
RegisteredServiceProvider<Economy> service = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if (service != null)
|
||||
economy = service.getProvider();
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -339,9 +339,7 @@ public class SystemWorld {
|
||||
public boolean isLoaded() {
|
||||
File worldAsDir = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
World w = Bukkit.getWorld(worldname);
|
||||
if (worldAsDir.exists() && w != null)
|
||||
return true;
|
||||
return false;
|
||||
return worldAsDir.exists() && w != null;
|
||||
}
|
||||
|
||||
private boolean exists() {
|
||||
|
Loading…
Reference in New Issue
Block a user