Completely switched over to service-based events

This commit is contained in:
JeromSar 2015-11-16 00:32:04 +01:00
parent 848f103afa
commit 0c3bc40b03
171 changed files with 3731 additions and 3572 deletions

View File

@ -1,13 +1,4 @@
# #
# TotalFreedomMod banning config # TotalFreedomMod ban config
# Warning: modification of this file is not recommended # 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'

View File

@ -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<TotalFreedomMod>
{
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);
}
}
}

View File

@ -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<TotalFreedomMod>
{
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);
}
}
}

View File

@ -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<TotalFreedomMod>
{
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.");
}
}
}
}

View File

@ -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<TotalFreedomMod>
{
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");
}
}
}

View File

@ -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<TotalFreedomMod>
{
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());
}
}
}
}

View File

@ -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<TotalFreedomMod>
{
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);
}
}

View File

@ -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<TotalFreedomMod>
{
private static final long WIPE_RATE = 5 * 20L;
//
private final List<Class<? extends Entity>> wipables = new ArrayList<Class<? extends Entity>>();
//
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<Class<? extends Entity>> 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<World> worlds = Bukkit.getWorlds().iterator();
while (worlds.hasNext())
{
Iterator<Entity> entities = worlds.next().getEntities().iterator();
while (entities.hasNext())
{
Entity entity = entities.next();
if (canWipe(entity, wipeExplosives, wipeVehicles))
{
entity.remove();
removed++;
}
}
}
return removed;
}
}

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -12,7 +13,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import me.totalfreedom.totalfreedommod.admin.Admin; 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.Command_trail;
import me.totalfreedom.totalfreedommod.commands.FreedomCommand; import me.totalfreedom.totalfreedommod.commands.FreedomCommand;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -207,7 +208,7 @@ public class FrontDoor extends AbstractService<TotalFreedomMod>
break; 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; break;
} }
@ -416,12 +417,7 @@ public class FrontDoor extends AbstractService<TotalFreedomMod>
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true); FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
Location targetPos = player.getLocation().clone().add(0, 1, 0); Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.setCaged(true, targetPos, Material.SKULL, Material.AIR); playerdata.getCageData().cage(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);
break; break;
} }

View File

@ -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<TotalFreedomMod>
{
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;
}
}
}
}

View File

@ -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<TotalFreedomMod> 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);
}
}
}
}
}

View File

@ -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<TotalFreedomMod>
{
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);
}
}

View File

@ -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<TotalFreedomMod>
{
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
}
}
}

View File

@ -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<TotalFreedomMod>
{
// TODO: Match actual commands
public final List<String> 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);
}
}
}

View File

@ -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<TotalFreedomMod>
{
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));
}
}
}

View File

@ -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<TotalFreedomMod>
{
@Getter
private final Set<String> permbannedNames = Sets.newHashSet();
@Getter
private final Set<String> 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()
{
}
}

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FLog;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -14,10 +13,16 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.component.service.AbstractService; import net.pravian.aero.component.service.AbstractService;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; 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; import org.bukkit.util.Vector;
public class ProtectArea extends AbstractService<TotalFreedomMod> public class ProtectArea extends AbstractService<TotalFreedomMod>
@ -83,6 +88,50 @@ public class ProtectArea extends AbstractService<TotalFreedomMod>
} }
} }
@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) public boolean isInProtectedArea(final Location modifyLocation)
{ {
boolean doSave = false; boolean doSave = false;
@ -284,7 +333,7 @@ public class ProtectArea extends AbstractService<TotalFreedomMod>
} }
} }
public class SerializableProtectedRegion implements Serializable public static class SerializableProtectedRegion implements Serializable
{ {
private static final long serialVersionUID = 213123517828282L; private static final long serialVersionUID = 213123517828282L;
private final double x, y, z; private final double x, y, z;

View File

@ -1,30 +1,16 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; 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.EntityPlayer;
import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PropertyManager; import net.minecraft.server.v1_8_R3.PropertyManager;
import net.pravian.aero.component.service.AbstractService; 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<TotalFreedomMod> public class ServerInterface extends AbstractService<TotalFreedomMod>
{ {
public static final String COMPILE_NMS_VERSION = "v1_8_R3"; 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) public ServerInterface(TotalFreedomMod plugin)
{ {
@ -84,177 +70,4 @@ public class ServerInterface extends AbstractService<TotalFreedomMod>
return MinecraftServer.getServer().getVersion(); 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());
}
}
} }

View File

@ -1,18 +1,33 @@
package me.totalfreedom.totalfreedommod.listener; package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.component.PluginListener;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
public class ServerListener extends PluginListener<TotalFreedomMod> public class ServerPing extends AbstractService<TotalFreedomMod>
{ {
@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) public void onServerPing(ServerListPingEvent event)
{ {
final String ip = event.getAddress().getHostAddress().trim(); final String ip = event.getAddress().getHostAddress().trim();
@ -58,4 +73,5 @@ public class ServerListener extends PluginListener<TotalFreedomMod>
event.setMotd(FUtil.colorize(motd.toString())); event.setMotd(FUtil.colorize(motd.toString()));
} }
} }

