Fix Fly and GameMode

This commit is contained in:
Xephi59 2015-07-09 18:04:43 +02:00
parent 1b9f4e7141
commit 7a4550246f
10 changed files with 59 additions and 63 deletions

View File

@ -460,7 +460,7 @@ public class AuthMe extends JavaPlugin {
public void savePlayer(Player player)
throws IllegalStateException, NullPointerException {
try {
if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
if ((citizens.isNPC(player)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
return;
}
} catch (Exception e) {

View File

@ -67,25 +67,13 @@ public class API {
return PlayerCache.getInstance().isAuthenticated(player.getName());
}
/**
*
* @param player
* @return true if player is a npc
*/
@Deprecated
public boolean isaNPC(Player player) {
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
return true;
return CombatTagComunicator.isNPC(player);
}
/**
*
* @param player
* @return true if player is a npc
*/
public boolean isNPC(Player player) {
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return true;
return CombatTagComunicator.isNPC(player);
}

View File

@ -39,7 +39,7 @@ public class LimboCache {
boolean flying = false;
if (playerData.doesCacheExist(player)) {
StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
final StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
inv = event.getInventory();
@ -90,6 +90,9 @@ public class LimboCache {
player.sendMessage("Your inventory has been cleaned!");
}
}
if (gameMode == GameMode.CREATIVE) {
flying = false;
}
gameMode = GameMode.SURVIVAL;
}
if (player.isDead()) {

View File

@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent;
@ -44,7 +44,7 @@ public class AuthMeEntityListener implements Listener {
return;
}
if (instance.citizens.isNPC(entity, instance))
if (instance.citizens.isNPC(entity))
return;
Player player = (Player) entity;
@ -79,7 +79,7 @@ public class AuthMeEntityListener implements Listener {
return;
}
if (instance.citizens.isNPC(entity, instance))
if (instance.citizens.isNPC(entity))
return;
Player player = (Player) entity;
@ -137,7 +137,7 @@ public class AuthMeEntityListener implements Listener {
return;
}
if (instance.citizens.isNPC(entity, instance))
if (instance.citizens.isNPC(entity))
return;
Player player = (Player) entity;
@ -168,7 +168,7 @@ public class AuthMeEntityListener implements Listener {
return;
}
if (instance.citizens.isNPC(entity, instance))
if (instance.citizens.isNPC(entity))
return;
Player player = (Player) entity;
@ -205,7 +205,7 @@ public class AuthMeEntityListener implements Listener {
return;
}
if (instance.citizens.isNPC(player, instance))
if (instance.citizens.isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
@ -237,7 +237,7 @@ public class AuthMeEntityListener implements Listener {
return;
}
if (instance.citizens.isNPC(player, instance))
if (instance.citizens.isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {

View File

@ -50,7 +50,6 @@ import fr.xephi.authme.settings.Settings;
public class AuthMePlayerListener implements Listener {
public static GameMode gm = GameMode.SURVIVAL;
public static ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<String, GameMode>();
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<String, String>();
private Messages m = Messages.getInstance();
@ -328,7 +327,7 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
@ -407,7 +406,7 @@ public class AuthMePlayerListener implements Listener {
final String name = player.getName().toLowerCase();
boolean isAuthAvailable = data.isAuthAvailable(name);
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
@ -616,7 +615,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(name)) {
@ -644,7 +643,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
@ -673,7 +672,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
@ -702,7 +701,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
@ -727,7 +726,7 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
@ -755,7 +754,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
@ -827,7 +826,7 @@ public class AuthMePlayerListener implements Listener {
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
return;
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(name))
@ -855,8 +854,6 @@ public class AuthMePlayerListener implements Listener {
return;
if (event.getPlayer() == null || event == null)
return;
if (!Settings.isForceSurvivalModeEnabled)
return;
Player player = event.getPlayer();
@ -868,7 +865,7 @@ public class AuthMePlayerListener implements Listener {
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
return;
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
if (plugin.getCitizensCommunicator().isNPC(player))
return;
if (PlayerCache.getInstance().isAuthenticated(name))
@ -880,6 +877,7 @@ public class AuthMePlayerListener implements Listener {
if (causeByAuthMe.containsKey(name) && causeByAuthMe.get(name))
return;
event.setCancelled(true);
}
}

View File

@ -13,7 +13,7 @@ public class CitizensCommunicator {
this.instance = instance;
}
public boolean isNPC(final Entity player, AuthMe instance) {
public boolean isNPC(final Entity player) {
if (!this.instance.isCitizensActive)
return false;
try {

View File

@ -53,7 +53,7 @@ public class AsyncronousJoin {
AuthMePlayerListener.gameMode.put(name, player.getGameMode());
BukkitScheduler sched = plugin.getServer().getScheduler();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
@ -216,7 +216,7 @@ public class AsyncronousJoin {
public void run() {
if (player.isOp())
player.setOp(false);
if (!Settings.isMovementAllowed) {
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(true);
player.setFlying(true);
}

View File

@ -10,7 +10,6 @@ import org.bukkit.potion.PotionEffectType;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import fr.xephi.authme.Utils.groupType;
import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.backup.FileCache;
import fr.xephi.authme.cache.limbo.LimboCache;
@ -53,8 +52,13 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
protected void restoreOpState() {
player.setOp(limbo.getOperator());
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
if (limbo.getGameMode() != GameMode.CREATIVE) {
player.setAllowFlight(limbo.isFlying());
player.setFlying(limbo.isFlying());
} else {
player.setAllowFlight(false);
player.setFlying(false);
}
}
}
@ -120,8 +124,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
* ProtectInventoryEvent after Teleporting Also it's the current
* world inventory !
*/
if (!Settings.forceOnlyAfterLogin) {
player.setGameMode(limbo.getGameMode());
if (!Settings.forceOnlyAfterLogin) {
// Inventory - Make it after restore GameMode , cause we need to
// restore the
// right inventory in the right gamemode
@ -146,7 +150,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
} else {
teleportBackFromSpawn();
}
} else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
} else
if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
teleportToSpawn();
} else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
packQuitLocation();

View File

@ -51,8 +51,10 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
player.setOp(false);
if (!Settings.isMovementAllowed) {
player.setAllowFlight(true);
player.setFlying(true);
}
// Player is now logout... Time to fire event !
sched.scheduleSyncDelayedTask(plugin, new Runnable() {

View File

@ -45,7 +45,7 @@ public class AsyncronousQuit {
public void process() {
final Player player = p;
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}