From 82ede4530a0d873508ebc504d3f9d2f7cf076afa Mon Sep 17 00:00:00 2001 From: DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com> Date: Sat, 5 Jan 2019 20:42:09 +0200 Subject: [PATCH] Lots of little fixes in the Essentials modules (#2337) @DoNotSpamPls Look at changed files for the changes --- .gitignore | 72 +++------ Essentials/pom.xml | 15 +- EssentialsAntiBuild/pom.xml | 7 - .../EssentialsAntiBuildListener.java | 11 +- .../antibuild/EssentialsConnect.java | 18 +-- EssentialsAntiBuild/src/plugin.yml | 2 +- EssentialsChat/pom.xml | 7 - .../earth2me/essentials/chat/ChatStore.java | 14 +- .../essentials/chat/EssentialsChat.java | 9 +- .../essentials/chat/EssentialsChatPlayer.java | 24 +-- .../EssentialsChatPlayerListenerHighest.java | 6 +- .../EssentialsChatPlayerListenerLowest.java | 6 +- .../EssentialsChatPlayerListenerNormal.java | 11 +- EssentialsChat/src/plugin.yml | 2 +- EssentialsGeoIP/pom.xml | 46 +++--- .../essentials/geoip/EssentialsGeoIP.java | 9 +- .../geoip/EssentialsGeoIPPlayerListener.java | 31 ++-- EssentialsGeoIP/src/config.yml | 4 +- EssentialsGeoIP/src/plugin.yml | 1 + EssentialsProtect/pom.xml | 7 - .../essentials/protect/EmergencyListener.java | 2 +- .../essentials/protect/EssentialsConnect.java | 10 +- .../essentials/protect/EssentialsProtect.java | 10 +- .../EssentialsProtectBlockListener.java | 6 +- .../EssentialsProtectEntityListener.java | 8 +- .../EssentialsProtectWeatherListener.java | 2 +- .../essentials/protect/ProtectConfig.java | 12 +- EssentialsProtect/src/plugin.yml | 2 +- EssentialsSpawn/pom.xml | 7 - .../essentials/spawn/Commandsetspawn.java | 2 +- .../essentials/spawn/EssentialsSpawn.java | 25 +-- .../spawn/EssentialsSpawnPlayerListener.java | 96 +++++------ .../essentials/spawn/IEssentialsSpawn.java | 4 +- .../essentials/spawn/SpawnStorage.java | 14 +- EssentialsSpawn/src/plugin.yml | 5 +- EssentialsXMPP/pom.xml | 49 +++--- .../essentials/xmpp/EssentialsXMPP.java | 14 +- .../xmpp/EssentialsXMPPPlayerListener.java | 26 +-- .../earth2me/essentials/xmpp/UserManager.java | 20 +-- .../earth2me/essentials/xmpp/XMPPManager.java | 115 +++++++------- EssentialsXMPP/src/config.yml | 4 +- EssentialsXMPP/src/plugin.yml | 12 +- examples/bpermissions.yml | 134 ---------------- examples/permissionsbukkit.yml | 133 ---------------- examples/permissionsex.yml | 150 ------------------ nms/1_8_R1Provider/README.md | 1 - nms/1_8_R1Provider/pom.xml | 8 - nms/1_8_R2Provider/README.md | 1 - nms/1_8_R2Provider/pom.xml | 8 - .../nms/legacy/LegacyPotionMetaProvider.java | 1 + .../nms/legacy/LegacySpawnEggProvider.java | 2 +- .../nms/legacy/LegacySpawnerProvider.java | 1 + .../src/net/ess3/nms/SpawnerProvider.java | 3 +- .../net/ess3/providers/ProviderFactory.java | 2 +- .../src/net/ess3/nms/refl/ReflUtil.java | 14 +- .../src/net/ess3/nms/refl/SpawnEggRefl.java | 16 +- .../net/ess3/nms/refl/NMSVersionTest.java | 6 +- pom.xml | 13 +- 58 files changed, 316 insertions(+), 924 deletions(-) delete mode 100644 examples/bpermissions.yml delete mode 100644 examples/permissionsbukkit.yml delete mode 100644 examples/permissionsex.yml delete mode 100644 nms/1_8_R1Provider/README.md delete mode 100644 nms/1_8_R2Provider/README.md diff --git a/.gitignore b/.gitignore index 105229ecc..5cb07e59b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,54 +1,18 @@ -.DS_Store -/BuildAll/nbproject/private/ -/EssentialsProtect/nbproject/private/ -/EssentialsChat/nbproject/private/ -/EssentialsGroupBridge/nbproject/private/ -/EssentialsGeoIP/nbproject/private/ -/EssentialsSpawn/nbproject/private/ -/EssentialsXMPP/nbproject/private/ -/BuildAll/build/ -/EssentialsGroupBridge/dist/ -/EssentialsGroupBridge/build/ -/EssentialsGeoIP/dist/ -/EssentialsGeoIP/build/ -/BuildAll/dist/ -/EssentialsChat/build/ -/EssentialsChat/dist/ -/EssentialsSpawn/build/ -/EssentialsSpawn/dist/ -/EssentialsXMPP/dist/ -/EssentialsXMPP/build/ -/EssentialsProtect/dist/ -/EssentialsProtect/build/ -/EssentialsPermissionsCommands/nbproject/private/ -/EssentialsPermissionsCommands/build/ -/EssentialsPermissionsCommands/dist/ -/Essentials/nbproject/private/ -/Essentials/dist/ -/Essentials/build/ -/YamlAnnotations/ -/EssentialsUpdate/nbproject/private/ -/EssentialsRelease/ -/EssentialsUpdate/dist/ -/EssentialsUpdate/build/ -/WebPush/apikey.php -/WebPush/nbproject/private -/EssentialsAntiBuild/nbproject/private/ -/EssentialsAntiBuild/dist/ -/EssentialsAntiBuild/build/ -/jars -/out -.idea/ -.buildtools/ -*.iml -*.classpath -*.project -*.settings/ -target/ -dependency-reduced-pom.xml -/Essentials/config.yml -/Essentials/kits.yml -/Essentials/userdata/testplayer1.yml -/Essentials/usermap.csv -/Essentials/userdata -/EssentialsGroupManager/target/ +# IDE files +*.classpath +*.project +*.settings/ +.idea/ +*.iml +.DS_Store + +# Essentials files +/Essentials/userdata +/Essentials/config.yml +/Essentials/kits.yml +/Essentials/userdata/testplayer1.yml +/Essentials/usermap.csv + +# Build files +target/ +jars/ \ No newline at end of file diff --git a/Essentials/pom.xml b/Essentials/pom.xml index 773c74283..055298cd2 100644 --- a/Essentials/pom.xml +++ b/Essentials/pom.xml @@ -11,20 +11,13 @@ EssentialsX - - - GPLv3 - http://www.gnu.org/copyleft/gpl.html - - - EssentialsX-${full.version} org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.8.0 false @@ -32,7 +25,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.2.1 package @@ -41,6 +34,9 @@ + + false + @@ -113,6 +109,7 @@ compile + vault-repo diff --git a/EssentialsAntiBuild/pom.xml b/EssentialsAntiBuild/pom.xml index 83a3e3155..dbc800b09 100644 --- a/EssentialsAntiBuild/pom.xml +++ b/EssentialsAntiBuild/pom.xml @@ -11,13 +11,6 @@ EssentialsXAntiBuild - - - GPLv3 - http://www.gnu.org/copyleft/gpl.html - - - EssentialsXAntiBuild-${full.version} diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java index 7284789bc..a9cff948f 100644 --- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java +++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java @@ -22,15 +22,18 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import java.util.logging.Level; +import java.util.logging.Logger; + import static com.earth2me.essentials.I18n.tl; public class EssentialsAntiBuildListener implements Listener { + private static final Logger logger = Logger.getLogger("EssentialsAntiBuild"); final private transient IAntiBuild prot; final private transient IEssentials ess; - public EssentialsAntiBuildListener(final IAntiBuild parent) { + EssentialsAntiBuildListener(final IAntiBuild parent) { this.prot = parent; this.ess = prot.getEssentialsConnect().getEssentials(); @@ -53,14 +56,14 @@ public class EssentialsAntiBuildListener implements Listener { private boolean metaPermCheck(final User user, final String action, final Block block) { if (block == null) { if (ess.getSettings().isDebug()) { - ess.getLogger().log(Level.INFO, "AntiBuild permission check failed, invalid block."); + logger.log(Level.INFO, "AntiBuild permission check failed, invalid block."); } return false; } return metaPermCheck(user, action, block.getType(), block.getData()); } - private boolean metaPermCheck(final User user, final String action, final Material material) { + public boolean metaPermCheck(final User user, final String action, final Material material) { final String blockPerm = "essentials.build." + action + "." + material; return user.isAuthorized(blockPerm); } @@ -74,7 +77,7 @@ public class EssentialsAntiBuildListener implements Listener { return user.isAuthorized(dataPerm); } else { if (ess.getSettings().isDebug()) { - ess.getLogger().log(Level.INFO, "DataValue perm on " + user.getName() + " is not directly set: " + dataPerm); + logger.log(Level.INFO, "DataValue perm on " + user.getName() + " is not directly set: " + dataPerm); } } } diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsConnect.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsConnect.java index c2a8f7a2d..41de89449 100644 --- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsConnect.java +++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsConnect.java @@ -13,14 +13,14 @@ import java.util.logging.Logger; import static com.earth2me.essentials.I18n.tl; -public class EssentialsConnect { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); +class EssentialsConnect { + private static final Logger logger = Logger.getLogger("EssentialsAntiBuild"); private final transient IEssentials ess; private final transient IAntiBuild protect; - public EssentialsConnect(Plugin essPlugin, Plugin essProtect) { + EssentialsConnect(Plugin essPlugin, Plugin essProtect) { if (!essProtect.getDescription().getVersion().equals(essPlugin.getDescription().getVersion())) { - LOGGER.log(Level.WARNING, tl("versionMismatchAll")); + logger.log(Level.WARNING, tl("versionMismatchAll")); } ess = (IEssentials) essPlugin; protect = (IAntiBuild) essProtect; @@ -29,17 +29,14 @@ public class EssentialsConnect { ess.addReloadListener(pr); } - public void onDisable() { - } - - public IEssentials getEssentials() { + IEssentials getEssentials() { return ess; } - public void alert(final User user, final String item, final String type) { + void alert(final User user, final String item, final String type) { final Location loc = user.getLocation(); final String warnMessage = tl("alertFormat", user.getName(), type, item, loc.getWorld().getName() + "," + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ()); - LOGGER.log(Level.WARNING, warnMessage); + logger.log(Level.WARNING, warnMessage); for (Player p : ess.getServer().getOnlinePlayers()) { final User alertUser = ess.getUser(p); if (alertUser.isAuthorized("essentials.protect.alerts")) { @@ -48,7 +45,6 @@ public class EssentialsConnect { } } - private class AntiBuildReloader implements IConf { @Override public void reloadConfig() { diff --git a/EssentialsAntiBuild/src/plugin.yml b/EssentialsAntiBuild/src/plugin.yml index 15c1fe515..7ab7b3f01 100644 --- a/EssentialsAntiBuild/src/plugin.yml +++ b/EssentialsAntiBuild/src/plugin.yml @@ -6,5 +6,5 @@ version: ${full.version} website: http://tiny.cc/EssentialsCommands description: Provides build protection. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Iaccidentally] -api-version: 1.13 depend: [Essentials] +api-version: 1.13 diff --git a/EssentialsChat/pom.xml b/EssentialsChat/pom.xml index 755e66982..83a298ef4 100644 --- a/EssentialsChat/pom.xml +++ b/EssentialsChat/pom.xml @@ -11,13 +11,6 @@ EssentialsXChat - - - GPLv3 - http://www.gnu.org/copyleft/gpl.html - - - EssentialsXChat-${full.version} diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java b/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java index d82cbb63f..b1bab89f1 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/ChatStore.java @@ -5,7 +5,7 @@ import com.earth2me.essentials.User; import net.ess3.api.IEssentials; -public class ChatStore { +class ChatStore { private final User user; private final String type; private final Trade charge; @@ -17,27 +17,27 @@ public class ChatStore { this.charge = new Trade(getLongType(), ess); } - public User getUser() { + User getUser() { return user; } - public Trade getCharge() { + Trade getCharge() { return charge; } - public String getType() { + String getType() { return type; } - public final String getLongType() { + final String getLongType() { return type.length() == 0 ? "chat" : "chat-" + type; } - public long getRadius() { + long getRadius() { return radius; } - public void setRadius(long radius) { + void setRadius(long radius) { this.radius = radius; } } diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java index f2963064f..d9c273941 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java @@ -10,13 +10,12 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; -import java.util.logging.Logger; import static com.earth2me.essentials.I18n.tl; public class EssentialsChat extends JavaPlugin { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private transient Metrics metrics = null; @Override @@ -24,14 +23,14 @@ public class EssentialsChat extends JavaPlugin { final PluginManager pluginManager = getServer().getPluginManager(); final IEssentials ess = (IEssentials) pluginManager.getPlugin("Essentials"); if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) { - LOGGER.log(Level.WARNING, tl("versionMismatchAll")); + getLogger().log(Level.WARNING, tl("versionMismatchAll")); } if (!ess.isEnabled()) { this.setEnabled(false); return; } - final Map chatStore = Collections.synchronizedMap(new HashMap()); + final Map chatStore = Collections.synchronizedMap(new HashMap<>()); final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatStore); final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatStore); @@ -43,6 +42,6 @@ public class EssentialsChat extends JavaPlugin { if (metrics == null) { metrics = new Metrics(this); } - } + } diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java index 2526e8b60..38cf0e811 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java @@ -13,12 +13,12 @@ import java.util.logging.Logger; public abstract class EssentialsChatPlayer implements Listener { - protected static final Logger logger = Logger.getLogger("Minecraft"); - protected transient IEssentials ess; - protected final transient Server server; - protected final transient Map chatStorage; + static final Logger logger = Logger.getLogger("EssentialsChat"); + transient IEssentials ess; + final transient Server server; + private final transient Map chatStorage; - public EssentialsChatPlayer(final Server server, final IEssentials ess, final Map chatStorage) { + EssentialsChatPlayer(final Server server, final IEssentials ess, final Map chatStorage) { this.ess = ess; this.server = server; this.chatStorage = chatStorage; @@ -26,11 +26,11 @@ public abstract class EssentialsChatPlayer implements Listener { public abstract void onPlayerChat(final AsyncPlayerChatEvent event); - public boolean isAborted(final AsyncPlayerChatEvent event) { + boolean isAborted(final AsyncPlayerChatEvent event) { return event.isCancelled(); } - public String getChatType(final String message) { + String getChatType(final String message) { if (message.length() == 0) { //Ignore empty chat events generated by plugins return ""; @@ -46,23 +46,23 @@ public abstract class EssentialsChatPlayer implements Listener { } } - public ChatStore getChatStore(final AsyncPlayerChatEvent event) { + ChatStore getChatStore(final AsyncPlayerChatEvent event) { return chatStorage.get(event); } - public void setChatStore(final AsyncPlayerChatEvent event, final ChatStore chatStore) { + void setChatStore(final AsyncPlayerChatEvent event, final ChatStore chatStore) { chatStorage.put(event, chatStore); } - public ChatStore delChatStore(final AsyncPlayerChatEvent event) { + ChatStore delChatStore(final AsyncPlayerChatEvent event) { return chatStorage.remove(event); } - protected void charge(final User user, final Trade charge) throws ChargeException { + private void charge(final User user, final Trade charge) throws ChargeException { charge.charge(user); } - protected boolean charge(final AsyncPlayerChatEvent event, final ChatStore chatStore) { + boolean charge(final AsyncPlayerChatEvent event, final ChatStore chatStore) { try { charge(chatStore.getUser(), chatStore.getCharge()); } catch (ChargeException e) { diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java index ce62c2bc3..65845e560 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java @@ -10,7 +10,7 @@ import java.util.Map; public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer { - public EssentialsChatPlayerListenerHighest(final Server server, final IEssentials ess, final Map chatStorage) { + EssentialsChatPlayerListenerHighest(final Server server, final IEssentials ess, final Map chatStorage) { super(server, ess, chatStorage); } @@ -22,9 +22,7 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer { return; } - /** - * This file should handle charging the user for the action before returning control back - */ + // This file should handle charging the user for the action before returning control back charge(event, chatStore); } } diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java index 95284e5c9..1969315c0 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java @@ -15,7 +15,7 @@ import java.util.Map; public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer { - public EssentialsChatPlayerListenerLowest(final Server server, final IEssentials ess, final Map chatStorage) { + EssentialsChatPlayerListenerLowest(final Server server, final IEssentials ess, final Map chatStorage) { super(server, ess, chatStorage); } @@ -36,9 +36,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer { final ChatStore chatStore = new ChatStore(ess, user, getChatType(event.getMessage())); setChatStore(event, chatStore); - /** - * This listener should apply the general chat formatting only...then return control back the event handler - */ + // This listener should apply the general chat formatting only...then return control back the event handler event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage())); String group = user.getGroup(); String world = user.getWorld().getName(); diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java index f493f7106..3157701a6 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java @@ -18,7 +18,7 @@ import static com.earth2me.essentials.I18n.tl; public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer { - public EssentialsChatPlayerListenerNormal(final Server server, final IEssentials ess, final Map chatStorage) { + EssentialsChatPlayerListenerNormal(final Server server, final IEssentials ess, final Map chatStorage) { super(server, ess, chatStorage); } @@ -29,10 +29,7 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer { return; } - /** - * This file should handle detection of the local chat features... if local chat is enabled, we need to handle - * it here - */ + // This file should handle detection of the local chat features; if local chat is enabled, we need to handle it here long radius = ess.getSettings().getChatRadius(); if (radius < 1) { return; @@ -66,13 +63,13 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer { } Set outList = event.getRecipients(); - Set spyList = new HashSet(); + Set spyList = new HashSet<>(); try { outList.add(event.getPlayer()); } catch (UnsupportedOperationException ex) { if (ess.getSettings().isDebug()) { - ess.getLogger().log(Level.INFO, "Plugin triggered custom chat event, local chat handling aborted.", ex); + logger.log(Level.INFO, "Plugin triggered custom chat event, local chat handling aborted.", ex); } return; } diff --git a/EssentialsChat/src/plugin.yml b/EssentialsChat/src/plugin.yml index 5f855228b..827e5e218 100644 --- a/EssentialsChat/src/plugin.yml +++ b/EssentialsChat/src/plugin.yml @@ -7,4 +7,4 @@ website: http://tiny.cc/EssentialsCommands description: Provides chat control features for Essentials. Requires Permissions. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy, Iaccidentally] depend: [Essentials] -#softdepend: [Factions] +api-version: 1.13 diff --git a/EssentialsGeoIP/pom.xml b/EssentialsGeoIP/pom.xml index 1d01b2dee..71a539982 100644 --- a/EssentialsGeoIP/pom.xml +++ b/EssentialsGeoIP/pom.xml @@ -11,38 +11,13 @@ EssentialsXGeoIP - - - GPLv3 - http://www.gnu.org/copyleft/gpl.html - - - - - - net.ess3 - EssentialsX - ${project.version} - - - com.maxmind.geoip2 - geoip2 - 0.7.2 - - - javatar - javatar - 2.5 - - - EssentialsXGeoIP-${full.version} org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.2.1 package @@ -52,6 +27,7 @@ + false true @@ -65,4 +41,22 @@ + + + + net.ess3 + EssentialsX + ${project.version} + + + com.maxmind.geoip2 + geoip2 + 2.12.0 + + + javatar + javatar + 2.5 + + \ No newline at end of file diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java index 9460d3a04..89c599e6f 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIP.java @@ -11,15 +11,9 @@ import static com.earth2me.essentials.I18n.tl; public class EssentialsGeoIP extends JavaPlugin { + private transient Metrics metrics = null; - public EssentialsGeoIP() { - } - - @Override - public void onDisable() { - } - @Override public void onEnable() { final PluginManager pm = getServer().getPluginManager(); @@ -41,4 +35,5 @@ public class EssentialsGeoIP extends JavaPlugin { metrics = new Metrics(this); } } + } diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java index 8bb2649a5..9e64aaf57 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java @@ -20,11 +20,10 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.logging.Level; -import java.util.logging.Logger; import java.util.Date; +import java.util.logging.Logger; import java.util.zip.GZIPInputStream; import java.util.Arrays; -import java.util.List; import com.ice.tar.TarInputStream; import com.ice.tar.TarEntry; @@ -32,14 +31,14 @@ import static com.earth2me.essentials.I18n.tl; public class EssentialsGeoIPPlayerListener implements Listener, IConf { - DatabaseReader mmreader = null; // initialize maxmind geoip2 reader - private static final Logger logger = Logger.getLogger("Minecraft"); - File databaseFile; - File dataFolder; - final EssentialsConf config; + private DatabaseReader mmreader = null; // initialize maxmind geoip2 reader + private static final Logger logger = Logger.getLogger("EssentialsGeoIP"); + private File databaseFile; + private File dataFolder; + private final EssentialsConf config; private final transient IEssentials ess; - public EssentialsGeoIPPlayerListener(File dataFolder, IEssentials ess) { + EssentialsGeoIPPlayerListener(File dataFolder, IEssentials ess) { this.ess = ess; this.dataFolder = dataFolder; this.config = new EssentialsConf(new File(dataFolder, "config.yml")); @@ -49,15 +48,10 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf { @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(final PlayerJoinEvent event) { - ess.runTaskAsynchronously(new Runnable() { - @Override - public void run() { - delayedJoin(event.getPlayer()); - } - }); + ess.runTaskAsynchronously(() -> delayedJoin(event.getPlayer())); } - public void delayedJoin(Player player) { + private void delayedJoin(Player player) { User u = ess.getUser(player); if (u.isAuthorized("essentials.geoip.hide") || player.getAddress() == null) { return; @@ -114,8 +108,8 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf { // detect and update the old config.yml. migrate from legacy GeoIP to GeoIP2. if (!config.isSet("enable-locale")) { - config.set("database.download-url", "http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz"); - config.set("database.download-url-city", "http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz"); + config.set("database.download-url", "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz"); + config.set("database.download-url-city", "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz"); config.set("database.update.enable", true); config.set("database.update.by-every-x-days", 30); config.set("enable-locale", true); @@ -187,7 +181,7 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf { String filename; TarInputStream tarInputStream = new TarInputStream(input); TarEntry entry; - while ((entry = (TarEntry) tarInputStream.getNextEntry()) != null) { + while ((entry = tarInputStream.getNextEntry()) != null) { if (!entry.isDirectory()) { filename = entry.getName(); if (filename.substring(filename.length() - 5).equalsIgnoreCase(".mmdb")) { @@ -207,7 +201,6 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf { input.close(); } catch (MalformedURLException ex) { logger.log(Level.SEVERE, tl("geoIpUrlInvalid"), ex); - return; } catch (IOException ex) { logger.log(Level.SEVERE, tl("connectionFailed"), ex); } diff --git a/EssentialsGeoIP/src/config.yml b/EssentialsGeoIP/src/config.yml index be2872b65..5cae35de0 100644 --- a/EssentialsGeoIP/src/config.yml +++ b/EssentialsGeoIP/src/config.yml @@ -2,9 +2,9 @@ database: show-cities: false download-if-missing: true # Url for country - download-url: "http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz" + download-url: "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz" # Url for cities - download-url-city: "http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz" + download-url-city: "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz" update: enable: true by-every-x-days: 30 diff --git a/EssentialsGeoIP/src/plugin.yml b/EssentialsGeoIP/src/plugin.yml index 2976c2996..3b54fec15 100644 --- a/EssentialsGeoIP/src/plugin.yml +++ b/EssentialsGeoIP/src/plugin.yml @@ -7,3 +7,4 @@ website: http://tiny.cc/EssentialsCommands description: Shows the country or city of a user on login and /whois. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, kjiang] depend: [Essentials] +api-version: 1.13 diff --git a/EssentialsProtect/pom.xml b/EssentialsProtect/pom.xml index bf9879087..69321e79a 100644 --- a/EssentialsProtect/pom.xml +++ b/EssentialsProtect/pom.xml @@ -11,13 +11,6 @@ EssentialsXProtect - - - GPLv3 - http://www.gnu.org/copyleft/gpl.html - - - EssentialsXProtect-${full.version} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java index 7a9f2bba8..bfd1886c2 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java @@ -14,7 +14,7 @@ import org.bukkit.event.server.PluginEnableEvent; public class EmergencyListener implements Listener { - EssentialsProtect plugin; + private EssentialsProtect plugin; EmergencyListener(final EssentialsProtect essProtPlugin) { plugin = essProtPlugin; diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java index 2c827a171..d24221ced 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java @@ -10,14 +10,14 @@ import java.util.logging.Logger; import static com.earth2me.essentials.I18n.tl; -public class EssentialsConnect { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); +class EssentialsConnect { + private static final Logger logger = Logger.getLogger("EssentialsProtect"); private final IEssentials ess; private final IProtect protect; - public EssentialsConnect(Plugin essPlugin, Plugin essProtect) { + EssentialsConnect(Plugin essPlugin, Plugin essProtect) { if (!essProtect.getDescription().getVersion().equals(essPlugin.getDescription().getVersion())) { - LOGGER.log(Level.WARNING, tl("versionMismatchAll")); + logger.log(Level.WARNING, tl("versionMismatchAll")); } ess = (IEssentials) essPlugin; protect = (IProtect) essProtect; @@ -26,7 +26,7 @@ public class EssentialsConnect { ess.addReloadListener(pr); } - public IEssentials getEssentials() { + IEssentials getEssentials() { return ess; } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index 56c1d3186..ea7d729ed 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -12,11 +12,9 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; import java.util.logging.Level; -import java.util.logging.Logger; public class EssentialsProtect extends JavaPlugin implements IProtect { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); private final Map settingsBoolean = new EnumMap<>(ProtectConfig.class); private final Map settingsString = new EnumMap<>(ProtectConfig.class); private final Map> settingsList = new EnumMap<>(ProtectConfig.class); @@ -42,7 +40,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect { } private void initialize(final PluginManager pm, final Plugin essPlugin) { - LOGGER.log(Level.INFO, "Continuing to enable Protect."); + getLogger().log(Level.INFO, "Continuing to enable Protect."); ess = new EssentialsConnect(essPlugin, this); final EssentialsProtectBlockListener blockListener = new EssentialsProtectBlockListener(this); @@ -61,14 +59,14 @@ public class EssentialsProtect extends JavaPlugin implements IProtect { for (Player player : getServer().getOnlinePlayers()) { player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors."); } - LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essentials Protect is in emergency mode now."); + getLogger().log(Level.SEVERE, "Essentials not installed or failed to load. Essentials Protect is in emergency mode now."); } void disableEmergencyMode() { final PluginManager pm = this.getServer().getPluginManager(); final Plugin essPlugin = pm.getPlugin("Essentials"); if (essPlugin == null || !essPlugin.isEnabled()) { - LOGGER.log(Level.SEVERE, "Tried to disable emergency mode, but Essentials still isn't enabled!"); + getLogger().log(Level.SEVERE, "Tried to disable emergency mode, but Essentials still isn't enabled!"); return; } @@ -77,7 +75,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect { for (Player player : getServer().getOnlinePlayers()) { player.sendMessage("Essentials Protect is no longer in emergency mode."); } - LOGGER.log(Level.SEVERE, "Essentials was loaded late! Essentials Protect is no longer in emergency mode."); + getLogger().log(Level.SEVERE, "Essentials was loaded late! Essentials Protect is no longer in emergency mode."); initialize(pm, essPlugin); } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java index 0129ec3e0..5f20a58f6 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -1,7 +1,7 @@ package com.earth2me.essentials.protect; import com.earth2me.essentials.utils.EnumUtil; -import net.ess3.api.IEssentials; + import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -22,11 +22,9 @@ public class EssentialsProtectBlockListener implements Listener { private static final Set LAVA_TYPES = EnumUtil.getAllMatching(Material.class, "LAVA", "STATIONARY_LAVA"); final private IProtect prot; - final private IEssentials ess; - public EssentialsProtectBlockListener(final IProtect parent) { + EssentialsProtectBlockListener(final IProtect parent) { this.prot = parent; - this.ess = prot.getEssentialsConnect().getEssentials(); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java index b0cc4fd57..6081657a4 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java @@ -20,7 +20,7 @@ public class EssentialsProtectEntityListener implements Listener { private final IProtect prot; private final IEssentials ess; - public EssentialsProtectEntityListener(final IProtect prot) { + EssentialsProtectEntityListener(final IProtect prot) { this.prot = prot; this.ess = prot.getEssentialsConnect().getEssentials(); } @@ -159,7 +159,7 @@ public class EssentialsProtectEntityListener implements Listener { } else if (entity instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_explosion)) { event.setCancelled(true); - } else if ((entity instanceof Fireball || entity instanceof SmallFireball) && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion)) { + } else if (entity instanceof Fireball && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion)) { event.setCancelled(true); } else if ((entity instanceof WitherSkull) && prot.getSettingBool(ProtectConfig.prevent_witherskull_explosion)) { @@ -180,7 +180,7 @@ public class EssentialsProtectEntityListener implements Listener { return; } final String creatureName = creature.toString().toLowerCase(Locale.ENGLISH); - if (creatureName == null || creatureName.isEmpty()) { + if (creatureName.isEmpty()) { return; } if (ess.getSettings().getProtectPreventSpawn(creatureName)) { @@ -194,7 +194,7 @@ public class EssentialsProtectEntityListener implements Listener { return; } final User user = ess.getUser((Player) event.getTarget()); - if ((event.getReason() == TargetReason.CLOSEST_PLAYER || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET || event.getReason() == TargetReason.RANDOM_TARGET || event.getReason() == TargetReason.DEFEND_VILLAGE || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET) && prot.getSettingBool(ProtectConfig.prevent_entitytarget) && !user.isAuthorized("essentials.protect.entitytarget.bypass")) { + if ((event.getReason() == TargetReason.CLOSEST_PLAYER || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY || event.getReason() == TargetReason.TARGET_ATTACKED_NEARBY_ENTITY || event.getReason() == TargetReason.RANDOM_TARGET || event.getReason() == TargetReason.DEFEND_VILLAGE || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET) && prot.getSettingBool(ProtectConfig.prevent_entitytarget) && !user.isAuthorized("essentials.protect.entitytarget.bypass")) { event.setCancelled(true); } } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java index 00b135065..ba11ac3b2 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java @@ -11,7 +11,7 @@ import org.bukkit.event.weather.WeatherChangeEvent; public class EssentialsProtectWeatherListener implements Listener { private final IProtect prot; - public EssentialsProtectWeatherListener(final IProtect prot) { + EssentialsProtectWeatherListener(final IProtect prot) { this.prot = prot; } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java index 4c99624a0..3d8e06cd7 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java @@ -49,19 +49,11 @@ public enum ProtectConfig { private final boolean isList; private final boolean isString; - private ProtectConfig(final String configName) { - this(configName, null, false, true, false); - } - - private ProtectConfig(final String configName, final String defValueString) { - this(configName, defValueString, false, false, true); - } - - private ProtectConfig(final String configName, final boolean defValueBoolean) { + ProtectConfig(final String configName, final boolean defValueBoolean) { this(configName, null, defValueBoolean, false, false); } - private ProtectConfig(final String configName, final String defValueString, final boolean defValueBoolean, final boolean isList, final boolean isString) { + ProtectConfig(final String configName, final String defValueString, final boolean defValueBoolean, final boolean isList, final boolean isString) { this.configName = configName; this.defValueString = defValueString; this.defValueBoolean = defValueBoolean; diff --git a/EssentialsProtect/src/plugin.yml b/EssentialsProtect/src/plugin.yml index a286db353..050af7d08 100644 --- a/EssentialsProtect/src/plugin.yml +++ b/EssentialsProtect/src/plugin.yml @@ -6,5 +6,5 @@ version: ${full.version} website: http://tiny.cc/EssentialsCommands description: Provides protection for various parts of the world. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] -api-version: 1.13 softdepend: [Essentials] +api-version: 1.13 diff --git a/EssentialsSpawn/pom.xml b/EssentialsSpawn/pom.xml index 3a2213e9c..f32b8eace 100644 --- a/EssentialsSpawn/pom.xml +++ b/EssentialsSpawn/pom.xml @@ -11,13 +11,6 @@ EssentialsXSpawn - - - GPLv3 - http://www.gnu.org/copyleft/gpl.html - - - EssentialsXSpawn-${full.version} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java index da4593ded..c0d876f83 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java @@ -13,7 +13,7 @@ public class Commandsetspawn extends EssentialsCommand { } @Override - public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { + public void run(final Server server, final User user, final String commandLabel, final String[] args) { final String group = args.length > 0 ? getFinalArg(args, 0) : "default"; ((SpawnStorage) module).setSpawn(user.getLocation(), group); user.sendMessage(tl("spawnSet", group)); diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java index a0b3d4334..e37500e2d 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java @@ -2,28 +2,21 @@ package com.earth2me.essentials.spawn; import com.earth2me.essentials.metrics.Metrics; import net.ess3.api.IEssentials; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.bukkit.event.Event; -import org.bukkit.event.EventException; import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import java.util.logging.Level; -import java.util.logging.Logger; import static com.earth2me.essentials.I18n.tl; public class EssentialsSpawn extends JavaPlugin implements IEssentialsSpawn { - private static final Logger LOGGER = Bukkit.getLogger(); private transient IEssentials ess; private transient SpawnStorage spawns; private transient Metrics metrics = null; @@ -33,7 +26,7 @@ public class EssentialsSpawn extends JavaPlugin implements IEssentialsSpawn { final PluginManager pluginManager = getServer().getPluginManager(); ess = (IEssentials) pluginManager.getPlugin("Essentials"); if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) { - LOGGER.log(Level.WARNING, tl("versionMismatchAll")); + getLogger().log(Level.WARNING, tl("versionMismatchAll")); } if (!ess.isEnabled()) { this.setEnabled(false); @@ -47,22 +40,14 @@ public class EssentialsSpawn extends JavaPlugin implements IEssentialsSpawn { EventPriority respawnPriority = ess.getSettings().getRespawnPriority(); if (respawnPriority != null) { - pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, new EventExecutor() { - @Override - public void execute(final Listener ll, final Event event) throws EventException { - ((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event); - } - }, this); + pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, (ll, event) -> + ((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event), this); } EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority(); if (joinPriority != null) { - pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, new EventExecutor() { - @Override - public void execute(final Listener ll, final Event event) throws EventException { - ((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event); - } - }, this); + pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, (ll, event) -> + ((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event), this); } if (metrics == null) { diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index 6a2cb3a24..d4e787f6b 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -7,7 +7,6 @@ import com.earth2me.essentials.textreader.IText; import com.earth2me.essentials.textreader.KeywordReplacer; import com.earth2me.essentials.textreader.SimpleTextPager; import net.ess3.api.IEssentials; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -23,18 +22,18 @@ import java.util.logging.Logger; import static com.earth2me.essentials.I18n.tl; -public class EssentialsSpawnPlayerListener implements Listener { - private static final Logger LOGGER = Bukkit.getLogger(); +class EssentialsSpawnPlayerListener implements Listener { + private static final Logger logger = Logger.getLogger("EssentialsSpawn"); private final transient IEssentials ess; private final transient SpawnStorage spawns; - public EssentialsSpawnPlayerListener(final IEssentials ess, final SpawnStorage spawns) { + EssentialsSpawnPlayerListener(final IEssentials ess, final SpawnStorage spawns) { super(); this.ess = ess; this.spawns = spawns; } - public void onPlayerRespawn(final PlayerRespawnEvent event) { + void onPlayerRespawn(final PlayerRespawnEvent event) { final User user = ess.getUser(event.getPlayer()); if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) { @@ -60,33 +59,25 @@ public class EssentialsSpawnPlayerListener implements Listener { } } - public void onPlayerJoin(final PlayerJoinEvent event) { - ess.runTaskAsynchronously(new Runnable() { - @Override - public void run() { - delayedJoin(event.getPlayer()); - } - }); + void onPlayerJoin(final PlayerJoinEvent event) { + ess.runTaskAsynchronously(() -> delayedJoin(event.getPlayer())); } - public void delayedJoin(final Player player) { + private void delayedJoin(final Player player) { if (player.hasPlayedBefore()) { - LOGGER.log(Level.FINE, "Old player join"); + logger.log(Level.FINE, "Old player join"); List spawnOnJoinGroups = ess.getSettings().getSpawnOnJoinGroups(); if (!spawnOnJoinGroups.isEmpty()) { final User user = ess.getUser(player); if (ess.getSettings().isUserInSpawnOnJoinGroup(user) && !user.isAuthorized("essentials.spawn-on-join.exempt")) { - ess.scheduleSyncDelayedTask(new Runnable() { - @Override - public void run() { - Location spawn = spawns.getSpawn(user.getGroup()); - try { - // We don't use user.getTeleport() because it stores last location, which is unwanted in this case. - user.getBase().teleport(spawn, TeleportCause.PLUGIN); - } catch (Exception e) { - ess.showError(user.getSource(), e, "spawn-on-join"); - } + ess.scheduleSyncDelayedTask(() -> { + Location spawn = spawns.getSpawn(user.getGroup()); + try { + // We don't use user.getTeleport() because it stores last location, which is unwanted in this case. + user.getBase().teleport(spawn, TeleportCause.PLUGIN); + } catch (Exception e) { + ess.showError(user.getSource(), e, "spawn-on-join"); } }); } @@ -101,35 +92,32 @@ public class EssentialsSpawnPlayerListener implements Listener { ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L); } - ess.scheduleSyncDelayedTask(new Runnable() { - @Override - public void run() { - if (!user.getBase().isOnline()) { - return; - } - - //This method allows for multiple line player announce messages using multiline yaml syntax #EasterEgg - if (ess.getSettings().getAnnounceNewPlayers()) { - final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user.getSource(), ess); - final SimpleTextPager pager = new SimpleTextPager(output); - - for (String line : pager.getLines()) { - ess.broadcastMessage(user, line); - } - } - - final String kitName = ess.getSettings().getNewPlayerKit(); - if (!kitName.isEmpty()) { - try { - final Kit kit = new Kit(kitName.toLowerCase(Locale.ENGLISH), ess); - kit.expandItems(user); - } catch (Exception ex) { - LOGGER.log(Level.WARNING, ex.getMessage()); - } - } - - LOGGER.log(Level.FINE, "New player join"); + ess.scheduleSyncDelayedTask(() -> { + if (!user.getBase().isOnline()) { + return; } + + //This method allows for multiple line player announce messages using multiline yaml syntax #EasterEgg + if (ess.getSettings().getAnnounceNewPlayers()) { + final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user.getSource(), ess); + final SimpleTextPager pager = new SimpleTextPager(output); + + for (String line : pager.getLines()) { + ess.broadcastMessage(user, line); + } + } + + final String kitName = ess.getSettings().getNewPlayerKit(); + if (!kitName.isEmpty()) { + try { + final Kit kit = new Kit(kitName.toLowerCase(Locale.ENGLISH), ess); + kit.expandItems(user); + } catch (Exception ex) { + logger.log(Level.WARNING, ex.getMessage()); + } + } + + logger.log(Level.FINE, "New player join"); }, 2L); } @@ -137,7 +125,7 @@ public class EssentialsSpawnPlayerListener implements Listener { private class NewPlayerTeleport implements Runnable { private final transient User user; - public NewPlayerTeleport(final User user) { + NewPlayerTeleport(final User user) { this.user = user; } @@ -153,7 +141,7 @@ public class EssentialsSpawnPlayerListener implements Listener { user.getTeleport().now(spawn, false, TeleportCause.PLUGIN); } } catch (Exception ex) { - Bukkit.getLogger().log(Level.WARNING, tl("teleportNewPlayerError"), ex); + logger.log(Level.WARNING, tl("teleportNewPlayerError"), ex); } } } diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/IEssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/IEssentialsSpawn.java index 224d2672f..f71d48937 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/IEssentialsSpawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/IEssentialsSpawn.java @@ -14,7 +14,7 @@ public interface IEssentialsSpawn extends Plugin { * * @throws IllegalArgumentException If group is null */ - public void setSpawn(Location loc, String group); + void setSpawn(Location loc, String group); /** * Gets the spawn location for a given group. @@ -25,5 +25,5 @@ public interface IEssentialsSpawn extends Plugin { * * @throws IllegalArgumentException If group is null */ - public Location getSpawn(String group); + Location getSpawn(String group); } diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java index bc9a97fae..2c7f666b9 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java @@ -14,7 +14,7 @@ import java.util.Map; public class SpawnStorage extends AsyncStorageObjectHolder implements IEssentialsModule { - public SpawnStorage(final IEssentials ess) { + SpawnStorage(final IEssentials ess) { super(ess, Spawns.class); reloadConfig(); } @@ -25,18 +25,16 @@ public class SpawnStorage extends AsyncStorageObjectHolder implements IE } @Override - public void finishRead() { - } + public void finishRead() { } @Override - public void finishWrite() { - } + public void finishWrite() { } - public void setSpawn(final Location loc, final String group) { + void setSpawn(final Location loc, final String group) { acquireWriteLock(); try { if (getData().getSpawns() == null) { - getData().setSpawns(new HashMap()); + getData().setSpawns(new HashMap<>()); } getData().getSpawns().put(group.toLowerCase(Locale.ENGLISH), loc); } finally { @@ -48,7 +46,7 @@ public class SpawnStorage extends AsyncStorageObjectHolder implements IE } } - public Location getSpawn(final String group) { + Location getSpawn(final String group) { acquireReadLock(); try { if (getData().getSpawns() == null || group == null) { diff --git a/EssentialsSpawn/src/plugin.yml b/EssentialsSpawn/src/plugin.yml index 3e83aa950..3475d3ac2 100644 --- a/EssentialsSpawn/src/plugin.yml +++ b/EssentialsSpawn/src/plugin.yml @@ -7,13 +7,14 @@ website: http://tiny.cc/EssentialsCommands description: Provides spawn control commands, utilizing Essentials. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] depend: [Essentials] +api-version: 1.13 commands: setspawn: - description: Set the spawnpoint to your current position. + description: Sets the spawn point to your current position. usage: / aliases: [esetspawn] spawn: - description: Teleport to the spawnpoint. + description: Teleports to the spawn point. usage: / [player] aliases: [espawn] permissions: diff --git a/EssentialsXMPP/pom.xml b/EssentialsXMPP/pom.xml index 7fad0f27b..2a0da7ba6 100644 --- a/EssentialsXMPP/pom.xml +++ b/EssentialsXMPP/pom.xml @@ -11,12 +11,27 @@ EssentialsXXMPP - - - GPLv3 - http://www.gnu.org/copyleft/gpl.html - - + + EssentialsXXMPP-${full.version} + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + + + false + + + + @@ -32,26 +47,4 @@ compile - - - - - EssentialsXXMPP-${full.version} - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.0 - - - package - - shade - - - - - - - \ No newline at end of file diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java index 9a02042ca..bd142319f 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java @@ -12,20 +12,18 @@ import org.bukkit.plugin.java.JavaPlugin; import java.util.List; import java.util.Locale; import java.util.logging.Level; -import java.util.logging.Logger; import static com.earth2me.essentials.I18n.tl; public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static EssentialsXMPP instance = null; private transient UserManager users; private transient XMPPManager xmpp; private transient IEssentials ess; private transient Metrics metrics = null; - public static IEssentialsXMPP getInstance() { + static IEssentialsXMPP getInstance() { return instance; } @@ -36,7 +34,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP { final PluginManager pluginManager = getServer().getPluginManager(); ess = (IEssentials) pluginManager.getPlugin("Essentials"); if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) { - LOGGER.log(Level.WARNING, tl("versionMismatchAll")); + getLogger().log(Level.WARNING, tl("versionMismatchAll")); } if (!ess.isEnabled()) { this.setEnabled(false); @@ -111,10 +109,8 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP { return instance.xmpp.sendMessage(address, message); } - // @Override - public static boolean updatePresence() { + static void updatePresence() { instance.xmpp.updatePresence(); - return true; } @Override @@ -131,9 +127,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP { sendMessage(address, message); } } - } catch (Exception ex) { - // Ignore exceptions - } + } catch (Exception ignored) {} } @Override diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java index 06b603eb0..e832ed4fa 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java @@ -25,12 +25,7 @@ class EssentialsXMPPPlayerListener implements Listener { public void onPlayerJoin(final PlayerJoinEvent event) { final User user = ess.getUser(event.getPlayer()); - Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable() { - @Override - public void run() { - EssentialsXMPP.updatePresence(); - } - }); + Bukkit.getScheduler().scheduleSyncDelayedTask(ess, EssentialsXMPP::updatePresence); sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game"); } @@ -45,12 +40,7 @@ class EssentialsXMPPPlayerListener implements Listener { public void onPlayerQuit(final PlayerQuitEvent event) { final User user = ess.getUser(event.getPlayer()); - Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable() { - @Override - public void run() { - EssentialsXMPP.updatePresence(); - } - }); + Bukkit.getScheduler().scheduleSyncDelayedTask(ess, EssentialsXMPP::updatePresence); sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game"); @@ -61,17 +51,9 @@ class EssentialsXMPPPlayerListener implements Listener { List users = EssentialsXMPP.getInstance().getSpyUsers(); synchronized (users) { for (final String address : users) { - Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable() { - @Override - public void run() { - EssentialsXMPP.getInstance().sendMessage(address, message); - } - }); - + Bukkit.getScheduler().scheduleSyncDelayedTask(ess, () -> EssentialsXMPP.getInstance().sendMessage(address, message)); } } - } catch (Exception ex) { - // Ignore exceptions - } + } catch (Exception ignored) {} } } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java index 22aa398ce..736e7b507 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java @@ -9,48 +9,48 @@ import java.util.*; public class UserManager implements IConf { private final transient EssentialsConf users; - private final transient List spyusers = Collections.synchronizedList(new ArrayList()); + private final transient List spyusers = Collections.synchronizedList(new ArrayList<>()); private static final String ADDRESS = "address"; private static final String SPY = "spy"; - public UserManager(final File folder) { + UserManager(final File folder) { users = new EssentialsConf(new File(folder, "users.yml")); reloadConfig(); } - public final boolean isSpy(final String username) { + final boolean isSpy(final String username) { return users.getBoolean(username.toLowerCase(Locale.ENGLISH) + "." + SPY, false); } - public void setSpy(final String username, final boolean spy) { + void setSpy(final String username, final boolean spy) { setUser(username.toLowerCase(Locale.ENGLISH), getAddress(username), spy); } - public final String getAddress(final String username) { + final String getAddress(final String username) { return users.getString(username.toLowerCase(Locale.ENGLISH) + "." + ADDRESS, null); } - public final String getUserByAddress(final String search) { + final String getUserByAddress(final String search) { final Set usernames = users.getKeys(false); for (String username : usernames) { final String address = users.getString(username + "." + ADDRESS, null); - if (address != null && search.equalsIgnoreCase(address)) { + if (search.equalsIgnoreCase(address)) { return username; } } return null; } - public void setAddress(final String username, final String address) { + void setAddress(final String username, final String address) { setUser(username.toLowerCase(Locale.ENGLISH), address, isSpy(username)); } - public List getSpyUsers() { + List getSpyUsers() { return spyusers; } private void setUser(final String username, final String address, final boolean spy) { - final Map userdata = new HashMap(); + final Map userdata = new HashMap<>(); userdata.put(ADDRESS, address); userdata.put(SPY, spy); users.setProperty(username, userdata); diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java index 28a2d64f9..863189bb6 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -18,13 +18,13 @@ import java.util.logging.*; public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf { - private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private static final Logger logger = Logger.getLogger("EssentialsXMPP"); private static final SimpleFormatter formatter = new SimpleFormatter(); private final transient EssentialsConf config; private transient XMPPConnection connection; private transient ChatManager chatManager; - private final transient Map chats = Collections.synchronizedMap(new HashMap()); - private final transient Set logrecords = Collections.synchronizedSet(new HashSet()); + private final transient Map chats = Collections.synchronizedMap(new HashMap<>()); + private final transient Set logrecords = Collections.synchronizedSet(new HashSet<>()); private final transient IEssentialsXMPP parent; private transient List logUsers; private transient Level logLevel; @@ -32,7 +32,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager private transient Thread loggerThread; private transient boolean threadrunning = true; - public XMPPManager(final IEssentialsXMPP parent) { + XMPPManager(final IEssentialsXMPP parent) { super(); this.parent = parent; config = new EssentialsConf(new File(parent.getDataFolder(), "config.yml")); @@ -40,7 +40,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager reloadConfig(); } - public boolean sendMessage(final String address, final String message) { + boolean sendMessage(final String address, final String message) { if (address != null && !address.isEmpty()) { try { startChat(address); @@ -86,7 +86,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager private boolean connect() { final String server = config.getString("xmpp.server"); if (server == null || server.equals("example.com")) { - LOGGER.log(Level.WARNING, "config broken for xmpp"); + logger.log(Level.WARNING, "config broken for xmpp"); return false; } final int port = config.getInt("xmpp.port", 5222); @@ -94,10 +94,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager final String xmppuser = config.getString("xmpp.user"); final String password = config.getString("xmpp.password"); final ConnectionConfiguration connConf = new ConnectionConfiguration(server, port, serviceName); - final StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("Connecting to xmpp server ").append(server).append(":").append(port); - stringBuilder.append(" as user ").append(xmppuser).append("."); - LOGGER.log(Level.INFO, stringBuilder.toString()); + String stringBuilder = "Connecting to xmpp server " + server + ":" + port + " as user " + xmppuser + "."; + logger.log(Level.INFO, stringBuilder); connConf.setSASLAuthenticationEnabled(config.getBoolean("xmpp.sasl-enabled", false)); connConf.setSendPresence(true); connConf.setReconnectionAllowed(true); @@ -114,12 +112,12 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager chatManager.addChatListener(this); return true; } catch (XMPPException ex) { - LOGGER.log(Level.WARNING, "Failed to connect to server: " + server, ex); + logger.log(Level.WARNING, "Failed to connect to server: " + server, ex); return false; } } - public final void disconnect() { + final void disconnect() { if (loggerThread != null) { loggerThread.interrupt(); } @@ -133,7 +131,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager } - public final void updatePresence() { + final void updatePresence() { final int usercount; final StringBuilder stringBuilder = new StringBuilder(); @@ -166,7 +164,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager @Override public final void reloadConfig() { - LOGGER.removeHandler(this); + logger.removeHandler(this); config.load(); synchronized (chats) { disconnect(); @@ -177,7 +175,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager startLoggerThread(); } if (config.getBoolean("log-enabled", false)) { - LOGGER.addHandler(this); + logger.addHandler(this); logUsers = config.getStringList("log-users"); final String level = config.getString("log-level", "info"); try { @@ -200,7 +198,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager logrecords.add(logRecord); } } - } catch (Exception e) { + } catch (Exception ignored) { // Ignore all exceptions // Otherwise we create a loop. } @@ -217,51 +215,48 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager } private void startLoggerThread() { - loggerThread = new Thread(new Runnable() { - @Override - public void run() { - final Set copy = new HashSet(); - final Set failedUsers = new HashSet(); - while (threadrunning) { - synchronized (logrecords) { - if (!logrecords.isEmpty()) { - copy.addAll(logrecords); - logrecords.clear(); - } - } - if (!copy.isEmpty()) { - for (String user : logUsers) { - try { - XMPPManager.this.startChat(user); - for (LogRecord logRecord : copy) { - final String message = formatter.format(logRecord); - if (!XMPPManager.this.sendMessage(user, FormatUtil.stripLogColorFormat(message))) { - failedUsers.add(user); - break; - } - - } - } catch (XMPPException ex) { - failedUsers.add(user); - LOGGER.removeHandler(XMPPManager.this); - LOGGER.log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex); - } - } - logUsers.removeAll(failedUsers); - if (logUsers.isEmpty()) { - LOGGER.removeHandler(XMPPManager.this); - threadrunning = false; - } - copy.clear(); - } - try { - Thread.sleep(2000); - } catch (InterruptedException ex) { - threadrunning = false; + loggerThread = new Thread(() -> { + final Set copy = new HashSet<>(); + final Set failedUsers = new HashSet<>(); + while (threadrunning) { + synchronized (logrecords) { + if (!logrecords.isEmpty()) { + copy.addAll(logrecords); + logrecords.clear(); } } - LOGGER.removeHandler(XMPPManager.this); + if (!copy.isEmpty()) { + for (String user : logUsers) { + try { + XMPPManager.this.startChat(user); + for (LogRecord logRecord : copy) { + final String message = formatter.format(logRecord); + if (!XMPPManager.this.sendMessage(user, FormatUtil.stripLogColorFormat(message))) { + failedUsers.add(user); + break; + } + + } + } catch (XMPPException ex) { + failedUsers.add(user); + logger.removeHandler(XMPPManager.this); + logger.log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex); + } + } + logUsers.removeAll(failedUsers); + if (logUsers.isEmpty()) { + logger.removeHandler(XMPPManager.this); + threadrunning = false; + } + copy.clear(); + } + try { + Thread.sleep(2000); + } catch (InterruptedException ex) { + threadrunning = false; + } } + logger.removeHandler(XMPPManager.this); }); loggerThread.start(); } @@ -290,7 +285,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager try { chat.sendMessage("User " + parts[0] + " not found"); } catch (XMPPException ex) { - LOGGER.log(Level.WARNING, "Failed to send xmpp message.", ex); + logger.log(Level.WARNING, "Failed to send xmpp message.", ex); } } else { final String from = "[" + parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">"; @@ -306,7 +301,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager try { parent.getServer().dispatchCommand(Console.getInstance().getCommandSender(), message.substring(1)); } catch (Exception ex) { - LOGGER.log(Level.SEVERE, ex.getMessage(), ex); + logger.log(Level.SEVERE, ex.getMessage(), ex); } } } diff --git a/EssentialsXMPP/src/config.yml b/EssentialsXMPP/src/config.yml index 64b9a539f..3826dd773 100644 --- a/EssentialsXMPP/src/config.yml +++ b/EssentialsXMPP/src/config.yml @@ -6,12 +6,10 @@ xmpp: # port: 5222 # sasl-enabled: false -debug: false - op-users: # - 'name@example.com' - +debug: false log-enabled: false # Level is minimum level that should be send: info, warning, severe log-level: warning diff --git a/EssentialsXMPP/src/plugin.yml b/EssentialsXMPP/src/plugin.yml index 4c82ada31..77ae92bd0 100644 --- a/EssentialsXMPP/src/plugin.yml +++ b/EssentialsXMPP/src/plugin.yml @@ -4,17 +4,17 @@ main: com.earth2me.essentials.xmpp.EssentialsXMPP # Note to developers: This next line cannot change, or the automatic versioning system will break. version: ${full.version} website: http://ess.khhq.net/wiki/XMPP -description: Provides xmpp communication. -authors: - - snowleo +description: Provides XMPP communication. +authors: [snowleo] depend: [Essentials] +api-version: 1.13 commands: setxmpp: - description: set your xmpp address + description: Sets your XMPP address. usage: / xmpp: - description: send a message to a player + description: Sends a message to a player. usage: / xmppspy: - description: toggle xmpp spy for all messages + description: Toggles XMPP spy for all messages. usage: / diff --git a/examples/bpermissions.yml b/examples/bpermissions.yml deleted file mode 100644 index a6ca8d8d0..000000000 --- a/examples/bpermissions.yml +++ /dev/null @@ -1,134 +0,0 @@ -default: Default -groups: - Default: - permissions: - - essentials.spawn - - essentials.rules - - essentials.motd - - essentials.list - - essentials.helpop - - essentials.help - groups: [] - meta: [] - Builder: - permissions: - - essentials.build - - essentials.afk - - essentials.back - - essentials.back.ondeath - - essentials.balance - - essentials.balance.others - - essentials.balancetop - - essentials.chat.color - - essentials.chat.shout - - essentials.chat.question - - essentials.compass - - essentials.depth - - essentials.home - - essentials.ignore - - essentials.kit - - essentials.kits.tools - - essentials.mail - - essentials.mail.send - - essentials.me - - essentials.msg - - essentials.nick - - essentials.pay - - essentials.ping - - essentials.powertool - - essentials.protect - - essentials.sethome - - essentials.signs.use.* - - essentials.signs.create.disposal - - essentials.signs.create.mail - - essentials.signs.create.protection - - essentials.signs.create.trade - - essentials.signs.break.disposal - - essentials.signs.break.mail - - essentials.signs.break.protection - - essentials.signs.break.trade - - essentials.suicide - - essentials.time - - essentials.tpa - - essentials.tpaccept - - essentials.tpahere - - essentials.tpdeny - - essentials.warp - - essentials.warp.list - - essentials.worth - groups: - - Default - meta: - priority: '20' - Moderator: - permissions: - - essentials.ban - - essentials.ban.notify - - essentials.banip - - essentials.broadcast - - essentials.clearinventory - - essentials.delwarp - - essentials.eco.loan - - essentials.ext - - essentials.getpos - - essentials.helpop.recieve - - essentials.home.others - - essentials.invsee - - essentials.jails - - essentials.jump - - essentials.kick - - essentials.kick.notify - - essentials.kits.* - - essentials.kill - - essentials.mute - - essentials.nick.others - - essentials.realname - - essentials.setwarp - - essentials.signs.create.* - - essentials.signs.break.* - - essentials.spawner - - essentials.thunder - - essentials.time - - essentials.time.set - - essentials.protect.alerts - - essentials.protect.admin - - essentials.protect.ownerinfo - - essentials.ptime - - essentials.ptime.others - - essentials.togglejail - - essentials.top - - essentials.tp - - essentials.tphere - - essentials.tppos - - essentials.tptoggle - - essentials.unban - - essentials.unbanip - - essentials.warps.* - - essentials.weather - - essentials.whois - - essentials.world - - essentials.worlds.* - groups: - - Builder - meta: - priority: '40' - Admin: - permissions: - # Since we use essentials.* permission here, we can still disable commands like this - # This can be done with any pemission nodes - - ^essentials.backup - - ^essentials.essentials - - ^essentials.setspawn - - ^essentials.reloadall - - essentials.* - groups: - - Moderator - meta: - priority: '80' - Owner: - permissions: - - essentials.* - groups: - - Admin - meta: - priority: '100' diff --git a/examples/permissionsbukkit.yml b/examples/permissionsbukkit.yml deleted file mode 100644 index 490be0398..000000000 --- a/examples/permissionsbukkit.yml +++ /dev/null @@ -1,133 +0,0 @@ -users: - snowleo: - groups: - - Admin -groups: - Default: - permissions: - permissions.build: false - essentials.spawn: true - essentials.rules: true - essentials.motd: true - essentials.list: true - essentials.helpop: true - essentials.help: true - Builder: - permissions: - permissions.build: true - essentials.afk: true - essentials.back: true - essentials.back.ondeath: true - essentials.balance: true - essentials.balance.others: true - essentials.balancetop: true - essentials.chat.color: true - essentials.chat.shout: true - essentials.chat.question: true - essentials.compass: true - essentials.depth: true - essentials.home: true - essentials.ignore: true - essentials.kit: true - essentials.kits.tools: true - essentials.mail: true - essentials.mail.send: true - essentials.me: true - essentials.msg: true - essentials.nick: true - essentials.pay: true - essentials.ping: true - essentials.powertool: true - essentials.protect: true - essentials.sethome: true - essentials.signs.use.*: true - essentials.signs.create.disposal: true - essentials.signs.create.mail: true - essentials.signs.create.protection: true - essentials.signs.create.trade: true - essentials.signs.break.disposal: true - essentials.signs.break.mail: true - essentials.signs.break.protection: true - essentials.signs.break.trade: true - essentials.suicide: true - essentials.time: true - essentials.tpa: true - essentials.tpaccept: true - essentials.tpahere: true - essentials.tpdeny: true - essentials.warp: true - essentials.warp.list: true - essentials.worth: true - inheritance: - - Default - Moderator: - permissions: - essentials.ban: true - essentials.ban.notify: true - essentials.banip: true - essentials.broadcast: true - essentials.clearinventory: true - essentials.delwarp: true - essentials.eco.loan: true - essentials.ext: true - essentials.getpos: true - essentials.helpop.recieve: true - essentials.home.others: true - essentials.invsee: true - essentials.jails: true - essentials.jump: true - essentials.kick: true - essentials.kick.notify: true - essentials.kill: true - essentials.mute: true - essentials.nick.others: true - essentials.realname: true - essentials.setwarp: true - essentials.signs.create.*: true - essentials.signs.break.*: true - essentials.spawner: true - essentials.thunder: true - essentials.time: true - essentials.time.set: true - essentials.protect.alerts: true - essentials.protect.admin: true - essentials.protect.ownerinfo: true - essentials.ptime: true - essentials.ptime.others: true - essentials.togglejail: true - essentials.top: true - essentials.tp: true - essentials.tphere: true - essentials.tppos: true - essentials.tptoggle: true - essentials.unban: true - essentials.unbanip: true - essentials.weather: true - essentials.whois: true - essentials.world: true - essentials.worlds.*: true - inheritance: - - Builder - Admin: - permissions: - permissions.*: true - # Since we use essentials.* permission here, we can still disable commands like this - # This is only available for essentials permissions - -essentials.backup: true - -essentials.essentials: true - -essentials.setspawn: true - -essentials.reloadall: true - essentials.*: true - inheritance: - - Moderator - Owner: - permissions: - # Double negation - -essentials.backup: false - -essentials.essentials: false - -essentials.setspawn: false - -essentials.reloadall: false - inheritance: - - Admin -messages: - build: '&cYou do not have permission to build here.' diff --git a/examples/permissionsex.yml b/examples/permissionsex.yml deleted file mode 100644 index 8c5eabd2a..000000000 --- a/examples/permissionsex.yml +++ /dev/null @@ -1,150 +0,0 @@ -groups: - Default: - default: true - permissions: - - essentials.spawn - - essentials.rules - - essentials.motd - - essentials.list - - essentials.helpop - - essentials.help - - modifyworld.* - prefix: '&e' - options: - build: false - rank: '1000' - Builder: - permissions: - - essentials.afk - - essentials.back - - essentials.back.ondeath - - essentials.balance - - essentials.balance.others - - essentials.balancetop - - essentials.chat.color - - essentials.chat.shout - - essentials.chat.question - - essentials.compass - - essentials.depth - - essentials.home - - essentials.ignore - - essentials.kit - - essentials.kits.tools - - essentials.mail - - essentials.mail.send - - essentials.me - - essentials.msg - - essentials.nick - - essentials.pay - - essentials.ping - - essentials.powertool - - essentials.protect - - essentials.sethome - - essentials.signs.use.* - - essentials.signs.create.disposal - - essentials.signs.create.mail - - essentials.signs.create.protection - - essentials.signs.create.trade - - essentials.signs.break.disposal - - essentials.signs.break.mail - - essentials.signs.break.protection - - essentials.signs.break.trade - - essentials.suicide - - essentials.time - - essentials.tpa - - essentials.tpaccept - - essentials.tpahere - - essentials.tpdeny - - essentials.warp - - essentials.warp.list - - essentials.worth - inheritance: - - default - prefix: '&2' - options: - build: true - rank: '500' - Moderator: - permissions: - - essentials.ban - - essentials.ban.notify - - essentials.banip - - essentials.broadcast - - essentials.clearinventory - - essentials.delwarp - - essentials.eco.loan - - essentials.ext - - essentials.getpos - - essentials.helpop.recieve - - essentials.home.others - - essentials.invsee - - essentials.jails - - essentials.jump - - essentials.kick - - essentials.kick.notify - - essentials.kill - - essentials.mute - - essentials.nick.others - - essentials.realname - - essentials.setwarp - - essentials.signs.create.* - - essentials.signs.break.* - - essentials.spawner - - essentials.thunder - - essentials.time - - essentials.time.set - - essentials.protect.alerts - - essentials.protect.admin - - essentials.protect.ownerinfo - - essentials.ptime - - essentials.ptime.others - - essentials.togglejail - - essentials.top - - essentials.tp - - essentials.tphere - - essentials.tppos - - essentials.tptoggle - - essentials.unban - - essentials.unbanip - - essentials.weather - - essentials.whois - - essentials.world - - essentials.worlds.* - - permissions.user.promote.default - - permissions.user.demote.default - - permissions.manage.membership - inheritance: - - builder - prefix: '&5' - options: - build: true - rank: '200' - Admin: - permissions: - - -essentials.backup - - -essentials.essentials - - -essentials.setspawn - - -essentials.reloadall - - essentials.* - - permissions.manage.users - - permissions.manage.users.permissions - - permissions.manage.users.permissions.timed - inheritance: - - moderator - prefix: '&c' - options: - build: true - rank: '100' - Owner: - permissions: - - '*' - inheritance: - - admin - prefix: '&4' - options: - build: true - rank: '0' -users: - snowleo: - group: - - Builder diff --git a/nms/1_8_R1Provider/README.md b/nms/1_8_R1Provider/README.md deleted file mode 100644 index a4a714ffb..000000000 --- a/nms/1_8_R1Provider/README.md +++ /dev/null @@ -1 +0,0 @@ -Put a 1.8 Spigot/CraftBukkit JAR with filename `craftbukkit-1.8-R0.1-SNAPSHOT.jar` in `lib/org/bukkit/craftbukkit/1.8-R0.1-SNAPSHOT`. \ No newline at end of file diff --git a/nms/1_8_R1Provider/pom.xml b/nms/1_8_R1Provider/pom.xml index 3e2cc70af..5b0766791 100644 --- a/nms/1_8_R1Provider/pom.xml +++ b/nms/1_8_R1Provider/pom.xml @@ -12,14 +12,6 @@ 1_8_R1Provider - - - project.local - local repo - file:${project.basedir}/lib - - - org.bukkit diff --git a/nms/1_8_R2Provider/README.md b/nms/1_8_R2Provider/README.md deleted file mode 100644 index b9da55f8b..000000000 --- a/nms/1_8_R2Provider/README.md +++ /dev/null @@ -1 +0,0 @@ -Put a 1.8.3 Spigot/CraftBukkit JAR with filename `craftbukkit-1.8.3-R0.1-SNAPSHOT.jar` in `lib/org/bukkit/craftbukkit/1.8.3-R0.1-SNAPSHOT`. \ No newline at end of file diff --git a/nms/1_8_R2Provider/pom.xml b/nms/1_8_R2Provider/pom.xml index 9fecc2650..fea691a78 100644 --- a/nms/1_8_R2Provider/pom.xml +++ b/nms/1_8_R2Provider/pom.xml @@ -12,14 +12,6 @@ 1_8_R2Provider - - - project.local - local repo - file:${project.basedir}/lib - - - org.bukkit diff --git a/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacyPotionMetaProvider.java b/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacyPotionMetaProvider.java index 029d54a5d..8ffa477d7 100644 --- a/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacyPotionMetaProvider.java +++ b/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacyPotionMetaProvider.java @@ -4,6 +4,7 @@ import net.ess3.nms.PotionMetaProvider; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +@SuppressWarnings("deprecation") public class LegacyPotionMetaProvider extends PotionMetaProvider { @Override public ItemStack createPotionItem(Material initial, int effectId) { diff --git a/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnEggProvider.java b/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnEggProvider.java index 9975659db..63e8be7c6 100644 --- a/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnEggProvider.java +++ b/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnEggProvider.java @@ -6,6 +6,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.material.SpawnEgg; +@SuppressWarnings("deprecation") public class LegacySpawnEggProvider extends SpawnEggProvider { @Override public ItemStack createEggItem(EntityType type) throws IllegalArgumentException { @@ -13,7 +14,6 @@ public class LegacySpawnEggProvider extends SpawnEggProvider { } @Override - @SuppressWarnings("deprecation") public EntityType getSpawnedType(ItemStack eggItem) throws IllegalArgumentException { MaterialData data = eggItem.getData(); if (data instanceof SpawnEgg) { diff --git a/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnerProvider.java b/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnerProvider.java index 94b61df69..2311df701 100644 --- a/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnerProvider.java +++ b/nms/LegacyProvider/src/net/ess3/nms/legacy/LegacySpawnerProvider.java @@ -4,6 +4,7 @@ import net.ess3.nms.SpawnerProvider; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; +@SuppressWarnings("deprecation") public class LegacySpawnerProvider extends SpawnerProvider { @Override public ItemStack setEntityType(ItemStack is, EntityType type) { diff --git a/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java b/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java index 702fbe7d5..387c517a9 100644 --- a/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java +++ b/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java @@ -11,7 +11,7 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.Map; public abstract class SpawnerProvider implements Provider { - protected Map entityToDisplayName = ImmutableMap.builder() + private Map entityToDisplayName = ImmutableMap.builder() .put(EntityType.CAVE_SPIDER, "Cave Spider") .put(EntityType.PIG_ZOMBIE, "Zombie Pigman") .put(EntityType.MAGMA_CUBE, "Magma Cube") @@ -45,6 +45,7 @@ public abstract class SpawnerProvider implements Provider { } } + @SuppressWarnings("deprecation") protected ItemStack setDisplayName(ItemStack is, EntityType type) { ItemMeta meta = is.getItemMeta(); String displayName; diff --git a/nms/NMSProvider/src/net/ess3/providers/ProviderFactory.java b/nms/NMSProvider/src/net/ess3/providers/ProviderFactory.java index 458f2dea7..0abda6400 100644 --- a/nms/NMSProvider/src/net/ess3/providers/ProviderFactory.java +++ b/nms/NMSProvider/src/net/ess3/providers/ProviderFactory.java @@ -28,7 +28,7 @@ public class ProviderFactory { private T loadProvider(Class extends T> providerClass) { try { - return providerClass.newInstance(); + return providerClass.getConstructor().newInstance(); } catch (Throwable ignored) { return null; } diff --git a/nms/ReflectionProvider/src/net/ess3/nms/refl/ReflUtil.java b/nms/ReflectionProvider/src/net/ess3/nms/refl/ReflUtil.java index fd9ffd607..fb0e5f619 100644 --- a/nms/ReflectionProvider/src/net/ess3/nms/refl/ReflUtil.java +++ b/nms/ReflectionProvider/src/net/ess3/nms/refl/ReflUtil.java @@ -154,7 +154,7 @@ public class ReflUtil { private final String name; private final Class>[] params; - public MethodParams(final String name, final Class>[] params) { + MethodParams(final String name, final Class>[] params) { this.name = name; this.params = params; } @@ -202,7 +202,7 @@ public class ReflUtil { private static class ConstructorParams { private final Class>[] params; - public ConstructorParams(Class>[] params) { + ConstructorParams(Class>[] params) { this.params = params; } @@ -315,14 +315,8 @@ public class ReflUtil { return -1; } else if (minor > o.minor) { return 1; - } else { // equal minor - if (release < o.release) { - return -1; - } else if (release > o.release) { - return 1; - } else { - return 0; // o is the same version as this. - } + } else { + return Integer.compare(release, o.release); } } } diff --git a/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java b/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java index 6f7f8617b..d17f7c91b 100644 --- a/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java +++ b/nms/ReflectionProvider/src/net/ess3/nms/refl/SpawnEggRefl.java @@ -1,4 +1,5 @@ -/******************************************************************************* +/* + ****************************************************************************** * This file is part of ASkyBlock. * * ASkyBlock is free software: you can redistribute it and/or modify @@ -13,11 +14,10 @@ * * You should have received a copy of the GNU General Public License * along with ASkyBlock. If not, see . - *******************************************************************************/ + ****************************************************************************** +*/ package net.ess3.nms.refl; -import net.ess3.nms.refl.ReflUtil.NMSVersion; - import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; @@ -33,7 +33,7 @@ import java.lang.reflect.Method; public class SpawnEggRefl { private EntityType type; - public SpawnEggRefl(EntityType type) { + SpawnEggRefl(EntityType type) { this.type = type; } @@ -42,7 +42,7 @@ public class SpawnEggRefl { * * @return The entity type. */ - public EntityType getSpawnedType() { + EntityType getSpawnedType() { return type; } @@ -67,7 +67,7 @@ public class SpawnEggRefl { * * @return ItemStack */ - public ItemStack toItemStack() throws Exception { + ItemStack toItemStack() throws Exception { return toItemStack(1); } @@ -119,7 +119,7 @@ public class SpawnEggRefl { * @param item - ItemStack, quantity is disregarded * @return SpawnEgg */ - public static SpawnEggRefl fromItemStack(ItemStack item) throws Exception { + static SpawnEggRefl fromItemStack(ItemStack item) throws Exception { if (item == null) throw new IllegalArgumentException("Item cannot be null"); if (item.getType() != Material.MONSTER_EGG) diff --git a/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java b/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java index 636ffd512..433fcd23f 100644 --- a/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java +++ b/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java @@ -8,7 +8,7 @@ import org.junit.Test; public class NMSVersionTest { @Test - public void testMajor() throws Exception { + public void testMajor() { NMSVersion v2_9_R1 = NMSVersion.fromString("v2_9_R1"); Assert.assertEquals(2, v2_9_R1.getMajor()); @@ -22,7 +22,7 @@ public class NMSVersionTest { } @Test - public void testMinor() throws Exception { + public void testMinor() { NMSVersion v1_10_R1 = NMSVersion.fromString("v1_10_R1"); Assert.assertEquals(1, v1_10_R1.getMajor()); @@ -36,7 +36,7 @@ public class NMSVersionTest { } @Test - public void testRelease() throws Exception { + public void testRelease() { NMSVersion v1_9_R2 = NMSVersion.fromString("v1_9_R2"); Assert.assertEquals(1, v1_9_R2.getMajor()); diff --git a/pom.xml b/pom.xml index 0f96b1d4d..84bdab522 100644 --- a/pom.xml +++ b/pom.xml @@ -72,13 +72,14 @@ + clean install src test org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.8.0 1.8 1.8 @@ -87,7 +88,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.0.2 + 3.1.1 jars true @@ -133,7 +134,7 @@ maven-resources-plugin - 3.0.2 + 3.1.0 package @@ -192,7 +193,7 @@ org.apache.maven.plugins maven-clean-plugin - 2.5 + 3.1.0 @@ -211,7 +212,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.0 + 3.0.1 org.apache.maven.plugins @@ -224,7 +225,7 @@ pl.project13.maven git-commit-id-plugin - 2.2.4 + 2.2.5
* ASkyBlock is free software: you can redistribute it and/or modify @@ -13,11 +14,10 @@ *
* You should have received a copy of the GNU General Public License * along with ASkyBlock. If not, see . - *******************************************************************************/ + ****************************************************************************** +*/ package net.ess3.nms.refl; -import net.ess3.nms.refl.ReflUtil.NMSVersion; - import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; @@ -33,7 +33,7 @@ import java.lang.reflect.Method; public class SpawnEggRefl { private EntityType type; - public SpawnEggRefl(EntityType type) { + SpawnEggRefl(EntityType type) { this.type = type; } @@ -42,7 +42,7 @@ public class SpawnEggRefl { * * @return The entity type. */ - public EntityType getSpawnedType() { + EntityType getSpawnedType() { return type; } @@ -67,7 +67,7 @@ public class SpawnEggRefl { * * @return ItemStack */ - public ItemStack toItemStack() throws Exception { + ItemStack toItemStack() throws Exception { return toItemStack(1); } @@ -119,7 +119,7 @@ public class SpawnEggRefl { * @param item - ItemStack, quantity is disregarded * @return SpawnEgg */ - public static SpawnEggRefl fromItemStack(ItemStack item) throws Exception { + static SpawnEggRefl fromItemStack(ItemStack item) throws Exception { if (item == null) throw new IllegalArgumentException("Item cannot be null"); if (item.getType() != Material.MONSTER_EGG) diff --git a/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java b/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java index 636ffd512..433fcd23f 100644 --- a/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java +++ b/nms/ReflectionProvider/test/net/ess3/nms/refl/NMSVersionTest.java @@ -8,7 +8,7 @@ import org.junit.Test; public class NMSVersionTest { @Test - public void testMajor() throws Exception { + public void testMajor() { NMSVersion v2_9_R1 = NMSVersion.fromString("v2_9_R1"); Assert.assertEquals(2, v2_9_R1.getMajor()); @@ -22,7 +22,7 @@ public class NMSVersionTest { } @Test - public void testMinor() throws Exception { + public void testMinor() { NMSVersion v1_10_R1 = NMSVersion.fromString("v1_10_R1"); Assert.assertEquals(1, v1_10_R1.getMajor()); @@ -36,7 +36,7 @@ public class NMSVersionTest { } @Test - public void testRelease() throws Exception { + public void testRelease() { NMSVersion v1_9_R2 = NMSVersion.fromString("v1_9_R2"); Assert.assertEquals(1, v1_9_R2.getMajor()); diff --git a/pom.xml b/pom.xml index 0f96b1d4d..84bdab522 100644 --- a/pom.xml +++ b/pom.xml @@ -72,13 +72,14 @@