prevent eating food

This commit is contained in:
DNx5 2015-09-14 00:19:37 +07:00
parent 7458224ada
commit 355c04c361

View File

@ -21,21 +21,7 @@ import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.*;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
@ -407,7 +393,7 @@ public class AuthMePlayerListener implements Listener {
// Shedule login task so works after the prelogin // Shedule login task so works after the prelogin
// (Fix found by Koolaid5000) // (Fix found by Koolaid5000)
Bukkit.getScheduler().runTask(plugin, new Runnable(){ Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -681,6 +667,35 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
if (event.getPlayer() == null)
return;
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
if (Utils.getInstance().isUnrestricted(player)) {
return;
}
if (plugin.getCitizensCommunicator().isNPC(player)) {
return;
}
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
}
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInventoryOpen(InventoryOpenEvent event) { public void onPlayerInventoryOpen(InventoryOpenEvent event) {
if (event.getPlayer() == null) if (event.getPlayer() == null)