Lots of little fixes in the Essentials modules (#2337) @DoNotSpamPls

Look at changed files for the changes
This commit is contained in:
DoNotSpamPls 2019-01-05 20:42:09 +02:00 committed by md678685
parent e8ab2db8e8
commit 82ede4530a
58 changed files with 316 additions and 924 deletions

72
.gitignore vendored
View File

@ -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/

View File

@ -11,20 +11,13 @@
<artifactId>EssentialsX</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsX-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.0</version>
<configuration>
<showDeprecation>false</showDeprecation>
</configuration>
@ -32,7 +25,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
@ -41,6 +34,9 @@
</goals>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
</plugins>
</build>
@ -113,6 +109,7 @@
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>vault-repo</id>

View File

@ -11,13 +11,6 @@
<artifactId>EssentialsXAntiBuild</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXAntiBuild-${full.version}</finalName>
</build>

View File

@ -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);
}
}
}

View File

@ -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() {

View File

@ -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

View File

@ -11,13 +11,6 @@
<artifactId>EssentialsXChat</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXChat-${full.version}</finalName>
</build>

View File

@ -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;
}
}

View File

@ -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<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<AsyncPlayerChatEvent, ChatStore>());
final Map<AsyncPlayerChatEvent, ChatStore> 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);
}
}
}

View File

@ -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<AsyncPlayerChatEvent, ChatStore> chatStorage;
static final Logger logger = Logger.getLogger("EssentialsChat");
transient IEssentials ess;
final transient Server server;
private final transient Map<AsyncPlayerChatEvent, ChatStore> chatStorage;
public EssentialsChatPlayer(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayer(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> 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) {

View File

@ -10,7 +10,7 @@ import java.util.Map;
public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer {
public EssentialsChatPlayerListenerHighest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayerListenerHighest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> 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);
}
}

View File

@ -15,7 +15,7 @@ import java.util.Map;
public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer {
public EssentialsChatPlayerListenerLowest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayerListenerLowest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> 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();

View File

@ -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<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayerListenerNormal(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> 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<Player> outList = event.getRecipients();
Set<Player> spyList = new HashSet<Player>();
Set<Player> 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;
}

View File

@ -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

View File

@ -11,38 +11,13 @@
<artifactId>EssentialsXGeoIP</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>0.7.2</version>
</dependency>
<dependency>
<groupId>javatar</groupId>
<artifactId>javatar</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
<build>
<finalName>EssentialsXGeoIP-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
@ -52,6 +27,7 @@
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
@ -65,4 +41,22 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>javatar</groupId>
<artifactId>javatar</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</project>

View File

@ -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);
}
}
}

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -11,13 +11,6 @@
<artifactId>EssentialsXProtect</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXProtect-${full.version}</finalName>
</build>

View File

@ -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;

View File

@ -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;
}

View File

@ -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<ProtectConfig, Boolean> settingsBoolean = new EnumMap<>(ProtectConfig.class);
private final Map<ProtectConfig, String> settingsString = new EnumMap<>(ProtectConfig.class);
private final Map<ProtectConfig, List<Material>> 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);
}

View File

@ -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<Material> 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)

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -11,13 +11,6 @@
<artifactId>EssentialsXSpawn</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXSpawn-${full.version}</finalName>
</build>

View File

@ -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));

View File

@ -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) {

View File

@ -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<String> 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);
}
}
}

View File

@ -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);
}

View File

