diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index b1487910..d665877a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -79,10 +79,8 @@ import com.onarandombox.MultiverseCore.destination.PlayerDestination; import com.onarandombox.MultiverseCore.destination.WorldDestination; import com.onarandombox.MultiverseCore.event.MVDebugModeEvent; import com.onarandombox.MultiverseCore.event.MVVersionEvent; -import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener; import com.onarandombox.MultiverseCore.listeners.MVChatListener; import com.onarandombox.MultiverseCore.listeners.MVEntityListener; -import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener; import com.onarandombox.MultiverseCore.listeners.MVPlayerListener; import com.onarandombox.MultiverseCore.listeners.MVPortalListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; @@ -323,17 +321,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { // A test that had no worlds loaded was being run. This should never happen in production } this.saveMVConfig(); - // Register async or sync player chat according to config - try { - Class.forName("org.bukkit.event.player.AsyncPlayerChatEvent"); - } catch (ClassNotFoundException e) { - getMVConfig().setUseAsyncChat(false); - } - if (getMVConfig().getUseAsyncChat()) { - this.chatListener = new MVAsyncPlayerChatListener(this, this.playerListener); - } else { - this.chatListener = new MVPlayerChatListener(this, this.playerListener); - } + + this.chatListener = new MVChatListener(this, this.playerListener); getServer().getPluginManager().registerEvents(this.chatListener, this); this.initializeBuscript(); diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java index aaf21275..cc9b5fce 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java @@ -48,8 +48,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements @Property private volatile String prefixchatformat; @Property - private volatile boolean useasyncchat; - @Property private volatile boolean teleportintercept; @Property private volatile boolean firstspawnoverride; @@ -95,7 +93,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements protected void setDefaults() { // BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck enforceaccess = false; - useasyncchat = true; prefixchat = false; prefixchatformat = "[%world%]%chat%"; teleportintercept = true; @@ -322,16 +319,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements this.teleportcooldown = teleportCooldown; } - @Override - public void setUseAsyncChat(boolean useAsyncChat) { - this.useasyncchat = useAsyncChat; - } - - @Override - public boolean getUseAsyncChat() { - return this.useasyncchat; - } - @Override public void setSilentStart(boolean silentStart) { Logging.setShowingConfig(!silentStart); diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java index 07b2bb91..ee8d0b16 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseCoreConfig.java @@ -158,18 +158,6 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable { */ boolean getEnforceAccess(); - /** - * Sets useasyncchat. - * @param useAsyncChat The new value. - */ - void setUseAsyncChat(boolean useAsyncChat); - - /** - * Gets useasyncchat. - * @return useasyncchat. - */ - boolean getUseAsyncChat(); - /** * Sets whether to suppress startup messages. * diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandsold/VersionCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commandsold/VersionCommand.java index c0a938ad..941e4713 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandsold/VersionCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandsold/VersionCommand.java @@ -7,6 +7,10 @@ package com.onarandombox.MultiverseCore.commandsold; +import java.io.File; +import java.util.List; +import java.util.Map; + import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.event.MVVersionEvent; @@ -26,10 +30,6 @@ import org.bukkit.entity.Player; import org.bukkit.permissions.PermissionDefault; import org.bukkit.scheduler.BukkitRunnable; -import java.io.File; -import java.util.List; -import java.util.Map; - /** * Dumps version info to the console. */ @@ -63,7 +63,6 @@ public class VersionCommand extends MultiverseCommand { + "[Multiverse-Core] enforceaccess: " + plugin.getMVConfig().getEnforceAccess() + '\n' + "[Multiverse-Core] prefixchat: " + plugin.getMVConfig().getPrefixChat() + '\n' + "[Multiverse-Core] prefixchatformat: " + plugin.getMVConfig().getPrefixChatFormat() + '\n' - + "[Multiverse-Core] useasyncchat: " + plugin.getMVConfig().getUseAsyncChat() + '\n' + "[Multiverse-Core] teleportintercept: " + plugin.getMVConfig().getTeleportIntercept() + '\n' + "[Multiverse-Core] firstspawnoverride: " + plugin.getMVConfig().getFirstSpawnOverride() + '\n' + "[Multiverse-Core] displaypermerrors: " + plugin.getMVConfig().getDisplayPermErrors() + '\n' diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/AsyncChatEvent.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/AsyncChatEvent.java deleted file mode 100644 index 38d48bef..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/AsyncChatEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.onarandombox.MultiverseCore.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.player.AsyncPlayerChatEvent; - -/** - * A wrapper for the {@link AsyncPlayerChatEvent}. - */ -public class AsyncChatEvent implements ChatEvent { - private final AsyncPlayerChatEvent event; - - public AsyncChatEvent(AsyncPlayerChatEvent event) { - this.event = event; - } - - @Override - public boolean isCancelled() { - return event.isCancelled(); - } - - @Override - public String getFormat() { - return event.getFormat(); - } - - @Override - public void setFormat(String s) { - event.setFormat(s); - } - - @Override - public Player getPlayer() { - return event.getPlayer(); - } -} diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/ChatEvent.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/ChatEvent.java deleted file mode 100644 index 16cafb81..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/ChatEvent.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.onarandombox.MultiverseCore.listeners; - -import org.bukkit.entity.Player; - -/** - * A wrapper for the two chat-events in Bukkit. - */ -public interface ChatEvent { - /** - * @return Whether this event is cancelled. - */ - boolean isCancelled(); - - /** - * @return The format. - */ - String getFormat(); - - /** - * Sets the format. - * @param s The new format. - */ - void setFormat(String s); - - /** - * @return The player. - */ - Player getPlayer(); -} diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVAsyncPlayerChatListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVAsyncPlayerChatListener.java deleted file mode 100644 index c6210253..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVAsyncPlayerChatListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * Multiverse 2 Copyright (c) the Multiverse Team 2011. * - * Multiverse 2 is licensed under the BSD License. * - * For more information please check the README.md file included * - * with this project. * - ******************************************************************************/ - -package com.onarandombox.MultiverseCore.listeners; - -import java.util.logging.Level; - -import com.dumptruckman.minecraft.util.Logging; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.AsyncPlayerChatEvent; - -import com.onarandombox.MultiverseCore.MultiverseCore; - -/** - * Multiverse's {@link org.bukkit.event.Listener} for players. - */ -public class MVAsyncPlayerChatListener extends MVChatListener { - public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { - super(plugin, playerListener); - Logging.fine("Created AsyncPlayerChatEvent listener."); - } - - /** - * This method is called when a player wants to chat. - * @param event The Event that was fired. - */ - @EventHandler - public void playerChat(AsyncPlayerChatEvent event) { - this.playerChat(new AsyncChatEvent(event)); - } -} diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java index aaa05ab5..84fcb11f 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java @@ -5,12 +5,14 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MultiverseWorld; import org.bukkit.ChatColor; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; /** * Multiverse's {@link org.bukkit.event.Listener} for players. */ -public abstract class MVChatListener implements Listener { +public class MVChatListener implements Listener { private final MultiverseCore plugin; private final MVWorldManager worldManager; private final MVPlayerListener playerListener; @@ -22,10 +24,11 @@ public abstract class MVChatListener implements Listener { } /** - * This handles a {@link ChatEvent}. - * @param event The {@link ChatEvent}. + * This handles a {@link AsyncPlayerChatEvent}. + * @param event The {@link AsyncPlayerChatEvent}. */ - public void playerChat(ChatEvent event) { + @EventHandler + public void playerChat(AsyncPlayerChatEvent event) { if (event.isCancelled()) { return; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerChatListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerChatListener.java deleted file mode 100644 index fff535da..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerChatListener.java +++ /dev/null @@ -1,36 +0,0 @@ -/****************************************************************************** - * Multiverse 2 Copyright (c) the Multiverse Team 2011. * - * Multiverse 2 is licensed under the BSD License. * - * For more information please check the README.md file included * - * with this project. * - ******************************************************************************/ - -package com.onarandombox.MultiverseCore.listeners; - -import java.util.logging.Level; - -import com.dumptruckman.minecraft.util.Logging; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerChatEvent; - -import com.onarandombox.MultiverseCore.MultiverseCore; - -/** - * Multiverse's {@link org.bukkit.event.Listener} for players. - */ -@SuppressWarnings("deprecation") // this exists only for downwards compatibility -public class MVPlayerChatListener extends MVChatListener { - public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { - super(plugin, playerListener); - Logging.fine("Registered PlayerChatEvent listener."); - } - - /** - * This method is called when a player wants to chat. - * @param event The Event that was fired. - */ - @EventHandler - public void playerChat(PlayerChatEvent event) { - this.playerChat(new NormalChatEvent(event)); - } -} diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/NormalChatEvent.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/NormalChatEvent.java deleted file mode 100644 index a712c627..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/NormalChatEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.onarandombox.MultiverseCore.listeners; - -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerChatEvent; - -/** - * A wrapper for the {@link PlayerChatEvent}. - * @deprecated This is deprecated like the {@link PlayerChatEvent}. - */ -@Deprecated -public class NormalChatEvent implements ChatEvent { - private final PlayerChatEvent event; - - public NormalChatEvent(PlayerChatEvent event) { - this.event = event; - } - - @Override - public boolean isCancelled() { - return event.isCancelled(); - } - - @Override - public String getFormat() { - return event.getFormat(); - } - - @Override - public void setFormat(String s) { - event.setFormat(s); - } - - @Override - public Player getPlayer() { - return event.getPlayer(); - } -} diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java b/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java index 3766e46a..a431e8b7 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java @@ -7,10 +7,11 @@ package com.onarandombox.MultiverseCore; +import java.io.File; + import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.configuration.SpawnLocation; -import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener; import com.onarandombox.MultiverseCore.utils.MockWorldFactory; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import org.bukkit.ChatColor; @@ -38,8 +39,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.io.File; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -178,10 +177,10 @@ public class TestWorldProperties { // call player chat event core.getMVConfig().setPrefixChat(true); - ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent); + core.getChatListener().playerChat(playerChatEvent); verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format"); core.getMVConfig().setPrefixChat(false); - ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent); + core.getChatListener().playerChat(playerChatEvent); verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!) // call player join events @@ -272,15 +271,15 @@ public class TestWorldProperties { // call player chat event core.getMVConfig().setPrefixChat(true); - ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent); + core.getChatListener().playerChat(playerChatEvent); // never because it's hidden! verify(playerChatEvent, never()).setFormat( "[" + mvWorld.getColoredWorldString() + "]" + "format"); mvWorld.setHidden(false); - ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent); + core.getChatListener().playerChat(playerChatEvent); verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format"); core.getMVConfig().setPrefixChat(false); - ((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent); + core.getChatListener().playerChat(playerChatEvent); verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!) mvWorld.setHidden(true); // reset hidden-state