View File

@ -1,50 +1,41 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
import me.totalfreedom.totalfreedommod.PermbanList; import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.ProtectArea; import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.ServiceChecker; import me.totalfreedom.totalfreedommod.fun.MP44;
import me.totalfreedom.totalfreedommod.ServerInterface; import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.Jumppads; import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
import me.totalfreedom.totalfreedommod.GameRuleHandler; import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
import me.totalfreedom.totalfreedommod.Heartbeat; import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.FrontDoor;
import me.totalfreedom.totalfreedommod.Announcer;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import me.totalfreedom.totalfreedommod.admin.AdminList; import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.banning.BanManager; import me.totalfreedom.totalfreedommod.banning.BanManager;
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge; import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge; import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge; 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.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.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.listener.BlockListener; import me.totalfreedom.totalfreedommod.rank.RankManager;
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.player.PlayerList; import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.rollback.RollbackManager; 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.component.service.ServiceManager;
import net.pravian.aero.plugin.AeroPlugin; import net.pravian.aero.plugin.AeroPlugin;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.mcstats.Metrics; import org.mcstats.Metrics;
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod> public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
{ {
public static final long HEARTBEAT_RATE = 5L; // Seconds
public static final long SERVICE_CHECKER_RATE = 120L; public static final long SERVICE_CHECKER_RATE = 120L;
public static final int MAX_USERNAME_LENGTH = 20; public static final int MAX_USERNAME_LENGTH = 20;
// //
@ -57,17 +48,27 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
// //
public static final BuildProperties build = new BuildProperties(); public static final BuildProperties build = new BuildProperties();
// //
@SuppressWarnings("FieldNameHidesFieldInSuperclass")
public static TotalFreedomMod plugin; public static TotalFreedomMod plugin;
public static String pluginName; public static String pluginName;
public static String pluginVersion; public static String pluginVersion;
// //
public static boolean lockdownEnabled = false; public static boolean lockdownEnabled = false;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
// //
// Services // Services
public ServiceManager<TotalFreedomMod> services; public ServiceManager<TotalFreedomMod> services;
public ServerInterface si; public ServerInterface si;
public ConsoleLogger co;
public WorldManager wm;
public AdminList al; 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 RankManager rm;
public BanManager bm; public BanManager bm;
public PlayerList pl; public PlayerList pl;
@ -79,11 +80,17 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public ServiceChecker sc; public ServiceChecker sc;
public GameRuleHandler gr; public GameRuleHandler gr;
public RollbackManager rb; public RollbackManager rb;
public Heartbeat hb;
public Jumppads jp; public Jumppads jp;
public Cager ca;
public Freezer fm;
public Fuckoff fo;
public EntityWiper ew;
public FrontDoor fd; public FrontDoor fd;
public ServerPing sp;
public ItemFun it;
public Landminer lm;
public MP44 mp;
public HTTPDaemon hd; public HTTPDaemon hd;
public TFM_WorldManager wm;
// //
// Bridges // Bridges
public ServiceManager<TotalFreedomMod> bridges; public ServiceManager<TotalFreedomMod> bridges;
@ -102,31 +109,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
FLog.setServerLogger(server.getLogger()); FLog.setServerLogger(server.getLogger());
build.load(); build.load();
services = new ServiceManager<TotalFreedomMod>(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<TotalFreedomMod>(plugin);
btb = bridges.registerService(BukkitTelnetBridge.class);
esb = bridges.registerService(EssentialsBridge.class);
web = bridges.registerService(WorldEditBridge.class);
} }
@Override @Override
@ -156,29 +138,51 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
FUtil.createBackups(SUPERADMIN_FILENAME); FUtil.createBackups(SUPERADMIN_FILENAME);
FUtil.createBackups(PERMBAN_FILENAME); FUtil.createBackups(PERMBAN_FILENAME);
// Start services and bridges // Start services and bridgess
services = new ServiceManager<TotalFreedomMod>(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(); services.start();
// Register bridges
bridges = new ServiceManager<TotalFreedomMod>(plugin);
btb = bridges.registerService(BukkitTelnetBridge.class);
esb = bridges.registerService(EssentialsBridge.class);
web = bridges.registerService(WorldEditBridge.class);
bridges.start(); 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(); timer.update();
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms"); FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");

View File

@ -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;
}
}

View File

@ -5,7 +5,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable; import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable; import net.pravian.aero.base.ConfigSavable;
@ -93,7 +93,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
cs.set("username", name); cs.set("username", name);
cs.set("active", activated); cs.set("active", activated);
cs.set("rank", rank.toString()); cs.set("rank", rank.toString());
cs.set("ips", ips); cs.set("ips", Lists.newArrayList(ips));
cs.set("last_login", lastLogin); cs.set("last_login", lastLogin);
cs.set("login_message", null); cs.set("login_message", null);
} }

View File

