mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 20:57:35 +01:00
Merge pull request #84 from games647/gamemode
Remove gamemode and flying switching
This commit is contained in:
commit
da84efe090
@ -6,19 +6,16 @@ public class DataFileCache {
|
|||||||
|
|
||||||
private final String group;
|
private final String group;
|
||||||
private final boolean operator;
|
private final boolean operator;
|
||||||
private final boolean flying;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for DataFileCache.
|
* Constructor for DataFileCache.
|
||||||
*
|
*
|
||||||
* @param group String
|
* @param group String
|
||||||
* @param operator boolean
|
* @param operator boolean
|
||||||
* @param flying boolean
|
|
||||||
*/
|
*/
|
||||||
public DataFileCache(String group, boolean operator, boolean flying) {
|
public DataFileCache(String group, boolean operator) {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
this.flying = flying;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,13 +35,4 @@ public class DataFileCache {
|
|||||||
public boolean getOperator() {
|
public boolean getOperator() {
|
||||||
return operator;
|
return operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method isFlying.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean isFlying() {
|
|
||||||
return flying;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,6 @@ public class JsonCache {
|
|||||||
JsonElement e;
|
JsonElement e;
|
||||||
String group = null;
|
String group = null;
|
||||||
boolean operator = false;
|
boolean operator = false;
|
||||||
boolean flying = false;
|
|
||||||
|
|
||||||
if ((e = jsonObject.get("group")) != null) {
|
if ((e = jsonObject.get("group")) != null) {
|
||||||
group = e.getAsString();
|
group = e.getAsString();
|
||||||
@ -162,11 +161,8 @@ public class JsonCache {
|
|||||||
if ((e = jsonObject.get("operator")) != null) {
|
if ((e = jsonObject.get("operator")) != null) {
|
||||||
operator = e.getAsBoolean();
|
operator = e.getAsBoolean();
|
||||||
}
|
}
|
||||||
if ((e = jsonObject.get("flying")) != null) {
|
|
||||||
flying = e.getAsBoolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new DataFileCache(group, operator, flying);
|
return new DataFileCache(group, operator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +183,6 @@ public class JsonCache {
|
|||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
jsonObject.addProperty("group", dataFileCache.getGroup());
|
jsonObject.addProperty("group", dataFileCache.getGroup());
|
||||||
jsonObject.addProperty("operator", dataFileCache.getOperator());
|
jsonObject.addProperty("operator", dataFileCache.getOperator());
|
||||||
jsonObject.addProperty("flying", dataFileCache.isFlying());
|
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.backup.DataFileCache;
|
import fr.xephi.authme.cache.backup.DataFileCache;
|
||||||
import fr.xephi.authme.cache.backup.JsonCache;
|
import fr.xephi.authme.cache.backup.JsonCache;
|
||||||
import fr.xephi.authme.events.ResetInventoryEvent;
|
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.Settings;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -56,10 +52,8 @@ public class LimboCache {
|
|||||||
public void addLimboPlayer(Player player) {
|
public void addLimboPlayer(Player player) {
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
GameMode gameMode = player.getGameMode();
|
|
||||||
boolean operator = false;
|
boolean operator = false;
|
||||||
String playerGroup = "";
|
String playerGroup = "";
|
||||||
boolean flying = false;
|
|
||||||
|
|
||||||
// Get the permissions manager, and make sure it's valid
|
// Get the permissions manager, and make sure it's valid
|
||||||
PermissionsManager permsMan = this.plugin.getPermissionsManager();
|
PermissionsManager permsMan = this.plugin.getPermissionsManager();
|
||||||
@ -72,35 +66,20 @@ public class LimboCache {
|
|||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
playerGroup = cache.getGroup();
|
playerGroup = cache.getGroup();
|
||||||
operator = cache.getOperator();
|
operator = cache.getOperator();
|
||||||
flying = cache.isFlying();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
operator = player.isOp();
|
operator = player.isOp();
|
||||||
flying = player.isFlying();
|
|
||||||
|
|
||||||
// Check whether groups are supported
|
// Check whether groups are supported
|
||||||
if (permsMan.hasGroupSupport())
|
if (permsMan.hasGroupSupport())
|
||||||
playerGroup = permsMan.getPrimaryGroup(player);
|
playerGroup = permsMan.getPrimaryGroup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.isForceSurvivalModeEnabled) {
|
|
||||||
if (Settings.isResetInventoryIfCreative && gameMode == GameMode.CREATIVE) {
|
|
||||||
ResetInventoryEvent event = new ResetInventoryEvent(player);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
player.getInventory().clear();
|
|
||||||
player.sendMessage("Your inventory has been cleaned!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (gameMode == GameMode.CREATIVE) {
|
|
||||||
flying = false;
|
|
||||||
}
|
|
||||||
gameMode = GameMode.SURVIVAL;
|
|
||||||
}
|
|
||||||
if (player.isDead()) {
|
if (player.isDead()) {
|
||||||
loc = plugin.getSpawnLocation(player);
|
loc = plugin.getSpawnLocation(player);
|
||||||
}
|
}
|
||||||
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
|
|
||||||
|
cache.put(name, new LimboPlayer(name, loc, operator, playerGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.xephi.authme.cache.limbo;
|
package fr.xephi.authme.cache.limbo;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -12,29 +11,23 @@ public class LimboPlayer {
|
|||||||
private Location loc = null;
|
private Location loc = null;
|
||||||
private BukkitTask timeoutTaskId = null;
|
private BukkitTask timeoutTaskId = null;
|
||||||
private BukkitTask messageTaskId = null;
|
private BukkitTask messageTaskId = null;
|
||||||
private GameMode gameMode = GameMode.SURVIVAL;
|
|
||||||
private boolean operator = false;
|
private boolean operator = false;
|
||||||
private String group = "";
|
private String group = "";
|
||||||
private boolean flying = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for LimboPlayer.
|
* Constructor for LimboPlayer.
|
||||||
*
|
*
|
||||||
* @param name String
|
* @param name String
|
||||||
* @param loc Location
|
* @param loc Location
|
||||||
* @param gameMode GameMode
|
|
||||||
* @param operator boolean
|
* @param operator boolean
|
||||||
* @param group String
|
* @param group String
|
||||||
* @param flying boolean
|
|
||||||
*/
|
*/
|
||||||
public LimboPlayer(String name, Location loc, GameMode gameMode,
|
public LimboPlayer(String name, Location loc,
|
||||||
boolean operator, String group, boolean flying) {
|
boolean operator, String group) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
this.gameMode = gameMode;
|
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.flying = flying;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,15 +59,6 @@ public class LimboPlayer {
|
|||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method getGameMode.
|
|
||||||
*
|
|
||||||
* @return GameMode
|
|
||||||
*/
|
|
||||||
public GameMode getGameMode() {
|
|
||||||
return gameMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method getOperator.
|
* Method getOperator.
|
||||||
*
|
*
|
||||||
@ -149,13 +133,4 @@ public class LimboPlayer {
|
|||||||
}
|
}
|
||||||
timeoutTaskId = null;
|
timeoutTaskId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method isFlying.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean isFlying() {
|
|
||||||
return flying;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import fr.xephi.authme.util.GeoLiteAPI;
|
|||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -35,7 +34,6 @@ import org.bukkit.event.player.PlayerBedEnterEvent;
|
|||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
@ -57,7 +55,6 @@ import static fr.xephi.authme.listener.ListenerService.shouldCancelEvent;
|
|||||||
*/
|
*/
|
||||||
public class AuthMePlayerListener implements Listener {
|
public class AuthMePlayerListener implements Listener {
|
||||||
|
|
||||||
public static final ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<>();
|
|
||||||
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||||
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||||
public final AuthMe plugin;
|
public final AuthMe plugin;
|
||||||
@ -493,25 +490,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
|
||||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
|
||||||
if (!shouldCancelEvent(event)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String name = player.getName().toLowerCase();
|
|
||||||
if (causeByAuthMe.containsKey(name)) {
|
|
||||||
causeByAuthMe.remove(name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
public void onPlayerShear(PlayerShearEntityEvent event) {
|
public void onPlayerShear(PlayerShearEntityEvent event) {
|
||||||
if (shouldCancelEvent(event)) {
|
if (shouldCancelEvent(event)) {
|
||||||
|
@ -20,7 +20,6 @@ import fr.xephi.authme.task.TimeoutTask;
|
|||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import fr.xephi.authme.util.Utils.GroupType;
|
import fr.xephi.authme.util.Utils.GroupType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -54,26 +53,21 @@ public class AsynchronousJoin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthMePlayerListener.gameMode.put(name, player.getGameMode());
|
|
||||||
|
|
||||||
if (plugin.ess != null && Settings.disableSocialSpy) {
|
if (plugin.ess != null && Settings.disableSocialSpy) {
|
||||||
plugin.ess.getUser(player).setSocialSpyEnabled(false);
|
plugin.ess.getUser(player).setSocialSpyEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String ip = plugin.getIP(player);
|
final String ip = plugin.getIP(player);
|
||||||
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
|
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
|
||||||
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
|
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
|
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
|
||||||
player.setGameMode(gM);
|
|
||||||
player.kickPlayer("You are not the Owner of this account, please try another name!");
|
player.kickPlayer("You are not the Owner of this account, please try another name!");
|
||||||
if (Settings.banUnsafeIp)
|
if (Settings.banUnsafeIp)
|
||||||
plugin.getServer().banIP(ip);
|
plugin.getServer().banIP(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -96,18 +90,6 @@ public class AsynchronousJoin {
|
|||||||
final Location spawnLoc = plugin.getSpawnLocation(player);
|
final Location spawnLoc = plugin.getSpawnLocation(player);
|
||||||
final boolean isAuthAvailable = database.isAuthAvailable(name);
|
final boolean isAuthAvailable = database.isAuthAvailable(name);
|
||||||
if (isAuthAvailable) {
|
if (isAuthAvailable) {
|
||||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
|
|
||||||
Utils.forceGM(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Settings.noTeleport) {
|
if (!Settings.noTeleport) {
|
||||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
@ -145,17 +127,6 @@ public class AsynchronousJoin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
|
|
||||||
Utils.forceGM(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!Settings.unRegisteredGroup.isEmpty()) {
|
if (!Settings.unRegisteredGroup.isEmpty()) {
|
||||||
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
|
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
|
||||||
}
|
}
|
||||||
@ -197,10 +168,6 @@ public class AsynchronousJoin {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
if (!Settings.isMovementAllowed) {
|
|
||||||
player.setAllowFlight(true);
|
|
||||||
player.setFlying(true);
|
|
||||||
}
|
|
||||||
if (Settings.isRemoveSpeedEnabled) {
|
if (Settings.isRemoveSpeedEnabled) {
|
||||||
player.setFlySpeed(0.0f);
|
player.setFlySpeed(0.0f);
|
||||||
player.setWalkSpeed(0.0f);
|
player.setWalkSpeed(0.0f);
|
||||||
|
@ -7,7 +7,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
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.AuthMeAsyncPreLoginEvent;
|
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
@ -204,9 +203,6 @@ public class AsynchronousLogin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (AuthMePlayerListener.gameMode != null && AuthMePlayerListener.gameMode.containsKey(name)) {
|
|
||||||
player.setGameMode(AuthMePlayerListener.gameMode.get(name));
|
|
||||||
}
|
|
||||||
player.kickPlayer(m.retrieveSingle(MessageKey.WRONG_PASSWORD));
|
player.kickPlayer(m.retrieveSingle(MessageKey.WRONG_PASSWORD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -67,16 +67,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
player.setOp(limbo.getOperator());
|
player.setOp(limbo.getOperator());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void restoreFlyghtState() {
|
|
||||||
if (Settings.isForceSurvivalModeEnabled) {
|
|
||||||
player.setAllowFlight(false);
|
|
||||||
player.setFlying(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.setAllowFlight(limbo.isFlying());
|
|
||||||
player.setFlying(limbo.isFlying());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void packQuitLocation() {
|
protected void packQuitLocation() {
|
||||||
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
||||||
}
|
}
|
||||||
@ -160,13 +150,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.isForceSurvivalModeEnabled && Settings.forceOnlyAfterLogin) {
|
|
||||||
Utils.forceGM(player);
|
|
||||||
} else {
|
|
||||||
player.setGameMode(limbo.getGameMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
restoreFlyghtState();
|
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||||
restoreInventory();
|
restoreInventory();
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,6 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
if (Settings.applyBlindEffect)
|
if (Settings.applyBlindEffect)
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
if (!Settings.isMovementAllowed) {
|
|
||||||
player.setAllowFlight(true);
|
|
||||||
player.setFlying(true);
|
|
||||||
}
|
|
||||||
// Player is now logout... Time to fire event !
|
// Player is now logout... Time to fire event !
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||||
if (Settings.bungee)
|
if (Settings.bungee)
|
||||||
|
@ -6,7 +6,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -23,7 +22,6 @@ public class AsynchronousQuit {
|
|||||||
protected final Player player;
|
protected final Player player;
|
||||||
private final String name;
|
private final String name;
|
||||||
private boolean isOp = false;
|
private boolean isOp = false;
|
||||||
private boolean isFlying = false;
|
|
||||||
private boolean needToChange = false;
|
private boolean needToChange = false;
|
||||||
private boolean isKick = false;
|
private boolean isKick = false;
|
||||||
|
|
||||||
@ -69,7 +67,6 @@ public class AsynchronousQuit {
|
|||||||
Utils.addNormal(player, limbo.getGroup());
|
Utils.addNormal(player, limbo.getGroup());
|
||||||
needToChange = true;
|
needToChange = true;
|
||||||
isOp = limbo.getOperator();
|
isOp = limbo.getOperator();
|
||||||
isFlying = limbo.isFlying();
|
|
||||||
if (limbo.getTimeoutTaskId() != null)
|
if (limbo.getTimeoutTaskId() != null)
|
||||||
limbo.getTimeoutTaskId().cancel();
|
limbo.getTimeoutTaskId().cancel();
|
||||||
if (limbo.getMessageTaskId() != null)
|
if (limbo.getMessageTaskId() != null)
|
||||||
@ -96,7 +93,6 @@ public class AsynchronousQuit {
|
|||||||
database.setUnlogged(name);
|
database.setUnlogged(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthMePlayerListener.gameMode.remove(name);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, isFlying, needToChange));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package fr.xephi.authme.process.quit;
|
package fr.xephi.authme.process.quit;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.settings.Settings;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +10,6 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
|||||||
protected final AuthMe plugin;
|
protected final AuthMe plugin;
|
||||||
protected final Player player;
|
protected final Player player;
|
||||||
protected final boolean isOp;
|
protected final boolean isOp;
|
||||||
protected final boolean isFlying;
|
|
||||||
protected final boolean needToChange;
|
protected final boolean needToChange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,16 +18,13 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
|||||||
* @param plugin AuthMe
|
* @param plugin AuthMe
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @param isOp boolean
|
* @param isOp boolean
|
||||||
* @param isFlying boolean
|
|
||||||
* @param needToChange boolean
|
* @param needToChange boolean
|
||||||
*/
|
*/
|
||||||
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
|
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
|
||||||
, boolean isOp, boolean isFlying
|
, boolean isOp, boolean needToChange) {
|
||||||
, boolean needToChange) {
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.isOp = isOp;
|
this.isOp = isOp;
|
||||||
this.isFlying = isFlying;
|
|
||||||
this.needToChange = needToChange;
|
this.needToChange = needToChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,13 +35,8 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
if (needToChange) {
|
if (needToChange) {
|
||||||
player.setOp(isOp);
|
player.setOp(isOp);
|
||||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
|
||||||
player.setAllowFlight(isFlying);
|
|
||||||
player.setFlying(isFlying);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
|
@ -15,7 +15,6 @@ import fr.xephi.authme.task.MessageTask;
|
|||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
@ -96,7 +95,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
player.setGameMode(limbo.getGameMode());
|
|
||||||
Utils.teleportToSpawn(player);
|
Utils.teleportToSpawn(player);
|
||||||
|
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
||||||
@ -119,10 +117,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
|||||||
if (!Settings.getmailAccount.isEmpty()) {
|
if (!Settings.getmailAccount.isEmpty()) {
|
||||||
m.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
m.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
||||||
}
|
}
|
||||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
|
||||||
player.setAllowFlight(false);
|
|
||||||
player.setFlying(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.applyBlindEffect) {
|
if (Settings.applyBlindEffect) {
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||||
|
@ -65,15 +65,15 @@ public final class Settings {
|
|||||||
isSessionsEnabled, isAllowRestrictedIp,
|
isSessionsEnabled, isAllowRestrictedIp,
|
||||||
isMovementAllowed, isKickNonRegisteredEnabled,
|
isMovementAllowed, isKickNonRegisteredEnabled,
|
||||||
isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled,
|
isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled,
|
||||||
isSaveQuitLocationEnabled, isForceSurvivalModeEnabled,
|
isSaveQuitLocationEnabled,
|
||||||
isResetInventoryIfCreative, isCachingEnabled,
|
isCachingEnabled,
|
||||||
isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
|
isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
|
||||||
protectInventoryBeforeLogInEnabled, isBackupActivated,
|
protectInventoryBeforeLogInEnabled, isBackupActivated,
|
||||||
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
|
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
|
||||||
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
||||||
useCaptcha, emailRegistration, multiverse, bungee,
|
useCaptcha, emailRegistration, multiverse, bungee,
|
||||||
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
||||||
disableSocialSpy, forceOnlyAfterLogin, useEssentialsMotd, usePurge,
|
disableSocialSpy, useEssentialsMotd, usePurge,
|
||||||
purgePlayerDat, purgeEssentialsFile, supportOldPassword,
|
purgePlayerDat, purgeEssentialsFile, supportOldPassword,
|
||||||
purgeLimitedCreative, purgeAntiXray, purgePermissions,
|
purgeLimitedCreative, purgeAntiXray, purgePermissions,
|
||||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||||
@ -168,8 +168,6 @@ public final class Settings {
|
|||||||
isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true);
|
isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true);
|
||||||
isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
|
isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
|
||||||
isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
|
isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
|
||||||
isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
|
|
||||||
isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative", false);
|
|
||||||
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
|
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
|
||||||
getPasswordHash = getPasswordHash();
|
getPasswordHash = getPasswordHash();
|
||||||
getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
|
getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
|
||||||
@ -255,7 +253,6 @@ public final class Settings {
|
|||||||
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
||||||
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
||||||
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
||||||
forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
|
|
||||||
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
||||||
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
|
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
|
||||||
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
|
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
|
||||||
|
@ -7,10 +7,9 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -195,17 +194,6 @@ public final class Utils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Force the game mode of a player.
|
|
||||||
*
|
|
||||||
* @param player the player to modify.
|
|
||||||
*/
|
|
||||||
public static void forceGM(Player player) {
|
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) {
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safe way to retrieve the list of online players from the server. Depending on the
|
* Safe way to retrieve the list of online players from the server. Depending on the
|
||||||
* implementation of the server, either an array of {@link Player} instances is being returned,
|
* implementation of the server, either an array of {@link Player} instances is being returned,
|
||||||
|
@ -152,14 +152,6 @@ settings:
|
|||||||
noTeleport: false
|
noTeleport: false
|
||||||
# Regex syntax for allowed Chars in passwords.
|
# Regex syntax for allowed Chars in passwords.
|
||||||
allowedPasswordCharacters: '[\x21-\x7E]*'
|
allowedPasswordCharacters: '[\x21-\x7E]*'
|
||||||
GameMode:
|
|
||||||
# ForceSurvivalMode to player when join ?
|
|
||||||
ForceSurvivalMode: false
|
|
||||||
# if player join with CreativeMode and ForceSurvivalMode: true
|
|
||||||
# inventory will be wipped
|
|
||||||
ResetInventoryIfCreative: false
|
|
||||||
# Do we need to force the survival mode ONLY after /login process?
|
|
||||||
ForceOnlyAfterLogin: false
|
|
||||||
security:
|
security:
|
||||||
# minimum Length of password
|
# minimum Length of password
|
||||||
minPasswordLength: 5
|
minPasswordLength: 5
|
||||||
|
@ -3,9 +3,8 @@ package fr.xephi.authme.util;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ReflectionTestUtils;
|
import fr.xephi.authme.ReflectionTestUtils;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
@ -50,35 +49,6 @@ public class UtilsTest {
|
|||||||
when(authMeMock.getPermissionsManager()).thenReturn(permissionsManagerMock);
|
when(authMeMock.getPermissionsManager()).thenReturn(permissionsManagerMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldForceSurvivalGameMode() {
|
|
||||||
// given
|
|
||||||
Player player = mock(Player.class);
|
|
||||||
given(permissionsManagerMock.hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)).willReturn(false);
|
|
||||||
|
|
||||||
// when
|
|
||||||
Utils.forceGM(player);
|
|
||||||
|
|
||||||
// then
|
|
||||||
verify(authMeMock).getPermissionsManager();
|
|
||||||
verify(player).setGameMode(GameMode.SURVIVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldNotForceGameModeForUserWithBypassPermission() {
|
|
||||||
// given
|
|
||||||
Player player = mock(Player.class);
|
|
||||||
given(permissionsManagerMock.hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)).willReturn(true);
|
|
||||||
|
|
||||||
// when
|
|
||||||
Utils.forceGM(player);
|
|
||||||
|
|
||||||
// then
|
|
||||||
verify(authMeMock).getPermissionsManager();
|
|
||||||
verify(permissionsManagerMock).hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL);
|
|
||||||
verify(player, never()).setGameMode(any(GameMode.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldNotAddToNormalGroupIfPermissionsAreDisabled() {
|
public void shouldNotAddToNormalGroupIfPermissionsAreDisabled() {
|
||||||
// given
|
// given
|
||||||
|
Loading…
Reference in New Issue
Block a user