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