Moved PlayerQuit to use normal PlayerEvent, dropped Reason param

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2010-12-26 23:21:21 +00:00
parent a3ff0f1177
commit 8f8f4aef90
4 changed files with 3 additions and 49 deletions

View file

@ -3,7 +3,6 @@ package com.dinnerbone.bukkit.sample;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
/** /**
* Handle events for all Player related events * Handle events for all Player related events
@ -22,7 +21,7 @@ public class SamplePlayerListener extends PlayerListener {
} }
@Override @Override
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerEvent event) {
System.out.println(event.getPlayer().getName() + " left the server! :'("); System.out.println(event.getPlayer().getName() + " left the server! :'(");
} }
} }

View file

@ -21,6 +21,6 @@ public class PlayerListener implements Listener {
* Called when a player leaves a server * Called when a player leaves a server
* @param event Relevant event details * @param event Relevant event details
*/ */
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerEvent event) {
} }
} }

View file

@ -1,45 +0,0 @@
package org.bukkit.event.player;
import org.bukkit.Player;
import org.bukkit.Server;
/**
* Handles all event arguments in relation to a player joining a server
*/
public class PlayerQuitEvent extends PlayerEvent {
private final PlayerQuitReason reason;
public PlayerQuitEvent(final Server server, final Player player, final PlayerQuitReason because) {
super(server, player);
reason = because;
}
/**
* Return the reason for a player quitting the game
* @return PlayerQuitReason with the relevant reason
*/
public PlayerQuitReason getReason() {
return reason;
}
/**
* The reason a player quit the game
*/
public enum PlayerQuitReason {
/**
* A player willingly quit the game
*/
Quit,
/**
* A player disconnected due to a technical fault
*/
Disconnected,
/**
* A player was kicked by another player
*/
Kicked
}
}

View file

@ -85,7 +85,7 @@ public final class JavaPluginLoader implements PluginLoader {
trueListener.onPlayerJoin((PlayerEvent)event); trueListener.onPlayerJoin((PlayerEvent)event);
break; break;
case Quit: case Quit:
trueListener.onPlayerQuit((PlayerQuitEvent)event); trueListener.onPlayerQuit((PlayerEvent)event);
break; break;
} }
} }