mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2024-12-02 13:23:21 +01:00
Some code clean up
This commit is contained in:
parent
30558df018
commit
93b322116b
@ -48,7 +48,7 @@ public class OrcListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void on(InventoryCloseEvent e) {
|
||||
if (e.getInventory() != null && invs.containsKey(e.getPlayer().getUniqueId())) {
|
||||
if (e.getInventory() != null) {
|
||||
invs.remove(e.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package de.butzlabben.inventory.pages;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import de.butzlabben.inventory.OrcInventory;
|
||||
@ -60,15 +58,4 @@ public class InventoryPage extends OrcInventory {
|
||||
addItem(i, item);
|
||||
i++;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(InventoryClickEvent e) {
|
||||
if (e.getClickedInventory() != null && e.getClickedInventory().getTitle() != null
|
||||
&& e.getClickedInventory().getTitle().equals(title)) {
|
||||
e.setCancelled(true);
|
||||
OrcItem item = items.get(e.getSlot());
|
||||
if (item != null)
|
||||
item.onClick((Player) e.getWhoClicked(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class PageGUICreator<T> {
|
||||
if (items == null || items.size() == 0)
|
||||
return;
|
||||
|
||||
int pages = (int) (Math.ceil((double) (items.size() / (double) elementsPerPage) < 1 ? 1 : Math.ceil((double) items.size() / (double) elementsPerPage)));
|
||||
int pages = (int) (Math.ceil((items.size() / (double) elementsPerPage) < 1 ? 1 : Math.ceil((double) items.size() / (double) elementsPerPage)));
|
||||
|
||||
invpages = new ArrayList<>(pages);
|
||||
|
||||
|
@ -40,15 +40,15 @@ public class GameProfileBuilder {
|
||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create();
|
||||
private static HashMap<UUID, CachedProfile> cache = new HashMap<>();
|
||||
private static long cacheTime = -1L;
|
||||
private static Object sync = new Object();
|
||||
private static final Object sync = new Object();
|
||||
|
||||
public static GameProfile fetch(UUID uuid) throws IOException {
|
||||
return fetch(uuid, false);
|
||||
}
|
||||
|
||||
public static GameProfile fetch(UUID uuid, boolean forceNew) throws IOException {
|
||||
if ((!forceNew) && (cache.containsKey(uuid)) && (((CachedProfile) cache.get(uuid)).isValid())) {
|
||||
return ((CachedProfile) cache.get(uuid)).profile;
|
||||
if ((!forceNew) && (cache.containsKey(uuid)) && (cache.get(uuid).isValid())) {
|
||||
return cache.get(uuid).profile;
|
||||
}
|
||||
|
||||
HttpURLConnection connection;
|
||||
@ -61,12 +61,12 @@ public class GameProfileBuilder {
|
||||
if (connection.getResponseCode() == 200) {
|
||||
String json = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();
|
||||
|
||||
GameProfile result = (GameProfile) gson.fromJson(json, GameProfile.class);
|
||||
GameProfile result = gson.fromJson(json, GameProfile.class);
|
||||
cache.put(uuid, new CachedProfile(result));
|
||||
return result;
|
||||
}
|
||||
if ((!forceNew) && (cache.containsKey(uuid))) {
|
||||
return ((CachedProfile) cache.get(uuid)).profile;
|
||||
return cache.get(uuid).profile;
|
||||
}
|
||||
throw new IOException("Could not connect to mojang servers for unknown player: " + uuid.toString());
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class GameProfileBuilder {
|
||||
Base64Coder.encodeString(String.format(
|
||||
cape ? "{\"timestamp\":%d,\"profileId\":\"%s\",\"profileName\":\"%s\",\"isPublic\":true,\"textures\":{\"SKIN\":{\"url\":\"%s\"},\"CAPE\":{\"url\":\"%s\"}}}"
|
||||
: "{\"timestamp\":%d,\"profileId\":\"%s\",\"profileName\":\"%s\",\"isPublic\":true,\"textures\":{\"SKIN\":{\"url\":\"%s\"}}}",
|
||||
args.toArray(new Object[args.size()])))));
|
||||
args.toArray(new Object[0])))));
|
||||
return profile;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class GameProfileBuilder {
|
||||
if (object.has("properties")) {
|
||||
for (Map.Entry<String, Property> prop : ((PropertyMap) context.deserialize(object.get("properties"),
|
||||
PropertyMap.class)).entries()) {
|
||||
profile.getProperties().put((String) prop.getKey(), (Property) prop.getValue());
|
||||
profile.getProperties().put(prop.getKey(), prop.getValue());
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
|
@ -28,19 +28,19 @@ public class WorldCheckerRunnable implements Runnable {
|
||||
String ownerofWorld = null;
|
||||
for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
|
||||
if (p.getUniqueId().toString()
|
||||
.equals(worldname.substring(worldname.length() - 36, worldname.length())))
|
||||
.equals(worldname.substring(worldname.length() - 36)))
|
||||
ownerofWorld = p.getName();
|
||||
}
|
||||
String members = "";
|
||||
StringBuilder members = new StringBuilder();
|
||||
for (Player p : world.getPlayers()) {
|
||||
members += p.getName() + " ";
|
||||
members.append(p.getName()).append(" ");
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!p.hasPermission("ws.lag"))
|
||||
continue;
|
||||
p.sendMessage(MessageConfig.getLagDetection().replaceAll("%world",
|
||||
ownerofWorld + " ( ID: " + world.getName().substring(2, worldname.length() - 37) + " )"));
|
||||
p.sendMessage(MessageConfig.getPlayerList().replaceAll("%players", members));
|
||||
p.sendMessage(MessageConfig.getPlayerList().replaceAll("%players", members.toString()));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package de.butzlabben.world;
|
||||
import de.butzlabben.autoupdater.AutoUpdater;
|
||||
import de.butzlabben.world.command.*;
|
||||
import de.butzlabben.world.config.*;
|
||||
import de.butzlabben.world.gui.GuiCommand;
|
||||
import de.butzlabben.world.listener.*;
|
||||
import de.butzlabben.world.wrapper.AsyncCreatorAdapter;
|
||||
import de.butzlabben.world.wrapper.CreatorAdapter;
|
||||
|
@ -83,7 +83,6 @@ public class WorldSettingsCommands {
|
||||
|
||||
} else {
|
||||
p.sendMessage(MessageConfig.getInvalidInput().replaceAll("input", args.getArgument(0)));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (sw.isLoaded())
|
||||
|
@ -24,7 +24,8 @@ public class MessageConfig {
|
||||
}
|
||||
|
||||
private static List<String> defaultCmdHelp = new ArrayList<>(20);
|
||||
{
|
||||
|
||||
static {
|
||||
defaultCmdHelp.add("/ws get §8- §7Will give you a World");
|
||||
defaultCmdHelp.add("/ws home §8- §7Teleports you on your World");
|
||||
defaultCmdHelp.add("/ws sethome §8- §7Sets a specific home");
|
||||
|
@ -81,8 +81,7 @@ public class CommandListener implements Listener {
|
||||
if (!wp.canChangeGamemode() && !wp.isOwnerofWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoPermission());
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (cmd.startsWith("/tp") || cmd.startsWith("/teleport")) {
|
||||
String[] args = e.getMessage().split(" ");
|
||||
if (args.length == 2) {
|
||||
@ -106,8 +105,7 @@ public class CommandListener implements Listener {
|
||||
if (!wp.canTeleport()) {
|
||||
p.sendMessage(MessageConfig.getNoPermission());
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
if (!p.hasPermission("ws.tp.other")) {
|
||||
p.sendMessage(MessageConfig.getNoPermission());
|
||||
@ -127,8 +125,7 @@ public class CommandListener implements Listener {
|
||||
if (!wp.canTeleport()) {
|
||||
p.sendMessage(MessageConfig.getNoPermission());
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ public class AsyncCreatorAdapter implements CreatorAdapter {
|
||||
r.run();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ import org.bukkit.WorldCreator;
|
||||
*/
|
||||
public interface CreatorAdapter {
|
||||
|
||||
public void create(WorldCreator creator, SystemWorld world, Runnable sendPlayerMessageCallback);
|
||||
void create(WorldCreator creator, SystemWorld world, Runnable sendPlayerMessageCallback);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -331,7 +332,7 @@ public class Metrics {
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes("UTF-8"));
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user