@ -8,18 +8,22 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import lombok.Getter; import lombok.Getter;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.commands.Command_logs; import me.totalfreedom.totalfreedommod.commands.Command_logs;
import me.totalfreedom.totalfreedommod.config.FConfig; 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.util.FLog;
import me.totalfreedom.totalfreedommod.TwitterHandler;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService; import net.pravian.aero.component.service.AbstractService;
import net.pravian.aero.util.Ips; import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; 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; import org.bukkit.plugin.ServicePriority;
public class AdminList extends AbstractService<TotalFreedomMod> public class AdminList extends AbstractService<TotalFreedomMod>
@ -68,7 +72,7 @@ public class AdminList extends AbstractService<TotalFreedomMod>
config.load(); config.load();
allAdmins.clear(); allAdmins.clear();
for (String key : config.getKeys(true)) for (String key : config.getKeys(false))
{ {
Admin admin = new Admin(key); Admin admin = new Admin(key);
admin.loadFrom(config.getConfigurationSection(key)); admin.loadFrom(config.getConfigurationSection(key));
@ -305,6 +309,29 @@ public class AdminList extends AbstractService<TotalFreedomMod>
return ipTable.keySet(); 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) public void addAdmin(OfflinePlayer player)
{ {
@ -402,7 +429,6 @@ public class AdminList extends AbstractService<TotalFreedomMod>
admin.setActivated(false); admin.setActivated(false);
Command_logs.deactivateSuperadmin(admin); Command_logs.deactivateSuperadmin(admin);
TwitterHandler.delTwitter(admin.getName());
} }
save(); save();

View File

@ -18,7 +18,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; 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"); 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 @Setter
private long expiryUnix = -1; 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, this(username,
new String[] new String[]
@ -53,7 +53,7 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
reason); 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; this.username = username;
if (ips != null) if (ips != null)
@ -66,34 +66,34 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
// //
// For player IP // 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); 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) Ips.getIp(player)
}, by.getName(), expiry, reason); }, 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 // 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); 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, (String[]) null,
by.getName(), by.getName(),
expiry, expiry,
@ -102,23 +102,23 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
// //
// For player // For player
public static FBan forPlayer(Player player, CommandSender by) public static Ban forPlayer(Player player, CommandSender by)
{ {
return forPlayerName(player, by, null, null); 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), Ips.getIp(player),
by.getName(), by.getName(),
expiry, expiry,
reason); 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)), FUtil.getFuzzyIp(Ips.getIp(player)),
by.getName(), by.getName(),
expiry, expiry,
@ -197,12 +197,12 @@ public class FBan implements ConfigLoadable, ConfigSavable, Validatable
return false; return false;
} }
if (!(object instanceof FBan)) if (!(object instanceof Ban))
{ {
return false; return false;
} }
final FBan ban = (FBan) object; final Ban ban = (Ban) object;
if (hasIps() != ban.hasIps() if (hasIps() != ban.hasIps()
|| hasUsername() != hasUsername()) || hasUsername() != hasUsername())
{ {

View File

@ -12,15 +12,22 @@ import java.util.Set;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; 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.component.service.AbstractService;
import net.pravian.aero.config.YamlConfig; import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips; 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<TotalFreedomMod> public class BanManager extends AbstractService<TotalFreedomMod>
{ {
private final Set<FBan> bans = Sets.newHashSet(); private final Set<Ban> bans = Sets.newHashSet();
private final Map<String, FBan> ipBans = Maps.newHashMap(); private final Map<String, Ban> ipBans = Maps.newHashMap();
private final Map<String, FBan> nameBans = Maps.newHashMap(); private final Map<String, Ban> nameBans = Maps.newHashMap();
private final List<String> unbannableUsernames = Lists.newArrayList(); private final List<String> unbannableUsernames = Lists.newArrayList();
// //
private final YamlConfig config; private final YamlConfig config;
@ -56,7 +63,7 @@ public class BanManager extends AbstractService<TotalFreedomMod>
continue; continue;
} }
FBan ban = new FBan(); Ban ban = new Ban();
ban.loadFrom(config.getConfigurationSection(id)); ban.loadFrom(config.getConfigurationSection(id));
if (!ban.isValid()) if (!ban.isValid())
@ -84,7 +91,7 @@ public class BanManager extends AbstractService<TotalFreedomMod>
{ {
// Remove expired bans // Remove expired bans
for (Iterator<FBan> it = bans.iterator(); it.hasNext();) for (Iterator<Ban> it = bans.iterator(); it.hasNext();)
{ {
if (it.next().isExpired()) if (it.next().isExpired())
{ {
@ -94,7 +101,7 @@ public class BanManager extends AbstractService<TotalFreedomMod>
ipBans.clear(); ipBans.clear();
nameBans.clear(); nameBans.clear();
for (FBan ban : bans) for (Ban ban : bans)
{ {
if (ban.hasUsername()) if (ban.hasUsername())
{ {
@ -116,7 +123,7 @@ public class BanManager extends AbstractService<TotalFreedomMod>
// Remove expired // Remove expired
updateViews(); updateViews();
for (FBan ban : bans) for (Ban ban : bans)
{ {
ban.saveTo(config.createSection(String.valueOf(ban.hashCode()))); ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
} }
@ -125,26 +132,26 @@ public class BanManager extends AbstractService<TotalFreedomMod>
config.save(); config.save();
} }
public Collection<FBan> getIpBans() public Collection<Ban> getIpBans()
{ {
return Collections.unmodifiableCollection(ipBans.values()); return Collections.unmodifiableCollection(ipBans.values());
} }
public Collection<FBan> getUsernameBans() public Collection<Ban> getUsernameBans()
{ {
return Collections.unmodifiableCollection(nameBans.values()); 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()) if (directBan != null && !directBan.isExpired())
{ {
return directBan; return directBan;
} }
// Match fuzzy IP // Match fuzzy IP
for (FBan loopBan : ipBans.values()) for (Ban loopBan : ipBans.values())
{ {
if (loopBan.isExpired()) if (loopBan.isExpired())
{ {
@ -168,10 +175,10 @@ public class BanManager extends AbstractService<TotalFreedomMod>
return null; return null;
} }
public FBan getByUsername(String username) public Ban getByUsername(String username)
{ {
username = username.toLowerCase(); username = username.toLowerCase();
final FBan directBan = nameBans.get(username); final Ban directBan = nameBans.get(username);
if (directBan != null && !directBan.isExpired()) if (directBan != null && !directBan.isExpired())
{ {
@ -181,9 +188,9 @@ public class BanManager extends AbstractService<TotalFreedomMod>
return null; 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) if (ban == null)
{ {
@ -195,9 +202,9 @@ public class BanManager extends AbstractService<TotalFreedomMod>
return ban; 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) if (ban == null)
{ {
@ -219,7 +226,7 @@ public class BanManager extends AbstractService<TotalFreedomMod>
return getByUsername(username) != null; return getByUsername(username) != null;
} }
public boolean addBan(FBan ban) public boolean addBan(Ban ban)
{ {
if (bans.add(ban)) if (bans.add(ban))
{ {
@ -230,7 +237,7 @@ public class BanManager extends AbstractService<TotalFreedomMod>
return false; return false;
} }
public boolean removeBan(FBan ban) public boolean removeBan(Ban ban)
{ {
if (bans.remove(ban)) if (bans.remove(ban))
{ {
@ -252,4 +259,46 @@ public class BanManager extends AbstractService<TotalFreedomMod>
nameBans.clear(); nameBans.clear();
saveAll(); 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);
}
} }

View File

@ -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<TotalFreedomMod>
{
@Getter
private final Set<String> permbannedNames = Sets.newHashSet();
@Getter
private final Set<String> 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;
}
}
}
}

View File

@ -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<TotalFreedomMod>
{
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;
}
}
}
}

View File

@ -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 me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.PluginListener; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.entity.Bat; import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; 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.Projectile;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; 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.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
public class EntityListener extends PluginListener<TotalFreedomMod> public class EventBlocker extends AbstractService<TotalFreedomMod>
{ {
public EntityListener(TotalFreedomMod plugin) public EventBlocker(TotalFreedomMod plugin)
{ {
super(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) @EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event) public void onEntityExplode(EntityExplodeEvent event)
{ {
@ -52,7 +87,7 @@ public class EntityListener extends PluginListener<TotalFreedomMod>
return; return;
} }
event.setRadius((float) ConfigEntry.EXPLOSIVE_RADIUS.getDouble().doubleValue()); event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -64,6 +99,28 @@ public class EntityListener extends PluginListener<TotalFreedomMod>
} }
} }
@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) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event) public void onEntityDamage(EntityDamageEvent event)
{ {
@ -93,97 +150,23 @@ public class EntityListener extends PluginListener<TotalFreedomMod>
} }
@EventHandler(priority = EventPriority.NORMAL) @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; return;
} }
Entity spawned = event.getEntity(); if (event.getPlayer().getWorld().getEntities().size() > 750)
if (spawned instanceof EnderDragon)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
{ {
event.setCancelled(true); 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);
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event)
{
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
event.setDroppedExp(0);
} }
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) public void onLeavesDecay(LeavesDecayEvent event)
{ {
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) event.setCancelled(true);
{
Projectile entity = event.getEntity();
if (event.getEntityType() == EntityType.ARROW)
{
entity.getWorld().createExplosion(entity.getLocation(), 2F);
}
}
} }
} }

View File

@ -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<TotalFreedomMod>
{
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;
}
}
}
}

