mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-21 23:51:42 +01:00
Make Essentials Update use new Listener system, and fix a few general mistakes, including that of the config
This commit is contained in:
parent
ad05516fd5
commit
0252d756f6
@ -40,7 +40,7 @@ change-displayname: true
|
||||
# The value of change-displayname (above) has to be true.
|
||||
# If you don't set this, it will default to true if essentials chat is installed.
|
||||
# Don't forget to remove the # infront of the line
|
||||
# add-prefix-suffix: false
|
||||
#add-prefix-suffix: false
|
||||
|
||||
# The delay, in seconds, required between /home, /tp, etc.
|
||||
teleport-cooldown: 0
|
||||
|
@ -7,8 +7,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -5,6 +5,6 @@ main: com.earth2me.essentials.chat.EssentialsChat
|
||||
version: TeamCity
|
||||
website: http://tiny.cc/EssentialsCommands
|
||||
description: Provides chat control features for Essentials. Requires Permissions.
|
||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Okamosy]
|
||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy]
|
||||
depend: [Essentials]
|
||||
#softdepend: [Factions]
|
@ -7,16 +7,15 @@ import java.util.Map;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class EssentialsHelp extends PlayerListener
|
||||
public class EssentialsHelp implements Listener
|
||||
{
|
||||
private transient Player chatUser;
|
||||
private final transient Server server;
|
||||
@ -39,8 +38,7 @@ public class EssentialsHelp extends PlayerListener
|
||||
public void registerEvents()
|
||||
{
|
||||
final PluginManager pluginManager = server.getPluginManager();
|
||||
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
|
||||
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Low, plugin);
|
||||
pluginManager.registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void onCommand(final CommandSender sender)
|
||||
@ -155,18 +153,17 @@ public class EssentialsHelp extends PlayerListener
|
||||
ircBot = new IrcBot(player, "Ess_" + player.getName(), UsernameUtil.createUsername(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
if (event.getPlayer() == chatUser)
|
||||
{
|
||||
final boolean success = sendChatMessage(event.getPlayer(), event.getMessage());
|
||||
event.setCancelled(success);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
closeConnection();
|
||||
|
@ -7,18 +7,16 @@ import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.CustomEventListener;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class UpdateProcess extends PlayerListener
|
||||
public class UpdateProcess implements Listener
|
||||
{
|
||||
private transient Player currentPlayer;
|
||||
private final transient Plugin plugin;
|
||||
@ -35,20 +33,6 @@ public class UpdateProcess extends PlayerListener
|
||||
public void registerEvents()
|
||||
{
|
||||
final PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
|
||||
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Lowest, plugin);
|
||||
pluginManager.registerEvent(Type.PLAYER_JOIN, this, Priority.Normal, plugin);
|
||||
pluginManager.registerEvent(Type.CUSTOM_EVENT, new CustomEventListener()
|
||||
{
|
||||
@Override
|
||||
public void onCustomEvent(final Event event)
|
||||
{
|
||||
if (event instanceof InstallationFinishedEvent)
|
||||
{
|
||||
UpdateProcess.this.currentPlayer = null;
|
||||
}
|
||||
}
|
||||
}, Priority.Normal, plugin);
|
||||
}
|
||||
|
||||
public boolean selfUpdate()
|
||||
@ -110,7 +94,13 @@ public class UpdateProcess extends PlayerListener
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void onInstallationFinished(final InstallationFinishedEvent event)
|
||||
{
|
||||
UpdateProcess.this.currentPlayer = null;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
if (event.getPlayer() == currentPlayer)
|
||||
@ -130,7 +120,7 @@ public class UpdateProcess extends PlayerListener
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
Loading…
Reference in New Issue
Block a user