mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +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 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<CommandSender, Boolean> superadminCache = new HashMap<CommandSender, Boolean>();
|
private final Map<CommandSender, Boolean> superadminCache = new HashMap<CommandSender, Boolean>();
|
||||||
|
private Long cacheLastCleared = null;
|
||||||
private World adminWorld = null;
|
private World adminWorld = null;
|
||||||
|
|
||||||
private TFM_AdminWorld()
|
private TFM_AdminWorld()
|
||||||
@ -33,10 +34,7 @@ public class TFM_AdminWorld
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adminWorld == null || !Bukkit.getWorlds().contains(adminWorld))
|
loadAdminWorld();
|
||||||
{
|
|
||||||
generateWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
player.teleport(adminWorld.getSpawnLocation());
|
player.teleport(adminWorld.getSpawnLocation());
|
||||||
}
|
}
|
||||||
@ -48,7 +46,7 @@ public class TFM_AdminWorld
|
|||||||
if (event.getTo().getWorld() == adminWorld)
|
if (event.getTo().getWorld() == adminWorld)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (!isUserSuperadmin(player))
|
if (!cachedIsUserSuperadmin(player))
|
||||||
{
|
{
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@ -66,8 +64,23 @@ public class TFM_AdminWorld
|
|||||||
return true;
|
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);
|
Boolean cached = superadminCache.get(user);
|
||||||
if (cached == null)
|
if (cached == null)
|
||||||
{
|
{
|
||||||
|
@ -83,6 +83,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
TFM_Util.generateFlatlands(flatlandsGenerationParams);
|
TFM_Util.generateFlatlands(flatlandsGenerationParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TFM_AdminWorld.getInstance().loadAdminWorld();
|
||||||
|
|
||||||
if (disableWeather)
|
if (disableWeather)
|
||||||
{
|
{
|
||||||
for (World world : server.getWorlds())
|
for (World world : server.getWorlds())
|
||||||
|
Loading…
Reference in New Issue
Block a user