added WE permissions to event servers.

This commit is contained in:
Cheese 2015-03-16 14:10:58 +11:00
parent 4581f49948
commit a700b61613
2 changed files with 38 additions and 0 deletions

View File

@ -37,6 +37,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.managers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import mineplex.core.common.Rank;
@ -32,6 +33,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
public class GameHostManager implements Listener
{
@ -58,6 +60,8 @@ public class GameHostManager implements Listener
private boolean _isEventServer = false;
private HashMap<Player, Boolean> _permissionMap = new HashMap<Player, Boolean>();
public GameHostManager(ArcadeManager manager)
{
Manager = manager;
@ -144,11 +148,17 @@ public class GameHostManager implements Listener
_host = event.getPlayer();
_hostRank = Manager.GetClients().Get(_host).GetRank();
System.out.println("Game Host Joined.");
if (isEventServer())
worldeditPermissionSet(event.getPlayer(), true);
}
else if (isAdmin(event.getPlayer(), false))
{
System.out.println("Admin Joined.");
_onlineAdmins.add(event.getPlayer());
if (isEventServer())
worldeditPermissionSet(event.getPlayer(), true);
}
}
@ -162,10 +172,31 @@ public class GameHostManager implements Listener
{
System.out.println("Game Host Quit.");
_host = null;
if (isEventServer())
worldeditPermissionSet(event.getPlayer(), false);
}
else if (isAdmin(event.getPlayer(), false))
{
_onlineAdmins.remove(event.getPlayer());
if (isEventServer())
worldeditPermissionSet(event.getPlayer(), false);
}
}
public void worldeditPermissionSet(Player player, boolean hasPermission)
{
if (!_permissionMap.containsKey(player) || _permissionMap.get(player) != hasPermission)
{
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
{
player.addAttachment(plugin, "worldedit.*", hasPermission);
}
_permissionMap.put(player, hasPermission);
UtilPlayer.message(player, "World Edit Permissions: " + F.tf(hasPermission));
}
}
@ -431,6 +462,9 @@ public class GameHostManager implements Listener
_adminList.add(player.getName());
_onlineAdmins.add(player);
UtilPlayer.message(player, F.main("Server", "You were given admin privileges."));
if (isEventServer())
worldeditPermissionSet(player, true);
}
public void removeAdmin(String playerName)
@ -448,6 +482,9 @@ public class GameHostManager implements Listener
UtilPlayer.message(player, F.main("Server", "Your admin privileges were removed."));
player.setGameMode(GameMode.SURVIVAL);
if (isEventServer())
worldeditPermissionSet(player, false);
}
}