diff --git a/src/bans.yml b/src/bans.yml
index 8692ffe3..5690d90e 100644
--- a/src/bans.yml
+++ b/src/bans.yml
@@ -1,13 +1,4 @@
#
-# TotalFreedomMod banning config
-# Warning: modification of this file is not recommended
+# TotalFreedomMod ban config
+# Warning: modifying this file is not recommended.
#
-# Format:
-# Ip: [IP-address / UUID]:[Last login name]:[Expiry unix timestamp (0 = never)][Banned by]:[Reason]
-#
-
-ips:
- - '192.168.1.254:Notch:Prozza:0:IP ban example'
-
-uuids:
- - '245d2f30-61fb-4840-9cd3-298b3920f4a4:Cobrex:Prozza:0:UUID ban example'
\ No newline at end of file
diff --git a/src/me/totalfreedom/totalfreedommod/AntiNuke.java b/src/me/totalfreedom/totalfreedommod/AntiNuke.java
new file mode 100644
index 00000000..80323b70
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/AntiNuke.java
@@ -0,0 +1,134 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
+
+public class AntiNuke extends AbstractService
+{
+ public AntiNuke(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onBlockBreak(BlockBreakEvent event)
+ {
+ if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
+ {
+ return;
+ }
+
+ final Player player = event.getPlayer();
+ final Location location = event.getBlock().getLocation();
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ final Location playerLocation = player.getLocation();
+
+ final double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
+
+ boolean outOfRange = false;
+ if (!playerLocation.getWorld().equals(location.getWorld()))
+ {
+ outOfRange = true;
+ }
+ else if (playerLocation.distanceSquared(location) > (nukeMonitorRange * nukeMonitorRange))
+ {
+ outOfRange = true;
+ }
+
+ if (outOfRange)
+ {
+ if (fPlayer.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
+ {
+ FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
+ FUtil.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
+
+ fPlayer.resetFreecamDestroyCount();
+
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
+ {
+ FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
+ FUtil.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
+
+ fPlayer.resetBlockDestroyCount();
+
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onBlockPlace(BlockPlaceEvent event)
+ {
+ if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
+ {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ Location blockLocation = event.getBlock().getLocation();
+ FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ Location playerLocation = player.getLocation();
+
+ double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
+
+ boolean outOfRange = false;
+ if (!playerLocation.getWorld().equals(blockLocation.getWorld()))
+ {
+ outOfRange = true;
+ }
+ else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange))
+ {
+ outOfRange = true;
+ }
+
+ if (outOfRange)
+ {
+ if (fPlayer.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
+ {
+ FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
+ FUtil.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
+
+ fPlayer.resetFreecamPlaceCount();
+
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
+ {
+ FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
+ FUtil.autoEject(player, "You are placing blocks too fast.");
+
+ fPlayer.resetBlockPlaceCount();
+
+ event.setCancelled(true);
+ }
+ }
+}
diff --git a/src/me/totalfreedom/totalfreedommod/AntiSpam.java b/src/me/totalfreedom/totalfreedommod/AntiSpam.java
new file mode 100644
index 00000000..e50cdbee
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/AntiSpam.java
@@ -0,0 +1,118 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.util.FSync;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.scheduler.BukkitTask;
+
+public class AntiSpam extends AbstractService
+{
+
+ public static final int MSG_PER_CYCLE = 8;
+ public static final int TICKS_PER_CYCLE = 2 * 10;
+ //
+ public BukkitTask cycleTask = null;
+
+ public AntiSpam(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ new BukkitRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ cycle();
+ }
+ }.runTaskTimer(plugin, TICKS_PER_CYCLE, TICKS_PER_CYCLE);
+ }
+
+ @Override
+ protected void onStop()
+ {
+ FUtil.cancel(cycleTask);
+ }
+
+ private void cycle()
+ {
+ for (Player player : server.getOnlinePlayers())
+ {
+ final FPlayer playerdata = plugin.pl.getPlayer(player);
+
+ // TODO: Move each to their own section
+ playerdata.resetMsgCount();
+ playerdata.resetBlockDestroyCount();
+ playerdata.resetBlockPlaceCount();
+ }
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
+ {
+ final Player player = event.getPlayer();
+ String message = event.getMessage().trim();
+
+ final FPlayer playerdata = plugin.pl.getPlayerSync(player);
+
+ // Check for spam
+ if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
+ {
+ FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
+ FSync.autoEject(player, "Kicked for spamming chat.");
+
+ playerdata.resetMsgCount();
+
+ event.setCancelled(true);
+ return;
+ }
+
+ // Check for message repeat
+ if (playerdata.getLastMessage().equalsIgnoreCase(message))
+ {
+ FSync.playerMsg(player, "Please do not repeat messages.");
+ event.setCancelled(true);
+ return;
+ }
+
+ playerdata.setLastMessage(message);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
+ {
+ String command = event.getMessage();
+ final Player player = event.getPlayer();
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+ fPlayer.setLastCommand(command);
+
+ if (fPlayer.allCommandsBlocked())
+ {
+ FUtil.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
+ event.setCancelled(true);
+ return;
+ }
+
+ if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
+ {
+ FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
+ FUtil.autoEject(player, "Kicked for spamming commands.");
+
+ fPlayer.resetMsgCount();
+ event.setCancelled(true);
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/AutoKick.java b/src/me/totalfreedom/totalfreedommod/AutoKick.java
new file mode 100644
index 00000000..45442db1
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/AutoKick.java
@@ -0,0 +1,75 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.scheduler.BukkitTask;
+
+public class AutoKick extends AbstractService
+{
+
+ public static final long AUTOKICK_RATE = 10 * 20L;
+ //
+ private BukkitTask kickTask = null;
+ private long autoKickTicks;
+ private double autoKickThreshold;
+
+ public AutoKick(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ autoKickTicks = (long) ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
+ autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
+
+ if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean())
+ {
+ return;
+ }
+
+ kickTask = new BukkitRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ autoKickCheck();
+ }
+ }.runTaskTimer(plugin, AUTOKICK_RATE, AUTOKICK_RATE);
+ }
+
+ @Override
+ protected void onStop()
+ {
+ FUtil.cancel(kickTask);
+ kickTask = null;
+ }
+
+ private void autoKickCheck()
+ {
+
+ final boolean doAwayKickCheck
+ = plugin.esb.isEssentialsEnabled()
+ && ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
+
+ if (!doAwayKickCheck)
+ {
+ return;
+ }
+
+ for (Player player : server.getOnlinePlayers())
+ {
+ final long lastActivity = plugin.esb.getLastActivity(player.getName());
+ if (lastActivity > 0 && lastActivity + autoKickTicks < System.currentTimeMillis())
+ {
+ player.kickPlayer("Automatically kicked by server for inactivity.");
+ }
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/ChatManager.java b/src/me/totalfreedom/totalfreedommod/ChatManager.java
new file mode 100644
index 00000000..3013d6e1
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/ChatManager.java
@@ -0,0 +1,96 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FSync;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+
+public class ChatManager extends AbstractService
+{
+
+ public ChatManager(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onPlayerChatFormat(AsyncPlayerChatEvent event)
+ {
+ try
+ {
+ handleChatEvent(event);
+ }
+ catch (Exception ex)
+ {
+ FLog.severe(ex);
+ }
+ }
+
+ private void handleChatEvent(AsyncPlayerChatEvent event)
+ {
+ final Player player = event.getPlayer();
+ String message = event.getMessage().trim();
+
+ final FPlayer playerdata = plugin.pl.getPlayerSync(player);
+
+ // Strip color from messages
+ message = ChatColor.stripColor(message);
+
+ // Truncate messages that are too long - 100 characters is vanilla client max
+ if (message.length() > 100)
+ {
+ message = message.substring(0, 100);
+ FSync.playerMsg(player, "Message was shortened because it was too long to send.");
+ }
+
+ // Check for caps
+ if (message.length() >= 6)
+ {
+ int caps = 0;
+ for (char c : message.toCharArray())
+ {
+ if (Character.isUpperCase(c))
+ {
+ caps++;
+ }
+ }
+ if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
+ {
+ message = message.toLowerCase();
+ }
+ }
+
+ // Check for adminchat
+ if (playerdata.inAdminChat())
+ {
+ FSync.adminChatMessage(player, message, false);
+ event.setCancelled(true);
+ return;
+ }
+
+ // Finally, set message
+ event.setMessage(message);
+
+ // Set the tag
+ if (playerdata.getTag() != null)
+ {
+ event.setFormat("<" + playerdata.getTag().replaceAll("%", "%%") + " %1$s> %2$s");
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/CommandSpy.java b/src/me/totalfreedom/totalfreedommod/CommandSpy.java
new file mode 100644
index 00000000..5ac2b338
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/CommandSpy.java
@@ -0,0 +1,45 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+
+public class CommandSpy extends AbstractService
+{
+
+ public CommandSpy(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
+ {
+ if (plugin.al.isAdmin(event.getPlayer()))
+ {
+ return;
+ }
+
+ for (Player player : server.getOnlinePlayers())
+ {
+ if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled())
+ {
+ FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
+ }
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/ConsoleLogger.java b/src/me/totalfreedom/totalfreedommod/ConsoleLogger.java
new file mode 100644
index 00000000..8a147419
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/ConsoleLogger.java
@@ -0,0 +1,43 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import net.pravian.aero.util.Ips;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class ConsoleLogger extends AbstractService
+{
+
+ public ConsoleLogger(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerQuit(PlayerQuitEvent event)
+ {
+ FLog.info("[EXIT] " + event.getPlayer().getName() + " left the game.", true);
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerJoin(PlayerJoinEvent event)
+ {
+ final String ip = Ips.getIp(event.getPlayer());
+ FLog.info("[JOIN] " + FUtil.formatPlayer(event.getPlayer()) + " joined the game with IP address: " + ip, true);
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/EntityWiper.java b/src/me/totalfreedom/totalfreedommod/EntityWiper.java
new file mode 100644
index 00000000..990d63f4
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/EntityWiper.java
@@ -0,0 +1,128 @@
+package me.totalfreedom.totalfreedommod;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+import org.bukkit.entity.Boat;
+import org.bukkit.entity.EnderCrystal;
+import org.bukkit.entity.EnderSignal;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.ExperienceOrb;
+import org.bukkit.entity.Explosive;
+import org.bukkit.entity.FallingBlock;
+import org.bukkit.entity.Firework;
+import org.bukkit.entity.Item;
+import org.bukkit.entity.Minecart;
+import org.bukkit.entity.Projectile;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.scheduler.BukkitTask;
+
+public class EntityWiper extends AbstractService
+{
+ private static final long WIPE_RATE = 5 * 20L;
+ //
+ private final List> wipables = new ArrayList>();
+ //
+ private BukkitTask wipeTask;
+
+ public EntityWiper(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ wipables.add(EnderCrystal.class);
+ wipables.add(EnderSignal.class);
+ wipables.add(ExperienceOrb.class);
+ wipables.add(Projectile.class);
+ wipables.add(FallingBlock.class);
+ wipables.add(Firework.class);
+ wipables.add(Item.class);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
+ {
+ return;
+ }
+
+ wipeTask = new BukkitRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ wipeEntities(!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean(), false);
+ }
+ }.runTaskTimer(plugin, WIPE_RATE, WIPE_RATE);
+
+ }
+
+ @Override
+ protected void onStop()
+ {
+ FUtil.cancel(wipeTask);
+ wipeTask = null;
+ }
+
+ public boolean canWipe(Entity entity, boolean wipeExplosives, boolean wipeVehicles)
+ {
+ if (wipeExplosives)
+ {
+ if (Explosive.class.isAssignableFrom(entity.getClass()))
+ {
+ return true;
+ }
+ }
+
+ if (wipeVehicles)
+ {
+ if (Boat.class.isAssignableFrom(entity.getClass()))
+ {
+ return true;
+ }
+ else if (Minecart.class.isAssignableFrom(entity.getClass()))
+ {
+ return true;
+ }
+ }
+
+ Iterator> it = wipables.iterator();
+ while (it.hasNext())
+ {
+ if (it.next().isAssignableFrom(entity.getClass()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public int wipeEntities(boolean wipeExplosives, boolean wipeVehicles)
+ {
+ int removed = 0;
+
+ Iterator worlds = Bukkit.getWorlds().iterator();
+ while (worlds.hasNext())
+ {
+ Iterator entities = worlds.next().getEntities().iterator();
+ while (entities.hasNext())
+ {
+ Entity entity = entities.next();
+ if (canWipe(entity, wipeExplosives, wipeVehicles))
+ {
+ entity.remove();
+ removed++;
+ }
+ }
+ }
+
+ return removed;
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/FrontDoor.java b/src/me/totalfreedom/totalfreedommod/FrontDoor.java
index d1f75a2f..d41f233c 100644
--- a/src/me/totalfreedom/totalfreedommod/FrontDoor.java
+++ b/src/me/totalfreedom/totalfreedommod/FrontDoor.java
@@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod;
+import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import java.io.BufferedReader;
@@ -12,7 +13,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Random;
import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.banning.FBan;
+import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.commands.Command_trail;
import me.totalfreedom.totalfreedommod.commands.FreedomCommand;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@@ -207,7 +208,7 @@ public class FrontDoor extends AbstractService
break;
}
- plugin.bm.addBan(FBan.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
+ plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
break;
}
@@ -416,12 +417,7 @@ public class FrontDoor extends AbstractService
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
Location targetPos = player.getLocation().clone().add(0, 1, 0);
- playerdata.setCaged(true, targetPos, Material.SKULL, Material.AIR);
- playerdata.regenerateHistory();
- playerdata.clearHistory();
- FUtil.buildHistory(targetPos, 2, playerdata);
- FUtil.generateHollowCube(targetPos, 2, Material.SKULL);
- FUtil.generateCube(targetPos, 1, Material.AIR);
+ playerdata.getCageData().cage(targetPos, Material.SKULL, Material.AIR);
break;
}
diff --git a/src/me/totalfreedom/totalfreedommod/Fuckoff.java b/src/me/totalfreedom/totalfreedommod/Fuckoff.java
new file mode 100644
index 00000000..a31b504d
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/Fuckoff.java
@@ -0,0 +1,68 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerMoveEvent;
+
+public class Fuckoff extends AbstractService
+{
+ public Fuckoff(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onPlayerMove(PlayerMoveEvent event)
+ {
+ final Player fuckoffPlayer = event.getPlayer();
+ if (plugin.al.isAdmin(fuckoffPlayer))
+ {
+ return;
+ }
+
+ for (Player onlinePlayer : server.getOnlinePlayers())
+ {
+ final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
+ if (!fPlayer.isFuckOff()
+ || fuckoffPlayer.equals(onlinePlayer))
+ {
+ continue;
+ }
+
+ double fuckoffRange = fPlayer.getFuckoffRadius();
+ Location opLocation = onlinePlayer.getLocation();
+ Location foLocation = fuckoffPlayer.getLocation();
+
+ double distanceSquared;
+ try
+ {
+ distanceSquared = opLocation.distanceSquared(foLocation);
+ }
+ catch (IllegalArgumentException ex)
+ {
+ continue;
+ }
+
+ if (distanceSquared < (fuckoffRange * fuckoffRange))
+ {
+ event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
+ break;
+ }
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/Heartbeat.java b/src/me/totalfreedom/totalfreedommod/Heartbeat.java
deleted file mode 100644
index 0cd6bdd5..00000000
--- a/src/me/totalfreedom/totalfreedommod/Heartbeat.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package me.totalfreedom.totalfreedommod;
-
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import lombok.Getter;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
-import static me.totalfreedom.totalfreedommod.TotalFreedomMod.HEARTBEAT_RATE;
-import me.totalfreedom.totalfreedommod.world.WorldWeather;
-import net.pravian.aero.component.service.AbstractService;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitTask;
-
-public class Heartbeat extends AbstractService implements Runnable
-{
- private long autoKickTime;
- private BukkitTask task;
- @Getter
- private Long lastRan = null;
-
- public Heartbeat(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
- @Override
- public void onStart()
- {
- autoKickTime = (long) ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
-
- task = server.getScheduler().runTaskTimer(plugin, this, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
- }
-
- @Override
- protected void onStop()
- {
- server.getScheduler().cancelTask(task.getTaskId());
- task = null;
- }
-
- @Override
- public void run()
- {
- lastRan = System.currentTimeMillis();
-
- final boolean doAwayKickCheck = ConfigEntry.AUTOKICK_ENABLED.getBoolean()
- && plugin.esb.isEssentialsEnabled()
- && ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > ConfigEntry.AUTOKICK_THRESHOLD.getDouble());
-
- for (Player player : server.getOnlinePlayers())
- {
- final FPlayer playerdata = plugin.pl.getPlayer(player);
- playerdata.resetMsgCount();
- playerdata.resetBlockDestroyCount();
- playerdata.resetBlockPlaceCount();
-
- if (doAwayKickCheck)
- {
- final long lastActivity = plugin.esb.getLastActivity(player.getName());
- if (lastActivity > 0 && lastActivity + autoKickTime < System.currentTimeMillis())
- {
- player.kickPlayer("Automatically kicked by server for inactivity.");
- }
- }
- }
-
- if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
- {
- FUtil.TFM_EntityWiper.wipeEntities(!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean(), false);
- }
-
- if (ConfigEntry.DISABLE_WEATHER.getBoolean())
- {
- for (World world : server.getWorlds())
- {
- try
- {
- if (world == plugin.wm.adminworld.getWorld() && plugin.wm.adminworld.getWeatherMode() != WorldWeather.OFF)
- {
- continue;
- }
- }
- catch (Exception ex)
- {
- }
-
- if (world.getWeatherDuration() > 0)
- {
- world.setThundering(false);
- world.setWeatherDuration(0);
- }
- else if (world.getThunderDuration() > 0)
- {
- world.setStorm(false);
- world.setThunderDuration(0);
- }
- }
- }
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/me/totalfreedom/totalfreedommod/LoginProcess.java
new file mode 100644
index 00000000..0cebb170
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/LoginProcess.java
@@ -0,0 +1,203 @@
+package me.totalfreedom.totalfreedommod;
+
+import java.util.regex.Pattern;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.util.FSync;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerLoginEvent;
+import org.bukkit.scheduler.BukkitRunnable;
+
+public class LoginProcess extends AbstractService
+{
+ public static final int DEFAULT_PORT = 25565;
+ public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
+
+ public LoginProcess(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ /*
+ * Banning and Permban checks are their respective services
+ */
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
+ {
+ final String ip = event.getAddress().getHostAddress().trim();
+ final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
+
+ // Check if the player is already online
+ for (Player onlinePlayer : server.getOnlinePlayers())
+ {
+ if (!onlinePlayer.getName().equalsIgnoreCase(event.getName()))
+ {
+ continue;
+ }
+
+ if (isAdmin)
+ {
+ event.allow();
+ FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
+ return;
+ }
+
+ event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username is already logged into this server.");
+ return;
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onPlayerLogin(PlayerLoginEvent event)
+ {
+ final Player player = event.getPlayer();
+ final String username = player.getName();
+ final String ip = event.getAddress().getHostAddress().trim();
+
+ // Check username length
+ if (username.length() < 3 || username.length() > TotalFreedomMod.MAX_USERNAME_LENGTH)
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is an invalid length (must be between 3 and 20 characters long).");
+ return;
+ }
+
+ // Check username characters
+ if (!USERNAME_REGEX.matcher(username).find())
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username contains invalid characters.");
+ return;
+ }
+
+ // Check force-IP match
+ if (ConfigEntry.FORCE_IP_ENABLED.getBoolean())
+ {
+ final String hostname = event.getHostname().replace("\u0000FML\u0000", ""); // Forge fix - https://github.com/TotalFreedom/TotalFreedomMod/issues/493
+ final String connectAddress = ConfigEntry.SERVER_ADDRESS.getString();
+ final int connectPort = server.getPort();
+
+ if (!hostname.equalsIgnoreCase(connectAddress + ":" + connectPort) && !hostname.equalsIgnoreCase(connectAddress + ".:" + connectPort))
+ {
+ final int forceIpPort = ConfigEntry.FORCE_IP_PORT.getInteger();
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
+ ConfigEntry.FORCE_IP_KICKMSG.getString()
+ .replace("%address%", ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == DEFAULT_PORT ? "" : ":" + forceIpPort)));
+ return;
+ }
+ }
+
+ // Generate playerdata if it is nonexistent
+ plugin.pl.getData(player);
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+ fPlayer.setSuperadminIdVerified(false);
+
+ // Check if player is admin
+ // Not safe to use TFM_Util.isSuperAdmin(player) because player.getAddress() will return a null until after player login.
+ final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
+
+ // Validation below this point
+ if (isAdmin) // Player is superadmin
+ {
+ // Force-allow log in
+ event.allow();
+
+ int count = server.getOnlinePlayers().size();
+ if (count >= server.getMaxPlayers())
+ {
+ for (Player onlinePlayer : server.getOnlinePlayers())
+ {
+ if (!plugin.al.isAdmin(onlinePlayer))
+ {
+ onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
+ count--;
+ }
+
+ if (count < server.getMaxPlayers())
+ {
+ break;
+ }
+ }
+ }
+
+ if (count >= server.getMaxPlayers())
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
+ return;
+ }
+
+ return;
+ }
+
+ // Player is not an admin
+ // Server full check
+ if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, but this server is full.");
+ return;
+ }
+
+ // Admin-only mode
+ if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
+ return;
+ }
+
+ // Lockdown mode
+ if (TotalFreedomMod.lockdownEnabled)
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is currently in lockdown mode.");
+ return;
+ }
+
+ // Whitelist
+ if (plugin.si.isWhitelisted())
+ {
+ if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
+ return;
+ }
+ }
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerJoin(PlayerJoinEvent event)
+ {
+ final Player player = event.getPlayer();
+
+ new BukkitRunnable()
+ {
+ @Override
+ public void run()
+ {
+ if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
+ {
+ player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
+ }
+
+ if (TotalFreedomMod.lockdownEnabled)
+ {
+ FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
+ }
+ }
+ }.runTaskLater(TotalFreedomMod.plugin, 20L * 1L);
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/MovementValidator.java b/src/me/totalfreedom/totalfreedommod/MovementValidator.java
new file mode 100644
index 00000000..12741f35
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/MovementValidator.java
@@ -0,0 +1,54 @@
+package me.totalfreedom.totalfreedommod;
+
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerLoginEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
+
+public class MovementValidator extends AbstractService
+{
+
+ public static final int MAX_XZ_COORD = 30000000;
+
+ public MovementValidator(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onPlayerTeleport(PlayerTeleportEvent event)
+ {
+ final Player player = event.getPlayer();
+
+ // Check absolute value to account for negatives
+ if (Math.abs(event.getTo().getX()) >= MAX_XZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XZ_COORD)
+ {
+ event.setCancelled(true); // illegal position, cancel it
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onPlayerLogin(PlayerLoginEvent event)
+ {
+ final Player player = event.getPlayer();
+
+ // Validate position
+ if (Math.abs(player.getLocation().getX()) >= MAX_XZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XZ_COORD)
+ {
+ player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/Muter.java b/src/me/totalfreedom/totalfreedommod/Muter.java
new file mode 100644
index 00000000..718e1edd
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/Muter.java
@@ -0,0 +1,96 @@
+package me.totalfreedom.totalfreedommod;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Pattern;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FSync;
+import net.pravian.aero.component.service.AbstractService;
+import org.apache.commons.lang3.StringUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+
+public class Muter extends AbstractService
+{
+ // TODO: Match actual commands
+ public final List MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ","));
+
+ public Muter(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
+ {
+ FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
+
+ if (!fPlayer.isMuted())
+ {
+ return;
+ }
+
+ if (plugin.al.isAdminSync(event.getPlayer()))
+ {
+ fPlayer.setMuted(false);
+ return;
+ }
+
+ FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
+ {
+
+ Player player = event.getPlayer();
+ FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
+
+ // Block commands if player is muted
+ if (!fPlayer.isMuted())
+ {
+ return;
+ }
+
+ String command = event.getMessage();
+ if (plugin.al.isAdmin(player))
+ {
+ fPlayer.setMuted(false);
+ return;
+ }
+
+ // TODO: Find match actual command, instead of label
+ for (String commandName : MUTE_COMMANDS)
+ {
+ if (Pattern.compile("^/" + commandName.toLowerCase() + " ").matcher(command.toLowerCase()).find())
+ {
+ player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean())
+ {
+ FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command), true);
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/Orbiter.java b/src/me/totalfreedom/totalfreedommod/Orbiter.java
new file mode 100644
index 00000000..c8e22a82
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/Orbiter.java
@@ -0,0 +1,47 @@
+package me.totalfreedom.totalfreedommod;
+
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.util.Vector;
+
+public class Orbiter extends AbstractService
+{
+
+ public Orbiter(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onPlayerMove(PlayerMoveEvent event)
+ {
+
+ final Player player = event.getPlayer();
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ if (!fPlayer.isOrbiting())
+ {
+ return;
+ }
+
+ if (player.getVelocity().length() < fPlayer.orbitStrength() * (2.0 / 3.0))
+ {
+ player.setVelocity(new Vector(0, fPlayer.orbitStrength(), 0));
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/PermbanList.java b/src/me/totalfreedom/totalfreedommod/PermbanList.java
deleted file mode 100644
index 6ce786a1..00000000
--- a/src/me/totalfreedom/totalfreedommod/PermbanList.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package me.totalfreedom.totalfreedommod;
-
-import me.totalfreedom.totalfreedommod.util.FLog;
-import com.google.common.collect.Sets;
-import java.util.Set;
-import lombok.Getter;
-import me.totalfreedom.totalfreedommod.config.FConfig;
-import net.pravian.aero.component.service.AbstractService;
-
-public class PermbanList extends AbstractService
-{
- @Getter
- private final Set permbannedNames = Sets.newHashSet();
- @Getter
- private final Set permbannedIps = Sets.newHashSet();
-
- public PermbanList(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
- @Override
- protected void onStart()
- {
- permbannedNames.clear();
- permbannedIps.clear();
-
- final FConfig config = new FConfig(TotalFreedomMod.plugin, TotalFreedomMod.PERMBAN_FILENAME, true);
- config.load();
-
- for (String name : config.getKeys(false))
- {
- permbannedNames.add(name.toLowerCase().trim());
- permbannedIps.addAll(config.getStringList(name));
- }
-
- FLog.info("Loaded " + permbannedNames.size() + " permanently banned usernames and " + permbannedIps.size() + " permanently banned IPs.");
- }
-
- @Override
- protected void onStop()
- {
- }
-
-}
diff --git a/src/me/totalfreedom/totalfreedommod/ProtectArea.java b/src/me/totalfreedom/totalfreedommod/ProtectArea.java
index 849ceb95..6ba94a53 100644
--- a/src/me/totalfreedom/totalfreedommod/ProtectArea.java
+++ b/src/me/totalfreedom/totalfreedommod/ProtectArea.java
@@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod;
-import me.totalfreedom.totalfreedommod.util.FLog;
import com.google.common.collect.Maps;
import java.io.File;
import java.io.FileInputStream;
@@ -14,10 +13,16 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.util.Vector;
public class ProtectArea extends AbstractService
@@ -83,6 +88,50 @@ public class ProtectArea extends AbstractService
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onBlockBreak(BlockBreakEvent event)
+ {
+ if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
+ {
+ return;
+ }
+
+ final Player player = event.getPlayer();
+ if (plugin.al.isAdmin(player))
+ {
+ return;
+ }
+
+ final Location location = event.getBlock().getLocation();
+
+ if (isInProtectedArea(location))
+ {
+ event.setCancelled(true);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onBlockPlace(BlockPlaceEvent event)
+ {
+ if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
+ {
+ return;
+ }
+
+ final Player player = event.getPlayer();
+ if (plugin.al.isAdmin(player))
+ {
+ return;
+ }
+
+ final Location location = event.getBlock().getLocation();
+
+ if (isInProtectedArea(location))
+ {
+ event.setCancelled(true);
+ }
+ }
+
public boolean isInProtectedArea(final Location modifyLocation)
{
boolean doSave = false;
@@ -284,7 +333,7 @@ public class ProtectArea extends AbstractService
}
}
- public class SerializableProtectedRegion implements Serializable
+ public static class SerializableProtectedRegion implements Serializable
{
private static final long serialVersionUID = 213123517828282L;
private final double x, y, z;
diff --git a/src/me/totalfreedom/totalfreedommod/ServerInterface.java b/src/me/totalfreedom/totalfreedommod/ServerInterface.java
index ede99627..7350dce6 100644
--- a/src/me/totalfreedom/totalfreedommod/ServerInterface.java
+++ b/src/me/totalfreedom/totalfreedommod/ServerInterface.java
@@ -1,30 +1,16 @@
package me.totalfreedom.totalfreedommod;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FLog;
import java.util.Arrays;
import java.util.List;
-import java.util.regex.Pattern;
-import me.totalfreedom.totalfreedommod.banning.FBan;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.listener.PlayerListener;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PropertyManager;
import net.pravian.aero.component.service.AbstractService;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
-import org.bukkit.event.player.PlayerLoginEvent;
-import org.bukkit.event.player.PlayerLoginEvent.Result;
public class ServerInterface extends AbstractService
{
public static final String COMPILE_NMS_VERSION = "v1_8_R3";
- public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
public ServerInterface(TotalFreedomMod plugin)
{
@@ -84,177 +70,4 @@ public class ServerInterface extends AbstractService
return MinecraftServer.getServer().getVersion();
}
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
- {
- final String ip = event.getAddress().getHostAddress().trim();
- final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
-
- // Check if the player is already online
- for (Player onlinePlayer : server.getOnlinePlayers())
- {
- if (!onlinePlayer.getName().equalsIgnoreCase(event.getName()))
- {
- continue;
- }
-
- if (!isAdmin)
- {
- event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username is already logged into this server.");
- }
- else
- {
- event.allow();
- FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
- }
- return;
- }
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onPlayerLogin(PlayerLoginEvent event)
- {
- final Player player = event.getPlayer();
- final String username = player.getName();
- final String ip = event.getAddress().getHostAddress().trim();
-
- // Check username length
- if (username.length() < 3 || username.length() > TotalFreedomMod.MAX_USERNAME_LENGTH)
- {
- event.disallow(Result.KICK_OTHER, "Your username is an invalid length (must be between 3 and 20 characters long).");
- return;
- }
-
- // Check username characters
- if (!USERNAME_REGEX.matcher(username).find())
- {
- event.disallow(Result.KICK_OTHER, "Your username contains invalid characters.");
- return;
- }
-
- // Check force-IP match
- if (ConfigEntry.FORCE_IP_ENABLED.getBoolean())
- {
- final String hostname = event.getHostname().replace("\u0000FML\u0000", ""); // Forge fix - https://github.com/TotalFreedom/TotalFreedomMod/issues/493
- final String connectAddress = ConfigEntry.SERVER_ADDRESS.getString();
- final int connectPort = server.getPort();
-
- if (!hostname.equalsIgnoreCase(connectAddress + ":" + connectPort) && !hostname.equalsIgnoreCase(connectAddress + ".:" + connectPort))
- {
- final int forceIpPort = ConfigEntry.FORCE_IP_PORT.getInteger();
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- ConfigEntry.FORCE_IP_KICKMSG.getString()
- .replace("%address%", ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == PlayerListener.DEFAULT_PORT ? "" : ":" + forceIpPort)));
- return;
- }
-
- }
-
- // Check if player is admin
- // Not safe to use TFM_Util.isSuperAdmin(player) because player.getAddress() will return a null until after player login.
- final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
-
- // Validation below this point
- if (isAdmin) // Player is superadmin
- {
- // Force-allow log in
- event.allow();
-
- int count = server.getOnlinePlayers().size();
- if (count >= server.getMaxPlayers())
- {
- for (Player onlinePlayer : server.getOnlinePlayers())
- {
- if (!plugin.al.isAdmin(onlinePlayer))
- {
- onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
- count--;
- }
-
- if (count < server.getMaxPlayers())
- {
- break;
- }
- }
- }
-
- if (count >= server.getMaxPlayers())
- {
- event.disallow(Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
- return;
- }
-
- return;
- }
-
- // Player is not an admin
- // Server full check
- if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
- {
- event.disallow(Result.KICK_FULL, "Sorry, but this server is full.");
- return;
- }
-
- // Admin-only mode
- if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
- {
- event.disallow(Result.KICK_OTHER, "Server is temporarily open to admins only.");
- return;
- }
-
- // Lockdown mode
- if (TotalFreedomMod.lockdownEnabled)
- {
- event.disallow(Result.KICK_OTHER, "Server is currently in lockdown mode.");
- return;
- }
-
- // Whitelist
- if (isWhitelisted())
- {
- if (!getWhitelisted().contains(username.toLowerCase()))
- {
- event.disallow(Result.KICK_OTHER, "You are not whitelisted on this server.");
- return;
- }
- }
-
- // Permbanned IPs
- for (String testIp : plugin.pb.getPermbannedIps())
- {
- if (FUtil.fuzzyIpMatch(testIp, ip, 4))
- {
- event.disallow(Result.KICK_OTHER,
- ChatColor.RED + "Your IP address is permanently banned from this server.\n"
- + "Release procedures are available at\n"
- + ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
- return;
- }
- }
-
- // Permbanned usernames
- for (String testPlayer : plugin.pb.getPermbannedNames())
- {
- if (testPlayer.equalsIgnoreCase(username))
- {
- event.disallow(Result.KICK_OTHER,
- ChatColor.RED + "Your username is permanently banned from this server.\n"
- + "Release procedures are available at\n"
- + ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
- return;
- }
- }
-
- // Regular ban
- FBan ban = plugin.bm.getByUsername(username);
- if (ban == null)
- {
- ban = plugin.bm.getByIp(ip);
- }
-
- if (ban != null)
- {
- event.disallow(Result.KICK_OTHER, ban.bakeKickMessage());
- }
- }
}
diff --git a/src/me/totalfreedom/totalfreedommod/listener/ServerListener.java b/src/me/totalfreedom/totalfreedommod/ServerPing.java
similarity index 80%
rename from src/me/totalfreedom/totalfreedommod/listener/ServerListener.java
rename to src/me/totalfreedom/totalfreedommod/ServerPing.java
index 8b76094e..63bfe340 100644
--- a/src/me/totalfreedom/totalfreedommod/listener/ServerListener.java
+++ b/src/me/totalfreedom/totalfreedommod/ServerPing.java
@@ -1,18 +1,33 @@
-package me.totalfreedom.totalfreedommod.listener;
+package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import net.pravian.aero.component.PluginListener;
+import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.server.ServerListPingEvent;
-public class ServerListener extends PluginListener
+public class ServerPing extends AbstractService
{
- @EventHandler(priority = EventPriority.HIGHEST)
+
+ public ServerPing(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
public void onServerPing(ServerListPingEvent event)
{
final String ip = event.getAddress().getHostAddress().trim();
@@ -58,4 +73,5 @@ public class ServerListener extends PluginListener
event.setMotd(FUtil.colorize(motd.toString()));
}
+
}
diff --git a/src/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
index 4a1e582a..40ef84c9 100644
--- a/src/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
+++ b/src/me/totalfreedom/totalfreedommod/TotalFreedomMod.java
@@ -1,50 +1,41 @@
package me.totalfreedom.totalfreedommod;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.PermbanList;
-import me.totalfreedom.totalfreedommod.ProtectArea;
-import me.totalfreedom.totalfreedommod.ServiceChecker;
-import me.totalfreedom.totalfreedommod.ServerInterface;
-import me.totalfreedom.totalfreedommod.Jumppads;
-import me.totalfreedom.totalfreedommod.GameRuleHandler;
-import me.totalfreedom.totalfreedommod.Heartbeat;
-import me.totalfreedom.totalfreedommod.util.FLog;
-import me.totalfreedom.totalfreedommod.FrontDoor;
-import me.totalfreedom.totalfreedommod.Announcer;
+import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
+import me.totalfreedom.totalfreedommod.banning.PermbanList;
+import me.totalfreedom.totalfreedommod.fun.Jumppads;
+import me.totalfreedom.totalfreedommod.fun.MP44;
+import me.totalfreedom.totalfreedommod.fun.ItemFun;
+import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
+import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
+import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Properties;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.banning.BanManager;
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
-import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
+import me.totalfreedom.totalfreedommod.caging.Cager;
+import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
import me.totalfreedom.totalfreedommod.commands.CommandLoader;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.freeze.Freezer;
+import me.totalfreedom.totalfreedommod.fun.Landminer;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
-import me.totalfreedom.totalfreedommod.listener.BlockListener;
-import me.totalfreedom.totalfreedommod.listener.EntityListener;
-import me.totalfreedom.totalfreedommod.listener.PlayerListener;
-import me.totalfreedom.totalfreedommod.listener.ServerListener;
-import me.totalfreedom.totalfreedommod.listener.WeatherListener;
-import me.totalfreedom.totalfreedommod.permission.RankManager;
+import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
-import me.totalfreedom.totalfreedommod.world.TFM_WorldManager;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import me.totalfreedom.totalfreedommod.world.WorldManager;
import net.pravian.aero.component.service.ServiceManager;
import net.pravian.aero.plugin.AeroPlugin;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.mcstats.Metrics;
public class TotalFreedomMod extends AeroPlugin
{
- public static final long HEARTBEAT_RATE = 5L; // Seconds
public static final long SERVICE_CHECKER_RATE = 120L;
public static final int MAX_USERNAME_LENGTH = 20;
//
@@ -57,17 +48,27 @@ public class TotalFreedomMod extends AeroPlugin
//
public static final BuildProperties build = new BuildProperties();
//
+ @SuppressWarnings("FieldNameHidesFieldInSuperclass")
public static TotalFreedomMod plugin;
public static String pluginName;
public static String pluginVersion;
//
public static boolean lockdownEnabled = false;
- public static Map fuckoffEnabledFor = new HashMap();
//
// Services
public ServiceManager services;
public ServerInterface si;
+ public ConsoleLogger co;
+ public WorldManager wm;
public AdminList al;
+ public EventBlocker eb;
+ public BlockBlocker bb;
+ public MobBlocker mb;
+ public InteractBlocker ib;
+ public LoginProcess lp;
+ public AntiNuke nu;
+ public AntiSpam as;
+ public Muter mu;
public RankManager rm;
public BanManager bm;
public PlayerList pl;
@@ -79,11 +80,17 @@ public class TotalFreedomMod extends AeroPlugin
public ServiceChecker sc;
public GameRuleHandler gr;
public RollbackManager rb;
- public Heartbeat hb;
public Jumppads jp;
+ public Cager ca;
+ public Freezer fm;
+ public Fuckoff fo;
+ public EntityWiper ew;
public FrontDoor fd;
+ public ServerPing sp;
+ public ItemFun it;
+ public Landminer lm;
+ public MP44 mp;
public HTTPDaemon hd;
- public TFM_WorldManager wm;
//
// Bridges
public ServiceManager bridges;
@@ -102,31 +109,6 @@ public class TotalFreedomMod extends AeroPlugin
FLog.setServerLogger(server.getLogger());
build.load();
-
- services = new ServiceManager(plugin);
- si = services.registerService(ServerInterface.class);
- al = services.registerService(AdminList.class);
- rm = services.registerService(RankManager.class);
- bm = services.registerService(BanManager.class);
- pl = services.registerService(PlayerList.class);
- cl = services.registerService(CommandLoader.class);
- cb = services.registerService(CommandBlocker.class);
- an = services.registerService(Announcer.class);
- pb = services.registerService(PermbanList.class);
- pa = services.registerService(ProtectArea.class);
- sc = services.registerService(ServiceChecker.class);
- gr = services.registerService(GameRuleHandler.class);
- rb = services.registerService(RollbackManager.class);
- hb = services.registerService(Heartbeat.class);
- jp = services.registerService(Jumppads.class);
- fd = services.registerService(FrontDoor.class);
- hd = services.registerService(HTTPDaemon.class);
- wm = services.registerService(TFM_WorldManager.class);
-
- bridges = new ServiceManager(plugin);
- btb = bridges.registerService(BukkitTelnetBridge.class);
- esb = bridges.registerService(EssentialsBridge.class);
- web = bridges.registerService(WorldEditBridge.class);
}
@Override
@@ -156,29 +138,51 @@ public class TotalFreedomMod extends AeroPlugin
FUtil.createBackups(SUPERADMIN_FILENAME);
FUtil.createBackups(PERMBAN_FILENAME);
- // Start services and bridges
+ // Start services and bridgess
+ services = new ServiceManager(plugin);
+ si = services.registerService(ServerInterface.class);
+ co = services.registerService(ConsoleLogger.class);
+ wm = services.registerService(WorldManager.class);
+ al = services.registerService(AdminList.class);
+ eb = services.registerService(EventBlocker.class);
+ bb = services.registerService(BlockBlocker.class);
+ mb = services.registerService(MobBlocker.class);
+ ib = services.registerService(InteractBlocker.class);
+ lp = services.registerService(LoginProcess.class);
+ nu = services.registerService(AntiNuke.class);
+ as = services.registerService(AntiSpam.class);
+ mu = services.registerService(Muter.class);
+ rm = services.registerService(RankManager.class);
+ bm = services.registerService(BanManager.class);
+ pl = services.registerService(PlayerList.class);
+ cl = services.registerService(CommandLoader.class);
+ cb = services.registerService(CommandBlocker.class);
+ an = services.registerService(Announcer.class);
+ pb = services.registerService(PermbanList.class);
+ pa = services.registerService(ProtectArea.class);
+ sc = services.registerService(ServiceChecker.class);
+ gr = services.registerService(GameRuleHandler.class);
+ rb = services.registerService(RollbackManager.class);
+ jp = services.registerService(Jumppads.class);
+ ca = services.registerService(Cager.class);
+ fm = services.registerService(Freezer.class);
+ fo = services.registerService(Fuckoff.class);
+ ew = services.registerService(EntityWiper.class);
+ fd = services.registerService(FrontDoor.class);
+ sp = services.registerService(ServerPing.class);
+ it = services.registerService(ItemFun.class);
+ lm = services.registerService(Landminer.class);
+ mp = services.registerService(MP44.class);
+ hd = services.registerService(HTTPDaemon.class);
services.start();
+
+ // Register bridges
+ bridges = new ServiceManager(plugin);
+ btb = bridges.registerService(BukkitTelnetBridge.class);
+ esb = bridges.registerService(EssentialsBridge.class);
+ web = bridges.registerService(WorldEditBridge.class);
bridges.start();
- // Register listeners
- register(EntityListener.class);
- register(BlockListener.class);
- register(PlayerListener.class);
- register(WeatherListener.class);
- register(ServerListener.class);
-
- // Disable weather
- if (ConfigEntry.DISABLE_WEATHER.getBoolean())
- {
- for (World world : server.getWorlds())
- {
- world.setThundering(false);
- world.setStorm(false);
- world.setThunderDuration(0);
- world.setWeatherDuration(0);
- }
- }
-
timer.update();
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
diff --git a/src/me/totalfreedom/totalfreedommod/TwitterHandler.java b/src/me/totalfreedom/totalfreedommod/TwitterHandler.java
deleted file mode 100644
index a88fa063..00000000
--- a/src/me/totalfreedom/totalfreedommod/TwitterHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package me.totalfreedom.totalfreedommod;
-
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.util.FLog;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-
-public class TwitterHandler
-{
- private TwitterHandler()
- {
- throw new AssertionError();
- }
-
- public static String getTwitter(String player)
- {
- return request("action=gettwitter&player=" + player);
- }
-
- public static String setTwitter(String player, String twitter)
- {
- if (twitter.startsWith("@"))
- {
- twitter = twitter.replaceAll("@", "");
- }
- return request("action=settwitter&player=" + player + "&twitter=" + twitter);
- }
-
- public static String delTwitter(String player)
- {
- return request("action=deltwitter&player=" + player);
- }
-
- public static void delTwitterVerbose(String targetName, CommandSender sender)
- {
- final String reply = delTwitter(targetName);
- if ("ok".equals(reply))
- {
- FUtil.adminAction(sender.getName(), "Removing " + targetName + " from TwitterBot", true);
- }
- else if ("disabled".equals(reply))
- {
- FUtil.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
- FUtil.playerMsg(sender, "TwitterBot has been temporarily disabled, please wait until it gets re-enabled", ChatColor.RED);
- }
- else if ("failed".equals(reply))
- {
- FUtil.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
- FUtil.playerMsg(sender, "There was a problem querying the database, please let a developer know.", ChatColor.RED);
- }
- else if ("false".equals(reply))
- {
- FUtil.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
- FUtil.playerMsg(sender, "There was a problem with the database, please let a developer know.", ChatColor.RED);
- }
- else if ("cannotauth".equals(reply))
- {
- FUtil.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
- FUtil.playerMsg(sender, "The database password is incorrect, please let a developer know.", ChatColor.RED);
- }
- else if ("notfound".equals(reply))
- {
- FUtil.playerMsg(sender, targetName + " did not have a twitter handle registered to their name.", ChatColor.GREEN);
- }
- }
-
- public static String isEnabled()
- {
- return request("action=getstatus");
- }
-
- public static String setEnabled(String status)
- {
- return request("action=setstatus&status=" + status);
- }
-
- private static String request(String queryString)
- {
- String line = "failed";
-
- final String twitterbotURL = ConfigEntry.TWITTERBOT_URL.getString();
- final String twitterbotSecret = ConfigEntry.TWITTERBOT_SECRET.getString();
-
- if (twitterbotURL != null && twitterbotSecret != null && !twitterbotURL.isEmpty() && !twitterbotSecret.isEmpty())
- {
- try
- {
- URL getUrl = new URL(twitterbotURL + "?auth=" + twitterbotSecret + "&" + queryString);
- URLConnection urlConnection = getUrl.openConnection();
- // Read the response
- BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
- line = in.readLine();
- in.close();
- }
- catch (Exception ex)
- {
- FLog.severe(ex);
- }
- }
-
- return line;
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/admin/Admin.java b/src/me/totalfreedom/totalfreedommod/admin/Admin.java
index 0895d104..bf4858e8 100644
--- a/src/me/totalfreedom/totalfreedommod/admin/Admin.java
+++ b/src/me/totalfreedom/totalfreedommod/admin/Admin.java
@@ -5,7 +5,7 @@ import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable;
@@ -93,7 +93,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
cs.set("username", name);
cs.set("active", activated);
cs.set("rank", rank.toString());
- cs.set("ips", ips);
+ cs.set("ips", Lists.newArrayList(ips));
cs.set("last_login", lastLogin);
cs.set("login_message", null);
}
diff --git a/src/me/totalfreedom/totalfreedommod/admin/AdminList.java b/src/me/totalfreedom/totalfreedommod/admin/AdminList.java
index 2b6c3b14..98ecff25 100644
--- a/src/me/totalfreedom/totalfreedommod/admin/AdminList.java
+++ b/src/me/totalfreedom/totalfreedommod/admin/AdminList.java
@@ -8,18 +8,22 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.commands.Command_logs;
import me.totalfreedom.totalfreedommod.config.FConfig;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FLog;
-import me.totalfreedom.totalfreedommod.TwitterHandler;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.ServicePriority;
public class AdminList extends AbstractService
@@ -68,7 +72,7 @@ public class AdminList extends AbstractService
config.load();
allAdmins.clear();
- for (String key : config.getKeys(true))
+ for (String key : config.getKeys(false))
{
Admin admin = new Admin(key);
admin.loadFrom(config.getConfigurationSection(key));
@@ -305,6 +309,29 @@ public class AdminList extends AbstractService
return ipTable.keySet();
}
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerJoin(PlayerJoinEvent event)
+ {
+ final Player player = event.getPlayer();
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ boolean isAdmin = plugin.al.isAdmin(player);
+ if (isAdmin)
+ {
+ // Verify strict IP match
+ if (!plugin.al.isIdentityMatched(player))
+ {
+ fPlayer.setSuperadminIdVerified(false);
+ FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
+ }
+ else
+ {
+ fPlayer.setSuperadminIdVerified(true);
+ plugin.al.updateLastLogin(player);
+ }
+ }
+ }
+
/*
public void addAdmin(OfflinePlayer player)
{
@@ -402,7 +429,6 @@ public class AdminList extends AbstractService
admin.setActivated(false);
Command_logs.deactivateSuperadmin(admin);
- TwitterHandler.delTwitter(admin.getName());
}
save();
diff --git a/src/me/totalfreedom/totalfreedommod/banning/FBan.java b/src/me/totalfreedom/totalfreedommod/banning/Ban.java
similarity index 82%
rename from src/me/totalfreedom/totalfreedommod/banning/FBan.java
rename to src/me/totalfreedom/totalfreedommod/banning/Ban.java
index ea4a8732..0f67bac9 100644
--- a/src/me/totalfreedom/totalfreedommod/banning/FBan.java
+++ b/src/me/totalfreedom/totalfreedommod/banning/Ban.java
@@ -18,7 +18,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
-public class FBan implements ConfigLoadable, ConfigSavable, Validatable
+public class Ban implements ConfigLoadable, ConfigSavable, Validatable
{
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
@@ -37,11 +37,11 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
@Setter
private long expiryUnix = -1;
- public FBan()
+ public Ban()
{
}
- public FBan(String username, String ip, String by, Date expire, String reason)
+ public Ban(String username, String ip, String by, Date expire, String reason)
{
this(username,
new String[]
@@ -53,7 +53,7 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
reason);
}
- public FBan(String username, String[] ips, String by, Date expire, String reason)
+ public Ban(String username, String[] ips, String by, Date expire, String reason)
{
this.username = username;
if (ips != null)
@@ -66,34 +66,34 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
//
// For player IP
- public static FBan forPlayerIp(Player player, CommandSender by)
+ public static Ban forPlayerIp(Player player, CommandSender by)
{
return forPlayerIp(player, by, null, null);
}
- public static FBan forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
+ public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
{
- return new FBan(null, new String[]
+ return new Ban(null, new String[]
{
Ips.getIp(player)
}, by.getName(), expiry, reason);
}
- public static FBan forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
+ public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
{
- return new FBan(null, ip, by.getName(), expiry, reason);
+ return new Ban(null, ip, by.getName(), expiry, reason);
}
//
// For player name
- public static FBan forPlayerName(Player player, CommandSender by, Date expiry, String reason)
+ public static Ban forPlayerName(Player player, CommandSender by, Date expiry, String reason)
{
return forPlayerName(player.getName(), by, expiry, reason);
}
- public static FBan forPlayerName(String player, CommandSender by, Date expiry, String reason)
+ public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
{
- return new FBan(player,
+ return new Ban(player,
(String[]) null,
by.getName(),
expiry,
@@ -102,23 +102,23 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
//
// For player
- public static FBan forPlayer(Player player, CommandSender by)
+ public static Ban forPlayer(Player player, CommandSender by)
{
return forPlayerName(player, by, null, null);
}
- public static FBan forPlayer(Player player, CommandSender by, Date expiry, String reason)
+ public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
{
- return new FBan(player.getName(),
+ return new Ban(player.getName(),
Ips.getIp(player),
by.getName(),
expiry,
reason);
}
- public static FBan forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
+ public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
{
- return new FBan(player.getName(),
+ return new Ban(player.getName(),
FUtil.getFuzzyIp(Ips.getIp(player)),
by.getName(),
expiry,
@@ -197,12 +197,12 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
return false;
}
- if (!(object instanceof FBan))
+ if (!(object instanceof Ban))
{
return false;
}
- final FBan ban = (FBan) object;
+ final Ban ban = (Ban) object;
if (hasIps() != ban.hasIps()
|| hasUsername() != hasUsername())
{
diff --git a/src/me/totalfreedom/totalfreedommod/banning/BanManager.java b/src/me/totalfreedom/totalfreedommod/banning/BanManager.java
index 69caacb2..552ce574 100644
--- a/src/me/totalfreedom/totalfreedommod/banning/BanManager.java
+++ b/src/me/totalfreedom/totalfreedommod/banning/BanManager.java
@@ -12,15 +12,22 @@ import java.util.Set;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerLoginEvent;
public class BanManager extends AbstractService
{
- private final Set bans = Sets.newHashSet();
- private final Map ipBans = Maps.newHashMap();
- private final Map nameBans = Maps.newHashMap();
+ private final Set bans = Sets.newHashSet();
+ private final Map ipBans = Maps.newHashMap();
+ private final Map nameBans = Maps.newHashMap();
private final List unbannableUsernames = Lists.newArrayList();
//
private final YamlConfig config;
@@ -56,7 +63,7 @@ public class BanManager extends AbstractService
continue;
}
- FBan ban = new FBan();
+ Ban ban = new Ban();
ban.loadFrom(config.getConfigurationSection(id));
if (!ban.isValid())
@@ -84,7 +91,7 @@ public class BanManager extends AbstractService
{
// Remove expired bans
- for (Iterator it = bans.iterator(); it.hasNext();)
+ for (Iterator it = bans.iterator(); it.hasNext();)
{
if (it.next().isExpired())
{
@@ -94,7 +101,7 @@ public class BanManager extends AbstractService
ipBans.clear();
nameBans.clear();
- for (FBan ban : bans)
+ for (Ban ban : bans)
{
if (ban.hasUsername())
{
@@ -116,7 +123,7 @@ public class BanManager extends AbstractService
// Remove expired
updateViews();
- for (FBan ban : bans)
+ for (Ban ban : bans)
{
ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
}
@@ -125,26 +132,26 @@ public class BanManager extends AbstractService
config.save();
}
- public Collection getIpBans()
+ public Collection getIpBans()
{
return Collections.unmodifiableCollection(ipBans.values());
}
- public Collection getUsernameBans()
+ public Collection getUsernameBans()
{
return Collections.unmodifiableCollection(nameBans.values());
}
- public FBan getByIp(String ip)
+ public Ban getByIp(String ip)
{
- final FBan directBan = ipBans.get(ip);
+ final Ban directBan = ipBans.get(ip);
if (directBan != null && !directBan.isExpired())
{
return directBan;
}
// Match fuzzy IP
- for (FBan loopBan : ipBans.values())
+ for (Ban loopBan : ipBans.values())
{
if (loopBan.isExpired())
{
@@ -168,10 +175,10 @@ public class BanManager extends AbstractService
return null;
}
- public FBan getByUsername(String username)
+ public Ban getByUsername(String username)
{
username = username.toLowerCase();
- final FBan directBan = nameBans.get(username);
+ final Ban directBan = nameBans.get(username);
if (directBan != null && !directBan.isExpired())
{
@@ -181,9 +188,9 @@ public class BanManager extends AbstractService
return null;
}
- public FBan unbanIp(String ip)
+ public Ban unbanIp(String ip)
{
- final FBan ban = getByIp(ip);
+ final Ban ban = getByIp(ip);
if (ban == null)
{
@@ -195,9 +202,9 @@ public class BanManager extends AbstractService
return ban;
}
- public FBan unbanUsername(String username)
+ public Ban unbanUsername(String username)
{
- final FBan ban = getByUsername(username);
+ final Ban ban = getByUsername(username);
if (ban == null)
{
@@ -219,7 +226,7 @@ public class BanManager extends AbstractService
return getByUsername(username) != null;
}
- public boolean addBan(FBan ban)
+ public boolean addBan(Ban ban)
{
if (bans.add(ban))
{
@@ -230,7 +237,7 @@ public class BanManager extends AbstractService
return false;
}
- public boolean removeBan(FBan ban)
+ public boolean removeBan(Ban ban)
{
if (bans.remove(ban))
{
@@ -252,4 +259,46 @@ public class BanManager extends AbstractService
nameBans.clear();
saveAll();
}
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onPlayerLogin(PlayerLoginEvent event)
+ {
+ final String username = event.getPlayer().getName();
+ final String ip = Ips.getIp(event);
+
+ // Regular ban
+ Ban ban = plugin.bm.getByUsername(username);
+ if (ban == null)
+ {
+ ban = plugin.bm.getByIp(ip);
+ }
+
+ if (ban != null)
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
+ }
+ }
+
+ @EventHandler(priority = EventPriority.LOW)
+ public void onPlayerJoin(PlayerJoinEvent event)
+ {
+ final Player player = event.getPlayer();
+ final PlayerData data = plugin.pl.getData(player);
+
+ if (!plugin.al.isAdmin(player))
+ {
+ return;
+ }
+
+ // Unban admins
+ for (String storedIp : data.getIps())
+ {
+ unbanIp(storedIp);
+ unbanIp(FUtil.getFuzzyIp(storedIp));
+ }
+
+ unbanUsername(player.getName());
+ player.setOp(true);
+ }
+
}
diff --git a/src/me/totalfreedom/totalfreedommod/banning/PermbanList.java b/src/me/totalfreedom/totalfreedommod/banning/PermbanList.java
new file mode 100644
index 00000000..2a79419b
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/banning/PermbanList.java
@@ -0,0 +1,87 @@
+package me.totalfreedom.totalfreedommod.banning;
+
+import me.totalfreedom.totalfreedommod.util.FLog;
+import com.google.common.collect.Sets;
+import java.util.Set;
+import lombok.Getter;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.config.FConfig;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import net.pravian.aero.util.Ips;
+import org.bukkit.ChatColor;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerLoginEvent;
+
+public class PermbanList extends AbstractService
+{
+ @Getter
+ private final Set permbannedNames = Sets.newHashSet();
+ @Getter
+ private final Set permbannedIps = Sets.newHashSet();
+
+ public PermbanList(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ permbannedNames.clear();
+ permbannedIps.clear();
+
+ final FConfig config = new FConfig(TotalFreedomMod.plugin, TotalFreedomMod.PERMBAN_FILENAME, true);
+ config.load();
+
+ for (String name : config.getKeys(false))
+ {
+ permbannedNames.add(name.toLowerCase().trim());
+ permbannedIps.addAll(config.getStringList(name));
+ }
+
+ FLog.info("Loaded " + permbannedNames.size() + " permanently banned usernames and " + permbannedIps.size() + " permanently banned IPs.");
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onPlayerLogin(PlayerLoginEvent event)
+ {
+ final String username = event.getPlayer().getName();
+ final String ip = Ips.getIp(event);
+
+ // Permbanned IPs
+ for (String testIp : getPermbannedIps())
+ {
+ if (FUtil.fuzzyIpMatch(testIp, ip, 4))
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
+ ChatColor.RED + "Your IP address is permanently banned from this server.\n"
+ + "Release procedures are available at\n"
+ + ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
+ return;
+ }
+ }
+
+ // Permbanned usernames
+ for (String testPlayer : getPermbannedNames())
+ {
+ if (testPlayer.equalsIgnoreCase(username))
+ {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
+ ChatColor.RED + "Your username is permanently banned from this server.\n"
+ + "Release procedures are available at\n"
+ + ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
+ return;
+ }
+ }
+
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/src/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java
new file mode 100644
index 00000000..839a62e0
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java
@@ -0,0 +1,114 @@
+package me.totalfreedom.totalfreedommod.blocking;
+
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.block.BlockPlaceEvent;
+import org.bukkit.inventory.ItemStack;
+
+public class BlockBlocker extends AbstractService
+{
+
+ public BlockBlocker(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onBlockPlace(BlockPlaceEvent event)
+ {
+ final Player player = event.getPlayer();
+
+ switch (event.getBlockPlaced().getType())
+ {
+ case LAVA:
+ case STATIONARY_LAVA:
+ {
+ if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
+ {
+ FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
+
+ player.getInventory().clear(player.getInventory().getHeldItemSlot());
+ }
+ else
+ {
+ player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
+ player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
+
+ event.setCancelled(true);
+ }
+ break;
+ }
+ case WATER:
+ case STATIONARY_WATER:
+ {
+ if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
+ {
+ FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
+
+ player.getInventory().clear(player.getInventory().getHeldItemSlot());
+ }
+ else
+ {
+ player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
+ player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
+
+ event.setCancelled(true);
+ }
+ break;
+ }
+ case FIRE:
+ {
+ if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
+ {
+ FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
+
+ player.getInventory().clear(player.getInventory().getHeldItemSlot());
+ }
+ else
+ {
+ player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
+ player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
+
+ event.setCancelled(true);
+ }
+ break;
+ }
+ case TNT:
+ {
+ if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
+ {
+ FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
+
+ player.getInventory().clear(player.getInventory().getHeldItemSlot());
+ }
+ else
+ {
+ player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
+
+ player.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
+ event.setCancelled(true);
+ }
+ break;
+ }
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/listener/EntityListener.java b/src/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java
similarity index 52%
rename from src/me/totalfreedom/totalfreedommod/listener/EntityListener.java
rename to src/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java
index 574678d2..8da5c782 100644
--- a/src/me/totalfreedom/totalfreedommod/listener/EntityListener.java
+++ b/src/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java
@@ -1,36 +1,71 @@
-package me.totalfreedom.totalfreedommod.listener;
+package me.totalfreedom.totalfreedommod.blocking;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import net.pravian.aero.component.PluginListener;
-import org.bukkit.entity.Bat;
-import org.bukkit.entity.EnderDragon;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Ghast;
-import org.bukkit.entity.Giant;
-import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Projectile;
-import org.bukkit.entity.Slime;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
-import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.block.BlockBurnEvent;
+import org.bukkit.event.block.BlockFromToEvent;
+import org.bukkit.event.block.BlockIgniteEvent;
+import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
-public class EntityListener extends PluginListener
+public class EventBlocker extends AbstractService
{
- public EntityListener(TotalFreedomMod plugin)
+ public EventBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onBlockBurn(BlockBurnEvent event)
+ {
+ if (!ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
+ {
+ event.setCancelled(true);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onBlockIgnite(BlockIgniteEvent event)
+ {
+ if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
+ {
+ event.setCancelled(true);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onBlockFromTo(BlockFromToEvent event)
+ {
+ if (!ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
+ {
+ event.setCancelled(true);
+ }
+ }
+
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event)
{
@@ -52,7 +87,7 @@ public class EntityListener extends PluginListener
return;
}
- event.setRadius((float) ConfigEntry.EXPLOSIVE_RADIUS.getDouble().doubleValue());
+ event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
}
@EventHandler(priority = EventPriority.HIGH)
@@ -64,6 +99,28 @@ public class EntityListener extends PluginListener
}
}
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onEntityDeath(EntityDeathEvent event)
+ {
+ if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
+ {
+ event.setDroppedExp(0);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onProjectileHit(ProjectileHitEvent event)
+ {
+ if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
+ {
+ Projectile entity = event.getEntity();
+ if (event.getEntityType() == EntityType.ARROW)
+ {
+ entity.getWorld().createExplosion(entity.getLocation(), 2F);
+ }
+ }
+ }
+
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event)
{
@@ -93,97 +150,23 @@ public class EntityListener extends PluginListener
}
@EventHandler(priority = EventPriority.NORMAL)
- public void onCreatureSpawn(CreatureSpawnEvent event)
+ public void onPlayerDropItem(PlayerDropItemEvent event)
{
- if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
+ if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
- if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.EGG))
- {
- event.setCancelled(true);
- return;
- }
-
- Entity spawned = event.getEntity();
-
- if (spawned instanceof EnderDragon)
- {
- if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
- {
- event.setCancelled(true);
- return;
- }
- }
- else if (spawned instanceof Ghast)
- {
- if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
- {
- event.setCancelled(true);
- return;
- }
- }
- else if (spawned instanceof Slime)
- {
- if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
- {
- event.setCancelled(true);
- return;
- }
- }
- else if (spawned instanceof Giant)
- {
- if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
- {
- event.setCancelled(true);
- return;
- }
- }
- else if (spawned instanceof Bat)
- {
- event.setCancelled(true);
- return;
- }
-
- int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger().intValue();
-
- if (mobLimiterMax > 0)
- {
- int mobcount = 0;
-
- for (Entity entity : event.getLocation().getWorld().getLivingEntities())
- {
- if (!(entity instanceof HumanEntity))
- {
- mobcount++;
- }
- }
-
- if (mobcount > mobLimiterMax)
- {
- event.setCancelled(true);
- }
- }
+ return;
}
- }
- @EventHandler(priority = EventPriority.HIGH)
- public void onEntityDeath(EntityDeathEvent event)
- {
- if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
+ if (event.getPlayer().getWorld().getEntities().size() > 750)
{
- event.setDroppedExp(0);
+ event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
- public void onProjectileHit(ProjectileHitEvent event)
+ public void onLeavesDecay(LeavesDecayEvent event)
{
- if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
- {
- Projectile entity = event.getEntity();
- if (event.getEntityType() == EntityType.ARROW)
- {
- entity.getWorld().createExplosion(entity.getLocation(), 2F);
- }
- }
+ event.setCancelled(true);
}
+
}
diff --git a/src/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/src/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
new file mode 100644
index 00000000..215d145c
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java
@@ -0,0 +1,103 @@
+package me.totalfreedom.totalfreedommod.blocking;
+
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.ItemStack;
+
+public class InteractBlocker extends AbstractService
+{
+
+ public InteractBlocker(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onPlayerInteract(PlayerInteractEvent event)
+ {
+ final Player player = event.getPlayer();
+ final FPlayer playerdata = plugin.pl.getPlayer(player);
+
+ switch (event.getAction())
+ {
+ case RIGHT_CLICK_AIR:
+ case RIGHT_CLICK_BLOCK:
+ {
+ handleRightClick(event);
+ break;
+ }
+
+ case LEFT_CLICK_AIR:
+ case LEFT_CLICK_BLOCK:
+ {
+ //
+ break;
+ }
+ }
+ }
+
+ private void handleRightClick(PlayerInteractEvent event)
+ {
+ final Player player = event.getPlayer();
+
+ switch (event.getMaterial())
+ {
+ case WATER_BUCKET:
+ {
+ if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
+ {
+ break;
+ }
+
+ player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
+ player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
+ event.setCancelled(true);
+ break;
+ }
+
+ case LAVA_BUCKET:
+ {
+ if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
+ {
+ break;
+ }
+
+ player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
+ player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
+ event.setCancelled(true);
+ break;
+ }
+
+ case EXPLOSIVE_MINECART:
+ {
+ if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
+ {
+ break;
+ }
+
+ player.getInventory().clear(player.getInventory().getHeldItemSlot());
+ player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
+ event.setCancelled(true);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java b/src/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java
new file mode 100644
index 00000000..02073654
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java
@@ -0,0 +1,104 @@
+package me.totalfreedom.totalfreedommod.blocking;
+
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.entity.Bat;
+import org.bukkit.entity.EnderDragon;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Ghast;
+import org.bukkit.entity.Giant;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.entity.Slime;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+
+public class MobBlocker extends AbstractService
+{
+
+ public MobBlocker(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onCreatureSpawn(CreatureSpawnEvent event)
+ {
+ if (!ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
+ {
+ return;
+ }
+
+ final Entity spawned = event.getEntity();
+ if (spawned instanceof EnderDragon)
+ {
+ if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+ else if (spawned instanceof Ghast)
+ {
+ if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+ else if (spawned instanceof Slime)
+ {
+ if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+ else if (spawned instanceof Giant)
+ {
+ if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
+ {
+ event.setCancelled(true);
+ return;
+ }
+ }
+ else if (spawned instanceof Bat)
+ {
+ event.setCancelled(true);
+ return;
+ }
+
+ int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger();
+
+ if (mobLimiterMax <= 0)
+ {
+ return;
+ }
+
+ int mobcount = 0;
+ for (Entity entity : event.getLocation().getWorld().getLivingEntities())
+ {
+ if (!(entity instanceof HumanEntity))
+ {
+ mobcount++;
+ }
+ }
+
+ if (mobcount > mobLimiterMax)
+ {
+ event.setCancelled(true);
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlocker.java b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java
similarity index 91%
rename from src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlocker.java
rename to src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java
index 6ddde794..2698d8b3 100644
--- a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlocker.java
+++ b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.commandblocker;
+package me.totalfreedom.totalfreedommod.blocking.command;
import com.google.common.collect.Maps;
import java.util.List;
@@ -15,6 +15,9 @@ import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandBlocker extends AbstractService
{
@@ -113,6 +116,17 @@ public class CommandBlocker extends AbstractService
FLog.info("Loaded " + blockedCommands.size() + " blocked commands");
}
+ @EventHandler(priority = EventPriority.HIGHEST)
+ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
+ {
+ // Blocked commands
+ if (isCommandBlocked(event.getMessage(), event.getPlayer(), true))
+ {
+ // CommandBlocker handles messages and broadcasts
+ event.setCancelled(true);
+ }
+ }
+
public boolean isCommandBlocked(String command, CommandSender sender)
{
return isCommandBlocked(command, sender, false);
diff --git a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerAction.java b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerAction.java
similarity index 91%
rename from src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerAction.java
rename to src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerAction.java
index c65f8cbd..9993b7fd 100644
--- a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerAction.java
+++ b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerAction.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.commandblocker;
+package me.totalfreedom.totalfreedommod.blocking.command;
public enum CommandBlockerAction
{
diff --git a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerEntry.java b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java
similarity index 96%
rename from src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerEntry.java
rename to src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java
index 66eb4cc4..9bf249f4 100644
--- a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerEntry.java
+++ b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.commandblocker;
+package me.totalfreedom.totalfreedommod.blocking.command;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.util.FUtil;
diff --git a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerRank.java b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java
similarity index 92%
rename from src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerRank.java
rename to src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java
index 4a4be723..ce9453ec 100644
--- a/src/me/totalfreedom/totalfreedommod/commandblocker/CommandBlockerRank.java
+++ b/src/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java
@@ -1,7 +1,7 @@
-package me.totalfreedom.totalfreedommod.commandblocker;
+package me.totalfreedom.totalfreedommod.blocking.command;
import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java b/src/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java
index 20b600d1..c2295bea 100644
--- a/src/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java
+++ b/src/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java
@@ -6,7 +6,7 @@ import me.StevenLawson.BukkitTelnet.api.TelnetCommandEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetPreLoginEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player;
diff --git a/src/me/totalfreedom/totalfreedommod/caging/CageData.java b/src/me/totalfreedom/totalfreedommod/caging/CageData.java
new file mode 100644
index 00000000..407888c2
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/caging/CageData.java
@@ -0,0 +1,194 @@
+package me.totalfreedom.totalfreedommod.caging;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Getter;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.SkullType;
+import org.bukkit.block.Block;
+import org.bukkit.block.Skull;
+
+public class CageData
+{
+ private final FPlayer fPlayer;
+ //
+ private final List cageHistory = new ArrayList();
+ //
+ @Getter
+ private boolean caged = false;
+ @Getter
+ private Location location;
+ @Getter
+ private Material outerMaterial = Material.GLASS;
+ @Getter
+ private Material innerMaterial = Material.AIR;
+
+ public CageData(FPlayer player)
+ {
+ this.fPlayer = player;
+ }
+
+ public void setCaged(boolean cage)
+ {
+ if (cage)
+ {
+ cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
+ }
+ else
+ {
+ this.caged = false;
+ regenerateHistory();
+ clearHistory();
+ }
+
+ }
+
+ public void cage(Location location, Material outer, Material inner)
+ {
+ if (isCaged())
+ {
+ setCaged(false);
+ }
+
+ this.caged = true;
+ this.location = location;
+ this.outerMaterial = outer;
+ this.innerMaterial = inner;
+
+ buildHistory(location, 2, fPlayer);
+ generateHollowCube(location, 2, outer);
+ generateCube(location, 1, inner);
+ }
+
+ // TODO: EventHandlerize this?
+ public void playerJoin()
+ {
+ if (!isCaged())
+ {
+ return;
+ }
+
+ cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial);
+ }
+
+ public void playerQuit()
+ {
+ regenerateHistory();
+ clearHistory();
+ }
+
+ public void clearHistory()
+ {
+ cageHistory.clear();
+ }
+
+ private void insertHistoryBlock(Location location, Material material)
+ {
+ cageHistory.add(new BlockData(location, material));
+ }
+
+ private void regenerateHistory()
+ {
+ for (BlockData blockdata : this.cageHistory)
+ {
+ blockdata.location.getBlock().setType(blockdata.material);
+ }
+ }
+
+ private void buildHistory(Location location, int length, FPlayer playerdata)
+ {
+ final Block center = location.getBlock();
+ for (int xOffset = -length; xOffset <= length; xOffset++)
+ {
+ for (int yOffset = -length; yOffset <= length; yOffset++)
+ {
+ for (int zOffset = -length; zOffset <= length; zOffset++)
+ {
+ final Block block = center.getRelative(xOffset, yOffset, zOffset);
+ insertHistoryBlock(block.getLocation(), block.getType());
+ }
+ }
+ }
+ }
+
+ // Util methods
+ public static void generateCube(Location location, int length, Material material)
+ {
+ final Block center = location.getBlock();
+ for (int xOffset = -length; xOffset <= length; xOffset++)
+ {
+ for (int yOffset = -length; yOffset <= length; yOffset++)
+ {
+ for (int zOffset = -length; zOffset <= length; zOffset++)
+ {
+ final Block block = center.getRelative(xOffset, yOffset, zOffset);
+ if (block.getType() != material)
+ {
+ block.setType(material);
+ }
+ }
+ }
+ }
+ }
+
+ public static void generateHollowCube(Location location, int length, Material material)
+ {
+ final Block center = location.getBlock();
+ for (int xOffset = -length; xOffset <= length; xOffset++)
+ {
+ for (int yOffset = -length; yOffset <= length; yOffset++)
+ {
+ for (int zOffset = -length; zOffset <= length; zOffset++)
+ {
+ // Hollow
+ if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
+ {
+ continue;
+ }
+
+ final Block block = center.getRelative(xOffset, yOffset, zOffset);
+
+ if (material != Material.SKULL)
+ {
+ // Glowstone light
+ if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
+ {
+ block.setType(Material.GLOWSTONE);
+ continue;
+ }
+
+ block.setType(material);
+ }
+ else // Darth mode
+ {
+ if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
+ {
+ block.setType(Material.GLOWSTONE);
+ continue;
+ }
+
+ block.setType(Material.SKULL);
+ final Skull skull = (Skull) block.getState();
+ skull.setSkullType(SkullType.PLAYER);
+ skull.setOwner("Prozza");
+ skull.update();
+ }
+ }
+ }
+ }
+ }
+
+ private static class BlockData
+ {
+ public Material material;
+ public Location location;
+
+ private BlockData(Location location, Material material)
+ {
+ this.location = location;
+ this.material = material;
+ }
+ }
+}
diff --git a/src/me/totalfreedom/totalfreedommod/caging/Cager.java b/src/me/totalfreedom/totalfreedommod/caging/Cager.java
new file mode 100644
index 00000000..6c66a252
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/caging/Cager.java
@@ -0,0 +1,88 @@
+package me.totalfreedom.totalfreedommod.caging;
+
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class Cager extends AbstractService
+{
+
+ public Cager(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler
+ public void onPlayerMove(PlayerMoveEvent event)
+ {
+ FPlayer player = plugin.pl.getPlayer(event.getPlayer());
+ CageData cage = player.getCageData();
+
+ if (!cage.isCaged())
+ {
+ return;
+ }
+
+ Location playerLoc = player.getPlayer().getLocation().add(0, 1, 0);
+ Location cageLoc = cage.getLocation();
+
+ final boolean outOfCage;
+ if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
+ {
+ outOfCage = true;
+ }
+ else
+ {
+ outOfCage = playerLoc.distanceSquared(cageLoc) > (2.5D * 2.5D);
+ }
+
+ if (outOfCage)
+ {
+ player.getPlayer().teleport(cageLoc.subtract(0, 0.5, 0));
+ FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
+ public void onPlayerQuit(PlayerQuitEvent event)
+ {
+ FPlayer player = plugin.pl.getPlayer(event.getPlayer());
+ CageData cage = player.getCageData();
+
+ if (cage.isCaged())
+ {
+ cage.playerQuit();
+ }
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
+ public void onPlayerJoin(PlayerJoinEvent event)
+ {
+ FPlayer player = plugin.pl.getPlayer(event.getPlayer());
+ CageData cage = player.getCageData();
+
+ if (cage.isCaged())
+ {
+ cage.playerJoin();
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/CommandLoader.java b/src/me/totalfreedom/totalfreedommod/commands/CommandLoader.java
index 4fe798e5..dfa3cfb4 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/CommandLoader.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/CommandLoader.java
@@ -1,14 +1,14 @@
package me.totalfreedom.totalfreedommod.commands;
import lombok.Getter;
-import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.command.handler.SimpleCommandHandler;
import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.ChatColor;
public class CommandLoader extends AbstractService
{
-
@Getter
private final SimpleCommandHandler handler;
@@ -23,12 +23,14 @@ public class CommandLoader extends AbstractService
protected void onStart()
{
handler.clearCommands();
- handler.setExecutorFactory(new FreedomCommandExecutor.TFM_CommandExecutorFactory());
+ handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory());
handler.setCommandClassPrefix("Command_");
- handler.loadFrom(FreedomCommand.class.getPackage());
- handler.registerAll();
+ handler.setPermissionMessage(ChatColor.YELLOW + "You do not have permission to use this command.");
- FLog.info("Loaded" + handler.getExecutors().size() + " commands");
+ handler.loadFrom(FreedomCommand.class.getPackage());
+ handler.registerAll("TotalFreedomMod", true);
+
+ FLog.info("Loaded " + handler.getExecutors().size() + " commands");
}
@Override
diff --git a/src/me/totalfreedom/totalfreedommod/commands/CommandPermissions.java b/src/me/totalfreedom/totalfreedommod/commands/CommandPermissions.java
index 95163095..0d491901 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/CommandPermissions.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/CommandPermissions.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_adminmode.java b/src/me/totalfreedom/totalfreedommod/commands/Command_adminmode.java
index 176134a7..eae0e001 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_adminmode.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_adminmode.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_adminworld.java b/src/me/totalfreedom/totalfreedommod/commands/Command_adminworld.java
index 4c158e26..c84e0102 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_adminworld.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_adminworld.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.world.WorldTime;
import me.totalfreedom.totalfreedommod.world.WorldWeather;
@@ -208,7 +208,12 @@ public class Command_adminworld extends FreedomCommand
}
catch (PermissionDeniedException ex)
{
+ if (ex.getMessage().isEmpty())
+ {
+ return noPerms();
+ }
sender.sendMessage(ex.getMessage());
+ return true;
}
return true;
@@ -219,7 +224,7 @@ public class Command_adminworld extends FreedomCommand
{
if (!(sender instanceof Player) || sender_p == null || !isAdmin(sender))
{
- throw new PermissionDeniedException(FreedomCommand.MSG_NO_PERMS);
+ throw new PermissionDeniedException();
}
}
@@ -228,6 +233,11 @@ public class Command_adminworld extends FreedomCommand
private static final long serialVersionUID = 1L;
+ private PermissionDeniedException()
+ {
+ super("");
+ }
+
private PermissionDeniedException(String string)
{
super(string);
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_blockcmd.java b/src/me/totalfreedom/totalfreedommod/commands/Command_blockcmd.java
index 14ea4874..977bb38e 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_blockcmd.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_blockcmd.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_cage.java b/src/me/totalfreedom/totalfreedommod/commands/Command_cage.java
index 025797b6..09b9a4a4 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_cage.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_cage.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
@@ -27,10 +27,7 @@ public class Command_cage extends FreedomCommand
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
FPlayer playerdata = plugin.pl.getPlayer(sender_p);
- playerdata.setCaged(false);
- playerdata.regenerateHistory();
- playerdata.clearHistory();
-
+ playerdata.getCageData().setCaged(false);
return true;
}
else if ("purge".equals(args[0]))
@@ -40,9 +37,7 @@ public class Command_cage extends FreedomCommand
for (Player player : server.getOnlinePlayers())
{
FPlayer playerdata = plugin.pl.getPlayer(player);
- playerdata.setCaged(false);
- playerdata.regenerateHistory();
- playerdata.clearHistory();
+ playerdata.getCageData().setCaged(false);
}
return true;
@@ -66,10 +61,7 @@ public class Command_cage extends FreedomCommand
if ("off".equals(args[1]))
{
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
-
- playerdata.setCaged(false);
- playerdata.regenerateHistory();
- playerdata.clearHistory();
+ playerdata.getCageData().setCaged(false);
return true;
}
@@ -99,12 +91,7 @@ public class Command_cage extends FreedomCommand
}
Location targetPos = player.getLocation().clone().add(0, 1, 0);
- playerdata.setCaged(true, targetPos, outerMaterial, innerMaterial);
- playerdata.regenerateHistory();
- playerdata.clearHistory();
- FUtil.buildHistory(targetPos, 2, playerdata);
- FUtil.generateHollowCube(targetPos, 2, outerMaterial);
- FUtil.generateCube(targetPos, 1, innerMaterial);
+ playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
player.setGameMode(GameMode.SURVIVAL);
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_cake.java b/src/me/totalfreedom/totalfreedommod/commands/Command_cake.java
index b061dbb1..75a5db0c 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_cake.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_cake.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Random;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Achievement;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_cartsit.java b/src/me/totalfreedom/totalfreedommod/commands/Command_cartsit.java
index c25ec6ba..ee76c695 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_cartsit.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_cartsit.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Minecart;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_cbtool.java b/src/me/totalfreedom/totalfreedommod/commands/Command_cbtool.java
index 0f2ca34e..9b652f20 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_cbtool.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_cbtool.java
@@ -1,10 +1,9 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang3.ArrayUtils;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_cmdspy.java b/src/me/totalfreedom/totalfreedommod/commands/Command_cmdspy.java
index 5bd157c9..16be9581 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_cmdspy.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_cmdspy.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_colorme.java b/src/me/totalfreedom/totalfreedommod/commands/Command_colorme.java
index 25e9156e..54a08de1 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_colorme.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_colorme.java
@@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Iterator;
import java.util.Map;
-import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_cmdlist.java b/src/me/totalfreedom/totalfreedommod/commands/Command_commandlist.java
similarity index 90%
rename from src/me/totalfreedom/totalfreedommod/commands/Command_cmdlist.java
rename to src/me/totalfreedom/totalfreedommod/commands/Command_commandlist.java
index c2e74b25..5c316b2f 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_cmdlist.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_commandlist.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -14,8 +14,8 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@CommandPermissions(level = PlayerRank.NON_OP, source = SourceType.BOTH)
-@CommandParameters(description = "Show all commands for all server plugins.", usage = "/")
-public class Command_cmdlist extends FreedomCommand
+@CommandParameters(description = "Show all commands for all server plugins.", usage = "/", aliases = "cmdlist")
+public class Command_commandlist extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_creative.java b/src/me/totalfreedom/totalfreedommod/commands/Command_creative.java
index 030ee6ff..e82ea2a4 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_creative.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_creative.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
@@ -34,7 +34,7 @@ public class Command_creative extends FreedomCommand
{
if (!isAdmin(sender))
{
- sender.sendMessage(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_csay.java b/src/me/totalfreedom/totalfreedommod/commands/Command_csay.java
index 72315c56..1a4c97f2 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_csay.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_csay.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_deafen.java b/src/me/totalfreedom/totalfreedommod/commands/Command_deafen.java
index 4f4f209b..00cce786 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_deafen.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_deafen.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Sound;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_debug.java b/src/me/totalfreedom/totalfreedommod/commands/Command_debug.java
index 7a49cfb0..83674c75 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_debug.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_debug.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.lang.reflect.Field;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_denick.java b/src/me/totalfreedom/totalfreedommod/commands/Command_denick.java
index cc9d9661..2e4f08d0 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_denick.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_denick.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_deop.java b/src/me/totalfreedom/totalfreedommod/commands/Command_deop.java
index dc282fe8..868f003d 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_deop.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_deop.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.OfflinePlayer;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_deopall.java b/src/me/totalfreedom/totalfreedommod/commands/Command_deopall.java
index 2b42560d..7b468f84 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_deopall.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_deopall.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_dispfill.java b/src/me/totalfreedom/totalfreedommod/commands/Command_dispfill.java
index 37777f5d..dd5887f2 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_dispfill.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_dispfill.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_doom.java b/src/me/totalfreedom/totalfreedommod/commands/Command_doom.java
index c6c98e2b..d89aa664 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_doom.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_doom.java
@@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.banning.FBan;
-import me.totalfreedom.totalfreedommod.player.PlayerList;
+import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@@ -53,7 +52,7 @@ public class Command_doom extends FreedomCommand
player.setOp(false);
// Ban player
- FBan ban = FBan.forPlayer(player, sender);
+ Ban ban = Ban.forPlayer(player, sender);
ban.setReason("&cFUCKOFF");
for (String playerIp : plugin.pl.getData(player).getIps())
{
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_enchant.java b/src/me/totalfreedom/totalfreedommod/commands/Command_enchant.java
index 5d9d3cc8..b790342a 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_enchant.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_enchant.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -10,113 +10,81 @@ import org.bukkit.inventory.ItemStack;
@CommandPermissions(level = PlayerRank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Enchant items.", usage = "/ | remove >")
-public class Command_enchant extends FreedomCommand
-{
+public class Command_enchant extends FreedomCommand {
+
@Override
- public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (args.length < 1)
- {
+ public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
+ if (args.length < 1) {
return false;
}
ItemStack itemInHand = sender_p.getItemInHand();
- if (itemInHand == null)
- {
+ if (itemInHand == null) {
playerMsg("You are holding an invalid item.");
return true;
}
- if (args[0].equalsIgnoreCase("list"))
- {
+ if (args[0].equalsIgnoreCase("list")) {
boolean has_enchantments = false;
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
- for (Enchantment ench : Enchantment.values())
- {
- if (ench.canEnchantItem(itemInHand))
- {
+ for (Enchantment ench : Enchantment.values()) {
+ if (ench.canEnchantItem(itemInHand)) {
has_enchantments = true;
possible_ench.append(ench.getName()).append(", ");
}
}
- if (has_enchantments)
- {
+ if (has_enchantments) {
playerMsg(possible_ench.toString());
- }
- else
- {
+ } else {
playerMsg("The held item has no enchantments.");
}
- }
- else if (args[0].equalsIgnoreCase("addall"))
- {
- for (Enchantment ench : Enchantment.values())
- {
- try
- {
- if (ench.canEnchantItem(itemInHand))
- {
+ } else if (args[0].equalsIgnoreCase("addall")) {
+ for (Enchantment ench : Enchantment.values()) {
+ try {
+ if (ench.canEnchantItem(itemInHand)) {
itemInHand.addEnchantment(ench, ench.getMaxLevel());
}
- }
- catch (Exception ex)
- {
+ } catch (Exception ex) {
FLog.info("Error using " + ench.getName() + " on " + itemInHand.getType().name() + " held by " + sender_p.getName() + ".");
}
}
playerMsg("Added all possible enchantments for this item.");
- }
- else if (args[0].equalsIgnoreCase("reset"))
- {
- for (Enchantment ench : itemInHand.getEnchantments().keySet())
- {
+ } else if (args[0].equalsIgnoreCase("reset")) {
+ for (Enchantment ench : itemInHand.getEnchantments().keySet()) {
itemInHand.removeEnchantment(ench);
}
playerMsg("Removed all enchantments.");
- }
- else
- {
- if (args.length < 2)
- {
+ } else {
+ if (args.length < 2) {
return false;
}
Enchantment ench = null;
- try
- {
+ try {
ench = Enchantment.getByName(args[1]);
- }
- catch (Exception ex)
- {
+ } catch (Exception ex) {
}
- if (ench == null)
- {
+ if (ench == null) {
playerMsg(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
return true;
}
- if (args[0].equalsIgnoreCase("add"))
- {
- if (ench.canEnchantItem(itemInHand))
- {
+ if (args[0].equalsIgnoreCase("add")) {
+ if (ench.canEnchantItem(itemInHand)) {
itemInHand.addEnchantment(ench, ench.getMaxLevel());
playerMsg("Added enchantment: " + ench.getName());
- }
- else
- {
+ } else {
playerMsg("Can't use this enchantment on held item.");
}
- }
- else if (args[0].equals("remove"))
- {
+ } else if (args[0].equals("remove")) {
itemInHand.removeEnchantment(ench);
playerMsg("Removed enchantment: " + ench.getName());
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_ender.java b/src/me/totalfreedom/totalfreedommod/commands/Command_ender.java
index 92b79b68..3a213075 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_ender.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_ender.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_expel.java b/src/me/totalfreedom/totalfreedommod/commands/Command_expel.java
index 57d632fc..97333989 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_expel.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_expel.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FUtil;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_findip.java b/src/me/totalfreedom/totalfreedommod/commands/Command_findip.java
index 7dd87b90..17169b34 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_findip.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_findip.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_flatlands.java b/src/me/totalfreedom/totalfreedommod/commands/Command_flatlands.java
index 1b3d38f1..9fde2676 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_flatlands.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_flatlands.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_fr.java b/src/me/totalfreedom/totalfreedommod/commands/Command_fr.java
index c6f82f6b..9b8fc4d5 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_fr.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_fr.java
@@ -1,10 +1,8 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import org.bukkit.Bukkit;
+import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -14,71 +12,56 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/ [target | purge]")
public class Command_fr extends FreedomCommand
{
- private static boolean allFrozen = false;
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
- allFrozen = !allFrozen;
+ boolean allFrozen = plugin.fm.isGlobalFreeze();
+ plugin.fm.setGlobalFreeze(!allFrozen);
- if (allFrozen)
+ if (!allFrozen)
{
- FUtil.adminAction(sender.getName(), "Freezing all players", false);
-
- setAllFrozen(true);
- playerMsg("Players are now frozen.");
-
- for (Player player : Bukkit.getOnlinePlayers())
- {
- if (!isAdmin(player))
- {
- playerMsg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
- }
- }
- }
- else
- {
- FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
- setAllFrozen(false);
+ FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
playerMsg("Players are now free to move.");
+ return true;
}
- }
- else
- {
- if (args[0].toLowerCase().equals("purge"))
- {
- setAllFrozen(false);
- FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
- }
- else
- {
- final Player player = getPlayer(args[0]);
- if (player == null)
+ FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
+ playerMsg("Players are now unfrozen.");
+
+ for (Player player : server.getOnlinePlayers())
+ {
+ if (!isAdmin(player))
{
- playerMsg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
- return true;
+ playerMsg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
}
-
- final FPlayer playerdata = plugin.pl.getPlayer(player);
- playerdata.setFrozen(!playerdata.isFrozen());
-
- playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
- playerMsg(player, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
}
+ return true;
}
+ if (args[0].equals("purge"))
+ {
+ FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
+ plugin.fm.purge();
+ return true;
+ }
+
+ final Player player = getPlayer(args[0]);
+
+ if (player == null)
+ {
+ playerMsg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
+ return true;
+ }
+
+ final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
+ fd.setFrozen(!fd.isFrozen());
+
+ playerMsg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
+ playerMsg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
+
return true;
}
-
- public static void setAllFrozen(boolean freeze)
- {
- allFrozen = freeze;
- for (FPlayer data : TotalFreedomMod.plugin.pl.playerMap.values())
- {
- data.setFrozen(freeze);
- }
- }
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_fuckoff.java b/src/me/totalfreedom/totalfreedommod/commands/Command_fuckoff.java
index d2018335..175c9603 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_fuckoff.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_fuckoff.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -19,36 +19,31 @@ public class Command_fuckoff extends FreedomCommand
return false;
}
- boolean fuckoff_enabled = false;
- double fuckoff_range = 25.0;
+ FPlayer player = plugin.pl.getPlayer(sender_p);
- if (args[0].equalsIgnoreCase("on"))
+ if (!args[0].equals("on"))
+ {
+ player.disableFuckoff();
+ }
+ else
{
- fuckoff_enabled = true;
+ double radius = 25.0;
if (args.length >= 2)
{
try
{
- fuckoff_range = Math.max(5.0, Math.min(100.0, Double.parseDouble(args[1])));
+ radius = Math.max(5.0, Math.min(50, Double.parseDouble(args[1])));
}
catch (NumberFormatException ex)
{
}
}
+
+ player.setFuckoff(radius);
}
- if (TotalFreedomMod.fuckoffEnabledFor.containsKey(sender_p))
- {
- TotalFreedomMod.fuckoffEnabledFor.remove(sender_p);
- }
-
- if (fuckoff_enabled)
- {
- TotalFreedomMod.fuckoffEnabledFor.put(sender_p, new Double(fuckoff_range));
- }
-
- playerMsg("Fuckoff " + (fuckoff_enabled ? ("enabled. Range: " + fuckoff_range + ".") : "disabled."));
+ playerMsg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_gadmin.java b/src/me/totalfreedom/totalfreedommod/commands/Command_gadmin.java
index aa6f21be..41e7fb7f 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_gadmin.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_gadmin.java
@@ -1,11 +1,11 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.UUID;
-import me.totalfreedom.totalfreedommod.banning.FBan;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.banning.Ban;
+import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -126,7 +126,7 @@ public class Command_gadmin extends FreedomCommand
case NAMEBAN:
{
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s.", target.getName()), true);
- plugin.bm.addBan(FBan.forPlayerName(target, sender, null, null));
+ plugin.bm.addBan(Ban.forPlayerName(target, sender, null, null));
target.kickPlayer("Username banned by Administrator.");
break;
@@ -140,7 +140,7 @@ public class Command_gadmin extends FreedomCommand
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
}
FUtil.adminAction(sender.getName(), String.format("Banning IP: %s.", ip), true);
- plugin.bm.addBan(FBan.forPlayerIp(ip, sender, null, null));
+ plugin.bm.addBan(Ban.forPlayerIp(ip, sender, null, null));
target.kickPlayer("IP address banned by Administrator.");
@@ -156,7 +156,7 @@ public class Command_gadmin extends FreedomCommand
}
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", target.getName(), ip), true);
- plugin.bm.addBan(FBan.forPlayer(target, sender));
+ plugin.bm.addBan(Ban.forPlayer(target, sender));
target.kickPlayer("IP and username banned by Administrator.");
@@ -186,11 +186,11 @@ public class Command_gadmin extends FreedomCommand
}
case FR:
{
- FPlayer playerdata = plugin.pl.getPlayer(target);
- playerdata.setFrozen(!playerdata.isFrozen());
+ FreezeData fd = plugin.pl.getPlayer(target).getFreezeData();
+ fd.setFrozen(!fd.isFrozen());
- playerMsg(target.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
- target.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
+ playerMsg(target.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
+ target.sendMessage(ChatColor.AQUA + "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
break;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_gcmd.java b/src/me/totalfreedom/totalfreedommod/commands/Command_gcmd.java
index 46f36d87..71b427ba 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_gcmd.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_gcmd.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_glist.java b/src/me/totalfreedom/totalfreedommod/commands/Command_glist.java
index cf4660cf..d527243e 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_glist.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_glist.java
@@ -1,9 +1,9 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
-import me.totalfreedom.totalfreedommod.banning.FBan;
+import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FUtil;
@@ -82,7 +82,7 @@ public class Command_glist extends FreedomCommand
target.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: " + ConfigEntry.SERVER_BAN_URL.getString());
}
- FBan ban = FBan.forPlayerFuzzy(player, sender, null, null);
+ Ban ban = Ban.forPlayerFuzzy(player, sender, null, null);
for (String ip : ips)
{
ban.addIp(ip);
@@ -96,7 +96,7 @@ public class Command_glist extends FreedomCommand
plugin.bm.removeBan(plugin.bm.getByUsername(username));
for (String ip : ips)
{
- FBan ban = plugin.bm.getByIp(ip);
+ Ban ban = plugin.bm.getByIp(ip);
if (ban != null)
{
plugin.bm.removeBan(ban);
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_gtfo.java b/src/me/totalfreedom/totalfreedommod/commands/Command_gtfo.java
index c26b17a0..7cb82295 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_gtfo.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_gtfo.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.banning.FBan;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.banning.Ban;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.ArrayUtils;
@@ -89,7 +89,7 @@ public class Command_gtfo extends FreedomCommand
FUtil.bcastMsg(bcast.toString());
// Ban player
- plugin.bm.addBan(FBan.forPlayerFuzzy(player, sender, null, reason));
+ plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason));
// Kick player
player.kickPlayer(ChatColor.RED + "GTFO");
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_halt.java b/src/me/totalfreedom/totalfreedommod/commands/Command_halt.java
deleted file mode 100644
index fe9da3c3..00000000
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_halt.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package me.totalfreedom.totalfreedommod.commands;
-
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
-@CommandParameters(description = "Halts a player", usage = "/ < | all | purge | list>")
-public class Command_halt extends FreedomCommand
-{
- @Override
- public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (args.length != 1)
- {
- return false;
- }
-
- if (args[0].equalsIgnoreCase("all"))
- {
- FUtil.adminAction(sender.getName(), "Halting all non-superadmins.", true);
- int counter = 0;
- for (Player player : server.getOnlinePlayers())
- {
- if (!plugin.al.isAdmin(player))
- {
- plugin.pl.getPlayer(player).setHalted(true);
- counter++;
- }
- }
- playerMsg("Halted " + counter + " players.");
- return true;
- }
-
- if (args[0].equalsIgnoreCase("purge"))
- {
- FUtil.adminAction(sender.getName(), "Unhalting all players.", true);
- int counter = 0;
- for (Player player : server.getOnlinePlayers())
- {
- FPlayer playerdata = plugin.pl.getPlayer(player);
- if (plugin.pl.getPlayer(player).isHalted())
- {
- playerdata.setHalted(false);
- counter++;
- }
- }
- playerMsg("Unhalted " + counter + " players.");
- return true;
- }
-
- if (args[0].equalsIgnoreCase("list"))
- {
- FPlayer info;
- int count = 0;
- for (Player hp : server.getOnlinePlayers())
- {
- info = plugin.pl.getPlayer(hp);
- if (info.isHalted())
- {
- if (count == 0)
- {
- playerMsg("Halted players:");
- }
- playerMsg("- " + hp.getName());
- count++;
- }
- }
- if (count == 0)
- {
- playerMsg("There are currently no halted players.");
- }
- return true;
- }
-
- final Player player = getPlayer(args[0]);
-
- if (player == null)
- {
- sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
- return true;
- }
-
- FPlayer playerdata = plugin.pl.getPlayer(player);
- if (!playerdata.isHalted())
- {
- FUtil.adminAction(sender.getName(), "Halting " + player.getName(), true);
- playerdata.setHalted(true);
- return true;
- }
- else
- {
- FUtil.adminAction(sender.getName(), "Unhalting " + player.getName(), true);
- playerdata.setHalted(false);
- return true;
- }
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_health.java b/src/me/totalfreedom/totalfreedommod/commands/Command_health.java
index a681fac7..ac0b8479 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_health.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_health.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.text.DecimalFormat;
import java.util.concurrent.atomic.AtomicInteger;
import me.totalfreedom.totalfreedommod.util.FLog;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_invis.java b/src/me/totalfreedom/totalfreedommod/commands/Command_invis.java
index 506f73c7..d49f2b7e 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_invis.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_invis.java
@@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_jumppads.java b/src/me/totalfreedom/totalfreedommod/commands/Command_jumppads.java
index 0125b96b..cebeb51a 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_jumppads.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_jumppads.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.Jumppads;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
+import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_kicknoob.java b/src/me/totalfreedom/totalfreedommod/commands/Command_kicknoob.java
index ca2e94b1..ca6ada50 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_kicknoob.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_kicknoob.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_landmine.java b/src/me/totalfreedom/totalfreedommod/commands/Command_landmine.java
index b1d51441..64ba86bf 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_landmine.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_landmine.java
@@ -1,12 +1,10 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import java.util.ArrayList;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Iterator;
-import java.util.List;
+import me.totalfreedom.totalfreedommod.fun.Landminer.Landmine;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.ChatColor;
-import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -37,9 +35,9 @@ public class Command_landmine extends FreedomCommand
if (args.length >= 1)
{
- if ("list".equalsIgnoreCase(args[0]))
+ if ("list".equals(args[0]))
{
- final Iterator landmines = TFM_LandmineData.landmines.iterator();
+ final Iterator landmines = plugin.lm.getLandmines().iterator();
while (landmines.hasNext())
{
playerMsg(landmines.next().toString());
@@ -58,31 +56,11 @@ public class Command_landmine extends FreedomCommand
final Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN);
landmine.setType(Material.TNT);
- TFM_LandmineData.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p, radius));
+ plugin.lm.add(new Landmine(landmine.getLocation(), sender_p, radius));
playerMsg("Landmine planted - Radius = " + radius + " blocks.", ChatColor.GREEN);
return true;
}
- public static class TFM_LandmineData
- {
- public static final List landmines = new ArrayList();
- public final Location location;
- public final Player player;
- public final double radius;
-
- public TFM_LandmineData(Location location, Player player, double radius)
- {
- this.location = location;
- this.player = player;
- this.radius = radius;
- }
-
- @Override
- public String toString()
- {
- return this.location.toString() + ", " + this.radius + ", " + this.player.getName();
- }
- }
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_lastcmd.java b/src/me/totalfreedom/totalfreedommod/commands/Command_lastcmd.java
index daa8be2e..76f3af24 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_lastcmd.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_lastcmd.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_list.java b/src/me/totalfreedom/totalfreedommod/commands/Command_list.java
index 9e837286..9b2f7e7a 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_list.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_list.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FUtil;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_localspawn.java b/src/me/totalfreedom/totalfreedommod/commands/Command_localspawn.java
index 29f9a4de..55ca066a 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_localspawn.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_localspawn.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_lockup.java b/src/me/totalfreedom/totalfreedommod/commands/Command_lockup.java
index 29027765..12986cf3 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_lockup.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_lockup.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_logs.java b/src/me/totalfreedom/totalfreedommod/commands/Command_logs.java
index 8640e2d5..07937ad4 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_logs.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_logs.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_moblimiter.java b/src/me/totalfreedom/totalfreedommod/commands/Command_moblimiter.java
index b91eeede..775494fd 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_moblimiter.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_moblimiter.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.GameRuleHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -9,70 +9,47 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Control mob rezzing parameters.", usage = "/ |dragon|giant|ghast|slime>")
-public class Command_moblimiter extends FreedomCommand
-{
+public class Command_moblimiter extends FreedomCommand {
+
@Override
- public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (args.length < 1)
- {
+ public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
+ if (args.length < 1) {
return false;
}
- if (args[0].equalsIgnoreCase("on"))
- {
+ if (args[0].equalsIgnoreCase("on")) {
ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true);
- }
- else if (args[0].equalsIgnoreCase("off"))
- {
+ } else if (args[0].equalsIgnoreCase("off")) {
ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(false);
- }
- else if (args[0].equalsIgnoreCase("dragon"))
- {
+ } else if (args[0].equalsIgnoreCase("dragon")) {
ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean());
- }
- else if (args[0].equalsIgnoreCase("giant"))
- {
+ } else if (args[0].equalsIgnoreCase("giant")) {
ConfigEntry.MOB_LIMITER_DISABLE_GIANT.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean());
- }
- else if (args[0].equalsIgnoreCase("slime"))
- {
+ } else if (args[0].equalsIgnoreCase("slime")) {
ConfigEntry.MOB_LIMITER_DISABLE_SLIME.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean());
- }
- else if (args[0].equalsIgnoreCase("ghast"))
- {
+ } else if (args[0].equalsIgnoreCase("ghast")) {
ConfigEntry.MOB_LIMITER_DISABLE_GHAST.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean());
- }
- else
- {
- if (args.length < 2)
- {
+ } else {
+ if (args.length < 2) {
return false;
}
- if (args[0].equalsIgnoreCase("setmax"))
- {
- try
- {
+ if (args[0].equalsIgnoreCase("setmax")) {
+ try {
ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
- }
- catch (NumberFormatException nfex)
- {
+ } catch (NumberFormatException nfex) {
}
}
}
- if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
- {
+ if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean()) {
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
playerMsg("Dragon: " + (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Giant: " + (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Slime: " + (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Ghast: " + (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean() ? "disabled" : "enabled") + ".");
- }
- else
- {
+ } else {
playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_mp.java b/src/me/totalfreedom/totalfreedommod/commands/Command_mobpurge.java
similarity index 89%
rename from src/me/totalfreedom/totalfreedommod/commands/Command_mp.java
rename to src/me/totalfreedom/totalfreedommod/commands/Command_mobpurge.java
index 10ae90f5..a2bf98ac 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_mp.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_mobpurge.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
@@ -14,8 +14,8 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
-@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/")
-public class Command_mp extends FreedomCommand
+@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/", aliases = "mp")
+public class Command_mobpurge extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_mp44.java b/src/me/totalfreedom/totalfreedommod/commands/Command_mp44.java
index 657f5059..15ad11d3 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_mp44.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_mp44.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_nether.java b/src/me/totalfreedom/totalfreedommod/commands/Command_nether.java
index fc499d53..904b5d99 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_nether.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_nether.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_nickclean.java b/src/me/totalfreedom/totalfreedommod/commands/Command_nickclean.java
index ca1fbb3a..2c2b67c2 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_nickclean.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_nickclean.java
@@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.commands;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_nf.java b/src/me/totalfreedom/totalfreedommod/commands/Command_nickfilter.java
similarity index 92%
rename from src/me/totalfreedom/totalfreedommod/commands/Command_nf.java
rename to src/me/totalfreedom/totalfreedommod/commands/Command_nickfilter.java
index 5bf7dae3..b5e8b2ac 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_nf.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_nickfilter.java
@@ -1,12 +1,11 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -15,8 +14,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = PlayerRank.OP, source = SourceType.BOTH)
-@CommandParameters(description = "NickFilter: Prefix any command with this command to replace nicknames in that command with real names. Nicknames should be prefixed with a !.", usage = "/ !")
-public class Command_nf extends FreedomCommand
+@CommandParameters(description = "NickFilter: Prefix any command with this command to replace nicknames in that command with real names. Nicknames should be prefixed with a !.",
+ usage = "/ !",
+ aliases = "nf")
+public class Command_nickfilter extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_nicknyan.java b/src/me/totalfreedom/totalfreedommod/commands/Command_nicknyan.java
index 1e6b99b2..488a7da6 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_nicknyan.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_nicknyan.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_o.java b/src/me/totalfreedom/totalfreedommod/commands/Command_o.java
index 0c22fea6..d27d88a2 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_o.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_o.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_onlinemode.java b/src/me/totalfreedom/totalfreedommod/commands/Command_onlinemode.java
index d53a2927..27302156 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_onlinemode.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_onlinemode.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
@@ -26,7 +26,7 @@ public class Command_onlinemode extends FreedomCommand
if (sender instanceof Player && !plugin.al.isSeniorAdmin(sender))
{
- playerMsg(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_op.java b/src/me/totalfreedom/totalfreedommod/commands/Command_op.java
index b3e165d7..24d63988 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_op.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_op.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_opall.java b/src/me/totalfreedom/totalfreedommod/commands/Command_opall.java
index 770f98ad..54ef9d03 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_opall.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_opall.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_opme.java b/src/me/totalfreedom/totalfreedommod/commands/Command_opme.java
index 8f1caf03..891f0053 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_opme.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_opme.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_ops.java b/src/me/totalfreedom/totalfreedommod/commands/Command_ops.java
index 24c8d53d..64eb0c78 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_ops.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_ops.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@@ -44,7 +43,7 @@ public class Command_ops extends FreedomCommand
{
if (!plugin.al.isAdmin(sender))
{
- playerMsg(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_orbit.java b/src/me/totalfreedom/totalfreedommod/commands/Command_orbit.java
index 766695e8..80682b1f 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_orbit.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_orbit.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_overlord.java b/src/me/totalfreedom/totalfreedommod/commands/Command_overlord.java
index f7e6a041..a3475b6f 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_overlord.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_overlord.java
@@ -5,7 +5,7 @@ import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.MainConfig;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_permban.java b/src/me/totalfreedom/totalfreedommod/commands/Command_permban.java
index a1155d7a..7cf46a9e 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_permban.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_permban.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_plugincontrol.java b/src/me/totalfreedom/totalfreedommod/commands/Command_plugincontrol.java
index 9a64ac58..7bde9a03 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_plugincontrol.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_plugincontrol.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_potion.java b/src/me/totalfreedom/totalfreedommod/commands/Command_potion.java
index 0276a730..47b4f498 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_potion.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_potion.java
@@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@@ -40,7 +39,7 @@ public class Command_potion extends FreedomCommand
{
if (!(plugin.al.isAdmin(sender) || senderIsConsole))
{
- playerMsg(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
FUtil.adminAction(sender.getName(), "Cleared all potion effects from all players", true);
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_premium.java b/src/me/totalfreedom/totalfreedommod/commands/Command_premium.java
index 87dae6e1..646807c0 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_premium.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_premium.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_protectarea.java b/src/me/totalfreedom/totalfreedommod/commands/Command_protectarea.java
index 99a8d802..a7f9a9c4 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_protectarea.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_protectarea.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.ProtectArea;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_purgeall.java b/src/me/totalfreedom/totalfreedommod/commands/Command_purgeall.java
index b80fa43c..02641cb8 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_purgeall.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_purgeall.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
@@ -18,40 +18,34 @@ public class Command_purgeall extends FreedomCommand
FUtil.adminAction(sender.getName(), "Purging all player data", true);
// Purge entities
- FUtil.TFM_EntityWiper.wipeEntities(true, true);
+ plugin.ew.wipeEntities(true, true);
for (Player player : server.getOnlinePlayers())
{
- FPlayer playerdata = plugin.pl.getPlayer(player);
+ FPlayer fPlayer = plugin.pl.getPlayer(player);
// Unmute all players
- if (playerdata.isMuted())
+ if (fPlayer.isMuted())
{
- playerdata.setMuted(false);
+ fPlayer.setMuted(false);
}
// Unblock all commands
- if (playerdata.allCommandsBlocked())
+ if (fPlayer.allCommandsBlocked())
{
- playerdata.setCommandsBlocked(false);
- }
-
- // Unhalt all players
- if (playerdata.isHalted())
- {
- playerdata.setHalted(false);
+ fPlayer.setCommandsBlocked(false);
}
// Stop orbiting
- if (playerdata.isOrbiting())
+ if (fPlayer.isOrbiting())
{
- playerdata.stopOrbiting();
+ fPlayer.stopOrbiting();
}
// Unfreeze
- if (playerdata.isFrozen())
+ if (fPlayer.getFreezeData().isFrozen())
{
- playerdata.setFrozen(false);
+ fPlayer.getFreezeData().setFrozen(false);
}
// Purge potion effects
@@ -61,19 +55,17 @@ public class Command_purgeall extends FreedomCommand
}
// Uncage
- if (playerdata.isCaged())
+ if (fPlayer.getCageData().isCaged())
{
- playerdata.setCaged(false);
- playerdata.regenerateHistory();
- playerdata.clearHistory();
+ fPlayer.getCageData().setCaged(false);
}
}
// Unfreeze all players
- Command_fr.setAllFrozen(false);
+ plugin.fm.setGlobalFreeze(false);
// Remove all mobs
- Command_mp.purgeMobs();
+ Command_mobpurge.purgeMobs();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_qdeop.java b/src/me/totalfreedom/totalfreedommod/commands/Command_qdeop.java
index 7b0bbd93..67bf4bb0 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_qdeop.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_qdeop.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FUtil;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_qop.java b/src/me/totalfreedom/totalfreedommod/commands/Command_qop.java
index ee0cc5b3..ee370da4 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_qop.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_qop.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FUtil;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_radar.java b/src/me/totalfreedom/totalfreedommod/commands/Command_radar.java
index 6eaa98f3..52de0709 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_radar.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_radar.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_rank.java b/src/me/totalfreedom/totalfreedommod/commands/Command_rank.java
index 621ffa2a..1fb59aa4 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_rank.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_rank.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_rawsay.java b/src/me/totalfreedom/totalfreedommod/commands/Command_rawsay.java
index c4c64d8a..ffda4514 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_rawsay.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_rawsay.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_rd.java b/src/me/totalfreedom/totalfreedommod/commands/Command_rd.java
index 5c6ee60f..1876d39a 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_rd.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_rd.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -14,7 +14,7 @@ public class Command_rd extends FreedomCommand
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FUtil.adminAction(sender.getName(), "Removing all server entities.", true);
- playerMsg((FUtil.TFM_EntityWiper.wipeEntities(true, true)) + " entities removed.");
+ playerMsg((plugin.ew.wipeEntities(true, true)) + " entities removed.");
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_report.java b/src/me/totalfreedom/totalfreedommod/commands/Command_report.java
index dbeae840..7866d0cf 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_report.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_report.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_ro.java b/src/me/totalfreedom/totalfreedommod/commands/Command_ro.java
index ddb33078..742927a6 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_ro.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_ro.java
@@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.commands;
import java.util.ArrayList;
import java.util.List;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_rollback.java b/src/me/totalfreedom/totalfreedommod/commands/Command_rollback.java
index 5be33a0a..96be2c4b 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_rollback.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_rollback.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_saconfig.java b/src/me/totalfreedom/totalfreedommod/commands/Command_saconfig.java
index 79633e0e..48a1f3ca 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_saconfig.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_saconfig.java
@@ -1,12 +1,10 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.TwitterHandler;
-import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.admin.Admin;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@@ -28,7 +26,11 @@ public class Command_saconfig extends FreedomCommand
}
catch (final PermissionsException ex)
{
- playerMsg(ex.getMessage());
+ if (ex.getMessage().isEmpty())
+ {
+ return noPerms();
+ }
+ sender.sendMessage(ex.getMessage());
return true;
}
catch (final FormatException ex)
@@ -129,10 +131,10 @@ public class Command_saconfig extends FreedomCommand
}
case ADD:
{
- Player player = getPlayer(args[1]);
- Admin admin = player == null ? plugin.al.getAdmin(player) : plugin.al.getEntryByName(args[1]);
+ final Player player = getPlayer(args[1]);
// Existing admin
+ final Admin admin = player == null ? plugin.al.getAdmin(player) : plugin.al.getEntryByName(args[1]);
if (admin != null)
{
if (admin.isActivated())
@@ -143,8 +145,8 @@ public class Command_saconfig extends FreedomCommand
FUtil.adminAction(sender.getName(), "Readding " + admin.getName() + " to the admin list", true);
if (player != null)
- { // Reset IP, username
- admin.loadFrom(player);
+ {
+ admin.loadFrom(player); // Reset IP, username
}
admin.setActivated(true);
@@ -163,10 +165,10 @@ public class Command_saconfig extends FreedomCommand
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
plugin.al.addAdmin(new Admin(player));
- final FPlayer playerdata = plugin.pl.getPlayer(player.getPlayer());
- if (playerdata.isFrozen())
+ final FPlayer fPlayer = plugin.pl.getPlayer(player.getPlayer());
+ if (fPlayer.getFreezeData().isFrozen())
{
- playerdata.setFrozen(false);
+ fPlayer.getFreezeData().setFrozen(false);
playerMsg(player.getPlayer(), "You have been unfrozen.");
}
@@ -186,14 +188,10 @@ public class Command_saconfig extends FreedomCommand
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
plugin.al.removeAdmin(admin);
- // Twitterbot
- if (ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
- {
- TwitterHandler.delTwitterVerbose(admin.getName(), sender);
- }
-
break;
}
+ default:
+ return false;
}
return true;
@@ -241,14 +239,14 @@ public class Command_saconfig extends FreedomCommand
{
if (admin == null)
{
- throw new PermissionsException(FreedomCommand.MSG_NO_PERMS);
+ throw new PermissionsException();
}
}
else if (mode.rank == PlayerRank.SENIOR_ADMIN)
{
if (!isSeniorAdmin)
{
- throw new PermissionsException(FreedomCommand.MSG_NO_PERMS);
+ throw new PermissionsException();
}
}
@@ -286,6 +284,11 @@ public class Command_saconfig extends FreedomCommand
{
private static final long serialVersionUID = 234235261231L;
+ private PermissionsException()
+ {
+ super("");
+ }
+
private PermissionsException(final String message)
{
super(message);
@@ -296,7 +299,7 @@ public class Command_saconfig extends FreedomCommand
{
private static final long serialVersionUID = 33331341256779901L;
- private FormatException(final String message)
+ private FormatException(String message)
{
super(message);
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_say.java b/src/me/totalfreedom/totalfreedommod/commands/Command_say.java
index 11577f78..b445c0a9 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_say.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_say.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_services.java b/src/me/totalfreedom/totalfreedommod/commands/Command_services.java
index 3af44196..55371f7f 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_services.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_services.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.ServiceChecker.ServiceStatus;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_setl.java b/src/me/totalfreedom/totalfreedommod/commands/Command_setl.java
index fe180982..b755aacd 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_setl.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_setl.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_setlevel.java b/src/me/totalfreedom/totalfreedommod/commands/Command_setlevel.java
index 420780a3..2cd86a9c 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_setlevel.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_setlevel.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_setlever.java b/src/me/totalfreedom/totalfreedommod/commands/Command_setlever.java
index e9c04c8e..0b1586b9 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_setlever.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_setlever.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import org.bukkit.Location;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_setspawnworld.java b/src/me/totalfreedom/totalfreedommod/commands/Command_setspawnworld.java
index d6061d85..a30f70fa 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_setspawnworld.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_setspawnworld.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Location;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_smite.java b/src/me/totalfreedom/totalfreedommod/commands/Command_smite.java
index 4b90a317..e8858394 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_smite.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_smite.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_status.java b/src/me/totalfreedom/totalfreedommod/commands/Command_status.java
index 924285e4..5644a07f 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_status.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_status.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_stfu.java b/src/me/totalfreedom/totalfreedommod/commands/Command_stfu.java
index b6fbfa81..4a786fc5 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_stfu.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_stfu.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_stop.java b/src/me/totalfreedom/totalfreedommod/commands/Command_stop.java
index 54ef85c0..6bb42f85 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_stop.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_stop.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_survival.java b/src/me/totalfreedom/totalfreedommod/commands/Command_survival.java
index c7a303c5..2fec2282 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_survival.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_survival.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
@@ -36,7 +35,7 @@ public class Command_survival extends FreedomCommand
{
if (!plugin.al.isAdmin(sender) || senderIsConsole)
{
- sender.sendMessage(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tag.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tag.java
index bcff150d..dd76aa3d 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tag.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tag.java
@@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Arrays;
import java.util.List;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
@@ -45,7 +44,7 @@ public class Command_tag extends FreedomCommand
{
if (!plugin.al.isAdmin(sender))
{
- playerMsg(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
@@ -91,7 +90,7 @@ public class Command_tag extends FreedomCommand
{
if (!plugin.al.isAdmin(sender))
{
- playerMsg(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tagnyan.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tagnyan.java
index f1440b69..711171d9 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tagnyan.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tagnyan.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tban.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tban.java
index f5925e7b..4a734ede 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tban.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tban.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.banning.FBan;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
+import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -41,7 +41,7 @@ public class Command_tban extends FreedomCommand
}
FUtil.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
- plugin.bm.addBan(FBan.forPlayer(player, sender, FUtil.parseDateOffset("5m"), ChatColor.RED + "You have been temporarily banned for 5 minutes."));
+ plugin.bm.addBan(Ban.forPlayer(player, sender, FUtil.parseDateOffset("5m"), ChatColor.RED + "You have been temporarily banned for 5 minutes."));
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tempban.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tempban.java
index 2cdfe868..3e757529 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tempban.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tempban.java
@@ -2,8 +2,8 @@ package me.totalfreedom.totalfreedommod.commands;
import java.text.SimpleDateFormat;
import java.util.Date;
-import me.totalfreedom.totalfreedommod.banning.FBan;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.banning.Ban;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@@ -67,7 +67,7 @@ public class Command_tempban extends FreedomCommand
FUtil.adminAction(sender.getName(), message.toString(), true);
- plugin.bm.addBan(FBan.forPlayer(player, sender, expires, reason));
+ plugin.bm.addBan(Ban.forPlayer(player, sender, expires, reason));
player.kickPlayer(sender.getName() + " - " + message.toString());
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tfbanlist.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tfbanlist.java
index 33209173..bd4e39a6 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tfbanlist.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tfbanlist.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tfipbanlist.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tfipbanlist.java
index 03508339..341ca9e0 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tfipbanlist.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tfipbanlist.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tfm.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tfm.java
index be068b15..710b9967 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tfm.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tfm.java
@@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.MainConfig;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.ChatColor;
@@ -29,7 +29,7 @@ public class Command_tfm extends FreedomCommand
if (!plugin.al.isAdmin(sender))
{
- playerMsg(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tfupdate.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tfupdate.java
index c9732da0..3e629745 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tfupdate.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tfupdate.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.io.File;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
@@ -13,9 +13,11 @@ import org.bukkit.scheduler.BukkitRunnable;
@CommandParameters(description = "Update server files.", usage = "/")
public class Command_tfupdate extends FreedomCommand
{
- public static final String[] FILES =
- {
- };
+
+ public static final String[] FILES
+ =
+ {
+ };
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
@@ -28,7 +30,7 @@ public class Command_tfupdate extends FreedomCommand
if (!sender.getName().equalsIgnoreCase("madgeek1450"))
{
- playerMsg(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_toggle.java b/src/me/totalfreedom/totalfreedommod/commands/Command_toggle.java
index 70fe37ac..9082259a 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_toggle.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_toggle.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.GameRuleHandler.TFM_GameRule;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_tossmob.java b/src/me/totalfreedom/totalfreedommod/commands/Command_tossmob.java
index dcc3e3a5..29b48c91 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_tossmob.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_tossmob.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_trail.java b/src/me/totalfreedom/totalfreedommod/commands/Command_trail.java
index 5e018205..9daf606d 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_trail.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_trail.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_twitter.java b/src/me/totalfreedom/totalfreedommod/commands/Command_twitter.java
deleted file mode 100644
index cb7faa5b..00000000
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_twitter.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package me.totalfreedom.totalfreedommod.commands;
-
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.TwitterHandler;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import org.bukkit.ChatColor;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
-@CommandParameters(description = "Manage your twitter.", usage = "/ ")
-public class Command_twitter extends FreedomCommand
-{
- @Override
- public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
- {
- if (!ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
- {
- playerMsg("TwitterBot has been disabled in config.", ChatColor.RED);
- return true;
- }
-
- if (args.length < 1)
- {
- return false;
- }
-
- if ("set".equals(args[0]))
- {
- if (args.length != 2)
- {
- return false;
- }
-
- if (args[1].startsWith("@"))
- {
- playerMsg("Please do not prefix your twitter username with '@'");
- return true;
- }
-
- String reply = TwitterHandler.setTwitter(sender.getName(), args[1]);
-
- if ("ok".equals(reply))
- {
- playerMsg("Your twitter handle has been set to: " + ChatColor.AQUA + "@" + args[1] + ChatColor.GRAY + ".");
- }
- else if ("disabled".equals(reply))
- {
- playerMsg("TwitterBot has been temporarily disabled,, please wait until it get re-enabled", ChatColor.RED);
- }
- else if ("failed".equals(reply))
- {
- playerMsg("There was a problem querying the database, please let a developer know.", ChatColor.RED);
- }
- else if ("false".equals(reply))
- {
- playerMsg("There was a problem with the database, please let a developer know.", ChatColor.RED);
- }
- else if ("cannotauth".equals(reply))
- {
- playerMsg("The database password is incorrect, please let a developer know.", ChatColor.RED);
- }
- else
- {
- playerMsg("An unknown error occurred, please contact a developer", ChatColor.RED);
- playerMsg("Response code: " + reply);
- }
- return true;
- }
-
- if (args.length != 1)
- {
- return false;
- }
-
- if ("info".equals(args[0]))
- {
- String reply = TwitterHandler.getTwitter(sender.getName());
- playerMsg("-- Twitter Information --", ChatColor.BLUE);
- playerMsg("Using this feature, you can re-super yourself using twitter.");
- playerMsg("You can set your twitter handle using " + ChatColor.AQUA + "/twitter set [twittername]");
- playerMsg("Then, you can verify yourself by tweeting " + ChatColor.AQUA + "@TFUpdates #superme");
- if ("notfound".equals(reply))
- {
- playerMsg("You currently have " + ChatColor.RED + "no" + ChatColor.BLUE + " Twitter handle set.", ChatColor.BLUE);
- }
- else if ("disabled".equals(reply))
- {
- playerMsg("TwitterBot has been temporarily disabled, please wait until re-enabled", ChatColor.RED);
- }
- else if ("failed".equals(reply))
- {
- playerMsg("There was a problem querying the database, please let a developer know.", ChatColor.RED);
- }
- else if ("false".equals(reply))
- {
- playerMsg("There was a problem with the database, please let a developer know.", ChatColor.RED);
- }
- else if ("cannotauth".equals(reply))
- {
- playerMsg("The database password is incorrect, please let a developer know.", ChatColor.RED);
- }
- else
- {
- playerMsg("Your current twitter handle: " + ChatColor.AQUA + "@" + reply + ChatColor.BLUE + ".", ChatColor.BLUE);
- }
- return true;
- }
-
- if ("enable".equals(args[0]) || "disable".equals(args[0]))
- {
- if (!sender.getName().equalsIgnoreCase("DarthSalamon"))
- {
- sender.sendMessage(FreedomCommand.MSG_NO_PERMS);
- return true;
- }
-
- FUtil.adminAction(sender.getName(), ("enable".equals(args[0]) ? "Ena" : "Disa") + "bling Twitterbot", true);
- String reply = TwitterHandler.setEnabled(args[0] + "d");
- playerMsg("Reply: " + reply);
- return true;
- }
-
- // Command not recognised
- return false;
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_warn.java b/src/me/totalfreedom/totalfreedommod/commands/Command_warn.java
index 1f65e01c..ae0fa9f3 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_warn.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_warn.java
@@ -1,8 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_whitelist.java b/src/me/totalfreedom/totalfreedommod/commands/Command_whitelist.java
index e20b593f..cbd77e68 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_whitelist.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_whitelist.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.OfflinePlayer;
@@ -58,8 +58,7 @@ public class Command_whitelist extends FreedomCommand
// all commands past this line are superadmin-only
if (!(senderIsConsole || plugin.al.isAdmin(sender)))
{
- sender.sendMessage(FreedomCommand.MSG_NO_PERMS);
- return true;
+ return noPerms();
}
// on
@@ -152,7 +151,7 @@ public class Command_whitelist extends FreedomCommand
// all commands past this line are console/telnet only
if (!senderIsConsole)
{
- sender.sendMessage(FreedomCommand.MSG_NO_PERMS);
+ noPerms();
return true;
}
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_whohas.java b/src/me/totalfreedom/totalfreedommod/commands/Command_whohas.java
index 10e6498c..0b714bef 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_whohas.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_whohas.java
@@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.List;
-import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_wildcard.java b/src/me/totalfreedom/totalfreedommod/commands/Command_wildcard.java
index 24d18de8..f4911369 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_wildcard.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_wildcard.java
@@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_wipeflatlands.java b/src/me/totalfreedom/totalfreedommod/commands/Command_wipeflatlands.java
index bcaa4c48..8c9425d3 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_wipeflatlands.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_wipeflatlands.java
@@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/Command_wipeuserdata.java b/src/me/totalfreedom/totalfreedommod/commands/Command_wipeuserdata.java
index 79e7621f..cf466192 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/Command_wipeuserdata.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/Command_wipeuserdata.java
@@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands;
import java.io.File;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/me/totalfreedom/totalfreedommod/commands/FreedomCommand.java b/src/me/totalfreedom/totalfreedommod/commands/FreedomCommand.java
index f95205bb..d0a14fba 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/FreedomCommand.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/FreedomCommand.java
@@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
public abstract class FreedomCommand extends AbstractCommandBase
{
- public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
diff --git a/src/me/totalfreedom/totalfreedommod/commands/FreedomCommandExecutor.java b/src/me/totalfreedom/totalfreedommod/commands/FreedomCommandExecutor.java
index 60c67c8c..f952405d 100644
--- a/src/me/totalfreedom/totalfreedommod/commands/FreedomCommandExecutor.java
+++ b/src/me/totalfreedom/totalfreedommod/commands/FreedomCommandExecutor.java
@@ -1,9 +1,9 @@
package me.totalfreedom.totalfreedommod.commands;
import java.util.Arrays;
-import me.totalfreedom.totalfreedommod.permission.ConsoleRank;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
-import me.totalfreedom.totalfreedommod.permission.Rank;
+import me.totalfreedom.totalfreedommod.rank.ConsoleRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
@@ -146,7 +146,7 @@ public class FreedomCommandExecutor> extends Abstra
return result;
}
- public static class TFM_CommandExecutorFactory implements AeroCommandExecutorFactory
+ public static class FreedomExecutorFactory implements AeroCommandExecutorFactory
{
@Override
diff --git a/src/me/totalfreedom/totalfreedommod/freeze/FreezeData.java b/src/me/totalfreedom/totalfreedommod/freeze/FreezeData.java
new file mode 100644
index 00000000..2c42d66a
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/freeze/FreezeData.java
@@ -0,0 +1,70 @@
+package me.totalfreedom.totalfreedommod.freeze;
+
+import lombok.Getter;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import static me.totalfreedom.totalfreedommod.player.FPlayer.AUTO_PURGE_TICKS;
+import me.totalfreedom.totalfreedommod.util.FLog;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.scheduler.BukkitTask;
+
+public class FreezeData
+{
+ private final FPlayer fPlayer;
+ //
+ @Getter
+ private Location location = null;
+ private BukkitTask unfreeze = null;
+
+ public FreezeData(FPlayer fPlayer)
+ {
+ this.fPlayer = fPlayer;
+ }
+
+ public boolean isFrozen()
+ {
+ return unfreeze != null;
+ }
+
+ public void setFrozen(boolean freeze)
+ {
+ final Player player = fPlayer.getPlayer();
+ if (player == null)
+ {
+ FLog.info("Could not freeze " + fPlayer.getName() + ". Player not online!");
+ return;
+ }
+
+ FUtil.cancel(unfreeze);
+ unfreeze = null;
+ location = null;
+
+ if (!freeze)
+ {
+ if (fPlayer.getPlayer().getGameMode() != GameMode.CREATIVE)
+ {
+ FUtil.setFlying(player, false);
+ }
+
+ return;
+ }
+
+ location = player.getLocation(); // Blockify location
+ FUtil.setFlying(player, true); // Avoid infinite falling
+ unfreeze = new BukkitRunnable()
+ {
+ @Override
+ public void run()
+ {
+ FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
+ setFrozen(false);
+ }
+
+ }.runTaskLater(TotalFreedomMod.plugin, AUTO_PURGE_TICKS);
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/freeze/Freezer.java b/src/me/totalfreedom/totalfreedommod/freeze/Freezer.java
new file mode 100644
index 00000000..ddb5d097
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/freeze/Freezer.java
@@ -0,0 +1,66 @@
+package me.totalfreedom.totalfreedommod.freeze;
+
+import lombok.Getter;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerMoveEvent;
+
+public class Freezer extends AbstractService
+{
+ @Getter
+ private boolean globalFreeze = false;
+
+ public Freezer(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ globalFreeze = false;
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ public void setGlobalFreeze(boolean frozen)
+ {
+ this.globalFreeze = true;
+ }
+
+ public void purge()
+ {
+ setGlobalFreeze(false);
+
+ for (Player player : server.getOnlinePlayers())
+ {
+ plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onPlayerMove(PlayerMoveEvent event)
+ {
+ final Player player = event.getPlayer();
+
+ if (!plugin.al.isAdmin(player))
+ {
+ return;
+ }
+
+ final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
+ if (globalFreeze || fd.isFrozen())
+ {
+ FUtil.setFlying(player, true);
+ event.setTo(fd.getLocation());
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/fun/ItemFun.java b/src/me/totalfreedom/totalfreedommod/fun/ItemFun.java
new file mode 100644
index 00000000..365f474c
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/fun/ItemFun.java
@@ -0,0 +1,280 @@
+package me.totalfreedom.totalfreedommod.fun;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.block.Block;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.TNTPrimed;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.util.Vector;
+
+public class ItemFun extends AbstractService
+{
+
+ private final Random random = new Random();
+
+ public ItemFun(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler
+ public void onPlayerInteractEvent(PlayerInteractEvent event)
+ {
+ if (event.getAction() == Action.LEFT_CLICK_AIR
+ || event.getAction() == Action.LEFT_CLICK_BLOCK)
+ {
+ return;
+ }
+
+ final Player player = event.getPlayer();
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ switch (event.getMaterial())
+ {
+ case RAW_FISH:
+ {
+ final int RADIUS_HIT = 5;
+ final int STRENGTH = 4;
+
+ // Clownfish
+ if (DepreciationAggregator.getData_MaterialData(event.getItem().getData()) != 2)
+ {
+ break;
+ }
+
+ if (!plugin.al.isSeniorAdmin(player))
+ {
+ final StringBuilder msg = new StringBuilder();
+ final char[] chars = (player.getName() + " is a clown.").toCharArray();
+ for (char c : chars)
+ {
+ msg.append(FUtil.randomChatColor()).append(c);
+ }
+ FUtil.bcastMsg(msg.toString());
+
+ player.getInventory().getItemInHand().setType(Material.POTATO_ITEM);
+ break;
+ }
+
+ event.setCancelled(true);
+ boolean didHit = false;
+
+ final Location playerLoc = player.getLocation();
+ final Vector playerLocVec = playerLoc.toVector();
+
+ final List players = player.getWorld().getPlayers();
+ for (final Player target : players)
+ {
+ if (target == player)
+ {
+ continue;
+ }
+
+ final Location targetPos = target.getLocation();
+ final Vector targetPosVec = targetPos.toVector();
+
+ try
+ {
+ if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT))
+ {
+ FUtil.setFlying(player, false);
+ target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH));
+ didHit = true;
+ }
+ }
+ catch (IllegalArgumentException ex)
+ {
+ }
+ }
+
+ if (didHit)
+ {
+ final Sound[] sounds = Sound.values();
+ for (Sound sound : sounds)
+ {
+ if (sound.toString().contains("HIT"))
+ {
+ playerLoc.getWorld().playSound(randomOffset(playerLoc, 5.0), sound, 100.0f, randomDoubleRange(0.5, 2.0).floatValue());
+ }
+ }
+ }
+ break;
+ }
+
+ case CARROT:
+ {
+ if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
+ {
+ break;
+ }
+
+ if (!plugin.al.isSeniorAdmin(player))
+ {
+ break;
+ }
+
+ Location location = player.getLocation().clone();
+
+ Vector playerPostion = location.toVector().add(new Vector(0.0, 1.65, 0.0));
+ Vector playerDirection = location.getDirection().normalize();
+
+ double distance = 150.0;
+ Block targetBlock = DepreciationAggregator.getTargetBlock(player, null, Math.round((float) distance));
+ if (targetBlock != null)
+ {
+ distance = location.distance(targetBlock.getLocation());
+ }
+
+ final List affected = new ArrayList();
+
+ Block lastBlock = null;
+ for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
+ {
+ Block block = playerPostion.clone().add(playerDirection.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
+
+ if (!block.equals(lastBlock))
+ {
+ if (block.isEmpty())
+ {
+ affected.add(block);
+ block.setType(Material.TNT);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ lastBlock = block;
+ }
+
+ new BukkitRunnable()
+ {
+ @Override
+ public void run()
+ {
+ for (Block tntBlock : affected)
+ {
+ TNTPrimed tnt = tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class);
+ tnt.setFuseTicks(5);
+ tntBlock.setType(Material.AIR);
+ }
+ }
+ }.runTaskLater(TotalFreedomMod.plugin, 30L);
+
+ event.setCancelled(true);
+ break;
+ }
+
+ case BONE:
+ {
+ if (!fPlayer.mobThrowerEnabled())
+ {
+ break;
+ }
+
+ Location player_pos = player.getLocation();
+ Vector direction = player_pos.getDirection().normalize();
+
+ LivingEntity rezzed_mob = (LivingEntity) player.getWorld().spawnEntity(player_pos.add(direction.multiply(2.0)), fPlayer.mobThrowerCreature());
+ rezzed_mob.setVelocity(direction.multiply(fPlayer.mobThrowerSpeed()));
+ fPlayer.enqueueMob(rezzed_mob);
+
+ event.setCancelled(true);
+ break;
+ }
+
+ case SULPHUR:
+ {
+ if (!fPlayer.isMP44Armed())
+ {
+ break;
+ }
+
+ event.setCancelled(true);
+
+ if (fPlayer.toggleMP44Firing())
+ {
+ fPlayer.startArrowShooter(TotalFreedomMod.plugin);
+ }
+ else
+ {
+ fPlayer.stopArrowShooter();
+ }
+ break;
+ }
+
+ case BLAZE_ROD:
+ {
+ if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
+ {
+ break;
+ }
+
+ if (!plugin.al.isSeniorAdmin(player))
+ {
+ break;
+ }
+
+ event.setCancelled(true);
+ Block targetBlock;
+
+ if (event.getAction().equals(Action.LEFT_CLICK_AIR))
+ {
+ targetBlock = DepreciationAggregator.getTargetBlock(player, null, 120);
+ }
+ else
+ {
+ targetBlock = event.getClickedBlock();
+ }
+
+ if (targetBlock == null)
+ {
+ player.sendMessage("Can't resolve target block.");
+ break;
+ }
+
+ player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
+ player.getWorld().strikeLightning(targetBlock.getLocation());
+
+ break;
+ }
+ }
+ }
+
+ private Location randomOffset(Location a, double magnitude)
+ {
+ return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);
+ }
+
+ private Double randomDoubleRange(double min, double max)
+ {
+ return min + (random.nextDouble() * ((max - min) + 1.0));
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/Jumppads.java b/src/me/totalfreedom/totalfreedommod/fun/Jumppads.java
similarity index 97%
rename from src/me/totalfreedom/totalfreedommod/Jumppads.java
rename to src/me/totalfreedom/totalfreedommod/fun/Jumppads.java
index 06572a8d..fbe23712 100644
--- a/src/me/totalfreedom/totalfreedommod/Jumppads.java
+++ b/src/me/totalfreedom/totalfreedommod/fun/Jumppads.java
@@ -1,9 +1,10 @@
-package me.totalfreedom.totalfreedommod;
+package me.totalfreedom.totalfreedommod.fun;
import com.google.common.collect.Maps;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Material;
import org.bukkit.block.Block;
diff --git a/src/me/totalfreedom/totalfreedommod/fun/Landminer.java b/src/me/totalfreedom/totalfreedommod/fun/Landminer.java
new file mode 100644
index 00000000..57f944be
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/fun/Landminer.java
@@ -0,0 +1,126 @@
+package me.totalfreedom.totalfreedommod.fun;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import lombok.Getter;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.TNTPrimed;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.util.Vector;
+
+public class Landminer extends AbstractService
+{
+ @Getter
+ private final List landmines = new ArrayList();
+
+ public Landminer(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ landmines.clear();
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ public void add(Landmine landmine)
+ {
+ landmines.add(landmine);
+ }
+
+ public void remove(Landmine landmine)
+ {
+ landmines.remove(landmine);
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onPlayerMove(PlayerMoveEvent event)
+ {
+ if (!(ConfigEntry.LANDMINES_ENABLED.getBoolean() && ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()))
+ {
+ return;
+ }
+
+ final Player player = event.getPlayer();
+
+ final Iterator lit = landmines.iterator();
+ while (lit.hasNext())
+ {
+ final Landmine landmine = lit.next();
+
+ final Location location = landmine.location;
+ if (location.getBlock().getType() != Material.TNT)
+ {
+ lit.remove();
+ continue;
+ }
+
+ if (landmine.planter.equals(player))
+ {
+ break;
+ }
+
+ if (!player.getWorld().equals(location.getWorld()))
+ {
+ continue;
+ }
+
+ if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius)))
+ {
+ break;
+ }
+
+ landmine.location.getBlock().setType(Material.AIR);
+
+ final TNTPrimed tnt1 = location.getWorld().spawn(location, TNTPrimed.class);
+ tnt1.setFuseTicks(40);
+ tnt1.setPassenger(player);
+ tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));
+
+ final TNTPrimed tnt2 = location.getWorld().spawn(player.getLocation(), TNTPrimed.class);
+ tnt2.setFuseTicks(1);
+
+ player.setGameMode(GameMode.SURVIVAL);
+ lit.remove();
+ }
+ }
+
+ public static class Landmine
+ {
+ @Getter
+ private final Location location;
+ @Getter
+ private final Player planter;
+ @Getter
+ private final double radius;
+
+ public Landmine(Location location, Player player, double radius)
+ {
+ this.location = location;
+ this.planter = player;
+ this.radius = radius;
+ }
+
+ @Override
+ public String toString()
+ {
+ return this.location.toString() + ", " + this.radius + ", " + this.planter.getName();
+ }
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/fun/MP44.java b/src/me/totalfreedom/totalfreedommod/fun/MP44.java
new file mode 100644
index 00000000..1bf7041e
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/fun/MP44.java
@@ -0,0 +1,33 @@
+package me.totalfreedom.totalfreedommod.fun;
+
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+public class MP44 extends AbstractService
+{
+
+ public MP44(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerQuit(PlayerQuitEvent event)
+ {
+ plugin.pl.getPlayer(event.getPlayer()).disarmMP44();
+ }
+
+}
diff --git a/src/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java b/src/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
index 410a3dd1..d952f5e3 100644
--- a/src/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
+++ b/src/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java
@@ -6,11 +6,11 @@ import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
import me.totalfreedom.totalfreedommod.util.FLog;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -18,6 +18,7 @@ import org.bukkit.Bukkit;
public class HTTPDaemon extends AbstractService
{
+
public static String MIME_DEFAULT_BINARY = "application/octet-stream";
//
private static final Pattern EXT_REGEX = Pattern.compile("\\.([^\\.\\s]+)$");
@@ -26,7 +27,7 @@ public class HTTPDaemon extends AbstractService
//
private static final TFM_HTTPD HTTPD = new TFM_HTTPD(PORT);
- private HTTPDaemon(TotalFreedomMod plugin)
+ public HTTPDaemon(TotalFreedomMod plugin)
{
super(plugin);
}
@@ -73,6 +74,7 @@ public class HTTPDaemon extends AbstractService
private static enum ModuleType
{
+
DUMP(new ModuleExecutable(false, "dump")
{
@Override
@@ -147,6 +149,7 @@ public class HTTPDaemon extends AbstractService
private abstract static class ModuleExecutable
{
+
private final boolean runOnBukkitThread;
private final String name;
@@ -211,6 +214,7 @@ public class HTTPDaemon extends AbstractService
private static class TFM_HTTPD extends NanoHTTPD
{
+
public TFM_HTTPD(int port)
{
super(port);
diff --git a/src/me/totalfreedom/totalfreedommod/httpd/Module_help.java b/src/me/totalfreedom/totalfreedommod/httpd/Module_help.java
index 8eda48bb..a6519927 100644
--- a/src/me/totalfreedom/totalfreedommod/httpd/Module_help.java
+++ b/src/me/totalfreedom/totalfreedommod/httpd/Module_help.java
@@ -11,7 +11,7 @@ import java.util.Map;
import me.totalfreedom.totalfreedommod.commands.FreedomCommand;
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.heading;
import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph;
-import me.totalfreedom.totalfreedommod.permission.PlayerRank;
+import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.command.CommandReflection;
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
diff --git a/src/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java b/src/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java
index 2e4e27bd..114911c5 100644
--- a/src/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java
+++ b/src/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java
@@ -39,7 +39,8 @@ import me.totalfreedom.totalfreedommod.util.FLog;
*
*
* NanoHTTPD
- * Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
+ *
+ *
Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
*
*
* Features + limitations:
@@ -78,8 +79,8 @@ import me.totalfreedom.totalfreedommod.util.FLog;
*
* See the separate "LICENSE.md" file for the distribution license (Modified BSD licence)
*/
-public abstract class NanoHTTPD
-{
+public abstract class NanoHTTPD {
+
/**
* Common mime type for dynamic content: plain text
*/
@@ -114,60 +115,43 @@ public abstract class NanoHTTPD
/**
* Constructs an HTTP server on given port.
*/
- public NanoHTTPD(int port)
- {
+ public NanoHTTPD(int port) {
this(null, port);
}
/**
* Constructs an HTTP server on given hostname and port.
*/
- public NanoHTTPD(String hostname, int port)
- {
+ public NanoHTTPD(String hostname, int port) {
this.hostname = hostname;
this.myPort = port;
setTempFileManagerFactory(new DefaultTempFileManagerFactory());
setAsyncRunner(new DefaultAsyncRunner());
}
- private static final void safeClose(ServerSocket serverSocket)
- {
- if (serverSocket != null)
- {
- try
- {
+ private static final void safeClose(ServerSocket serverSocket) {
+ if (serverSocket != null) {
+ try {
serverSocket.close();
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
}
}
}
- private static final void safeClose(Socket socket)
- {
- if (socket != null)
- {
- try
- {
+ private static final void safeClose(Socket socket) {
+ if (socket != null) {
+ try {
socket.close();
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
}
}
}
- private static final void safeClose(Closeable closeable)
- {
- if (closeable != null)
- {
- try
- {
+ private static final void safeClose(Closeable closeable) {
+ if (closeable != null) {
+ try {
closeable.close();
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
}
}
}
@@ -177,55 +161,38 @@ public abstract class NanoHTTPD
*
* @throws IOException if the socket is in use.
*/
- public void start() throws IOException
- {
+ public void start() throws IOException {
myServerSocket = new ServerSocket();
myServerSocket.bind((hostname != null) ? new InetSocketAddress(hostname, myPort) : new InetSocketAddress(myPort));
- myThread = new Thread(new Runnable()
- {
+ myThread = new Thread(new Runnable() {
@Override
- public void run()
- {
- do
- {
- try
- {
+ public void run() {
+ do {
+ try {
final Socket finalAccept = myServerSocket.accept();
final InputStream inputStream = finalAccept.getInputStream();
- if (inputStream == null)
- {
+ if (inputStream == null) {
safeClose(finalAccept);
- }
- else
- {
- asyncRunner.exec(new Runnable()
- {
+ } else {
+ asyncRunner.exec(new Runnable() {
@Override
- public void run()
- {
+ public void run() {
OutputStream outputStream = null;
- try
- {
+ try {
outputStream = finalAccept.getOutputStream();
TempFileManager tempFileManager = tempFileManagerFactory.create();
HTTPSession session = new HTTPSession(tempFileManager, inputStream, outputStream, finalAccept);
- while (!finalAccept.isClosed())
- {
+ while (!finalAccept.isClosed()) {
session.execute();
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
// When the socket is closed by the client, we throw our own SocketException
// to break the "keep alive" loop above.
- if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage())))
- {
+ if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage()))) {
FLog.severe(e);
}
- }
- finally
- {
+ } finally {
safeClose(outputStream);
safeClose(inputStream);
safeClose(finalAccept);
@@ -233,12 +200,9 @@ public abstract class NanoHTTPD
}
});
}
+ } catch (IOException e) {
}
- catch (IOException e)
- {
- }
- }
- while (!myServerSocket.isClosed());
+ } while (!myServerSocket.isClosed());
}
});
myThread.setDaemon(true);
@@ -249,31 +213,24 @@ public abstract class NanoHTTPD
/**
* Stop the server.
*/
- public void stop()
- {
- try
- {
+ public void stop() {
+ try {
safeClose(myServerSocket);
myThread.join();
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
FLog.severe(e);
}
}
- public final int getListeningPort()
- {
+ public final int getListeningPort() {
return myServerSocket == null ? -1 : myServerSocket.getLocalPort();
}
- public final boolean wasStarted()
- {
+ public final boolean wasStarted() {
return myServerSocket != null && myThread != null;
}
- public final boolean isAlive()
- {
+ public final boolean isAlive() {
return wasStarted() && !myServerSocket.isClosed() && myThread.isAlive();
}
@@ -283,16 +240,15 @@ public abstract class NanoHTTPD
*
* (By default, this delegates to serveFile() and allows directory listing.)
*
- * @param uri Percent-decoded URI without parameters, for example "/index.cgi"
- * @param method "GET", "POST" etc.
- * @param parms Parsed, percent decoded parameters from URI and, in case of POST, data.
+ * @param uri Percent-decoded URI without parameters, for example "/index.cgi"
+ * @param method "GET", "POST" etc.
+ * @param parms Parsed, percent decoded parameters from URI and, in case of POST, data.
* @param headers Header entries, percent decoded
* @return HTTP response, see class Response for details
*/
@Deprecated
public Response serve(String uri, Method method, Map headers, Map parms,
- Map files)
- {
+ Map files) {
return new Response(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "Not Found");
}
@@ -305,22 +261,15 @@ public abstract class NanoHTTPD
* @param session The HTTP session
* @return HTTP response, see class Response for details
*/
- public Response serve(HTTPSession session)
- {
+ public Response serve(HTTPSession session) {
Map files = new HashMap();
Method method = session.getMethod();
- if (Method.PUT.equals(method) || Method.POST.equals(method))
- {
- try
- {
+ if (Method.PUT.equals(method) || Method.POST.equals(method)) {
+ try {
session.parseBody(files);
- }
- catch (IOException ioe)
- {
+ } catch (IOException ioe) {
return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
- }
- catch (ResponseException re)
- {
+ } catch (ResponseException re) {
return new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
}
}
@@ -334,58 +283,48 @@ public abstract class NanoHTTPD
* @param str the percent encoded String
* @return expanded form of the input, for example "foo%20bar" becomes "foo bar"
*/
- protected String decodePercent(String str)
- {
+ protected String decodePercent(String str) {
String decoded = null;
- try
- {
+ try {
decoded = URLDecoder.decode(str, "UTF8");
- }
- catch (UnsupportedEncodingException ignored)
- {
+ } catch (UnsupportedEncodingException ignored) {
}
return decoded;
}
/**
* Decode parameters from a URL, handing the case where a single parameter name might have been
- * supplied several times, by return lists of values. In general these lists will contain a single
+ * supplied several times, by return lists of values. In general these lists will contain a single
* element.
*
* @param parms original NanoHttpd parameters values, as passed to the serve()
method.
* @return a map of String
(parameter name) to List<String>
(a list of the values supplied).
*/
- protected Map> decodeParameters(Map parms)
- {
+ protected Map> decodeParameters(Map parms) {
return this.decodeParameters(parms.get(QUERY_STRING_PARAMETER));
}
/**
* Decode parameters from a URL, handing the case where a single parameter name might have been
- * supplied several times, by return lists of values. In general these lists will contain a single
+ * supplied several times, by return lists of values. In general these lists will contain a single
* element.
*
* @param queryString a query string pulled from the URL.
* @return a map of String
(parameter name) to List<String>
(a list of the values supplied).
*/
- protected Map> decodeParameters(String queryString)
- {
+ protected Map> decodeParameters(String queryString) {
Map> parms = new HashMap>();
- if (queryString != null)
- {
+ if (queryString != null) {
StringTokenizer st = new StringTokenizer(queryString, "&");
- while (st.hasMoreTokens())
- {
+ while (st.hasMoreTokens()) {
String e = st.nextToken();
int sep = e.indexOf('=');
String propertyName = (sep >= 0) ? decodePercent(e.substring(0, sep)).trim() : decodePercent(e).trim();
- if (!parms.containsKey(propertyName))
- {
+ if (!parms.containsKey(propertyName)) {
parms.put(propertyName, new ArrayList());
}
String propertyValue = (sep >= 0) ? decodePercent(e.substring(sep + 1)) : null;
- if (propertyValue != null)
- {
+ if (propertyValue != null) {
parms.get(propertyName).add(propertyValue);
}
}
@@ -403,8 +342,7 @@ public abstract class NanoHTTPD
*
* @param asyncRunner new strategy for handling threads.
*/
- public void setAsyncRunner(AsyncRunner asyncRunner)
- {
+ public void setAsyncRunner(AsyncRunner asyncRunner) {
this.asyncRunner = asyncRunner;
}
@@ -418,24 +356,20 @@ public abstract class NanoHTTPD
*
* @param tempFileManagerFactory new strategy for handling temp files.
*/
- public void setTempFileManagerFactory(TempFileManagerFactory tempFileManagerFactory)
- {
+ public void setTempFileManagerFactory(TempFileManagerFactory tempFileManagerFactory) {
this.tempFileManagerFactory = tempFileManagerFactory;
}
/**
* HTTP Request methods, with the ability to decode a String
back to its enum value.
*/
- public enum Method
- {
+ public enum Method {
+
GET, PUT, POST, DELETE, HEAD;
- static Method lookup(String method)
- {
- for (Method m : Method.values())
- {
- if (m.toString().equalsIgnoreCase(method))
- {
+ static Method lookup(String method) {
+ for (Method m : Method.values()) {
+ if (m.toString().equalsIgnoreCase(method)) {
return m;
}
}
@@ -446,16 +380,16 @@ public abstract class NanoHTTPD
/**
* Pluggable strategy for asynchronously executing requests.
*/
- public interface AsyncRunner
- {
+ public interface AsyncRunner {
+
void exec(Runnable code);
}
/**
* Factory to create temp file managers.
*/
- public interface TempFileManagerFactory
- {
+ public interface TempFileManagerFactory {
+
TempFileManager create();
}
@@ -463,11 +397,12 @@ public abstract class NanoHTTPD
/**
* Temp file manager.
*
- * Temp file managers are created 1-to-1 with incoming requests, to create and cleanup
+ *
+ * Temp file managers are created 1-to-1 with incoming requests, to create and cleanup
* temporary files created as a result of handling the request.
*/
- public interface TempFileManager
- {
+ public interface TempFileManager {
+
TempFile createTempFile() throws Exception;
void clear();
@@ -476,11 +411,12 @@ public abstract class NanoHTTPD
/**
* A temp file.
*
- * Temp files are responsible for managing the actual temporary storage and cleaning
+ *
+ * Temp files are responsible for managing the actual temporary storage and cleaning
* themselves up when no longer needed.
*/
- public interface TempFile
- {
+ public interface TempFile {
+
OutputStream open() throws Exception;
void delete() throws Exception;
@@ -491,17 +427,17 @@ public abstract class NanoHTTPD
/**
* Default threading strategy for NanoHttpd.
*
- * By default, the server spawns a new Thread for every incoming request. These are set
- * to daemon status, and named according to the request number. The name is
+ *
+ * By default, the server spawns a new Thread for every incoming request. These are set
+ * to daemon status, and named according to the request number. The name is
* useful when profiling the application.
*/
- public static class DefaultAsyncRunner implements AsyncRunner
- {
+ public static class DefaultAsyncRunner implements AsyncRunner {
+
private long requestCount;
@Override
- public void exec(Runnable code)
- {
+ public void exec(Runnable code) {
++requestCount;
Thread t = new Thread(code);
t.setDaemon(true);
@@ -513,42 +449,36 @@ public abstract class NanoHTTPD
/**
* Default strategy for creating and cleaning up temporary files.
*
- * This class stores its files in the standard location (that is,
- * wherever java.io.tmpdir
points to). Files are added
+ *
+ *
This class stores its files in the standard location (that is,
+ * wherever java.io.tmpdir
points to). Files are added
* to an internal list, and deleted when no longer needed (that is,
* when clear()
is invoked at the end of processing a
* request).
*/
- public static class DefaultTempFileManager implements TempFileManager
- {
+ public static class DefaultTempFileManager implements TempFileManager {
+
private final String tmpdir;
private final List tempFiles;
- public DefaultTempFileManager()
- {
+ public DefaultTempFileManager() {
tmpdir = System.getProperty("java.io.tmpdir");
tempFiles = new ArrayList();
}
@Override
- public TempFile createTempFile() throws Exception
- {
+ public TempFile createTempFile() throws Exception {
DefaultTempFile tempFile = new DefaultTempFile(tmpdir);
tempFiles.add(tempFile);
return tempFile;
}
@Override
- public void clear()
- {
- for (TempFile file : tempFiles)
- {
- try
- {
+ public void clear() {
+ for (TempFile file : tempFiles) {
+ try {
file.delete();
- }
- catch (Exception ignored)
- {
+ } catch (Exception ignored) {
}
}
tempFiles.clear();
@@ -558,36 +488,33 @@ public abstract class NanoHTTPD
/**
* Default strategy for creating and cleaning up temporary files.
*
- * [>By default, files are created by File.createTempFile()
in
+ *
+ *
[>By default, files are created by File.createTempFile()
in
* the directory specified.
*/
- public static class DefaultTempFile implements TempFile
- {
+ public static class DefaultTempFile implements TempFile {
+
private File file;
private OutputStream fstream;
- public DefaultTempFile(String tempdir) throws IOException
- {
+ public DefaultTempFile(String tempdir) throws IOException {
file = File.createTempFile("NanoHTTPD-", "", new File(tempdir));
fstream = new FileOutputStream(file);
}
@Override
- public OutputStream open() throws Exception
- {
+ public OutputStream open() throws Exception {
return fstream;
}
@Override
- public void delete() throws Exception
- {
+ public void delete() throws Exception {
safeClose(fstream);
file.delete();
}
@Override
- public String getName()
- {
+ public String getName() {
return file.getAbsolutePath();
}
}
@@ -595,8 +522,8 @@ public abstract class NanoHTTPD
/**
* HTTP response. Return one of these from serve().
*/
- public static class Response
- {
+ public static class Response {
+
/**
* HTTP status code after processing, e.g. "200 OK", HTTP_OK
*/
@@ -625,16 +552,14 @@ public abstract class NanoHTTPD
/**
* Default constructor: response = HTTP_OK, mime = MIME_HTML and your supplied message
*/
- public Response(String msg)
- {
+ public Response(String msg) {
this(Status.OK, MIME_HTML, msg);
}
/**
* Basic constructor.
*/
- public Response(Status status, String mimeType, InputStream data)
- {
+ public Response(Status status, String mimeType, InputStream data) {
this.status = status;
this.mimeType = mimeType;
this.data = data;
@@ -643,16 +568,12 @@ public abstract class NanoHTTPD
/**
* Convenience method that makes an InputStream out of given text.
*/
- public Response(Status status, String mimeType, String txt)
- {
+ public Response(Status status, String mimeType, String txt) {
this.status = status;
this.mimeType = mimeType;
- try
- {
+ try {
this.data = txt != null ? new ByteArrayInputStream(txt.getBytes("UTF-8")) : null;
- }
- catch (java.io.UnsupportedEncodingException uee)
- {
+ } catch (java.io.UnsupportedEncodingException uee) {
FLog.severe(uee);
}
}
@@ -660,43 +581,35 @@ public abstract class NanoHTTPD
/**
* Adds given line to the header.
*/
- public void addHeader(String name, String value)
- {
+ public void addHeader(String name, String value) {
header.put(name, value);
}
/**
* Sends given response to the socket.
*/
- private void send(OutputStream outputStream)
- {
+ private void send(OutputStream outputStream) {
String mime = mimeType;
SimpleDateFormat gmtFrmt = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
gmtFrmt.setTimeZone(TimeZone.getTimeZone("GMT"));
- try
- {
- if (status == null)
- {
+ try {
+ if (status == null) {
throw new Error("sendResponse(): Status can't be null.");
}
PrintWriter pw = new PrintWriter(outputStream);
pw.print("HTTP/1.1 " + status.getDescription() + " \r\n");
- if (mime != null)
- {
+ if (mime != null) {
pw.print("Content-Type: " + mime + "\r\n");
}
- if (header == null || header.get("Date") == null)
- {
+ if (header == null || header.get("Date") == null) {
pw.print("Date: " + gmtFrmt.format(new Date()) + "\r\n");
}
- if (header != null)
- {
- for (String key : header.keySet())
- {
+ if (header != null) {
+ for (String key : header.keySet()) {
String value = header.get(key);
pw.print(key + ": " + value + "\r\n");
}
@@ -704,25 +617,19 @@ public abstract class NanoHTTPD
pw.print("Connection: keep-alive\r\n");
- if (requestMethod != Method.HEAD && chunkedTransfer)
- {
+ if (requestMethod != Method.HEAD && chunkedTransfer) {
sendAsChunked(outputStream, pw);
- }
- else
- {
+ } else {
sendAsFixedLength(outputStream, pw);
}
outputStream.flush();
safeClose(data);
- }
- catch (IOException ioe)
- {
+ } catch (IOException ioe) {
// Couldn't write? No can do.
}
}
- private void sendAsChunked(OutputStream outputStream, PrintWriter pw) throws IOException
- {
+ private void sendAsChunked(OutputStream outputStream, PrintWriter pw) throws IOException {
pw.print("Transfer-Encoding: chunked\r\n");
pw.print("\r\n");
pw.flush();
@@ -730,8 +637,7 @@ public abstract class NanoHTTPD
byte[] CRLF = "\r\n".getBytes();
byte[] buff = new byte[BUFFER_SIZE];
int read;
- while ((read = data.read(buff)) > 0)
- {
+ while ((read = data.read(buff)) > 0) {
outputStream.write(String.format("%x\r\n", read).getBytes());
outputStream.write(buff, 0, read);
outputStream.write(CRLF);
@@ -739,23 +645,19 @@ public abstract class NanoHTTPD
outputStream.write(String.format("0\r\n\r\n").getBytes());
}
- private void sendAsFixedLength(OutputStream outputStream, PrintWriter pw) throws IOException
- {
+ private void sendAsFixedLength(OutputStream outputStream, PrintWriter pw) throws IOException {
int pending = data != null ? data.available() : 0; // This is to support partial sends, see serveFile()
pw.print("Content-Length: " + pending + "\r\n");
pw.print("\r\n");
pw.flush();
- if (requestMethod != Method.HEAD && data != null)
- {
+ if (requestMethod != Method.HEAD && data != null) {
int BUFFER_SIZE = 16 * 1024;
byte[] buff = new byte[BUFFER_SIZE];
- while (pending > 0)
- {
+ while (pending > 0) {
int read = data.read(buff, 0, ((pending > BUFFER_SIZE) ? BUFFER_SIZE : pending));
- if (read <= 0)
- {
+ if (read <= 0) {
break;
}
outputStream.write(buff, 0, read);
@@ -765,56 +667,47 @@ public abstract class NanoHTTPD
}
}
- public Status getStatus()
- {
+ public Status getStatus() {
return status;
}
- public void setStatus(Status status)
- {
+ public void setStatus(Status status) {
this.status = status;
}
- public String getMimeType()
- {
+ public String getMimeType() {
return mimeType;
}
- public void setMimeType(String mimeType)
- {
+ public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
- public InputStream getData()
- {
+ public InputStream getData() {
return data;
}
- public void setData(InputStream data)
- {
+ public void setData(InputStream data) {
this.data = data;
}
- public Method getRequestMethod()
- {
+ public Method getRequestMethod() {
return requestMethod;
}
- public void setRequestMethod(Method requestMethod)
- {
+ public void setRequestMethod(Method requestMethod) {
this.requestMethod = requestMethod;
}
- public void setChunkedTransfer(boolean chunkedTransfer)
- {
+ public void setChunkedTransfer(boolean chunkedTransfer) {
this.chunkedTransfer = chunkedTransfer;
}
/**
* Some HTTP response status codes
*/
- public enum Status
- {
+ public enum Status {
+
OK(200, "OK"), CREATED(201, "Created"), ACCEPTED(202, "Accepted"), NO_CONTENT(204, "No Content"), PARTIAL_CONTENT(206, "Partial Content"), REDIRECT(301,
"Moved Permanently"), NOT_MODIFIED(304, "Not Modified"), BAD_REQUEST(400, "Bad Request"), UNAUTHORIZED(401,
"Unauthorized"), FORBIDDEN(403, "Forbidden"), NOT_FOUND(404, "Not Found"), RANGE_NOT_SATISFIABLE(416,
@@ -822,42 +715,37 @@ public abstract class NanoHTTPD
private final int requestStatus;
private final String description;
- Status(int requestStatus, String description)
- {
+ Status(int requestStatus, String description) {
this.requestStatus = requestStatus;
this.description = description;
}
- public int getRequestStatus()
- {
+ public int getRequestStatus() {
return this.requestStatus;
}
- public String getDescription()
- {
+ public String getDescription() {
return "" + this.requestStatus + " " + description;
}
}
+
}
- public static final class ResponseException extends Exception
- {
+ public static final class ResponseException extends Exception {
+
private final Response.Status status;
- public ResponseException(Response.Status status, String message)
- {
+ public ResponseException(Response.Status status, String message) {
super(message);
this.status = status;
}
- public ResponseException(Response.Status status, String message, Exception e)
- {
+ public ResponseException(Response.Status status, String message, Exception e) {
super(message, e);
this.status = status;
}
- public Response.Status getStatus()
- {
+ public Response.Status getStatus() {
return status;
}
}
@@ -865,11 +753,10 @@ public abstract class NanoHTTPD
/**
* Default strategy for creating and cleaning up temporary files.
*/
- private class DefaultTempFileManagerFactory implements TempFileManagerFactory
- {
+ private class DefaultTempFileManagerFactory implements TempFileManagerFactory {
+
@Override
- public TempFileManager create()
- {
+ public TempFileManager create() {
return new DefaultTempFileManager();
}
}
@@ -877,8 +764,8 @@ public abstract class NanoHTTPD
/**
* Handles one session, i.e. parses the HTTP request and returns the response.
*/
- protected class HTTPSession
- {
+ protected class HTTPSession {
+
public static final int BUFSIZE = 8192;
private final TempFileManager tempFileManager;
private final OutputStream outputStream;
@@ -892,18 +779,15 @@ public abstract class NanoHTTPD
private Map headers;
private CookieHandler cookies;
- public HTTPSession(TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream, Socket socket)
- {
+ public HTTPSession(TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream, Socket socket) {
this.tempFileManager = tempFileManager;
this.inputStream = inputStream;
this.outputStream = outputStream;
this.socket = socket;
}
- public void execute() throws IOException
- {
- try
- {
+ public void execute() throws IOException {
+ try {
// Read the first 8192 bytes.
// The full header should fit in here.
// Apache's default header limit is 8KB.
@@ -913,25 +797,21 @@ public abstract class NanoHTTPD
rlen = 0;
{
int read = inputStream.read(buf, 0, BUFSIZE);
- if (read == -1)
- {
+ if (read == -1) {
// socket was been closed
throw new SocketException("NanoHttpd Shutdown");
}
- while (read > 0)
- {
+ while (read > 0) {
rlen += read;
splitbyte = findHeaderEnd(buf, rlen);
- if (splitbyte > 0)
- {
+ if (splitbyte > 0) {
break;
}
read = inputStream.read(buf, rlen, BUFSIZE - rlen);
}
}
- if (splitbyte < rlen)
- {
+ if (splitbyte < rlen) {
ByteArrayInputStream splitInputStream = new ByteArrayInputStream(buf, splitbyte, rlen - splitbyte);
SequenceInputStream sequenceInputStream = new SequenceInputStream(splitInputStream, inputStream);
inputStream = sequenceInputStream;
@@ -948,8 +828,7 @@ public abstract class NanoHTTPD
decodeHeader(hin, pre, parms, headers);
method = Method.lookup(pre.get("method"));
- if (method == null)
- {
+ if (method == null) {
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Syntax error.");
}
@@ -959,71 +838,51 @@ public abstract class NanoHTTPD
// Ok, now do the serve()
Response r = serve(this);
- if (r == null)
- {
+ if (r == null) {
throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: Serve() returned a null response.");
- }
- else
- {
+ } else {
cookies.unloadQueue(r);
r.setRequestMethod(method);
r.send(outputStream);
}
- }
- catch (SocketException e)
- {
+ } catch (SocketException e) {
// throw it out to close socket object (finalAccept)
throw e;
- }
- catch (IOException ioe)
- {
+ } catch (IOException ioe) {
Response r = new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
r.send(outputStream);
safeClose(outputStream);
- }
- catch (ResponseException re)
- {
+ } catch (ResponseException re) {
Response r = new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
r.send(outputStream);
safeClose(outputStream);
- }
- finally
- {
+ } finally {
tempFileManager.clear();
}
}
- protected void parseBody(Map files) throws IOException, ResponseException
- {
+ protected void parseBody(Map files) throws IOException, ResponseException {
RandomAccessFile randomAccessFile = null;
BufferedReader in = null;
- try
- {
+ try {
randomAccessFile = getTmpBucket();
long size;
- if (headers.containsKey("content-length"))
- {
+ if (headers.containsKey("content-length")) {
size = Integer.parseInt(headers.get("content-length"));
- }
- else if (splitbyte < rlen)
- {
+ } else if (splitbyte < rlen) {
size = rlen - splitbyte;
- }
- else
- {
+ } else {
size = 0;
}
// Now read all the body and write it to f
byte[] buf = new byte[512];
- while (rlen >= 0 && size > 0)
- {
+ while (rlen >= 0 && size > 0) {
rlen = inputStream.read(buf, 0, 512);
size -= rlen;
- if (rlen > 0)
- {
+ if (rlen > 0) {
randomAccessFile.write(buf, 0, rlen);
}
}
@@ -1038,61 +897,48 @@ public abstract class NanoHTTPD
// If the method is POST, there may be parameters
// in data section, too, read it:
- if (Method.POST.equals(method))
- {
+ if (Method.POST.equals(method)) {
String contentType = "";
String contentTypeHeader = headers.get("content-type");
StringTokenizer st = null;
- if (contentTypeHeader != null)
- {
+ if (contentTypeHeader != null) {
st = new StringTokenizer(contentTypeHeader, ",; ");
- if (st.hasMoreTokens())
- {
+ if (st.hasMoreTokens()) {
contentType = st.nextToken();
}
}
- if ("multipart/form-data".equalsIgnoreCase(contentType))
- {
+ if ("multipart/form-data".equalsIgnoreCase(contentType)) {
// Handle multipart/form-data
- if (!st.hasMoreTokens())
- {
+ if (!st.hasMoreTokens()) {
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but boundary missing. Usage: GET /example/file.html");
}
String boundaryStartString = "boundary=";
int boundaryContentStart = contentTypeHeader.indexOf(boundaryStartString) + boundaryStartString.length();
String boundary = contentTypeHeader.substring(boundaryContentStart, contentTypeHeader.length());
- if (boundary.startsWith("\"") && boundary.endsWith("\""))
- {
+ if (boundary.startsWith("\"") && boundary.endsWith("\"")) {
boundary = boundary.substring(1, boundary.length() - 1);
}
decodeMultipartData(boundary, fbuf, in, parms, files);
- }
- else
- {
+ } else {
// Handle application/x-www-form-urlencoded
String postLine = "";
char pbuf[] = new char[512];
int read = in.read(pbuf);
- while (read >= 0 && !postLine.endsWith("\r\n"))
- {
+ while (read >= 0 && !postLine.endsWith("\r\n")) {
postLine += String.valueOf(pbuf, 0, read);
read = in.read(pbuf);
}
postLine = postLine.trim();
decodeParms(postLine, parms);
}
- }
- else if (Method.PUT.equals(method))
- {
+ } else if (Method.PUT.equals(method)) {
files.put("content", saveTmpFile(fbuf, 0, fbuf.limit()));
}
- }
- finally
- {
+ } finally {
safeClose(randomAccessFile);
safeClose(in);
}
@@ -1102,27 +948,22 @@ public abstract class NanoHTTPD
* Decodes the sent headers and loads the data into Key/value pairs
*/
private void decodeHeader(BufferedReader in, Map pre, Map parms, Map headers)
- throws ResponseException
- {
- try
- {
+ throws ResponseException {
+ try {
// Read the request line
String inLine = in.readLine();
- if (inLine == null)
- {
+ if (inLine == null) {
return;
}
StringTokenizer st = new StringTokenizer(inLine);
- if (!st.hasMoreTokens())
- {
+ if (!st.hasMoreTokens()) {
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Syntax error. Usage: GET /example/file.html");
}
pre.put("method", st.nextToken());
- if (!st.hasMoreTokens())
- {
+ if (!st.hasMoreTokens()) {
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Missing URI. Usage: GET /example/file.html");
}
@@ -1130,13 +971,10 @@ public abstract class NanoHTTPD
// Decode parameters from the URI
int qmi = uri.indexOf('?');
- if (qmi >= 0)
- {
+ if (qmi >= 0) {
decodeParms(uri.substring(qmi + 1), parms);
uri = decodePercent(uri.substring(0, qmi));
- }
- else
- {
+ } else {
uri = decodePercent(uri);
}
@@ -1144,14 +982,11 @@ public abstract class NanoHTTPD
// followed by HTTP headers. Ignore version but parse headers.
// NOTE: this now forces header names lowercase since they are
// case insensitive and vary by client.
- if (st.hasMoreTokens())
- {
+ if (st.hasMoreTokens()) {
String line = in.readLine();
- while (line != null && line.trim().length() > 0)
- {
+ while (line != null && line.trim().length() > 0) {
int p = line.indexOf(':');
- if (p >= 0)
- {
+ if (p >= 0) {
headers.put(line.substring(0, p).trim().toLowerCase(), line.substring(p + 1).trim());
}
line = in.readLine();
@@ -1159,9 +994,7 @@ public abstract class NanoHTTPD
}
pre.put("uri", uri);
- }
- catch (IOException ioe)
- {
+ } catch (IOException ioe) {
throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage(), ioe);
}
}
@@ -1170,46 +1003,36 @@ public abstract class NanoHTTPD
* Decodes the Multipart Body data and put it into Key/Value pairs.
*/
private void decodeMultipartData(String boundary, ByteBuffer fbuf, BufferedReader in, Map parms,
- Map files) throws ResponseException
- {
- try
- {
+ Map files) throws ResponseException {
+ try {
int[] bpositions = getBoundaryPositions(fbuf, boundary.getBytes());
int boundarycount = 1;
String mpline = in.readLine();
- while (mpline != null)
- {
- if (!mpline.contains(boundary))
- {
+ while (mpline != null) {
+ if (!mpline.contains(boundary)) {
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but next chunk does not start with boundary. Usage: GET /example/file.html");
}
boundarycount++;
Map item = new HashMap();
mpline = in.readLine();
- while (mpline != null && mpline.trim().length() > 0)
- {
+ while (mpline != null && mpline.trim().length() > 0) {
int p = mpline.indexOf(':');
- if (p != -1)
- {
+ if (p != -1) {
item.put(mpline.substring(0, p).trim().toLowerCase(), mpline.substring(p + 1).trim());
}
mpline = in.readLine();
}
- if (mpline != null)
- {
+ if (mpline != null) {
String contentDisposition = item.get("content-disposition");
- if (contentDisposition == null)
- {
+ if (contentDisposition == null) {
throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but no content-disposition info found. Usage: GET /example/file.html");
}
StringTokenizer st = new StringTokenizer(contentDisposition, "; ");
Map disposition = new HashMap();
- while (st.hasMoreTokens())
- {
+ while (st.hasMoreTokens()) {
String token = st.nextToken();
int p = token.indexOf('=');
- if (p != -1)
- {
+ if (p != -1) {
disposition.put(token.substring(0, p).trim().toLowerCase(), token.substring(p + 1).trim());
}
}
@@ -1217,29 +1040,20 @@ public abstract class NanoHTTPD
pname = pname.substring(1, pname.length() - 1);
String value = "";
- if (item.get("content-type") == null)
- {
- while (mpline != null && !mpline.contains(boundary))
- {
+ if (item.get("content-type") == null) {
+ while (mpline != null && !mpline.contains(boundary)) {
mpline = in.readLine();
- if (mpline != null)
- {
+ if (mpline != null) {
int d = mpline.indexOf(boundary);
- if (d == -1)
- {
+ if (d == -1) {
value += mpline;
- }
- else
- {
+ } else {
value += mpline.substring(0, d - 2);
}
}
}
- }
- else
- {
- if (boundarycount > bpositions.length)
- {
+ } else {
+ if (boundarycount > bpositions.length) {
throw new ResponseException(Response.Status.INTERNAL_ERROR, "Error processing request");
}
int offset = stripMultipartHeaders(fbuf, bpositions[boundarycount - 2]);
@@ -1247,18 +1061,14 @@ public abstract class NanoHTTPD
files.put(pname, path);
value = disposition.get("filename");
value = value.substring(1, value.length() - 1);
- do
- {
+ do {
mpline = in.readLine();
- }
- while (mpline != null && !mpline.contains(boundary));
+ } while (mpline != null && !mpline.contains(boundary));
}
parms.put(pname, value);
}
}
- }
- catch (IOException ioe)
- {
+ } catch (IOException ioe) {
throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage(), ioe);
}
}
@@ -1266,13 +1076,10 @@ public abstract class NanoHTTPD
/**
* Find byte index separating header from body. It must be the last byte of the first two sequential new lines.
*/
- private int findHeaderEnd(final byte[] buf, int rlen)
- {
+ private int findHeaderEnd(final byte[] buf, int rlen) {
int splitbyte = 0;
- while (splitbyte + 3 < rlen)
- {
- if (buf[splitbyte] == '\r' && buf[splitbyte + 1] == '\n' && buf[splitbyte + 2] == '\r' && buf[splitbyte + 3] == '\n')
- {
+ while (splitbyte + 3 < rlen) {
+ if (buf[splitbyte] == '\r' && buf[splitbyte + 1] == '\n' && buf[splitbyte + 2] == '\r' && buf[splitbyte + 3] == '\n') {
return splitbyte + 4;
}
splitbyte++;
@@ -1283,37 +1090,29 @@ public abstract class NanoHTTPD
/**
* Find the byte positions where multipart boundaries start.
*/
- private int[] getBoundaryPositions(ByteBuffer b, byte[] boundary)
- {
+ private int[] getBoundaryPositions(ByteBuffer b, byte[] boundary) {
int matchcount = 0;
int matchbyte = -1;
List matchbytes = new ArrayList();
- for (int i = 0; i < b.limit(); i++)
- {
- if (b.get(i) == boundary[matchcount])
- {
- if (matchcount == 0)
- {
+ for (int i = 0; i < b.limit(); i++) {
+ if (b.get(i) == boundary[matchcount]) {
+ if (matchcount == 0) {
matchbyte = i;
}
matchcount++;
- if (matchcount == boundary.length)
- {
+ if (matchcount == boundary.length) {
matchbytes.add(matchbyte);
matchcount = 0;
matchbyte = -1;
}
- }
- else
- {
+ } else {
i -= matchcount;
matchcount = 0;
matchbyte = -1;
}
}
int[] ret = new int[matchbytes.size()];
- for (int i = 0; i < ret.length; i++)
- {
+ for (int i = 0; i < ret.length; i++) {
ret[i] = matchbytes.get(i);
}
return ret;
@@ -1322,14 +1121,11 @@ public abstract class NanoHTTPD
/**
* Retrieves the content of a sent file and saves it to a temporary file. The full path to the saved file is returned.
*/
- private String saveTmpFile(ByteBuffer b, int offset, int len)
- {
+ private String saveTmpFile(ByteBuffer b, int offset, int len) {
String path = "";
- if (len > 0)
- {
+ if (len > 0) {
FileOutputStream fileOutputStream = null;
- try
- {
+ try {
TempFile tempFile = tempFileManager.createTempFile();
ByteBuffer src = b.duplicate();
fileOutputStream = new FileOutputStream(tempFile.getName());
@@ -1337,28 +1133,20 @@ public abstract class NanoHTTPD
src.position(offset).limit(offset + len);
dest.write(src.slice());
path = tempFile.getName();
- }
- catch (Exception e)
- { // Catch exception if any
+ } catch (Exception e) { // Catch exception if any
FLog.severe(e);
- }
- finally
- {
+ } finally {
safeClose(fileOutputStream);
}
}
return path;
}
- private RandomAccessFile getTmpBucket()
- {
- try
- {
+ private RandomAccessFile getTmpBucket() {
+ try {
TempFile tempFile = tempFileManager.createTempFile();
return new RandomAccessFile(tempFile.getName(), "rw");
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
FLog.severe(e);
}
return null;
@@ -1367,13 +1155,10 @@ public abstract class NanoHTTPD
/**
* It returns the offset separating multipart file headers from the file's data.
*/
- private int stripMultipartHeaders(ByteBuffer b, int offset)
- {
+ private int stripMultipartHeaders(ByteBuffer b, int offset) {
int i;
- for (i = offset; i < b.limit(); i++)
- {
- if (b.get(i) == '\r' && b.get(++i) == '\n' && b.get(++i) == '\r' && b.get(++i) == '\n')
- {
+ for (i = offset; i < b.limit(); i++) {
+ if (b.get(i) == '\r' && b.get(++i) == '\n' && b.get(++i) == '\r' && b.get(++i) == '\n') {
break;
}
}
@@ -1384,99 +1169,81 @@ public abstract class NanoHTTPD
* Decodes parameters in percent-encoded URI-format ( e.g. "name=Jack%20Daniels&pass=Single%20Malt" ) and
* adds them to given Map. NOTE: this doesn't support multiple identical keys due to the simplicity of Map.
*/
- private void decodeParms(String parms, Map p)
- {
- if (parms == null)
- {
+ private void decodeParms(String parms, Map p) {
+ if (parms == null) {
p.put(QUERY_STRING_PARAMETER, "");
return;
}
p.put(QUERY_STRING_PARAMETER, parms);
StringTokenizer st = new StringTokenizer(parms, "&");
- while (st.hasMoreTokens())
- {
+ while (st.hasMoreTokens()) {
String e = st.nextToken();
int sep = e.indexOf('=');
- if (sep >= 0)
- {
+ if (sep >= 0) {
p.put(decodePercent(e.substring(0, sep)).trim(),
decodePercent(e.substring(sep + 1)));
- }
- else
- {
+ } else {
p.put(decodePercent(e).trim(), "");
}
}
}
- public final Map getParms()
- {
+ public final Map getParms() {
return parms;
}
- public final Map getHeaders()
- {
+ public final Map getHeaders() {
return headers;
}
- public final String getUri()
- {
+ public final String getUri() {
return uri;
}
- public final Method getMethod()
- {
+ public final Method getMethod() {
return method;
}
- public final InputStream getInputStream()
- {
+ public final InputStream getInputStream() {
return inputStream;
}
- public CookieHandler getCookies()
- {
+ public CookieHandler getCookies() {
return cookies;
}
- public Socket getSocket()
- {
+ public Socket getSocket() {
return socket;
}
}
- public static class Cookie
- {
+ public static class Cookie {
+
private String n, v, e;
- public Cookie(String name, String value, String expires)
- {
+ public Cookie(String name, String value, String expires) {
n = name;
v = value;
e = expires;
}
- public Cookie(String name, String value)
- {
+ public Cookie(String name, String value) {
this(name, value, 30);
}
- public Cookie(String name, String value, int numDays)
- {
+ public Cookie(String name, String value, int numDays) {
n = name;
v = value;
e = getHTTPTime(numDays);
}
- public String getHTTPHeader()
- {
+ public String getHTTPHeader() {
String fmt = "%s=%s; expires=%s";
return String.format(fmt, n, v, e);
}
- public static String getHTTPTime(int days)
- {
+ public static String getHTTPTime(int days) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -1492,22 +1259,18 @@ public abstract class NanoHTTPD
*
* @author LordFokas
*/
- public class CookieHandler implements Iterable
- {
+ public class CookieHandler implements Iterable {
+
private HashMap cookies = new HashMap();
private ArrayList queue = new ArrayList();
- public CookieHandler(Map httpHeaders)
- {
+ public CookieHandler(Map httpHeaders) {
String raw = httpHeaders.get("cookie");
- if (raw != null)
- {
+ if (raw != null) {
String[] tokens = raw.split(";");
- for (String token : tokens)
- {
+ for (String token : tokens) {
String[] data = token.trim().split("=");
- if (data.length == 2)
- {
+ if (data.length == 2) {
cookies.put(data[0], data[1]);
}
}
@@ -1515,8 +1278,7 @@ public abstract class NanoHTTPD
}
@Override
- public Iterator iterator()
- {
+ public Iterator iterator() {
return cookies.keySet().iterator();
}
@@ -1526,25 +1288,22 @@ public abstract class NanoHTTPD
* @param name The cookie's name.
* @return The cookie's value if it exists, null otherwise.
*/
- public String read(String name)
- {
+ public String read(String name) {
return cookies.get(name);
}
/**
* Sets a cookie.
*
- * @param name The cookie's name.
- * @param value The cookie's value.
+ * @param name The cookie's name.
+ * @param value The cookie's value.
* @param expires How many days until the cookie expires.
*/
- public void set(String name, String value, int expires)
- {
+ public void set(String name, String value, int expires) {
queue.add(new Cookie(name, value, Cookie.getHTTPTime(expires)));
}
- public void set(Cookie cookie)
- {
+ public void set(Cookie cookie) {
queue.add(cookie);
}
@@ -1553,8 +1312,7 @@ public abstract class NanoHTTPD
*
* @param name The cookie name.
*/
- public void delete(String name)
- {
+ public void delete(String name) {
set(name, "-delete-", -30);
}
@@ -1563,12 +1321,11 @@ public abstract class NanoHTTPD
*
* @param response The Response object to which headers the queued cookies will be added.
*/
- public void unloadQueue(Response response)
- {
- for (Cookie cookie : queue)
- {
+ public void unloadQueue(Response response) {
+ for (Cookie cookie : queue) {
response.addHeader("Set-Cookie", cookie.getHTTPHeader());
}
}
}
+
}
diff --git a/src/me/totalfreedom/totalfreedommod/listener/BlockListener.java b/src/me/totalfreedom/totalfreedommod/listener/BlockListener.java
deleted file mode 100644
index cff75fdd..00000000
--- a/src/me/totalfreedom/totalfreedommod/listener/BlockListener.java
+++ /dev/null
@@ -1,271 +0,0 @@
-package me.totalfreedom.totalfreedommod.listener;
-
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.util.FLog;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import net.pravian.aero.component.PluginListener;
-import org.bukkit.ChatColor;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.event.block.BlockBurnEvent;
-import org.bukkit.event.block.BlockFromToEvent;
-import org.bukkit.event.block.BlockIgniteEvent;
-import org.bukkit.event.block.BlockPlaceEvent;
-import org.bukkit.inventory.ItemStack;
-
-public class BlockListener extends PluginListener
-{
-
- public BlockListener(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
- @EventHandler(priority = EventPriority.HIGH)
- public void onBlockBurn(BlockBurnEvent event)
- {
- if (!ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
- {
- event.setCancelled(true);
- }
- }
-
- @EventHandler(priority = EventPriority.HIGH)
- public void onBlockIgnite(BlockIgniteEvent event)
- {
- if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
- {
- event.setCancelled(true);
- }
- }
-
- @EventHandler(priority = EventPriority.NORMAL)
- public void onBlockBreak(BlockBreakEvent event)
- {
- final Player player = event.getPlayer();
- final Location location = event.getBlock().getLocation();
-
- if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
- {
- final FPlayer playerdata = plugin.pl.getPlayer(player);
-
- final Location playerLocation = player.getLocation();
-
- final double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble().doubleValue();
-
- boolean outOfRange = false;
- if (!playerLocation.getWorld().equals(location.getWorld()))
- {
- outOfRange = true;
- }
- else if (playerLocation.distanceSquared(location) > (nukeMonitorRange * nukeMonitorRange))
- {
- outOfRange = true;
- }
-
- if (outOfRange)
- {
- if (playerdata.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
- {
- FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
- FUtil.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
-
- playerdata.resetFreecamDestroyCount();
-
- event.setCancelled(true);
- return;
- }
- }
-
- final Long lastRan = plugin.hb.getLastRan();
- if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
- {
- // TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
- }
- else
- {
- if (playerdata.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
- {
- FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
- FUtil.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
-
- playerdata.resetBlockDestroyCount();
-
- event.setCancelled(true);
- return;
- }
- }
- }
-
- if (ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
- {
- if (!plugin.al.isAdmin(player))
- {
- if (plugin.pa.isInProtectedArea(location))
- {
- event.setCancelled(true);
- }
- }
- }
- }
-
- @EventHandler(priority = EventPriority.HIGH)
- public void onBlockPlace(BlockPlaceEvent event)
- {
- Player player = event.getPlayer();
- Location blockLocation = event.getBlock().getLocation();
-
- if (ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
- {
- FPlayer playerdata = plugin.pl.getPlayer(player);
-
- Location playerLocation = player.getLocation();
-
- double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble().doubleValue();
-
- boolean outOfRange = false;
- if (!playerLocation.getWorld().equals(blockLocation.getWorld()))
- {
- outOfRange = true;
- }
- else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange))
- {
- outOfRange = true;
- }
-
- if (outOfRange)
- {
- if (playerdata.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
- {
- FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
- FUtil.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
-
- playerdata.resetFreecamPlaceCount();
-
- event.setCancelled(true);
- return;
- }
- }
-
- Long lastRan = plugin.hb.getLastRan();
- if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
- {
- //TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
- }
- else
- {
- if (playerdata.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
- {
- FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
- FUtil.autoEject(player, "You are placing blocks too fast.");
-
- playerdata.resetBlockPlaceCount();
-
- event.setCancelled(true);
- return;
- }
- }
- }
-
- if (ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
- {
- if (!plugin.al.isAdmin(player))
- {
- if (plugin.pa.isInProtectedArea(blockLocation))
- {
- event.setCancelled(true);
- return;
- }
- }
- }
-
- switch (event.getBlockPlaced().getType())
- {
- case LAVA:
- case STATIONARY_LAVA:
- {
- if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
- {
- FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
-
- player.getInventory().clear(player.getInventory().getHeldItemSlot());
- }
- else
- {
- player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
- player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
-
- event.setCancelled(true);
- }
- break;
- }
- case WATER:
- case STATIONARY_WATER:
- {
- if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
- {
- FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
-
- player.getInventory().clear(player.getInventory().getHeldItemSlot());
- }
- else
- {
- player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
- player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
-
- event.setCancelled(true);
- }
- break;
- }
- case FIRE:
- {
- if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
- {
- FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
-
- player.getInventory().clear(player.getInventory().getHeldItemSlot());
- }
- else
- {
- player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
- player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
-
- event.setCancelled(true);
- }
- break;
- }
- case TNT:
- {
- if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
- {
- FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
-
- player.getInventory().clear(player.getInventory().getHeldItemSlot());
- }
- else
- {
- player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
-
- player.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
- event.setCancelled(true);
- }
- break;
- }
- }
- }
-
- @EventHandler(priority = EventPriority.HIGH)
- public void onBlockFromTo(BlockFromToEvent event)
- {
- if (!ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
- {
- event.setCancelled(true);
- }
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/listener/PlayerListener.java b/src/me/totalfreedom/totalfreedommod/listener/PlayerListener.java
deleted file mode 100644
index 8cac9172..00000000
--- a/src/me/totalfreedom/totalfreedommod/listener/PlayerListener.java
+++ /dev/null
@@ -1,867 +0,0 @@
-package me.totalfreedom.totalfreedommod.listener;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.regex.Pattern;
-import me.totalfreedom.totalfreedommod.commands.Command_landmine;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.permission.Rank;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
-import me.totalfreedom.totalfreedommod.player.PlayerData;
-import me.totalfreedom.totalfreedommod.rollback.RollbackEntry;
-import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
-import me.totalfreedom.totalfreedommod.util.FLog;
-import me.totalfreedom.totalfreedommod.util.FSync;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import net.pravian.aero.component.PluginListener;
-import net.pravian.aero.util.Ips;
-import org.apache.commons.lang3.StringUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.Sound;
-import org.bukkit.block.Block;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.TNTPrimed;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.block.Action;
-import org.bukkit.event.block.LeavesDecayEvent;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.event.player.PlayerDropItemEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerKickEvent;
-import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.event.player.PlayerTeleportEvent;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitRunnable;
-import org.bukkit.util.Vector;
-
-public class PlayerListener extends PluginListener
-{
- public static final List BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ","));
- public static final int MSG_PER_HEARTBEAT = 10;
- public static final int DEFAULT_PORT = 25565;
- public static final int MAX_XY_COORD = 30000000;
-
- @EventHandler(priority = EventPriority.HIGH)
- public void onPlayerInteract(PlayerInteractEvent event)
- {
- final Player player = event.getPlayer();
- final FPlayer playerdata = plugin.pl.getPlayer(player);
-
- switch (event.getAction())
- {
- case RIGHT_CLICK_AIR:
- case RIGHT_CLICK_BLOCK:
- {
- switch (event.getMaterial())
- {
- case WATER_BUCKET:
- {
- if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
- {
- break;
- }
-
- player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
- player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
- event.setCancelled(true);
- break;
- }
-
- case LAVA_BUCKET:
- {
- if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
- {
- break;
- }
-
- player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
- player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
- event.setCancelled(true);
- break;
- }
-
- case EXPLOSIVE_MINECART:
- {
- if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
- {
- break;
- }
-
- player.getInventory().clear(player.getInventory().getHeldItemSlot());
- player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
- event.setCancelled(true);
- break;
- }
- }
- break;
- }
-
- case LEFT_CLICK_AIR:
- case LEFT_CLICK_BLOCK:
- {
- switch (event.getMaterial())
- {
- case STICK:
- {
- if (!plugin.al.isAdmin(player))
- {
- break;
- }
-
- event.setCancelled(true);
-
- final Location location = DepreciationAggregator.getTargetBlock(player, null, 5).getLocation();
- final List entries = plugin.rb.getEntriesAtLocation(location);
-
- if (entries.isEmpty())
- {
- FUtil.playerMsg(player, "No block edits at that location.");
- break;
- }
-
- FUtil.playerMsg(player, "Block edits at ("
- + ChatColor.WHITE + "x" + location.getBlockX()
- + ", y" + location.getBlockY()
- + ", z" + location.getBlockZ()
- + ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
- for (RollbackEntry entry : entries)
- {
- FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " "
- + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data));
- }
-
- break;
- }
-
- case BONE:
- {
- if (!playerdata.mobThrowerEnabled())
- {
- break;
- }
-
- Location player_pos = player.getLocation();
- Vector direction = player_pos.getDirection().normalize();
-
- LivingEntity rezzed_mob = (LivingEntity) player.getWorld().spawnEntity(player_pos.add(direction.multiply(2.0)), playerdata.mobThrowerCreature());
- rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed()));
- playerdata.enqueueMob(rezzed_mob);
-
- event.setCancelled(true);
- break;
- }
-
- case SULPHUR:
- {
- if (!playerdata.isMP44Armed())
- {
- break;
- }
-
- event.setCancelled(true);
-
- if (playerdata.toggleMP44Firing())
- {
- playerdata.startArrowShooter(TotalFreedomMod.plugin);
- }
- else
- {
- playerdata.stopArrowShooter();
- }
- break;
- }
-
- case BLAZE_ROD:
- {
- if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
- {
- break;
- }
-
- if (!plugin.al.isSeniorAdmin(player))
- {
- break;
- }
-
- event.setCancelled(true);
- Block targetBlock;
-
- if (event.getAction().equals(Action.LEFT_CLICK_AIR))
- {
- targetBlock = DepreciationAggregator.getTargetBlock(player, null, 120);
- }
- else
- {
- targetBlock = event.getClickedBlock();
- }
-
- if (targetBlock == null)
- {
- player.sendMessage("Can't resolve target block.");
- break;
- }
-
- player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
- player.getWorld().strikeLightning(targetBlock.getLocation());
-
- break;
- }
-
- case CARROT:
- {
- if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
- {
- break;
- }
-
- if (!plugin.al.isSeniorAdmin(player))
- {
- break;
- }
-
- Location location = player.getLocation().clone();
-
- Vector playerPostion = location.toVector().add(new Vector(0.0, 1.65, 0.0));
- Vector playerDirection = location.getDirection().normalize();
-
- double distance = 150.0;
- Block targetBlock = DepreciationAggregator.getTargetBlock(player, null, Math.round((float) distance));
- if (targetBlock != null)
- {
- distance = location.distance(targetBlock.getLocation());
- }
-
- final List affected = new ArrayList();
-
- Block lastBlock = null;
- for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
- {
- Block block = playerPostion.clone().add(playerDirection.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
-
- if (!block.equals(lastBlock))
- {
- if (block.isEmpty())
- {
- affected.add(block);
- block.setType(Material.TNT);
- }
- else
- {
- break;
- }
- }
-
- lastBlock = block;
- }
-
- new BukkitRunnable()
- {
- @Override
- public void run()
- {
- for (Block tntBlock : affected)
- {
- TNTPrimed tnt = tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class);
- tnt.setFuseTicks(5);
- tntBlock.setType(Material.AIR);
- }
- }
- }.runTaskLater(TotalFreedomMod.plugin, 30L);
-
- event.setCancelled(true);
- break;
- }
-
- case RAW_FISH:
- {
- final int RADIUS_HIT = 5;
- final int STRENGTH = 4;
-
- // Clownfish
- if (DepreciationAggregator.getData_MaterialData(event.getItem().getData()) == 2)
- {
- if (plugin.al.isSeniorAdmin(player))
- {
- boolean didHit = false;
-
- final Location playerLoc = player.getLocation();
- final Vector playerLocVec = playerLoc.toVector();
-
- final List players = player.getWorld().getPlayers();
- for (final Player target : players)
- {
- if (target == player)
- {
- continue;
- }
-
- final Location targetPos = target.getLocation();
- final Vector targetPosVec = targetPos.toVector();
-
- try
- {
- if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT))
- {
- FUtil.setFlying(player, false);
- target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH));
- didHit = true;
- }
- }
- catch (IllegalArgumentException ex)
- {
- }
- }
-
- if (didHit)
- {
- final Sound[] sounds = Sound.values();
- for (Sound sound : sounds)
- {
- if (sound.toString().contains("HIT"))
- {
- playerLoc.getWorld().playSound(randomOffset(playerLoc, 5.0), sound, 100.0f, randomDoubleRange(0.5, 2.0).floatValue());
- }
- }
- }
- }
- else
- {
- final StringBuilder msg = new StringBuilder();
- final char[] chars = (player.getName() + " is a clown.").toCharArray();
- for (char c : chars)
- {
- msg.append(FUtil.randomChatColor()).append(c);
- }
- FUtil.bcastMsg(msg.toString());
-
- player.getInventory().getItemInHand().setType(Material.POTATO_ITEM);
- }
-
- event.setCancelled(true);
- break;
- }
- }
- }
- break;
- }
- }
- }
- private static final Random RANDOM = new Random();
-
- private static Location randomOffset(Location a, double magnitude)
- {
- return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);
- }
-
- private static Double randomDoubleRange(double min, double max)
- {
- return min + (RANDOM.nextDouble() * ((max - min) + 1.0));
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onPlayerTeleport(PlayerTeleportEvent event)
- {
- final Player player = event.getPlayer();
- final FPlayer playerdata = plugin.pl.getPlayer(player);
- // Check absolute value to account for negatives
- if (Math.abs(event.getTo().getX()) >= MAX_XY_COORD || Math.abs(event.getTo().getZ()) >= MAX_XY_COORD)
- {
- event.setCancelled(true); // illegal position, cancel it
- }
-
- if (!plugin.al.isAdmin(player) && playerdata.isFrozen())
- {
- FUtil.setFlying(player, true);
- event.setTo(playerdata.getFreezeLocation());
- return; // Don't process adminworld validation
- }
-
- plugin.wm.adminworld.validateMovement(event);
- }
-
- @EventHandler(priority = EventPriority.NORMAL)
- public void onPlayerMove(PlayerMoveEvent event)
- {
- final Location from = event.getFrom();
- final Location to = event.getTo();
- try
- {
- if (from.getWorld() == to.getWorld() && from.distanceSquared(to) < (0.0001 * 0.0001))
- {
- // If player just rotated, but didn't move, don't process this event.
- return;
- }
- }
- catch (IllegalArgumentException ex)
- {
- }
-
- if (!plugin.wm.adminworld.validateMovement(event))
- {
- return;
- }
-
- final Player player = event.getPlayer();
- final FPlayer playerdata = plugin.pl.getPlayer(player);
-
- for (Entry fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet())
- {
- Player fuckoffPlayer = fuckoff.getKey();
-
- if (fuckoffPlayer.equals(player) || !fuckoffPlayer.isOnline())
- {
- continue;
- }
-
- double fuckoffRange = fuckoff.getValue();
-
- Location playerLocation = player.getLocation();
- Location fuckoffLocation = fuckoffPlayer.getLocation();
-
- double distanceSquared;
- try
- {
- distanceSquared = playerLocation.distanceSquared(fuckoffLocation);
- }
- catch (IllegalArgumentException ex)
- {
- continue;
- }
-
- if (distanceSquared < (fuckoffRange * fuckoffRange))
- {
- event.setTo(fuckoffLocation.clone().add(playerLocation.subtract(fuckoffLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
- break;
- }
- }
-
- // Freeze
- if (!plugin.al.isAdmin(player) && playerdata.isFrozen())
- {
- FUtil.setFlying(player, true);
- event.setTo(playerdata.getFreezeLocation());
- }
-
- if (playerdata.isCaged())
- {
- Location targetPos = player.getLocation().add(0, 1, 0);
-
- boolean outOfCage;
- if (!targetPos.getWorld().equals(playerdata.getCagePos().getWorld()))
- {
- outOfCage = true;
- }
- else
- {
- outOfCage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
- }
-
- if (outOfCage)
- {
- playerdata.setCaged(true, targetPos, playerdata.getCageMaterial(FPlayer.CageLayer.OUTER), playerdata.getCageMaterial(FPlayer.CageLayer.INNER));
- playerdata.regenerateHistory();
- playerdata.clearHistory();
- FUtil.buildHistory(targetPos, 2, playerdata);
- FUtil.generateHollowCube(targetPos, 2, playerdata.getCageMaterial(FPlayer.CageLayer.OUTER));
- FUtil.generateCube(targetPos, 1, playerdata.getCageMaterial(FPlayer.CageLayer.INNER));
- }
- }
-
- if (playerdata.isOrbiting())
- {
- if (player.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0))
- {
- player.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
- }
- }
-
- if (plugin.jp.getMode().isOn())
- {
- plugin.jp.onPlayerMove(event);
- }
-
- if (!(ConfigEntry.LANDMINES_ENABLED.getBoolean() && ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()))
- {
- return;
- }
-
- final Iterator landmines = Command_landmine.TFM_LandmineData.landmines.iterator();
- while (landmines.hasNext())
- {
- final Command_landmine.TFM_LandmineData landmine = landmines.next();
-
- final Location location = landmine.location;
- if (location.getBlock().getType() != Material.TNT)
- {
- landmines.remove();
- continue;
- }
-
- if (landmine.player.equals(player))
- {
- break;
- }
-
- if (!player.getWorld().equals(location.getWorld()))
- {
- continue;
- }
-
- if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius)))
- {
- break;
- }
-
- landmine.location.getBlock().setType(Material.AIR);
-
- final TNTPrimed tnt1 = location.getWorld().spawn(location, TNTPrimed.class);
- tnt1.setFuseTicks(40);
- tnt1.setPassenger(player);
- tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));
-
- final TNTPrimed tnt2 = location.getWorld().spawn(player.getLocation(), TNTPrimed.class);
- tnt2.setFuseTicks(1);
-
- player.setGameMode(GameMode.SURVIVAL);
- landmines.remove();
- }
- }
-
- @EventHandler(priority = EventPriority.NORMAL)
- public void onLeavesDecay(LeavesDecayEvent event)
- {
- event.setCancelled(true);
- }
-
- @EventHandler(priority = EventPriority.NORMAL)
- public void onPlayerChat(AsyncPlayerChatEvent event)
- {
- try
- {
- final Player player = event.getPlayer();
- String message = event.getMessage().trim();
-
- final FPlayer playerdata = plugin.pl.getPlayerSync(player);
-
- // Check for spam
- final Long lastRan = plugin.hb.getLastRan();
- if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
- {
- //TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
- }
- else
- {
- if (playerdata.incrementAndGetMsgCount() > MSG_PER_HEARTBEAT)
- {
- FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
- FSync.autoEject(player, "Kicked for spamming chat.");
-
- playerdata.resetMsgCount();
-
- event.setCancelled(true);
- return;
- }
- }
-
- // Check for message repeat
- if (playerdata.getLastMessage().equalsIgnoreCase(message))
- {
- FSync.playerMsg(player, "Please do not repeat messages.");
- event.setCancelled(true);
- return;
- }
-
- playerdata.setLastMessage(message);
-
- // Check for muted
- if (playerdata.isMuted())
- {
- if (!plugin.al.isAdminSync(player))
- {
- FSync.playerMsg(player, ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
- event.setCancelled(true);
- return;
- }
-
- playerdata.setMuted(false);
- }
-
- // Strip color from messages
- message = ChatColor.stripColor(message);
-
- // Truncate messages that are too long - 100 characters is vanilla client max
- if (message.length() > 100)
- {
- message = message.substring(0, 100);
- FSync.playerMsg(player, "Message was shortened because it was too long to send.");
- }
-
- // Check for caps
- if (message.length() >= 6)
- {
- int caps = 0;
- for (char c : message.toCharArray())
- {
- if (Character.isUpperCase(c))
- {
- caps++;
- }
- }
- if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
- {
- message = message.toLowerCase();
- }
- }
-
- // Check for adminchat
- if (playerdata.inAdminChat())
- {
- FSync.adminChatMessage(player, message, false);
- event.setCancelled(true);
- return;
- }
-
- // Finally, set message
- event.setMessage(message);
-
- // Set the tag
- if (playerdata.getTag() != null)
- {
- event.setFormat("<" + playerdata.getTag().replaceAll("%", "%%") + " %1$s> %2$s");
- }
- }
- catch (Exception ex)
- {
- FLog.severe(ex);
- }
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
- {
- String command = event.getMessage();
- final Player player = event.getPlayer();
-
- final FPlayer playerdata = plugin.pl.getPlayer(player);
- playerdata.setLastCommand(command);
-
- if (playerdata.incrementAndGetMsgCount() > MSG_PER_HEARTBEAT)
- {
- FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
- FUtil.autoEject(player, "Kicked for spamming commands.");
-
- playerdata.resetMsgCount();
-
- FUtil.TFM_EntityWiper.wipeEntities(true, true);
-
- event.setCancelled(true);
- return;
- }
-
- if (playerdata.allCommandsBlocked())
- {
- FUtil.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
- event.setCancelled(true);
- return;
- }
-
- // Block commands if player is muted
- if (playerdata.isMuted())
- {
- if (!plugin.al.isAdmin(player))
- {
- for (String commandName : BLOCKED_MUTED_CMDS)
- {
- if (Pattern.compile("^/" + commandName.toLowerCase() + " ").matcher(command.toLowerCase()).find())
- {
- player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
- event.setCancelled(true);
- return;
- }
- }
- }
- else
- {
- playerdata.setMuted(false);
- }
- }
-
- if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean())
- {
- FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command), true);
- }
-
- // Blocked commands
- if (plugin.cb.isCommandBlocked(command, player, true))
- {
- // CommandBlocker handles messages and broadcasts
- event.setCancelled(true);
- }
-
- if (!plugin.al.isAdmin(player))
- {
- for (Player pl : Bukkit.getOnlinePlayers())
- {
- if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(pl).cmdspyEnabled())
- {
- FUtil.playerMsg(pl, player.getName() + ": " + command);
- }
- }
- }
- }
-
- @EventHandler(priority = EventPriority.NORMAL)
- public void onPlayerDropItem(PlayerDropItemEvent event)
- {
- if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
- {
- if (event.getPlayer().getWorld().getEntities().size() > 750)
- {
- event.setCancelled(true);
- }
- else
- {
- event.getItemDrop().remove();
- }
- }
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerKick(PlayerKickEvent event)
- {
- playerLeave(event.getPlayer());
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerQuit(PlayerQuitEvent event)
- {
- playerLeave(event.getPlayer());
- }
-
- private void playerLeave(Player player)
- {
- if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
- {
- TotalFreedomMod.fuckoffEnabledFor.remove(player);
- }
-
- final FPlayer playerdata = plugin.pl.getPlayer(player);
-
- playerdata.disarmMP44();
-
- if (playerdata.isCaged())
- {
- playerdata.regenerateHistory();
- playerdata.clearHistory();
- }
-
- FLog.info("[EXIT] " + player.getName() + " left the game.", true);
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerJoin(PlayerJoinEvent event)
- {
- final Player player = event.getPlayer();
- final String ip = Ips.getIp(event.getPlayer());
- FLog.info("[JOIN] " + FUtil.formatPlayer(player) + " joined the game with IP address: " + ip, true);
- // Check absolute value to account for negatives
- if (Math.abs(player.getLocation().getX()) >= MAX_XY_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XY_COORD)
- {
- player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
- }
-
- // Ensure a playerlist entry is present
- PlayerData playerEntry = plugin.pl.getData(player);
-
- // Generate PlayerData (non-persistent)
- final FPlayer playerdata = plugin.pl.getPlayer(player);
- playerdata.setSuperadminIdVerified(false);
-
- if (plugin.al.isAdmin(player))
- {
- for (String storedIp : playerEntry.getIps())
- {
- plugin.bm.unbanIp(storedIp);
- plugin.bm.unbanIp(FUtil.getFuzzyIp(storedIp));
- }
-
- plugin.bm.unbanUsername(player.getName());
- player.setOp(true);
-
- // Verify strict IP match
- if (!plugin.al.isIdentityMatched(player))
- {
- playerdata.setSuperadminIdVerified(false);
- FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
- }
- else
- {
- playerdata.setSuperadminIdVerified(true);
- plugin.al.updateLastLogin(player);
- }
- }
-
- // Handle admin impostors
- if (plugin.al.isAdminImpostor(player))
- {
- FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
- FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + plugin.rm.getDisplayRank(player).getColoredLoginMessage());
- player.getInventory().clear();
- player.setOp(false);
- player.setGameMode(GameMode.SURVIVAL);
- plugin.pl.getPlayer(player).setFrozen(true);
- }
- else if (plugin.al.isAdmin(player) || FUtil.DEVELOPERS.contains(player.getName()))
- {
- FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + plugin.rm.getDisplayRank(player).getColoredLoginMessage());
- }
-
- // TODO: Cleanup
- if (plugin.al.isAdmin(player))
- {
- Rank rank = plugin.rm.getDisplayRank(player);
-
- plugin.pl.getPlayer(player).setTag(rank.getColoredTag());
-
- try
- {
- String displayName = rank.getColorString() + player.getName();
- player.setPlayerListName(displayName.substring(0, 16));
- }
- catch (IllegalArgumentException ex)
- {
- }
- }
-
- new BukkitRunnable()
- {
- @Override
- public void run()
- {
- if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
- {
- player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
- }
-
- if (TotalFreedomMod.lockdownEnabled)
- {
- FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
- }
- }
- }.runTaskLater(TotalFreedomMod.plugin, 20L * 1L);
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/listener/WeatherListener.java b/src/me/totalfreedom/totalfreedommod/listener/WeatherListener.java
deleted file mode 100644
index c089243b..00000000
--- a/src/me/totalfreedom/totalfreedommod/listener/WeatherListener.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package me.totalfreedom.totalfreedommod.listener;
-
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.world.WorldWeather;
-import net.pravian.aero.component.PluginListener;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.weather.ThunderChangeEvent;
-import org.bukkit.event.weather.WeatherChangeEvent;
-
-public class WeatherListener extends PluginListener
-{
- @EventHandler(priority = EventPriority.HIGH)
- public void onThunderChange(ThunderChangeEvent event)
- {
- try
- {
- if (event.getWorld() == plugin.wm.adminworld.getWorld()
- && plugin.wm.adminworld.getWeatherMode() != WorldWeather.OFF)
- {
- return;
- }
- }
- catch (Exception ex)
- {
- }
-
- if (event.toThunderState() && ConfigEntry.DISABLE_WEATHER.getBoolean())
- {
- event.setCancelled(true);
- return;
- }
- }
-
- @EventHandler(priority = EventPriority.HIGH)
- public void onWeatherChange(WeatherChangeEvent event)
- {
- try
- {
- if (event.getWorld() == plugin.wm.adminworld.getWorld() && plugin.wm.adminworld.getWeatherMode() != WorldWeather.OFF)
- {
- return;
- }
- }
- catch (Exception ex)
- {
- }
-
- if (event.toWeatherState() && ConfigEntry.DISABLE_WEATHER.getBoolean())
- {
- event.setCancelled(true);
- return;
- }
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/permission/RankManager.java b/src/me/totalfreedom/totalfreedommod/permission/RankManager.java
deleted file mode 100644
index fdb03d2f..00000000
--- a/src/me/totalfreedom/totalfreedommod/permission/RankManager.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package me.totalfreedom.totalfreedommod.permission;
-
-import java.util.List;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.admin.Admin;
-import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.config.MainConfig;
-import me.totalfreedom.totalfreedommod.util.FUtil;
-import net.pravian.aero.component.service.AbstractService;
-import net.pravian.aero.util.ChatUtils;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-public class RankManager extends AbstractService
-{
-
- public RankManager(TotalFreedomMod plugin)
- {
- super(plugin);
- }
-
- @Override
- protected void onStart()
- {
- }
-
- @Override
- protected void onStop()
- {
- }
-
- public Rank getDisplayRank(CommandSender sender)
- {
- if (!(sender instanceof Player))
- {
- return getRank(sender); // Consoles don't have display ranks
- }
-
- final Player player = (Player) sender;
-
- // Developers always show up
- if (FUtil.DEVELOPERS.contains(player.getName()))
- {
- return TitleRank.DEVELOPER;
- }
-
- final PlayerRank playerRank = getRank((Player) sender);
- final Admin admin = playerRank.isAdmin() ? plugin.al.getAdmin(sender) : null;
-
- // Titles except developer are only for admins
- if (admin == null)
- {
- return playerRank;
- }
-
- if (MainConfig.get(ConfigEntry.SERVER_OWNERS, List.class).contains(player.getName()))
- {
- return TitleRank.OWNER;
- }
-
- final String loginMessage = admin.getLoginMessage();
- return loginMessage == null ? playerRank : new CustomLoginRank(playerRank, ChatUtils.colorize(loginMessage));
-
- }
-
- public Rank getRank(CommandSender sender)
- {
- if (sender instanceof Player)
- {
- return getRank((Player) sender);
- }
-
- Admin admin = plugin.al.getEntryByName(sender.getName());
-
- return ConsoleRank.forRank(admin.getRank());
- }
-
- public PlayerRank getRank(Player player)
- {
- if (plugin.al.isAdminImpostor(player))
- {
- return PlayerRank.IMPOSTOR;
- }
-
- final Admin entry = plugin.al.getAdmin(player);
- if (entry == null)
- {
- return player.isOp() ? PlayerRank.OP : PlayerRank.NON_OP;
- }
-
- return entry.getRank();
- }
-}
diff --git a/src/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/me/totalfreedom/totalfreedommod/player/FPlayer.java
index 066efc8a..dd46f663 100644
--- a/src/me/totalfreedom/totalfreedommod/player/FPlayer.java
+++ b/src/me/totalfreedom/totalfreedommod/player/FPlayer.java
@@ -4,15 +4,14 @@ import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
+import me.totalfreedom.totalfreedommod.caging.CageData;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@@ -34,18 +33,17 @@ public class FPlayer
//
private BukkitTask unmuteTask;
private BukkitTask unfreezeTask;
- private Location freezeLocation;
- private boolean isHalted = false;
+ @Getter
+ private final FreezeData freezeData = new FreezeData(this);
+ @Getter
+ private double fuckoffRadius = 0;
private int messageCount = 0;
private int totalBlockDestroy = 0;
private int totalBlockPlace = 0;
private int freecamDestroyCount = 0;
private int freecamPlaceCount = 0;
- private boolean isCaged = false;
- private Location cagePosition;
- private final List cageHistory = new ArrayList();
- private Material cageOuterMaterial = Material.GLASS;
- private Material cageInnerMatterial = Material.AIR;
+ @Getter
+ private final CageData cageData = new CageData(this);
private boolean isOrbiting = false;
private double orbitStrength = 10.0;
private boolean mobThrowerEnabled = false;
@@ -119,99 +117,19 @@ public class FPlayer
return orbitStrength;
}
- public void setCaged(boolean state)
+ public boolean isFuckOff()
{
- this.isCaged = state;
+ return fuckoffRadius > 0;
}
- public void setCaged(boolean state, Location location, Material outer, Material inner)
+ public void setFuckoff(double radius)
{
- this.isCaged = state;
- this.cagePosition = location;
- this.cageOuterMaterial = outer;
- this.cageInnerMatterial = inner;
+ this.fuckoffRadius = radius;
}
- public boolean isCaged()
+ public void disableFuckoff()
{
- return isCaged;
- }
-
- public Material getCageMaterial(CageLayer layer)
- {
- switch (layer)
- {
- case OUTER:
- return this.cageOuterMaterial;
- case INNER:
- return this.cageInnerMatterial;
- default:
- return this.cageOuterMaterial;
- }
- }
-
- public Location getCagePos()
- {
- return cagePosition;
- }
-
- public void clearHistory()
- {
- cageHistory.clear();
- }
-
- public void insertHistoryBlock(Location location, Material material)
- {
- cageHistory.add(new TFM_BlockData(location, material));
- }
-
- public void regenerateHistory()
- {
- for (TFM_BlockData blockdata : this.cageHistory)
- {
- blockdata.location.getBlock().setType(blockdata.material);
- }
- }
-
- public Location getFreezeLocation()
- {
- return freezeLocation;
- }
-
- public boolean isFrozen()
- {
- return unfreezeTask != null;
- }
-
- public void setFrozen(boolean freeze)
- {
- cancel(unfreezeTask);
- unfreezeTask = null;
- freezeLocation = null;
-
- if (player.getGameMode() != GameMode.CREATIVE)
- {
- FUtil.setFlying(player, false);
- }
-
- if (!freeze)
- {
- return;
- }
-
- freezeLocation = player.getLocation(); // Blockify location
- FUtil.setFlying(player, true); // Avoid infinite falling
-
- unfreezeTask = new BukkitRunnable()
- {
- @Override
- public void run()
- {
- FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
- setFrozen(false);
- }
-
- }.runTaskLater(TotalFreedomMod.plugin, AUTO_PURGE_TICKS);
+ this.fuckoffRadius = 0;
}
public void resetMsgCount()
@@ -351,7 +269,7 @@ public class FPlayer
public void setMuted(boolean muted)
{
- cancel(unmuteTask);
+ FUtil.cancel(unmuteTask);
unmuteTask = null;
if (!muted)
@@ -370,42 +288,6 @@ public class FPlayer
}.runTaskLater(TotalFreedomMod.plugin, AUTO_PURGE_TICKS);
}
- public boolean isHalted()
- {
- return this.isHalted;
- }
-
- public void setHalted(boolean halted)
- {
- this.isHalted = halted;
-
- if (halted)
- {
- player.setOp(false);
- player.setGameMode(GameMode.SURVIVAL);
- FUtil.setFlying(player, false);
- TotalFreedomMod.plugin.esb.setNickname(player.getName(), player.getName());
- player.closeInventory();
- player.setTotalExperience(0);
-
- stopOrbiting();
- setFrozen(true);
- setMuted(true);
-
- player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
- }
- else
- {
- player.setOp(true);
- player.setGameMode(GameMode.CREATIVE);
- setFrozen(false);
- setMuted(false);
-
- player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
- }
-
- }
-
public BukkitTask getLockupScheduleID()
{
return this.lockupScheduleTask;
@@ -513,42 +395,9 @@ public class FPlayer
}
}
- public void cancel(BukkitTask task)
- {
- if (task == null)
- {
- return;
- }
-
- try
- {
- task.cancel();
- }
- catch (Exception ex)
- {
- }
- }
-
- public enum CageLayer
- {
- INNER, OUTER
- }
-
- private class TFM_BlockData
- {
- public Material material;
- public Location location;
-
- private TFM_BlockData(Location location, Material material)
- {
- this.location = location;
- this.material = material;
- }
- }
-
private class ArrowShooter extends BukkitRunnable
{
- private Player player;
+ private final Player player;
private ArrowShooter(Player player)
{
diff --git a/src/me/totalfreedom/totalfreedommod/permission/ConsoleRank.java b/src/me/totalfreedom/totalfreedommod/rank/ConsoleRank.java
similarity index 97%
rename from src/me/totalfreedom/totalfreedommod/permission/ConsoleRank.java
rename to src/me/totalfreedom/totalfreedommod/rank/ConsoleRank.java
index 09682e1f..f2d63b86 100644
--- a/src/me/totalfreedom/totalfreedommod/permission/ConsoleRank.java
+++ b/src/me/totalfreedom/totalfreedommod/rank/ConsoleRank.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.permission;
+package me.totalfreedom.totalfreedommod.rank;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/permission/CustomLoginRank.java b/src/me/totalfreedom/totalfreedommod/rank/CustomLoginRank.java
similarity index 84%
rename from src/me/totalfreedom/totalfreedommod/permission/CustomLoginRank.java
rename to src/me/totalfreedom/totalfreedommod/rank/CustomLoginRank.java
index 6a0b5d92..2507b0b1 100644
--- a/src/me/totalfreedom/totalfreedommod/permission/CustomLoginRank.java
+++ b/src/me/totalfreedom/totalfreedommod/rank/CustomLoginRank.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.permission;
+package me.totalfreedom.totalfreedommod.rank;
public class CustomLoginRank extends RankProxy
{
diff --git a/src/me/totalfreedom/totalfreedommod/permission/PlayerRank.java b/src/me/totalfreedom/totalfreedommod/rank/PlayerRank.java
similarity index 97%
rename from src/me/totalfreedom/totalfreedommod/permission/PlayerRank.java
rename to src/me/totalfreedom/totalfreedommod/rank/PlayerRank.java
index 0afd3d74..65aa4c19 100644
--- a/src/me/totalfreedom/totalfreedommod/permission/PlayerRank.java
+++ b/src/me/totalfreedom/totalfreedommod/rank/PlayerRank.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.permission;
+package me.totalfreedom.totalfreedommod.rank;
import lombok.Getter;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/permission/Rank.java b/src/me/totalfreedom/totalfreedommod/rank/Rank.java
similarity index 87%
rename from src/me/totalfreedom/totalfreedommod/permission/Rank.java
rename to src/me/totalfreedom/totalfreedommod/rank/Rank.java
index 56997a4d..6a8dcfc3 100644
--- a/src/me/totalfreedom/totalfreedommod/permission/Rank.java
+++ b/src/me/totalfreedom/totalfreedommod/rank/Rank.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.permission;
+package me.totalfreedom.totalfreedommod.rank;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/rank/RankManager.java b/src/me/totalfreedom/totalfreedommod/rank/RankManager.java
new file mode 100644
index 00000000..7c52f3d4
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/rank/RankManager.java
@@ -0,0 +1,157 @@
+package me.totalfreedom.totalfreedommod.rank;
+
+import java.util.List;
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.admin.Admin;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.config.MainConfig;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import me.totalfreedom.totalfreedommod.player.PlayerData;
+import me.totalfreedom.totalfreedommod.util.FUtil;
+import net.pravian.aero.component.service.AbstractService;
+import net.pravian.aero.util.ChatUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.GameMode;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerJoinEvent;
+
+public class RankManager extends AbstractService
+{
+
+ public RankManager(TotalFreedomMod plugin)
+ {
+ super(plugin);
+ }
+
+ @Override
+ protected void onStart()
+ {
+ }
+
+ @Override
+ protected void onStop()
+ {
+ }
+
+ public Rank getDisplayRank(CommandSender sender)
+ {
+ if (!(sender instanceof Player))
+ {
+ return getRank(sender); // Consoles don't have display ranks
+ }
+
+ final Player player = (Player) sender;
+
+ // Developers always show up
+ if (FUtil.DEVELOPERS.contains(player.getName()))
+ {
+ return TitleRank.DEVELOPER;
+ }
+
+ final PlayerRank playerRank = getRank((Player) sender);
+ final Admin admin = playerRank.isAdmin() ? plugin.al.getAdmin(sender) : null;
+
+ // Titles except developer are only for admins
+ if (admin == null)
+ {
+ return playerRank;
+ }
+
+ if (MainConfig.get(ConfigEntry.SERVER_OWNERS, List.class).contains(player.getName()))
+ {
+ return TitleRank.OWNER;
+ }
+
+ final String loginMessage = admin.getLoginMessage();
+ return loginMessage == null ? playerRank : new CustomLoginRank(playerRank, ChatUtils.colorize(loginMessage));
+
+ }
+
+ public Rank getRank(CommandSender sender)
+ {
+ if (sender instanceof Player)
+ {
+ return getRank((Player) sender);
+ }
+
+ Admin admin = plugin.al.getEntryByName(sender.getName());
+
+ if (admin == null)
+ { // Unknown console, RCon, CONSOLE?
+ return ConsoleRank.SENIOR_CONSOLE;
+ }
+
+ return ConsoleRank.forRank(admin.getRank());
+ }
+
+ public PlayerRank getRank(Player player)
+ {
+ if (plugin.al.isAdminImpostor(player))
+ {
+ return PlayerRank.IMPOSTOR;
+ }
+
+ final Admin entry = plugin.al.getAdmin(player);
+ if (entry == null)
+ {
+ return player.isOp() ? PlayerRank.OP : PlayerRank.NON_OP;
+ }
+
+ return entry.getRank();
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerJoin(PlayerJoinEvent event)
+ {
+ final Player player = event.getPlayer();
+ final PlayerData data = plugin.pl.getData(player);
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ // Unban admins
+ boolean isAdmin = plugin.al.isAdmin(player);
+ if (isAdmin)
+ {
+ // Verify strict IP match
+ if (!plugin.al.isIdentityMatched(player))
+ {
+ fPlayer.setSuperadminIdVerified(false);
+ FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
+ }
+ else
+ {
+ fPlayer.setSuperadminIdVerified(true);
+ plugin.al.updateLastLogin(player);
+ }
+ }
+
+ // Handle impostors
+ if (plugin.al.isAdminImpostor(player))
+ {
+ FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
+ FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + plugin.rm.getDisplayRank(player).getColoredLoginMessage());
+ player.getInventory().clear();
+ player.setOp(false);
+ player.setGameMode(GameMode.SURVIVAL);
+ plugin.pl.getPlayer(player).getFreezeData().setFrozen(true);
+ }
+
+ // Set display
+ Rank display = getDisplayRank(player);
+ if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()))
+ {
+ FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + display.getColoredLoginMessage());
+ plugin.pl.getPlayer(player).setTag(display.getColoredTag());
+ try
+ {
+ String displayName = display.getColorString() + player.getName();
+ player.setPlayerListName(displayName.substring(0, 16));
+ }
+ catch (IllegalArgumentException ex)
+ {
+ }
+ }
+ }
+}
diff --git a/src/me/totalfreedom/totalfreedommod/permission/RankProxy.java b/src/me/totalfreedom/totalfreedommod/rank/RankProxy.java
similarity index 95%
rename from src/me/totalfreedom/totalfreedommod/permission/RankProxy.java
rename to src/me/totalfreedom/totalfreedommod/rank/RankProxy.java
index cdb36f52..23aa12e6 100644
--- a/src/me/totalfreedom/totalfreedommod/permission/RankProxy.java
+++ b/src/me/totalfreedom/totalfreedommod/rank/RankProxy.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.permission;
+package me.totalfreedom.totalfreedommod.rank;
import lombok.Getter;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/permission/TitleRank.java b/src/me/totalfreedom/totalfreedommod/rank/TitleRank.java
similarity index 96%
rename from src/me/totalfreedom/totalfreedommod/permission/TitleRank.java
rename to src/me/totalfreedom/totalfreedommod/rank/TitleRank.java
index 34a30dfe..1a3b13b2 100644
--- a/src/me/totalfreedom/totalfreedommod/permission/TitleRank.java
+++ b/src/me/totalfreedom/totalfreedommod/rank/TitleRank.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.totalfreedommod.permission;
+package me.totalfreedom.totalfreedommod.rank;
import lombok.Getter;
import org.bukkit.ChatColor;
diff --git a/src/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java b/src/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java
index 3d12159e..2d45d0f7 100644
--- a/src/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java
+++ b/src/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java
@@ -8,13 +8,19 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
+import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.service.AbstractService;
+import org.apache.commons.lang3.StringUtils;
+import org.bukkit.ChatColor;
import org.bukkit.Location;
+import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
+import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class RollbackManager extends AbstractService
@@ -22,7 +28,7 @@ public class RollbackManager extends AbstractService
private static final Map> history = Maps.newHashMap();
private static final List removeHistory = Lists.newArrayList();
- private RollbackManager(TotalFreedomMod plugin)
+ public RollbackManager(TotalFreedomMod plugin)
{
super(plugin);
}
@@ -220,6 +226,41 @@ public class RollbackManager extends AbstractService
return entries;
}
+ @EventHandler(ignoreCancelled = false)
+ public void onPlayerInteract(PlayerInteractEvent event)
+ {
+ final Player player = event.getPlayer();
+
+ if (!event.hasItem()
+ || event.getItem().getType() != Material.STICK
+ || !plugin.al.isAdmin(player))
+ {
+ return;
+ }
+
+ event.setCancelled(true);
+
+ final Location location = DepreciationAggregator.getTargetBlock(player, null, 5).getLocation();
+ final List entries = plugin.rb.getEntriesAtLocation(location);
+
+ if (entries.isEmpty())
+ {
+ FUtil.playerMsg(player, "No block edits at that location.");
+ return;
+ }
+
+ FUtil.playerMsg(player, "Block edits at ("
+ + ChatColor.WHITE + "x" + location.getBlockX()
+ + ", y" + location.getBlockY()
+ + ", z" + location.getBlockZ()
+ + ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
+ for (RollbackEntry entry : entries)
+ {
+ FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " "
+ + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data));
+ }
+ }
+
private List getEntriesByPlayer(String playerName)
{
playerName = playerName.toLowerCase();
diff --git a/src/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/me/totalfreedom/totalfreedommod/util/FUtil.java
index 662b1c9b..808102cd 100644
--- a/src/me/totalfreedom/totalfreedommod/util/FUtil.java
+++ b/src/me/totalfreedom/totalfreedommod/util/FUtil.java
@@ -23,7 +23,6 @@ import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -33,10 +32,9 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import me.totalfreedom.totalfreedommod.banning.FBan;
+import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.config.FConfig;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
-import me.totalfreedom.totalfreedommod.player.FPlayer;
import net.pravian.aero.util.Ips;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
@@ -46,26 +44,14 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
-import org.bukkit.SkullType;
import org.bukkit.World;
import org.bukkit.block.Block;
-import org.bukkit.block.Skull;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Boat;
import org.bukkit.entity.Creature;
-import org.bukkit.entity.EnderCrystal;
-import org.bukkit.entity.EnderSignal;
-import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
-import org.bukkit.entity.ExperienceOrb;
-import org.bukkit.entity.Explosive;
-import org.bukkit.entity.FallingBlock;
-import org.bukkit.entity.Firework;
-import org.bukkit.entity.Item;
-import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
-import org.bukkit.entity.Projectile;
import org.bukkit.plugin.Plugin;
+import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.FileUtil;
public class FUtil
@@ -122,6 +108,22 @@ public class FUtil
throw new AssertionError();
}
+ public static void cancel(BukkitTask task)
+ {
+ if (task == null)
+ {
+ return;
+ }
+
+ try
+ {
+ task.cancel();
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+
public static void bcastMsg(String message, ChatColor color)
{
FLog.info(message, true);
@@ -255,88 +257,6 @@ public class FUtil
return string.replaceAll("\\u00A7(?=[0-9a-fk-or])", "&");
}
- public static void buildHistory(Location location, int length, FPlayer playerdata)
- {
- final Block center = location.getBlock();
- for (int xOffset = -length; xOffset <= length; xOffset++)
- {
- for (int yOffset = -length; yOffset <= length; yOffset++)
- {
- for (int zOffset = -length; zOffset <= length; zOffset++)
- {
- final Block block = center.getRelative(xOffset, yOffset, zOffset);
- playerdata.insertHistoryBlock(block.getLocation(), block.getType());
- }
- }
- }
- }
-
- public static void generateCube(Location location, int length, Material material)
- {
- final Block center = location.getBlock();
- for (int xOffset = -length; xOffset <= length; xOffset++)
- {
- for (int yOffset = -length; yOffset <= length; yOffset++)
- {
- for (int zOffset = -length; zOffset <= length; zOffset++)
- {
- final Block block = center.getRelative(xOffset, yOffset, zOffset);
- if (block.getType() != material)
- {
- block.setType(material);
- }
- }
- }
- }
- }
-
- public static void generateHollowCube(Location location, int length, Material material)
- {
- final Block center = location.getBlock();
- for (int xOffset = -length; xOffset <= length; xOffset++)
- {
- for (int yOffset = -length; yOffset <= length; yOffset++)
- {
- for (int zOffset = -length; zOffset <= length; zOffset++)
- {
- // Hollow
- if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
- {
- continue;
- }
-
- final Block block = center.getRelative(xOffset, yOffset, zOffset);
-
- if (material != Material.SKULL)
- {
- // Glowstone light
- if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
- {
- block.setType(Material.GLOWSTONE);
- continue;
- }
-
- block.setType(material);
- }
- else // Darth mode
- {
- if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
- {
- block.setType(Material.GLOWSTONE);
- continue;
- }
-
- block.setType(Material.SKULL);
- final Skull skull = (Skull) block.getState();
- skull.setSkullType(SkullType.PLAYER);
- skull.setOwner("Prozza");
- skull.update();
- }
- }
- }
- }
- }
-
public static void setWorldTime(World world, long ticks)
{
long time = world.getTime();
@@ -487,7 +407,7 @@ public class FUtil
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 1 minute.");
- TotalFreedomMod.plugin.bm.addBan(FBan.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
+ TotalFreedomMod.plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
player.kickPlayer(kickMessage);
break;
@@ -500,13 +420,13 @@ public class FUtil
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 3 minutes.");
- TotalFreedomMod.plugin.bm.addBan(FBan.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
+ TotalFreedomMod.plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
player.kickPlayer(kickMessage);
break;
}
case STRIKE_THREE:
{
- TotalFreedomMod.plugin.bm.addBan(FBan.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
+ TotalFreedomMod.plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
@@ -995,84 +915,6 @@ public class FUtil
}
}
- public static class TFM_EntityWiper
- {
-
- private static final List> WIPEABLES = new ArrayList>();
-
- static
- {
- WIPEABLES.add(EnderCrystal.class);
- WIPEABLES.add(EnderSignal.class);
- WIPEABLES.add(ExperienceOrb.class);
- WIPEABLES.add(Projectile.class);
- WIPEABLES.add(FallingBlock.class);
- WIPEABLES.add(Firework.class);
- WIPEABLES.add(Item.class);
- }
-
- private TFM_EntityWiper()
- {
- throw new AssertionError();
- }
-
- private static boolean canWipe(Entity entity, boolean wipeExplosives, boolean wipeVehicles)
- {
- if (wipeExplosives)
- {
- if (Explosive.class.isAssignableFrom(entity.getClass()))
- {
- return true;
- }
- }
-
- if (wipeVehicles)
- {
- if (Boat.class.isAssignableFrom(entity.getClass()))
- {
- return true;
- }
- else if (Minecart.class.isAssignableFrom(entity.getClass()))
- {
- return true;
- }
- }
-
- Iterator> it = WIPEABLES.iterator();
- while (it.hasNext())
- {
- if (it.next().isAssignableFrom(entity.getClass()))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static int wipeEntities(boolean wipeExplosives, boolean wipeVehicles)
- {
- int removed = 0;
-
- Iterator worlds = Bukkit.getWorlds().iterator();
- while (worlds.hasNext())
- {
- Iterator entities = worlds.next().getEntities().iterator();
- while (entities.hasNext())
- {
- Entity entity = entities.next();
- if (canWipe(entity, wipeExplosives, wipeVehicles))
- {
- entity.remove();
- removed++;
- }
- }
- }
-
- return removed;
- }
- }
-
public static enum EjectMethod
{
diff --git a/src/me/totalfreedom/totalfreedommod/world/TFM_AdminWorld.java b/src/me/totalfreedom/totalfreedommod/world/AdminWorld.java
similarity index 84%
rename from src/me/totalfreedom/totalfreedommod/world/TFM_AdminWorld.java
rename to src/me/totalfreedom/totalfreedommod/world/AdminWorld.java
index 34dd35fe..a797d263 100644
--- a/src/me/totalfreedom/totalfreedommod/world/TFM_AdminWorld.java
+++ b/src/me/totalfreedom/totalfreedommod/world/AdminWorld.java
@@ -8,7 +8,6 @@ import java.util.Map;
import java.util.Map.Entry;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -21,9 +20,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.scheduler.BukkitRunnable;
-public final class TFM_AdminWorld extends TFM_CustomWorld
+public final class AdminWorld extends CustomWorld
{
private static final long CACHE_CLEAR_FREQUENCY = 30L * 1000L; //30 seconds, milliseconds
private static final long TP_COOLDOWN_TIME = 500L; //0.5 seconds, milliseconds
@@ -38,7 +36,7 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
private WorldWeather weather = WorldWeather.OFF;
private WorldTime time = WorldTime.INHERIT;
- public TFM_AdminWorld()
+ public AdminWorld()
{
super("adminworld");
}
@@ -159,32 +157,27 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
return true;
}
- if (world != null && event.getTo().getWorld() == world)
+ if (world == null || !event.getTo().getWorld().equals(world))
{
- final Player player = event.getPlayer();
- if (!canAccessWorld(player))
- {
- Long lastTP = teleportCooldown.get(player);
- long currentTimeMillis = System.currentTimeMillis();
- if (lastTP == null || lastTP.longValue() + TP_COOLDOWN_TIME <= currentTimeMillis)
- {
- teleportCooldown.put(player, currentTimeMillis);
- FLog.info(player.getName() + " attempted to access the AdminWorld.");
- new BukkitRunnable()
- {
- @Override
- public void run()
- {
- player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
- }
- }.runTaskLater(TotalFreedomMod.plugin, 1L);
- }
- event.setCancelled(true);
- return false;
- }
+ return true;
}
- return true;
+ final Player player = event.getPlayer();
+ if (canAccessWorld(player))
+ {
+ return true;
+ }
+
+ Long lastTP = teleportCooldown.get(player);
+
+ long currentTimeMillis = System.currentTimeMillis();
+ if (lastTP == null || lastTP + TP_COOLDOWN_TIME <= currentTimeMillis)
+ {
+ teleportCooldown.put(player, currentTimeMillis);
+ FLog.info(player.getName() + " attempted to access the AdminWorld.");
+ event.setTo(Bukkit.getWorlds().get(0).getSpawnLocation());
+ }
+ return false;
}
public void wipeAccessCache()
diff --git a/src/me/totalfreedom/totalfreedommod/world/TFM_CustomWorld.java b/src/me/totalfreedom/totalfreedommod/world/CustomWorld.java
similarity index 89%
rename from src/me/totalfreedom/totalfreedommod/world/TFM_CustomWorld.java
rename to src/me/totalfreedom/totalfreedommod/world/CustomWorld.java
index ea84b6b8..6c8e39cb 100644
--- a/src/me/totalfreedom/totalfreedommod/world/TFM_CustomWorld.java
+++ b/src/me/totalfreedom/totalfreedommod/world/CustomWorld.java
@@ -8,14 +8,14 @@ import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
-public abstract class TFM_CustomWorld extends PluginComponent
+public abstract class CustomWorld extends PluginComponent
{
@Getter
private final String name;
//
private World world;
- public TFM_CustomWorld(String name)
+ public CustomWorld(String name)
{
this.name = name;
}
diff --git a/src/me/totalfreedom/totalfreedommod/world/TFM_Flatlands.java b/src/me/totalfreedom/totalfreedommod/world/Flatlands.java
similarity index 97%
rename from src/me/totalfreedom/totalfreedommod/world/TFM_Flatlands.java
rename to src/me/totalfreedom/totalfreedommod/world/Flatlands.java
index 57e481b7..a1bf663f 100644
--- a/src/me/totalfreedom/totalfreedommod/world/TFM_Flatlands.java
+++ b/src/me/totalfreedom/totalfreedommod/world/Flatlands.java
@@ -14,13 +14,13 @@ import org.bukkit.WorldType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
-public class TFM_Flatlands extends TFM_CustomWorld
+public class Flatlands extends CustomWorld
{
private static final String GENERATION_PARAMETERS = ConfigEntry.FLATLANDS_GENERATE_PARAMS.getString();
;
- public TFM_Flatlands()
+ public Flatlands()
{
super("flatlands");
}
diff --git a/src/me/totalfreedom/totalfreedommod/world/TFM_WorldManager.java b/src/me/totalfreedom/totalfreedommod/world/TFM_WorldManager.java
deleted file mode 100644
index cc61ecc8..00000000
--- a/src/me/totalfreedom/totalfreedommod/world/TFM_WorldManager.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package me.totalfreedom.totalfreedommod.world;
-
-import me.totalfreedom.totalfreedommod.TotalFreedomMod;
-import net.pravian.aero.component.service.AbstractService;
-
-public class TFM_WorldManager extends AbstractService
-{
-
- public TFM_Flatlands flatlands;
- public TFM_AdminWorld adminworld;
-
- public TFM_WorldManager(TotalFreedomMod plugin)
- {
- super(plugin);
-
- this.flatlands = new TFM_Flatlands();
- }
-
- @Override
- protected void onStart()
- {
- flatlands.getWorld();
- adminworld.getWorld();
- }
-
- @Override
- protected void onStop()
- {
-
- }
-
-}
diff --git a/src/me/totalfreedom/totalfreedommod/world/WorldManager.java b/src/me/totalfreedom/totalfreedommod/world/WorldManager.java
new file mode 100644
index 00000000..47e09069
--- /dev/null
+++ b/src/me/totalfreedom/totalfreedommod/world/WorldManager.java
@@ -0,0 +1,132 @@
+package me.totalfreedom.totalfreedommod.world;
+
+import me.totalfreedom.totalfreedommod.TotalFreedomMod;
+import me.totalfreedom.totalfreedommod.config.ConfigEntry;
+import me.totalfreedom.totalfreedommod.player.FPlayer;
+import net.pravian.aero.component.service.AbstractService;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
+import org.bukkit.event.weather.ThunderChangeEvent;
+import org.bukkit.event.weather.WeatherChangeEvent;
+
+public class WorldManager extends AbstractService
+{
+
+ public Flatlands flatlands;
+ public AdminWorld adminworld;
+
+ public WorldManager(TotalFreedomMod plugin)
+ {
+ super(plugin);
+
+ this.flatlands = new Flatlands();
+ this.adminworld = new AdminWorld();
+ }
+
+ @Override
+ protected void onStart()
+ {
+ flatlands.getWorld();
+ adminworld.getWorld();
+
+ // Disable weather
+ if (ConfigEntry.DISABLE_WEATHER.getBoolean())
+ {
+ for (World world : server.getWorlds())
+ {
+ world.setThundering(false);
+ world.setStorm(false);
+ world.setThunderDuration(0);
+ world.setWeatherDuration(0);
+ }
+ }
+ }
+
+ @Override
+ protected void onStop()
+ {
+ flatlands.getWorld().save();
+ adminworld.getWorld().save();
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onPlayerTeleport(PlayerTeleportEvent event)
+ {
+ final Player player = event.getPlayer();
+ final FPlayer fPlayer = plugin.pl.getPlayer(player);
+
+ if (!plugin.al.isAdmin(player) && fPlayer.getFreezeData().isFrozen())
+ {
+ return; // Don't process adminworld validation
+ }
+
+ adminworld.validateMovement(event);
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onPlayerMove(PlayerMoveEvent event)
+ {
+ final Location from = event.getFrom();
+ final Location to = event.getTo();
+
+ try
+ {
+ if (from.getWorld() == to.getWorld() && from.distanceSquared(to) < (0.0002 * 0.0002))
+ {
+ // If player just rotated, but didn't move, don't process this event.
+ return;
+ }
+ }
+ catch (IllegalArgumentException ex)
+ {
+ }
+
+ adminworld.validateMovement(event);
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onThunderChange(ThunderChangeEvent event)
+ {
+ try
+ {
+ if (event.getWorld().equals(adminworld.getWorld()) && adminworld.getWeatherMode() != WorldWeather.OFF)
+ {
+ return;
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+
+ if (ConfigEntry.DISABLE_WEATHER.getBoolean() && event.toThunderState())
+ {
+ event.setCancelled(true);
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onWeatherChange(WeatherChangeEvent event)
+ {
+ try
+ {
+ if (event.getWorld().equals(adminworld.getWorld()) && adminworld.getWeatherMode() != WorldWeather.OFF)
+ {
+ return;
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+
+ if (ConfigEntry.DISABLE_WEATHER.getBoolean() && event.toWeatherState())
+ {
+ event.setCancelled(true);
+ }
+ }
+
+}
diff --git a/src/plugin.yml b/src/plugin.yml
index eee2726c..f0765a95 100644
--- a/src/plugin.yml
+++ b/src/plugin.yml
@@ -2,6 +2,7 @@ name: TotalFreedomMod
main: me.totalfreedom.totalfreedommod.TotalFreedomMod
version: 5.0
description: Plugin for the Total Freedom server.
+depend: [Aero]
softdepend: [BukkitTelnet, WorldEdit, Essentials]
authors: [Madgeek1450, Prozza]