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