mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Working on guestlist
This commit is contained in:
parent
e64fd42855
commit
ff4751941b
@ -1,7 +1,9 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_AdminWorld;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -87,6 +89,12 @@ public class Command_adminworld extends TFM_Command
|
||||
}
|
||||
else if (args.length == 3)
|
||||
{
|
||||
if (!(sender instanceof Player) || sender_p == null || !TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("add".equalsIgnoreCase(args[1]))
|
||||
{
|
||||
//add args[2]
|
||||
@ -102,6 +110,13 @@ public class Command_adminworld extends TFM_Command
|
||||
case TIME:
|
||||
{
|
||||
// /adminworld time <morning|noon|evening|night>
|
||||
|
||||
if (!(sender instanceof Player) || sender_p == null || !TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
//set time = args[1]
|
||||
@ -112,6 +127,13 @@ public class Command_adminworld extends TFM_Command
|
||||
case WEATHER:
|
||||
{
|
||||
// /adminworld weather <off|on|storm>
|
||||
|
||||
if (!(sender instanceof Player) || sender_p == null || !TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
//set weather = args[1]
|
||||
|
@ -21,6 +21,7 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
|
||||
private final Map<CommandSender, Boolean> accessCache = new HashMap<CommandSender, Boolean>();
|
||||
//
|
||||
private Long cacheLastCleared = null;
|
||||
private Map<Player, Player> guestList = new HashMap<Player, Player>();
|
||||
|
||||
private TFM_AdminWorld()
|
||||
{
|
||||
@ -69,6 +70,19 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
|
||||
return world;
|
||||
}
|
||||
|
||||
public void addGuest(Player guest, Player supervisor)
|
||||
{
|
||||
if (TFM_SuperadminList.isUserSuperadmin(supervisor))
|
||||
{
|
||||
guestList.put(guest, supervisor);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeGuest(Player guest)
|
||||
{
|
||||
guestList.remove(guest);
|
||||
}
|
||||
|
||||
public boolean validateMovement(PlayerMoveEvent event)
|
||||
{
|
||||
World world;
|
||||
@ -115,7 +129,7 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
|
||||
accessCache.clear();
|
||||
}
|
||||
|
||||
public boolean canAccessWorld(CommandSender user)
|
||||
public boolean canAccessWorld(Player player)
|
||||
{
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (cacheLastCleared == null || cacheLastCleared.longValue() + CACHE_CLEAR_FREQUENCY <= currentTimeMillis)
|
||||
@ -124,11 +138,17 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
|
||||
accessCache.clear();
|
||||
}
|
||||
|
||||
Boolean cached = accessCache.get(user);
|
||||
Boolean cached = accessCache.get(player);
|
||||
if (cached == null)
|
||||
{
|
||||
cached = TFM_SuperadminList.isUserSuperadmin(user);
|
||||
accessCache.put(user, cached);
|
||||
boolean canAccess = TFM_SuperadminList.isUserSuperadmin(player);
|
||||
if (!canAccess)
|
||||
{
|
||||
Player supervisor = guestList.get(player);
|
||||
canAccess = supervisor != null && supervisor.isOnline() && TFM_SuperadminList.isUserSuperadmin(supervisor);
|
||||
}
|
||||
cached = canAccess;
|
||||
accessCache.put(player, cached);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user