mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-29 04:57:37 +00:00
More AdminWorld tweaks.
This commit is contained in:
parent
699d366efb
commit
6a5306dd7a
@ -20,6 +20,7 @@ public class TFM_AdminWorld
|
||||
private static final String GENERATION_PARAMETERS = "16,stone,32,dirt,1,grass";
|
||||
private static final String ADMINWORLD_NAME = "adminworld";
|
||||
private final Map<CommandSender, Boolean> superadminCache = new HashMap<CommandSender, Boolean>();
|
||||
private Long cacheLastCleared = null;
|
||||
private World adminWorld = null;
|
||||
|
||||
private TFM_AdminWorld()
|
||||
@ -33,10 +34,7 @@ public class TFM_AdminWorld
|
||||
return;
|
||||
}
|
||||
|
||||
if (adminWorld == null || !Bukkit.getWorlds().contains(adminWorld))
|
||||
{
|
||||
generateWorld();
|
||||
}
|
||||
loadAdminWorld();
|
||||
|
||||
player.teleport(adminWorld.getSpawnLocation());
|
||||
}
|
||||
@ -48,7 +46,7 @@ public class TFM_AdminWorld
|
||||
if (event.getTo().getWorld() == adminWorld)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
if (!isUserSuperadmin(player))
|
||||
if (!cachedIsUserSuperadmin(player))
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@ -66,8 +64,23 @@ public class TFM_AdminWorld
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isUserSuperadmin(CommandSender user)
|
||||
public void loadAdminWorld()
|
||||
{
|
||||
if (adminWorld == null || !Bukkit.getWorlds().contains(adminWorld))
|
||||
{
|
||||
generateWorld();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cachedIsUserSuperadmin(CommandSender user)
|
||||
{
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (cacheLastCleared == null || cacheLastCleared.longValue() >= currentTimeMillis + (10L * 1000L)) // Wipe every 10 seconds.
|
||||
{
|
||||
cacheLastCleared = currentTimeMillis;
|
||||
superadminCache.clear();
|
||||
}
|
||||
|
||||
Boolean cached = superadminCache.get(user);
|
||||
if (cached == null)
|
||||
{
|
||||
|
@ -83,6 +83,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_Util.generateFlatlands(flatlandsGenerationParams);
|
||||
}
|
||||
|
||||
TFM_AdminWorld.getInstance().loadAdminWorld();
|
||||
|
||||
if (disableWeather)
|
||||
{
|
||||
for (World world : server.getWorlds())
|
||||
|
Loading…
Reference in New Issue
Block a user