mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Finished adminworld, still needs testing.
This commit is contained in:
parent
bea480c1f1
commit
074630f720
@ -43,14 +43,17 @@ dist.jar=${dist.dir}/TotalFreedomMod.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.DisguiseCraft.jar=../_libs/DisguiseCraft.jar
|
||||
file.reference.minecraft_server.jar=../_libs/minecraft_server.jar
|
||||
file.reference.worldedit-5.5.8-SNAPSHOT.jar=../_libs/worldedit-5.5.8-SNAPSHOT.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=false
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${libs.CraftBukkit.classpath}:\
|
||||
${libs.WorldEdit.classpath}:\
|
||||
${libs.DisguiseCraft.classpath}
|
||||
${file.reference.DisguiseCraft.jar}:\
|
||||
${file.reference.minecraft_server.jar}:\
|
||||
${file.reference.worldedit-5.5.8-SNAPSHOT.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
||||
javac.deprecation=false
|
||||
|
@ -216,6 +216,11 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (!TFM_AdminWorld.getInstance().validateMovement(event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = event.getPlayer();
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
|
||||
@ -442,7 +447,8 @@ public class TFM_PlayerListener implements Listener
|
||||
event.setMessage(message);
|
||||
|
||||
// Set the tag
|
||||
if (playerdata.getTag() != null) {
|
||||
if (playerdata.getTag() != null)
|
||||
{
|
||||
p.setDisplayName((playerdata.getTag() + " " + p.getDisplayName().replaceAll(" ", "")));
|
||||
}
|
||||
|
||||
@ -645,10 +651,4 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
TFM_ServerInterface.handlePlayerLogin(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
TFM_AdminWorld.getInstance().validateTeleport(event);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,25 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
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 World adminWorld = null;
|
||||
|
||||
private TFM_AdminWorld()
|
||||
@ -35,21 +41,41 @@ public class TFM_AdminWorld
|
||||
player.teleport(adminWorld.getSpawnLocation());
|
||||
}
|
||||
|
||||
public void validateTeleport(PlayerTeleportEvent event)
|
||||
public boolean validateMovement(PlayerMoveEvent event)
|
||||
{
|
||||
if (adminWorld == null)
|
||||
if (adminWorld != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getTo().getWorld() == adminWorld)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(event.getPlayer()))
|
||||
final Player player = event.getPlayer();
|
||||
if (!isUserSuperadmin(player))
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 20L);
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isUserSuperadmin(CommandSender user)
|
||||
{
|
||||
Boolean cached = superadminCache.get(user);
|
||||
if (cached == null)
|
||||
{
|
||||
cached = TFM_SuperadminList.isUserSuperadmin(user);
|
||||
superadminCache.put(user, cached);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
private void generateWorld()
|
||||
{
|
||||
@ -67,10 +93,11 @@ public class TFM_AdminWorld
|
||||
Block welcomeSignBlock = adminWorld.getBlockAt(0, 50, 0);
|
||||
welcomeSignBlock.setType(Material.SIGN_POST);
|
||||
Sign welcomeSign = (Sign) welcomeSignBlock.getState();
|
||||
welcomeSign.setLine(0, "AdminWorld");
|
||||
welcomeSign.setLine(1, "");
|
||||
welcomeSign.setLine(2, "");
|
||||
welcomeSign.setLine(3, "");
|
||||
welcomeSign.setLine(0, ChatColor.GREEN + "AdminWorld");
|
||||
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
|
||||
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.update();
|
||||
|
||||
TFM_GameRuleHandler.commitGameRules();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user