Refactor OpenCommand
This commit is contained in:
parent
e4ecb9919c
commit
582ada4657
|
@ -63,6 +63,16 @@ public class OpenCommand extends MinepacksCommand
|
|||
}
|
||||
Player player = (Player) sender;
|
||||
if(args.length == 0)
|
||||
{
|
||||
executeSelf(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
executeOther(player, args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void executeSelf(Player player)
|
||||
{
|
||||
if(getMinepacksPlugin().isPlayerGameModeAllowed(player))
|
||||
{
|
||||
|
@ -72,7 +82,7 @@ public class OpenCommand extends MinepacksCommand
|
|||
if(cd > 0)
|
||||
{
|
||||
TimeSpan ts = TimeSpan.fromMilliseconds(cd);
|
||||
messageCooldown.send(sender, cd / 1000f, ts.toString());
|
||||
messageCooldown.send(player, cd / 1000f, ts.toString());
|
||||
return;
|
||||
}
|
||||
plugin.getCooldownManager().setCooldown(player);
|
||||
|
@ -84,15 +94,16 @@ public class OpenCommand extends MinepacksCommand
|
|||
messageWrongGameMode.send(player, player.getGameMode());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
void executeOther(Player player, String name)
|
||||
{
|
||||
if(player.hasPermission(Permissions.OTHERS))
|
||||
{
|
||||
OfflinePlayer target = Bukkit.getPlayer(args[0]);
|
||||
OfflinePlayer target = Bukkit.getPlayer(name);
|
||||
if(target == null)
|
||||
{
|
||||
//noinspection deprecation
|
||||
target = Bukkit.getOfflinePlayer(args[0]);
|
||||
target = Bukkit.getOfflinePlayer(name);
|
||||
}
|
||||
plugin.openBackpack(player, target, player.hasPermission(Permissions.OTHERS_EDIT));
|
||||
}
|
||||
|
@ -101,7 +112,6 @@ public class OpenCommand extends MinepacksCommand
|
|||
plugin.messageNoPermission.send(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleOpenFromConsole(final @NotNull CommandSender sender, final @NotNull String[] names)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue