Fixed opping & deopping players even when it's not needed

This commit is contained in:
isokissa3 2017-07-23 00:29:57 +03:00
parent 92216b055e
commit 0a15fa5dff
4 changed files with 41 additions and 30 deletions

View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.goldtreeservers</groupId>
<artifactId>worldguardextraflags</artifactId>
<version>2.14</version>
<version>2.14.1</version>
<name>WorldGuardExtraFlags</name>
<build>
<finalName>WorldGuardExtraFlagsPlugin</finalName>

View file

@ -45,29 +45,35 @@ public class CommandOnEntryFlag extends Handler
{
Collection<Set<String>> commands = toSet.queryAllValues(WorldGuardUtils.wrapPlayer(player), FlagUtils.COMMAND_ON_ENTRY);
boolean isOp = player.isOp();
try
for(Set<String> commands_ : commands)
{
player.setOp(true);
for(Set<String> commands_ : commands)
if (!this.lastCommands.contains(commands_))
{
if (!this.lastCommands.contains(commands_))
boolean isOp = player.isOp();
try
{
if (!isOp)
{
player.setOp(true);
}
for(String command : commands_)
{
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
}
break;
}
finally
{
if (!isOp)
{
player.setOp(isOp);
}
}
break;
}
}
finally
{
player.setOp(isOp);
}
this.lastCommands = new ArrayList<Set<String>>(commands);

View file

@ -63,29 +63,35 @@ public class CommandOnExitFlag extends Handler
}
}
boolean isOp = player.isOp();
try
for(Set<String> commands_ : commands)
{
player.setOp(true);
for(Set<String> commands_ : commands)
if (!this.lastCommands.contains(commands_))
{
if (!this.lastCommands.contains(commands_))
boolean isOp = player.isOp();
try
{
if (!isOp)
{
player.setOp(true);
}
for(String command : commands_)
{
WorldGuardExtraFlagsPlugin.getPlugin().getServer().dispatchCommand(player, command.substring(1).replace("%username%", player.getName())); //TODO: Make this better
}
break;
}
finally
{
if (!isOp)
{
player.setOp(isOp);
}
}
break;
}
}
finally
{
player.setOp(isOp);
}
this.lastCommands = commands;
}

View file

@ -1,8 +1,7 @@
name: WorldGuardExtraFlags
version: 2.14
description: Add more flags to worldguard to help manage your server easily!
version: 2.14.1
description: Adds more flags to worldguard to help manage your server easily!
author: isokissa3
authors: [isokissa3]
website: https://goldtreevers.net
depend: [ WorldGuard ]
softdepend: [ MythicMobs, FastAsyncWorldEdit, Essentials ]