mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-07 04:38:03 +02:00
Add Logout Event
This commit is contained in:
parent
9437efb08d
commit
7a19a1ce78
@ -2,6 +2,7 @@ package fr.xephi.authme.commands;
|
|||||||
|
|
||||||
import me.muizers.Notifications.Notification;
|
import me.muizers.Notifications.Notification;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -22,6 +23,7 @@ import fr.xephi.authme.cache.backup.FileCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||||
|
import fr.xephi.authme.events.LogoutEvent;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
@ -53,7 +55,7 @@ public class LogoutCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
|
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
if (!PlayerCache.getInstance().isAuthenticated(name)) {
|
||||||
@ -115,6 +117,13 @@ public class LogoutCommand implements CommandExecutor {
|
|||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
player.setAllowFlight(true);
|
player.setAllowFlight(true);
|
||||||
player.setFlying(true);
|
player.setFlying(true);
|
||||||
|
// Player is now logout... Time to fire event !
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||||
|
}
|
||||||
|
});
|
||||||
m._(player, "logout");
|
m._(player, "logout");
|
||||||
ConsoleLogger.info(player.getDisplayName() + " logged out");
|
ConsoleLogger.info(player.getDisplayName() + " logged out");
|
||||||
if (plugin.notifications != null) {
|
if (plugin.notifications != null) {
|
||||||
|
39
src/main/java/fr/xephi/authme/events/LogoutEvent.java
Normal file
39
src/main/java/fr/xephi/authme/events/LogoutEvent.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package fr.xephi.authme.events;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This event is called when a player logout through AuthMe.
|
||||||
|
*
|
||||||
|
* @author Xephi59
|
||||||
|
*/
|
||||||
|
public class LogoutEvent extends Event {
|
||||||
|
|
||||||
|
private Player player;
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public LogoutEvent(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayer(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user