mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-27 20:27:37 +00:00
AdminWorld tweaks.
This commit is contained in:
parent
0f6b053727
commit
eb4622fc28
@ -1,5 +1,5 @@
|
||||
#Mon, 12 Aug 2013 21:33:34 +0200
|
||||
#Mon, 12 Aug 2013 21:30:50 -0400
|
||||
|
||||
program.VERSION=2.22
|
||||
program.BUILDNUM=411
|
||||
program.BUILDDATE=08/12/2013 09\:33 PM
|
||||
program.BUILDNUM=426
|
||||
program.BUILDDATE=08/12/2013 09\:30 PM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Mon Aug 12 21:33:34 CEST 2013
|
||||
build.number=412
|
||||
#Mon Aug 12 21:30:50 EDT 2013
|
||||
build.number=427
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>")
|
||||
public class Command_findip extends TFM_Command
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -19,7 +18,7 @@ public class Command_findip extends TFM_Command
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
final Player p;
|
||||
try
|
||||
{
|
||||
@ -30,10 +29,9 @@ public class Command_findip extends TFM_Command
|
||||
playerMsg(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
playerMsg("Player IPs: " + StringUtils.join(TFM_UserList.getInstance(TotalFreedomMod.plugin).getEntry(p).getIpAddresses(), ", "));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,9 +17,14 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TFM_AdminWorld
|
||||
{
|
||||
private static final long CACHE_CLEAR_FREQUENCY = 30L * 1000L; //30 seconds, milliseconds
|
||||
private static final long TP_COOLDOWN_TIME = 500L; //0.5 seconds, milliseconds
|
||||
private static final String GENERATION_PARAMETERS = "16,stone,32,dirt,1,grass";
|
||||
private static final String ADMINWORLD_NAME = "adminworld";
|
||||
//
|
||||
private final Map<Player, Long> teleportCooldown = new HashMap<Player, Long>();
|
||||
private final Map<CommandSender, Boolean> superadminCache = new HashMap<CommandSender, Boolean>();
|
||||
//
|
||||
private Long cacheLastCleared = null;
|
||||
private World adminWorld = null;
|
||||
|
||||
@ -34,9 +39,7 @@ public class TFM_AdminWorld
|
||||
return;
|
||||
}
|
||||
|
||||
loadAdminWorld();
|
||||
|
||||
player.teleport(adminWorld.getSpawnLocation());
|
||||
player.teleport(getAdminWorld().getSpawnLocation());
|
||||
}
|
||||
|
||||
public boolean validateMovement(PlayerMoveEvent event)
|
||||
@ -48,14 +51,21 @@ public class TFM_AdminWorld
|
||||
final Player player = event.getPlayer();
|
||||
if (!cachedIsUserSuperadmin(player))
|
||||
{
|
||||
new BukkitRunnable()
|
||||
Long lastTP = teleportCooldown.get(player);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (lastTP == null || lastTP.longValue() + TP_COOLDOWN_TIME <= currentTimeMillis)
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
teleportCooldown.put(player, currentTimeMillis);
|
||||
TFM_Util.bcastMsg(player.getName() + " attempted to access the AdminWorld.", ChatColor.RED);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 20L);
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 1L);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
@ -64,23 +74,26 @@ public class TFM_AdminWorld
|
||||
return true;
|
||||
}
|
||||
|
||||
public void loadAdminWorld()
|
||||
public World getAdminWorld()
|
||||
{
|
||||
if (adminWorld == null || !Bukkit.getWorlds().contains(adminWorld))
|
||||
{
|
||||
generateWorld();
|
||||
}
|
||||
|
||||
return adminWorld;
|
||||
}
|
||||
|
||||
public World getAdminWorld()
|
||||
public void wipeSuperadminCache()
|
||||
{
|
||||
return adminWorld;
|
||||
cacheLastCleared = System.currentTimeMillis();
|
||||
superadminCache.clear();
|
||||
}
|
||||
|
||||
private boolean cachedIsUserSuperadmin(CommandSender user)
|
||||
{
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (cacheLastCleared == null || cacheLastCleared.longValue() >= currentTimeMillis + (10L * 1000L)) // Wipe every 10 seconds.
|
||||
if (cacheLastCleared == null || cacheLastCleared.longValue() + CACHE_CLEAR_FREQUENCY <= currentTimeMillis)
|
||||
{
|
||||
cacheLastCleared = currentTimeMillis;
|
||||
superadminCache.clear();
|
||||
|
@ -121,6 +121,8 @@ public class TFM_SuperadminList
|
||||
superadminNames = TFM_Util.removeDuplicates(superadminNames);
|
||||
superadminIPs = TFM_Util.removeDuplicates(superadminIPs);
|
||||
seniorAdminNames = TFM_Util.removeDuplicates(seniorAdminNames);
|
||||
|
||||
TFM_AdminWorld.getInstance().wipeSuperadminCache();
|
||||
}
|
||||
|
||||
public static void saveSuperadminList()
|
||||
|
@ -84,7 +84,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_Util.generateFlatlands(flatlandsGenerationParams);
|
||||
}
|
||||
|
||||
TFM_AdminWorld.getInstance().loadAdminWorld();
|
||||
TFM_AdminWorld.getInstance().getAdminWorld();
|
||||
|
||||
if (disableWeather)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user