mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-26 02:27:50 +01:00
update to use the new vault API
This commit is contained in:
parent
b27079026b
commit
c94f9c5cdc
@ -16,7 +16,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class Utils {
|
||||
|
||||
@ -34,68 +33,58 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void setGroup(Player player, GroupType group) {
|
||||
setGroup(player.getName(), group);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setGroup(String player, GroupType group) {
|
||||
if (!Settings.isPermissionCheckEnabled)
|
||||
return;
|
||||
if (plugin.permission == null)
|
||||
return;
|
||||
String name = player;
|
||||
String currentGroup;
|
||||
try {
|
||||
World world = null;
|
||||
currentGroup = plugin.permission.getPrimaryGroup(world, name);
|
||||
currentGroup = plugin.permission.getPrimaryGroup(player);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
ConsoleLogger.showError("Your permission plugin (" + plugin.permission.getName() + ") doesn't support the Group system... unhook!");
|
||||
plugin.permission = null;
|
||||
return;
|
||||
}
|
||||
World world = null;
|
||||
switch (group) {
|
||||
case UNREGISTERED: {
|
||||
plugin.permission.playerRemoveGroup(world, name, currentGroup);
|
||||
plugin.permission.playerAddGroup(world, name, Settings.unRegisteredGroup);
|
||||
plugin.permission.playerRemoveGroup(player, currentGroup);
|
||||
plugin.permission.playerAddGroup(player, Settings.unRegisteredGroup);
|
||||
break;
|
||||
}
|
||||
case REGISTERED: {
|
||||
plugin.permission.playerRemoveGroup(world, name, currentGroup);
|
||||
plugin.permission.playerAddGroup(world, name, Settings.getRegisteredGroup);
|
||||
plugin.permission.playerRemoveGroup(player, currentGroup);
|
||||
plugin.permission.playerAddGroup(player, Settings.getRegisteredGroup);
|
||||
break;
|
||||
}
|
||||
case NOTLOGGEDIN: {
|
||||
if (!useGroupSystem())
|
||||
break;
|
||||
plugin.permission.playerRemoveGroup(world, name, currentGroup);
|
||||
plugin.permission.playerAddGroup(world, name, Settings.getUnloggedinGroup);
|
||||
plugin.permission.playerRemoveGroup(player, currentGroup);
|
||||
plugin.permission.playerAddGroup(player, Settings.getUnloggedinGroup);
|
||||
break;
|
||||
}
|
||||
case LOGGEDIN: {
|
||||
if (!useGroupSystem())
|
||||
break;
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name.toLowerCase());
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
if (limbo == null)
|
||||
break;
|
||||
String realGroup = limbo.getGroup();
|
||||
plugin.permission.playerRemoveGroup(world, name, currentGroup);
|
||||
plugin.permission.playerAddGroup(world, name, realGroup);
|
||||
plugin.permission.playerRemoveGroup(player, currentGroup);
|
||||
plugin.permission.playerAddGroup(player, realGroup);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static boolean addNormal(Player player, String group) {
|
||||
if (!useGroupSystem()) {
|
||||
return false;
|
||||
}
|
||||
if (plugin.permission == null)
|
||||
return false;
|
||||
World world = null;
|
||||
try {
|
||||
if (plugin.permission.playerRemoveGroup(world, player.getName().toString(), Settings.getUnloggedinGroup) && plugin.permission.playerAddGroup(world, player.getName().toString(), group)) {
|
||||
if (plugin.permission.playerRemoveGroup(player, Settings.getUnloggedinGroup) && plugin.permission.playerAddGroup(player, group)) {
|
||||
return true;
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
@ -106,12 +95,12 @@ public class Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void hasPermOnJoin(Player player) {
|
||||
// TODO: remove if not needed
|
||||
@SuppressWarnings("unused")
|
||||
public static void hasPermOnJoin(Player player) {
|
||||
if (plugin.permission == null)
|
||||
return;
|
||||
Iterator<String> iter = Settings.getJoinPermissions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String permission = iter.next();
|
||||
for (String permission : Settings.getJoinPermissions) {
|
||||
if (plugin.permission.playerHas(player, permission)) {
|
||||
plugin.permission.playerAddTransient(player, permission);
|
||||
}
|
||||
@ -127,7 +116,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void packCoords(double x, double y, double z, String w,
|
||||
final Player pl) {
|
||||
final Player pl) {
|
||||
World theWorld;
|
||||
if (w.equals("unavailableworld")) {
|
||||
theWorld = pl.getWorld();
|
||||
@ -158,7 +147,7 @@ public class Utils {
|
||||
* Used for force player GameMode
|
||||
*/
|
||||
public static void forceGM(Player player) {
|
||||
if (!AuthMe.getInstance().authmePermissible(player, "authme.bypassforcesurvival"))
|
||||
if (!plugin.authmePermissible(player, "authme.bypassforcesurvival"))
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
@ -178,7 +167,7 @@ public class Utils {
|
||||
return;
|
||||
}
|
||||
for (File target : files) {
|
||||
if(target.isDirectory()) {
|
||||
if (target.isDirectory()) {
|
||||
purgeDirectory(target);
|
||||
target.delete();
|
||||
} else {
|
||||
@ -210,8 +199,8 @@ public class Utils {
|
||||
try {
|
||||
if (player.hasMetadata("NPC")) {
|
||||
return true;
|
||||
} else if(plugin.combatTagPlus != null
|
||||
&& player instanceof Player
|
||||
} else if (plugin.combatTagPlus != null
|
||||
&& player instanceof Player
|
||||
&& plugin.combatTagPlus.getNpcPlayerHelper().isNpc((Player) player)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
@SuppressWarnings("deprecation")
|
||||
Player target = Bukkit.getPlayer(name);
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
Utils.setGroup(name, GroupType.UNREGISTERED);
|
||||
Utils.setGroup(target, GroupType.UNREGISTERED);
|
||||
if (target != null) {
|
||||
if (target.isOnline()) {
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||
|
@ -103,7 +103,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
for (String command : Settings.forceCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
for (String command : Settings.forceCommandsAsConsole) {
|
||||
@ -125,20 +125,13 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
* world inventory !
|
||||
*/
|
||||
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
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
restoreInventory();
|
||||
}
|
||||
} else {
|
||||
// Inventory - Make it before force the survival GameMode to
|
||||
// cancel all
|
||||
// inventory problem
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
restoreInventory();
|
||||
}
|
||||
// Inventory - Make it after restore GameMode , cause we need to
|
||||
// restore the
|
||||
// right inventory in the right gamemode
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
restoreInventory();
|
||||
}
|
||||
if (Settings.forceOnlyAfterLogin) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
|
@ -120,8 +120,8 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
player.setWalkSpeed(0.2f);
|
||||
player.setFlySpeed(0.1f);
|
||||
}
|
||||
// The Loginevent now fires (as intended) after everything is processed
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
// The LoginEvent now fires (as intended) after everything is processed
|
||||
plugin.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
@ -133,7 +133,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
// Request Login after Registation
|
||||
// Request Login after Registration
|
||||
if (Settings.forceRegLogin) {
|
||||
forceLogin(player);
|
||||
return;
|
||||
@ -143,7 +143,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
if (Settings.useWelcomeMessage)
|
||||
if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
|
||||
plugin.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
|
Loading…
Reference in New Issue
Block a user