View File

@ -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<TotalFreedomMod>
{
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);
}
}
}

View File

@ -1,4 +1,4 @@
package me.totalfreedom.totalfreedommod.commandblocker; package me.totalfreedom.totalfreedommod.blocking.command;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import java.util.List; import java.util.List;
@ -15,6 +15,9 @@ import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender; 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<TotalFreedomMod> public class CommandBlocker extends AbstractService<TotalFreedomMod>
{ {
@ -113,6 +116,17 @@ public class CommandBlocker extends AbstractService<TotalFreedomMod>
FLog.info("Loaded " + blockedCommands.size() + " blocked commands"); 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) public boolean isCommandBlocked(String command, CommandSender sender)
{ {
return isCommandBlocked(command, sender, false); return isCommandBlocked(command, sender, false);

View File

@ -1,4 +1,4 @@
package me.totalfreedom.totalfreedommod.commandblocker; package me.totalfreedom.totalfreedommod.blocking.command;
public enum CommandBlockerAction public enum CommandBlockerAction
{ {

View File

@ -1,4 +1,4 @@
package me.totalfreedom.totalfreedommod.commandblocker; package me.totalfreedom.totalfreedommod.blocking.command;
import lombok.Getter; import lombok.Getter;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;

View File

@ -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.admin.Admin;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -6,7 +6,7 @@ import me.StevenLawson.BukkitTelnet.api.TelnetCommandEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetPreLoginEvent; import me.StevenLawson.BukkitTelnet.api.TelnetPreLoginEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetRequestDataTagsEvent; import me.StevenLawson.BukkitTelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.pravian.aero.component.service.AbstractService; import net.pravian.aero.component.service.AbstractService;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -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<BlockData> cageHistory = new ArrayList<BlockData>();
//
@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;
}
}
}

View File

@ -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<TotalFreedomMod>
{
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();
}
}
}

