From 75035470e1ab69959bdb9099187260b12e1e678b Mon Sep 17 00:00:00 2001 From: stonar96 <minecraft.stonar96@gmail.com> Date: Fri, 11 Oct 2019 13:38:23 +0200 Subject: [PATCH] Update to the new priority implementation and fix the project --- .gitignore | 26 +++++++++++++++++++ pom.xml | 8 +++++- .../vanillage/onlinecheck/OnlineCheck.java | 4 +-- .../OnlineCheckPlayerLoggedInListener.java | 15 ++++------- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index db6b2b3..c83f6f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# Maven target/ pom.xml.tag pom.xml.releaseBackup @@ -11,6 +12,31 @@ buildNumber.properties # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) !/.mvn/wrapper/maven-wrapper.jar +# Java +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + # IDE /.settings/ /lib/ diff --git a/pom.xml b/pom.xml index 4e9f0fb..0b897a4 100644 --- a/pom.xml +++ b/pom.xml @@ -2,8 +2,9 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.vanillage.onlinecheck</groupId> <artifactId>onlinecheck</artifactId> - <version>1.0</version> + <version>2.0</version> <name>OnlineCheck</name> + <description>A Minecraft-Alpha-Server plugin which checks that there isn't already a player with the username online instead of kicking the online player.</description> <dependencies> <dependency> <groupId>com.vanillage.minecraftalphaserver</groupId> @@ -16,4 +17,9 @@ <build> <finalName>OnlineCheck</finalName> </build> + <properties> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> </project> diff --git a/src/main/java/com/vanillage/onlinecheck/OnlineCheck.java b/src/main/java/com/vanillage/onlinecheck/OnlineCheck.java index abfd3f1..d98e480 100644 --- a/src/main/java/com/vanillage/onlinecheck/OnlineCheck.java +++ b/src/main/java/com/vanillage/onlinecheck/OnlineCheck.java @@ -5,13 +5,13 @@ public final class OnlineCheck extends Plugin { @Override - public void onEnable() { + protected void onEnable() { getMinecraftServer().getPluginManager().getEventManager().registerListener((PlayerLoggedInListener) new OnlineCheckPlayerLoggedInListener(this)); getMinecraftServer().log(getName() + " enabled"); } @Override - public void onDisable() { + protected void onDisable() { getMinecraftServer().log(getName() + " disabled"); } } diff --git a/src/main/java/com/vanillage/onlinecheck/OnlineCheckPlayerLoggedInListener.java b/src/main/java/com/vanillage/onlinecheck/OnlineCheckPlayerLoggedInListener.java index 91ad161..01e4f9b 100644 --- a/src/main/java/com/vanillage/onlinecheck/OnlineCheckPlayerLoggedInListener.java +++ b/src/main/java/com/vanillage/onlinecheck/OnlineCheckPlayerLoggedInListener.java @@ -5,11 +5,10 @@ public final class OnlineCheckPlayerLoggedInListener extends PlayerLoggedInListener { private final OnlineCheck plugin; - private final int priority; private String kickReason; public OnlineCheckPlayerLoggedInListener(OnlineCheck plugin) { - this(plugin, -5, null); + this(plugin, -10, null); } public OnlineCheckPlayerLoggedInListener(OnlineCheck plugin, int priority) { @@ -17,16 +16,17 @@ public OnlineCheckPlayerLoggedInListener(OnlineCheck plugin, int priority) { } public OnlineCheckPlayerLoggedInListener(OnlineCheck plugin, String kickReason) { - this(plugin, -5, kickReason); + this(plugin, -10, kickReason); } public OnlineCheckPlayerLoggedInListener(OnlineCheck plugin, int priority, String kickReason) { + super(priority); + if (plugin == null) { throw new IllegalArgumentException("plugin cannot be null"); } this.plugin = plugin; - this.priority = priority; this.kickReason = kickReason == null ? "<username> is already online" : kickReason; } @@ -47,15 +47,10 @@ public void setKickReason(String kickReason) { } @Override - public void onEvent(PlayerLoggedInEvent event) { + protected void onEvent(PlayerLoggedInEvent event) { if (!event.isDenied() && plugin.getMinecraftServer().configManager.getPlayerEntity(event.getPacket().username) != null) { event.deny(); event.setKickReason(kickReason.replace("<username>", event.getPacket().username)); } } - - @Override - public int getPriority() { - return priority; - } }