@ -14,7 +14,7 @@ import java.util.Map;
public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> 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<Spawns> 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<String, Location>());
getData().setSpawns(new HashMap<>());
}
getData().getSpawns().put(group.toLowerCase(Locale.ENGLISH), loc);
} finally {
@ -48,7 +46,7 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE
}
}
public Location getSpawn(final String group) {
Location getSpawn(final String group) {
acquireReadLock();
try {
if (getData().getSpawns() == null || group == null) {

View File

@ -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: /<command> <group>
aliases: [esetspawn]
spawn:
description: Teleport to the spawnpoint.
description: Teleports to the spawn point.
usage: /<command> [player]
aliases: [espawn]
permissions:

View File

@ -11,12 +11,27 @@
<artifactId>EssentialsXXMPP</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXXMPP-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
@ -32,26 +47,4 @@
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>EssentialsXXMPP-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -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

View File

@ -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<String> 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) {}
}
}

View File

@ -9,48 +9,48 @@ import java.util.*;
public class UserManager implements IConf {
private final transient EssentialsConf users;
private final transient List<String> spyusers = Collections.synchronizedList(new ArrayList<String>());
private final transient List<String> 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<String> 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<String> getSpyUsers() {
List<String> getSpyUsers() {
return spyusers;
}
private void setUser(final String username, final String address, final boolean spy) {
final Map<String, Object> userdata = new HashMap<String, Object>();
final Map<String, Object> userdata = new HashMap<>();
userdata.put(ADDRESS, address);
userdata.put(SPY, spy);
users.setProperty(username, userdata);

View File

@ -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<String, Chat> chats = Collections.synchronizedMap(new HashMap<String, Chat>());
private final transient Set<LogRecord> logrecords = Collections.synchronizedSet(new HashSet<LogRecord>());
private final transient Map<String, Chat> chats = Collections.synchronizedMap(new HashMap<>());
private final transient Set<LogRecord> logrecords = Collections.synchronizedSet(new HashSet<>());
private final transient IEssentialsXMPP parent;
private transient List<String> 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<LogRecord> copy = new HashSet<LogRecord>();
final Set<String> failedUsers = new HashSet<String>();
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<LogRecord> copy = new HashSet<>();
final Set<String> 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);
}
}
}

View File

@ -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

View File

@ -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: /<command> <address>
xmpp:
description: send a message to a player
description: Sends a message to a player.
usage: /<command> <player> <message>
xmppspy:
description: toggle xmpp spy for all messages
description: Toggles XMPP spy for all messages.
usage: /<command> <player>

View File

@ -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'

View File

@ -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.'

View File

@ -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

View File

@ -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`.

View File

@ -12,14 +12,6 @@
<artifactId>1_8_R1Provider</artifactId>
<repositories>
<repository>
<id>project.local</id>
<name>local repo</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>

View File

@ -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`.

View File

@ -12,14 +12,6 @@
<artifactId>1_8_R2Provider</artifactId>
<repositories>
<repository>
<id>project.local</id>
<name>local repo</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -11,7 +11,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.Map;
public abstract class SpawnerProvider implements Provider {
protected Map<EntityType, String> entityToDisplayName = ImmutableMap.<EntityType, String>builder()
private Map<EntityType, String> entityToDisplayName = ImmutableMap.<EntityType, String>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;

View File

@ -28,7 +28,7 @@ public class ProviderFactory<T extends Provider> {
private T loadProvider(Class<? extends T> providerClass) {
try {
return providerClass.newInstance();
return providerClass.getConstructor().newInstance();
} catch (Throwable ignored) {
return null;
}

View File

@ -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);
}
}
}

View File

@ -1,4 +1,5 @@
/*******************************************************************************
/*
******************************************************************************
* This file is part of ASkyBlock.
* <p>
* ASkyBlock is free software: you can redistribute it and/or modify
@ -13,11 +14,10 @@
* <p>
* You should have received a copy of the GNU General Public License
* along with ASkyBlock. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
******************************************************************************
*/
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)

View File

@ -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());

13
pom.xml
View File

@ -72,13 +72,14 @@
</dependencies>
<build>
<defaultGoal>clean install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -87,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.1</version>
<configuration>
<outputDirectory>jars</outputDirectory>
<stripVersion>true</stripVersion>
@ -133,7 +134,7 @@
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
@ -192,7 +193,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
@ -211,7 +212,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -224,7 +225,7 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.4</version>
<version>2.2.5</version>
<executions>
<execution>
<goals>