View File

@ -1,14 +1,14 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import lombok.Getter; import lombok.Getter;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.command.handler.SimpleCommandHandler; import net.pravian.aero.command.handler.SimpleCommandHandler;
import net.pravian.aero.component.service.AbstractService; import net.pravian.aero.component.service.AbstractService;
import org.bukkit.ChatColor;
public class CommandLoader extends AbstractService<TotalFreedomMod> public class CommandLoader extends AbstractService<TotalFreedomMod>
{ {
@Getter @Getter
private final SimpleCommandHandler<TotalFreedomMod> handler; private final SimpleCommandHandler<TotalFreedomMod> handler;
@ -23,12 +23,14 @@ public class CommandLoader extends AbstractService<TotalFreedomMod>
protected void onStart() protected void onStart()
{ {
handler.clearCommands(); handler.clearCommands();
handler.setExecutorFactory(new FreedomCommandExecutor.TFM_CommandExecutorFactory()); handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory());
handler.setCommandClassPrefix("Command_"); handler.setCommandClassPrefix("Command_");
handler.loadFrom(FreedomCommand.class.getPackage()); handler.setPermissionMessage(ChatColor.YELLOW + "You do not have permission to use this command.");
handler.registerAll();
FLog.info("Loaded" + handler.getExecutors().size() + " commands"); handler.loadFrom(FreedomCommand.class.getPackage());
handler.registerAll("TotalFreedomMod", true);
FLog.info("Loaded " + handler.getExecutors().size() + " commands");
} }
@Override @Override

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import me.totalfreedom.totalfreedommod.world.WorldTime; import me.totalfreedom.totalfreedommod.world.WorldTime;
import me.totalfreedom.totalfreedommod.world.WorldWeather; import me.totalfreedom.totalfreedommod.world.WorldWeather;
@ -208,7 +208,12 @@ public class Command_adminworld extends FreedomCommand
} }
catch (PermissionDeniedException ex) catch (PermissionDeniedException ex)
{ {
if (ex.getMessage().isEmpty())
{
return noPerms();
}
sender.sendMessage(ex.getMessage()); sender.sendMessage(ex.getMessage());
return true;
} }
return true; return true;
@ -219,7 +224,7 @@ public class Command_adminworld extends FreedomCommand
{ {
if (!(sender instanceof Player) || sender_p == null || !isAdmin(sender)) 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 static final long serialVersionUID = 1L;
private PermissionDeniedException()
{
super("");
}
private PermissionDeniedException(String string) private PermissionDeniedException(String string)
{ {
super(string); super(string);

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -27,10 +27,7 @@ public class Command_cage extends FreedomCommand
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true); FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
FPlayer playerdata = plugin.pl.getPlayer(sender_p); FPlayer playerdata = plugin.pl.getPlayer(sender_p);
playerdata.setCaged(false); playerdata.getCageData().setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
return true; return true;
} }
else if ("purge".equals(args[0])) else if ("purge".equals(args[0]))
@ -40,9 +37,7 @@ public class Command_cage extends FreedomCommand
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
FPlayer playerdata = plugin.pl.getPlayer(player); FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setCaged(false); playerdata.getCageData().setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
} }
return true; return true;
@ -66,10 +61,7 @@ public class Command_cage extends FreedomCommand
if ("off".equals(args[1])) if ("off".equals(args[1]))
{ {
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true); FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
playerdata.getCageData().setCaged(false);
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
return true; return true;
} }
@ -99,12 +91,7 @@ public class Command_cage extends FreedomCommand
} }
Location targetPos = player.getLocation().clone().add(0, 1, 0); Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.setCaged(true, targetPos, outerMaterial, innerMaterial); playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
playerdata.regenerateHistory();
playerdata.clearHistory();
FUtil.buildHistory(targetPos, 2, playerdata);
FUtil.generateHollowCube(targetPos, 2, outerMaterial);
FUtil.generateCube(targetPos, 1, innerMaterial);
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Random; import java.util.Random;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Achievement; import org.bukkit.Achievement;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Minecart; import org.bukkit.entity.Minecart;

View File

@ -1,10 +1,9 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.player.FPlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -14,8 +14,8 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
@CommandPermissions(level = PlayerRank.NON_OP, source = SourceType.BOTH) @CommandPermissions(level = PlayerRank.NON_OP, source = SourceType.BOTH)
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>") @CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>", aliases = "cmdlist")
public class Command_cmdlist extends FreedomCommand public class Command_commandlist extends FreedomCommand
{ {
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -34,7 +34,7 @@ public class Command_creative extends FreedomCommand
{ {
if (!isAdmin(sender)) if (!isAdmin(sender))
{ {
sender.sendMessage(FreedomCommand.MSG_NO_PERMS); noPerms();
return true; return true;
} }

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.Random; import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;

View File

@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands; 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.admin.Admin;
import me.totalfreedom.totalfreedommod.banning.FBan; import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -53,7 +52,7 @@ public class Command_doom extends FreedomCommand
player.setOp(false); player.setOp(false);
// Ban player // Ban player
FBan ban = FBan.forPlayer(player, sender); Ban ban = Ban.forPlayer(player, sender);
ban.setReason("&cFUCKOFF"); ban.setReason("&cFUCKOFF");
for (String playerIp : plugin.pl.getData(player).getIps()) for (String playerIp : plugin.pl.getData(player).getIps())
{ {

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.FLog;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -10,113 +10,81 @@ import org.bukkit.inventory.ItemStack;
@CommandPermissions(level = PlayerRank.OP, source = SourceType.ONLY_IN_GAME) @CommandPermissions(level = PlayerRank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> | remove <name>>") @CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> | remove <name>>")
public class Command_enchant extends FreedomCommand public class Command_enchant extends FreedomCommand {
{
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
{ if (args.length < 1) {
if (args.length < 1)
{
return false; return false;
} }
ItemStack itemInHand = sender_p.getItemInHand(); ItemStack itemInHand = sender_p.getItemInHand();
if (itemInHand == null) if (itemInHand == null) {
{
playerMsg("You are holding an invalid item."); playerMsg("You are holding an invalid item.");
return true; return true;
} }
if (args[0].equalsIgnoreCase("list")) if (args[0].equalsIgnoreCase("list")) {
{
boolean has_enchantments = false; boolean has_enchantments = false;
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: "); StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
for (Enchantment ench : Enchantment.values()) for (Enchantment ench : Enchantment.values()) {
{ if (ench.canEnchantItem(itemInHand)) {
if (ench.canEnchantItem(itemInHand))
{
has_enchantments = true; has_enchantments = true;
possible_ench.append(ench.getName()).append(", "); possible_ench.append(ench.getName()).append(", ");
} }
} }
if (has_enchantments) if (has_enchantments) {
{
playerMsg(possible_ench.toString()); playerMsg(possible_ench.toString());
} } else {
else
{
playerMsg("The held item has no enchantments."); playerMsg("The held item has no enchantments.");
} }
} } else if (args[0].equalsIgnoreCase("addall")) {
else if (args[0].equalsIgnoreCase("addall")) for (Enchantment ench : Enchantment.values()) {
{ try {
for (Enchantment ench : Enchantment.values()) if (ench.canEnchantItem(itemInHand)) {
{
try
{
if (ench.canEnchantItem(itemInHand))
{
itemInHand.addEnchantment(ench, ench.getMaxLevel()); 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() + "."); FLog.info("Error using " + ench.getName() + " on " + itemInHand.getType().name() + " held by " + sender_p.getName() + ".");
} }
} }
playerMsg("Added all possible enchantments for this item."); playerMsg("Added all possible enchantments for this item.");
} } else if (args[0].equalsIgnoreCase("reset")) {
else if (args[0].equalsIgnoreCase("reset")) for (Enchantment ench : itemInHand.getEnchantments().keySet()) {
{
for (Enchantment ench : itemInHand.getEnchantments().keySet())
{
itemInHand.removeEnchantment(ench); itemInHand.removeEnchantment(ench);
} }
playerMsg("Removed all enchantments."); playerMsg("Removed all enchantments.");
} } else {
else if (args.length < 2) {
{
if (args.length < 2)
{
return false; return false;
} }
Enchantment ench = null; Enchantment ench = null;
try try {
{
ench = Enchantment.getByName(args[1]); 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."); playerMsg(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
return true; return true;
} }
if (args[0].equalsIgnoreCase("add")) if (args[0].equalsIgnoreCase("add")) {
{ if (ench.canEnchantItem(itemInHand)) {
if (ench.canEnchantItem(itemInHand))
{
itemInHand.addEnchantment(ench, ench.getMaxLevel()); itemInHand.addEnchantment(ench, ench.getMaxLevel());
playerMsg("Added enchantment: " + ench.getName()); playerMsg("Added enchantment: " + ench.getName());
} } else {
else
{
playerMsg("Can't use this enchantment on held item."); playerMsg("Can't use this enchantment on held item.");
} }
} } else if (args[0].equals("remove")) {
else if (args[0].equals("remove"))
{
itemInHand.removeEnchantment(ench); itemInHand.removeEnchantment(ench);
playerMsg("Removed enchantment: " + ench.getName()); playerMsg("Removed enchantment: " + ench.getName());

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; 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.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,10 +1,8 @@
package me.totalfreedom.totalfreedommod.commands; 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 me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -14,46 +12,42 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]") @CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
public class Command_fr extends FreedomCommand public class Command_fr extends FreedomCommand
{ {
private static boolean allFrozen = false;
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
if (args.length == 0) 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); FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
playerMsg("Players are now free to move.");
return true;
}
setAllFrozen(true); FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
playerMsg("Players are now frozen."); playerMsg("Players are now unfrozen.");
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!isAdmin(player)) if (!isAdmin(player))
{ {
playerMsg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED); playerMsg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
} }
} }
return true;
} }
else
if (args[0].equals("purge"))
{ {
FUtil.adminAction(sender.getName(), "Unfreezing all players", false); FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
setAllFrozen(false); plugin.fm.purge();
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]); final Player player = getPlayer(args[0]);
if (player == null) if (player == null)
@ -62,23 +56,12 @@ public class Command_fr extends FreedomCommand
return true; return true;
} }
final FPlayer playerdata = plugin.pl.getPlayer(player); final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
playerdata.setFrozen(!playerdata.isFrozen()); fd.setFrozen(!fd.isFrozen());
playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); playerMsg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(player, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA); playerMsg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
}
}
return true; return true;
} }
public static void setAllFrozen(boolean freeze)
{
allFrozen = freeze;
for (FPlayer data : TotalFreedomMod.plugin.pl.playerMap.values())
{
data.setFrozen(freeze);
}
}
} }

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,36 +19,31 @@ public class Command_fuckoff extends FreedomCommand
return false; return false;
} }
boolean fuckoff_enabled = false; FPlayer player = plugin.pl.getPlayer(sender_p);
double fuckoff_range = 25.0;
if (args[0].equalsIgnoreCase("on")) if (!args[0].equals("on"))
{
player.disableFuckoff();
}
else
{ {
fuckoff_enabled = true;
double radius = 25.0;
if (args.length >= 2) if (args.length >= 2)
{ {
try 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) catch (NumberFormatException ex)
{ {
} }
} }
player.setFuckoff(radius);
} }
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(sender_p)) playerMsg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
{
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."));
return true; return true;
} }

View File

@ -1,11 +1,11 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import me.totalfreedom.totalfreedommod.banning.FBan; import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -126,7 +126,7 @@ public class Command_gadmin extends FreedomCommand
case NAMEBAN: case NAMEBAN:
{ {
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s.", target.getName()), true); 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."); target.kickPlayer("Username banned by Administrator.");
break; break;
@ -140,7 +140,7 @@ public class Command_gadmin extends FreedomCommand
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]); ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
} }
FUtil.adminAction(sender.getName(), String.format("Banning IP: %s.", ip), true); 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."); 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); 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."); target.kickPlayer("IP and username banned by Administrator.");
@ -186,11 +186,11 @@ public class Command_gadmin extends FreedomCommand
} }
case FR: case FR:
{ {
FPlayer playerdata = plugin.pl.getPlayer(target); FreezeData fd = plugin.pl.getPlayer(target).getFreezeData();
playerdata.setFrozen(!playerdata.isFrozen()); fd.setFrozen(!fd.isFrozen());
playerMsg(target.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); playerMsg(target.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
target.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); target.sendMessage(ChatColor.AQUA + "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
break; break;
} }

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,9 +1,9 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FUtil; 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()); 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) for (String ip : ips)
{ {
ban.addIp(ip); ban.addIp(ip);
@ -96,7 +96,7 @@ public class Command_glist extends FreedomCommand
plugin.bm.removeBan(plugin.bm.getByUsername(username)); plugin.bm.removeBan(plugin.bm.getByUsername(username));
for (String ip : ips) for (String ip : ips)
{ {
FBan ban = plugin.bm.getByIp(ip); Ban ban = plugin.bm.getByIp(ip);
if (ban != null) if (ban != null)
{ {
plugin.bm.removeBan(ban); plugin.bm.removeBan(ban);

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.banning.FBan; import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips; import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@ -89,7 +89,7 @@ public class Command_gtfo extends FreedomCommand
FUtil.bcastMsg(bcast.toString()); FUtil.bcastMsg(bcast.toString());
// Ban player // Ban player
plugin.bm.addBan(FBan.forPlayerFuzzy(player, sender, null, reason)); plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason));
// Kick player // Kick player
player.kickPlayer(ChatColor.RED + "GTFO"); player.kickPlayer(ChatColor.RED + "GTFO");

View File

@ -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 = "/<command> <<partialname> | 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;
}
}
}

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;

View File

@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.Jumppads; import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,12 +1,10 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import me.totalfreedom.totalfreedommod.fun.Landminer.Landmine;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -37,9 +35,9 @@ public class Command_landmine extends FreedomCommand
if (args.length >= 1) if (args.length >= 1)
{ {
if ("list".equalsIgnoreCase(args[0])) if ("list".equals(args[0]))
{ {
final Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator(); final Iterator<Landmine> landmines = plugin.lm.getLandmines().iterator();
while (landmines.hasNext()) while (landmines.hasNext())
{ {
playerMsg(landmines.next().toString()); playerMsg(landmines.next().toString());
@ -58,31 +56,11 @@ public class Command_landmine extends FreedomCommand
final Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN); final Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN);
landmine.setType(Material.TNT); 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); playerMsg("Landmine planted - Radius = " + radius + " blocks.", ChatColor.GREEN);
return true; return true;
} }
public static class TFM_LandmineData
{
public static final List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
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();
}
}
} }

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.player.FPlayer;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.GameRuleHandler; import me.totalfreedom.totalfreedommod.GameRuleHandler;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -9,70 +9,47 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE) @CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Control mob rezzing parameters.", usage = "/<command> <on|off|setmax <count>|dragon|giant|ghast|slime>") @CommandParameters(description = "Control mob rezzing parameters.", usage = "/<command> <on|off|setmax <count>|dragon|giant|ghast|slime>")
public class Command_moblimiter extends FreedomCommand public class Command_moblimiter extends FreedomCommand {
{
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
{ if (args.length < 1) {
if (args.length < 1)
{
return false; return false;
} }
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on")) {
{
ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true); ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true);
} } else if (args[0].equalsIgnoreCase("off")) {
else if (args[0].equalsIgnoreCase("off"))
{
ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(false); 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()); 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()); 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()); 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()); ConfigEntry.MOB_LIMITER_DISABLE_GHAST.setBoolean(!ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean());
} } else {
else if (args.length < 2) {
{
if (args.length < 2)
{
return false; return false;
} }
if (args[0].equalsIgnoreCase("setmax")) if (args[0].equalsIgnoreCase("setmax")) {
{ try {
try
{
ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1])))); 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() + "."); sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
playerMsg("Dragon: " + (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + "."); playerMsg("Dragon: " + (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Giant: " + (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + "."); playerMsg("Giant: " + (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Slime: " + (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean() ? "disabled" : "enabled") + "."); playerMsg("Slime: " + (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Ghast: " + (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.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."); playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
} }

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -14,8 +14,8 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command>") @CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command>", aliases = "mp")
public class Command_mp extends FreedomCommand public class Command_mobpurge extends FreedomCommand
{ {
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.commands;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,12 +1,11 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.commandblocker.CommandBlocker;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -15,8 +14,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = PlayerRank.OP, source = SourceType.BOTH) @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 = "/<command> <other_command> !<playernick>") @CommandParameters(description = "NickFilter: Prefix any command with this command to replace nicknames in that command with real names. Nicknames should be prefixed with a !.",
public class Command_nf extends FreedomCommand usage = "/<command> <other_command> !<playernick>",
aliases = "nf")
public class Command_nickfilter extends FreedomCommand
{ {
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -26,7 +26,7 @@ public class Command_onlinemode extends FreedomCommand
if (sender instanceof Player && !plugin.al.isSeniorAdmin(sender)) if (sender instanceof Player && !plugin.al.isSeniorAdmin(sender))
{ {
playerMsg(FreedomCommand.MSG_NO_PERMS); noPerms();
return true; return true;
} }

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -44,7 +43,7 @@ public class Command_ops extends FreedomCommand
{ {
if (!plugin.al.isAdmin(sender)) if (!plugin.al.isAdmin(sender))
{ {
playerMsg(FreedomCommand.MSG_NO_PERMS); noPerms();
return true; return true;
} }

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -5,7 +5,7 @@ import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.MainConfig; 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 net.pravian.aero.util.Ips;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; 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.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -40,7 +39,7 @@ public class Command_potion extends FreedomCommand
{ {
if (!(plugin.al.isAdmin(sender) || senderIsConsole)) if (!(plugin.al.isAdmin(sender) || senderIsConsole))
{ {
playerMsg(FreedomCommand.MSG_NO_PERMS); noPerms();
return true; return true;
} }
FUtil.adminAction(sender.getName(), "Cleared all potion effects from all players", true); FUtil.adminAction(sender.getName(), "Cleared all potion effects from all players", true);

View File

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.commands; package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.permission.PlayerRank; import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.ProtectArea; import me.totalfreedom.totalfreedommod.ProtectArea;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;

Some files were not shown because too many files have changed in this diff Show More