Fixing marco's mistakes (#8)

This commit is contained in:
Nathan Curran 2017-12-23 15:07:36 +11:00 committed by Lemon
parent a67fe49c98
commit b931cce3bb
24 changed files with 415 additions and 308 deletions

View File

@ -54,7 +54,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount(); final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled()) if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).isChestMonitorEnabled())
{ {
FUtil.playerMsg(player, p.getName() + " Moved in a chest with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player, p.getName() + " Moved in a chest with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }
@ -68,7 +68,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount(); final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled()) if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).isChestMonitorEnabled())
{ {
FUtil.playerMsg(player, p2.getName() + " Moved in a dispenser with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player, p2.getName() + " Moved in a dispenser with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }
@ -83,7 +83,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount(); final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled()) if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).isChestMonitorEnabled())
{ {
FUtil.playerMsg(player, p2.getName() + " Moved in a hopper with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player, p2.getName() + " Moved in a hopper with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }
@ -98,7 +98,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount(); final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled()) if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).isChestMonitorEnabled())
{ {
FUtil.playerMsg(player, p2.getName() + " Moved in a dropper with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player, p2.getName() + " Moved in a dropper with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }
@ -114,7 +114,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount(); final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled()) if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).isChestMonitorEnabled())
{ {
FUtil.playerMsg(player, p2.getName() + " Moved in a shulker box with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player, p2.getName() + " Moved in a shulker box with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }
@ -130,7 +130,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount(); final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled()) if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).isChestMonitorEnabled())
{ {
FUtil.playerMsg(player, p2.getName() + " Moved in a ender chest with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player, p2.getName() + " Moved in a ender chest with " + amount + " " + this.GetMaterial(item) + " [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }

View File

@ -46,7 +46,7 @@ public class DropMonitor extends FreedomService
final Location loc = event.getPlayer().getLocation(); final Location loc = event.getPlayer().getLocation();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).DropMonitorEnabled()) if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).isDropMonitorEnabled())
{ {
FUtil.playerMsg(player, event.getPlayer().getName() + " dropped " + event.getItemDrop().getItemStack().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player, event.getPlayer().getName() + " dropped " + event.getItemDrop().getItemStack().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }

View File

@ -30,7 +30,7 @@ public class EditBlocker extends FreedomService
public void BlockPlaceEvent(BlockPlaceEvent event) public void BlockPlaceEvent(BlockPlaceEvent event)
{ {
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer()); FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
if (!fPlayer.isEditBlock()) if (!fPlayer.isEditBlocked())
{ {
return; return;
} }
@ -49,7 +49,7 @@ public class EditBlocker extends FreedomService
public void BlockBreakEvent(BlockBreakEvent event) public void BlockBreakEvent(BlockBreakEvent event)
{ {
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer()); FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
if (!fPlayer.isEditBlock()) if (!fPlayer.isEditBlocked())
{ {
return; return;
} }
@ -64,4 +64,4 @@ public class EditBlocker extends FreedomService
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -1,7 +1,9 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
@ -11,10 +13,8 @@ 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.Ban; import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.command.Command_trail;
import me.totalfreedom.totalfreedommod.command.FreedomCommand; import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.fun.Jumppads; import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
@ -110,7 +110,6 @@ public class FrontDoor extends FreedomService
} }
dispatcher.runCommand(player, command, commandName, args); dispatcher.runCommand(player, command, commandName, args);
return;
} }
}; };
@ -201,7 +200,7 @@ public class FrontDoor extends FreedomService
} }
} }
} }
catch (Exception ex) catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
{ {
FLog.severe(ex); FLog.severe(ex);
} }
@ -214,7 +213,7 @@ public class FrontDoor extends FreedomService
{ {
((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null)).unregister(registeredListener); ((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null)).unregister(registeredListener);
} }
catch (Exception ex) catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
{ {
FLog.severe(ex); FLog.severe(ex);
} }
@ -239,9 +238,11 @@ public class FrontDoor extends FreedomService
try try
{ {
final URLConnection urlConnection = getUrl.openConnection(); final URLConnection urlConnection = getUrl.openConnection();
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); final String line;
final String line = in.readLine(); try (BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
in.close(); {
line = in.readLine();
}
if (!"false".equals(line)) if (!"false".equals(line))
{ {
@ -288,7 +289,7 @@ public class FrontDoor extends FreedomService
enabled = true; enabled = true;
} }
} }
catch (Exception ex) catch (IOException | IllegalArgumentException | IllegalStateException ex)
{ {
// TODO: Fix // TODO: Fix
//FLog.warning(ex); //FLog.warning(ex);

View File

@ -58,13 +58,11 @@ public class PotionMonitorer extends FreedomService
for (Player player2 : server.getOnlinePlayers()) for (Player player2 : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player2) && plugin.pl.getPlayer(player2).PotionMonitorEnabled()) if (plugin.al.isAdmin(player2) && plugin.pl.getPlayer(player2).isPotionMonitorEnabled())
{ {
FUtil.playerMsg(player2, player.getName() + " Splashed " + event.getEntity().getItem().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player2, player.getName() + " Splashed " + event.getEntity().getItem().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }
} }
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
@ -87,12 +85,10 @@ public class PotionMonitorer extends FreedomService
for (Player player2 : server.getOnlinePlayers()) for (Player player2 : server.getOnlinePlayers())
{ {
if (plugin.al.isAdmin(player2) && plugin.pl.getPlayer(player2).PotionMonitorEnabled()) if (plugin.al.isAdmin(player2) && plugin.pl.getPlayer(player2).isPotionMonitorEnabled())
{ {
FUtil.playerMsg(player2, player.getName() + " Splashed " + event.getPotion().getItem().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'."); FUtil.playerMsg(player2, player.getName() + " Splashed " + event.getPotion().getItem().getAmount() + " " + this.GetMaterial(dropeditem) + " at [" + this.df.format(loc.getX()) + ", " + this.df.format(loc.getY()) + ", " + this.df.format(loc.getZ()) + "] at the world '" + loc.getWorld().getName() + "'.");
} }
} }
} }
} }

View File

@ -48,14 +48,14 @@ public class PvPBlocker extends FreedomService
} }
} }
if (fPlayer == null || !fPlayer.isPVPBlock()) if (fPlayer == null || !fPlayer.isPvpBlocked())
{ {
return; return;
} }
if (plugin.al.isAdminSync(event.getDamager())) if (plugin.al.isAdminSync(event.getDamager()))
{ {
fPlayer.setPVPBlock(false); fPlayer.setPvpBlocked(false);
return; return;
} }
@ -64,4 +64,4 @@ public class PvPBlocker extends FreedomService
FSync.playerMsg(player, ChatColor.RED + "You have been disallowed from PvPing!"); FSync.playerMsg(player, ChatColor.RED + "You have been disallowed from PvPing!");
} }
} }

View File

@ -1,7 +1,14 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.util.Arrays;
import java.util.List;
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 net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_12_R1.PropertyManager;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
public class ServerInterface extends FreedomService public class ServerInterface extends FreedomService
{ {
@ -34,52 +41,52 @@ public class ServerInterface extends FreedomService
} }
} }
// public void setOnlineMode(boolean mode) public void setOnlineMode(boolean mode)
// { {
// final PropertyManager manager = getServer().getPropertyManager(); final PropertyManager manager = getServer().getPropertyManager();
// manager.setProperty("online-mode", mode); manager.setProperty("online-mode", mode);
// manager.savePropertiesFile(); manager.savePropertiesFile();
// } }
//
// public int purgeWhitelist() public int purgeWhitelist()
// { {
// String[] whitelisted = getServer().getPlayerList().getWhitelisted(); String[] whitelisted = getServer().getPlayerList().getWhitelisted();
// int size = whitelisted.length; int size = whitelisted.length;
// for (EntityPlayer player : getServer().getPlayerList().players) for (EntityPlayer player : getServer().getPlayerList().players)
// { {
// getServer().getPlayerList().getWhitelist().remove(player.getProfile()); getServer().getPlayerList().getWhitelist().remove(player.getProfile());
// } }
//
// try try
// { {
// getServer().getPlayerList().getWhitelist().save(); getServer().getPlayerList().getWhitelist().save();
// } }
// catch (Exception ex) catch (Exception ex)
// { {
// FLog.warning("Could not purge the whitelist!"); FLog.warning("Could not purge the whitelist!");
// FLog.warning(ex); FLog.warning(ex);
// } }
// return size; return size;
// } }
//
// public boolean isWhitelisted() public boolean isWhitelisted()
// { {
// return getServer().getPlayerList().getHasWhitelist(); return getServer().getPlayerList().getHasWhitelist();
// } }
//
// public List<?> getWhitelisted() public List<?> getWhitelisted()
// { {
// return Arrays.asList(getServer().getPlayerList().getWhitelisted()); return Arrays.asList(getServer().getPlayerList().getWhitelisted());
// } }
//
// public String getVersion() public String getVersion()
// { {
// return getServer().getVersion(); return getServer().getVersion();
// } }
//
// private MinecraftServer getServer() private MinecraftServer getServer()
// { {
// return ((CraftServer) Bukkit.getServer()).getServer(); return ((CraftServer) Bukkit.getServer()).getServer();
// } }
} }

View File

@ -1,5 +1,3 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -27,165 +25,216 @@ import me.totalfreedom.totalfreedommod.FreedomService;
public class EssentialsBridge extends FreedomService public class EssentialsBridge extends FreedomService
{ {
private Essentials essentialsPlugin; private Essentials essentialsPlugin;
public EssentialsBridge(final TotalFreedomMod plugin) { public EssentialsBridge(final TotalFreedomMod plugin)
{
super(plugin); super(plugin);
this.essentialsPlugin = null; this.essentialsPlugin = null;
} }
protected void onStart() { @Override
protected void onStart()
{
} }
protected void onStop() { @Override
protected void onStop()
{
Command_vanish.vanished.clear(); Command_vanish.vanished.clear();
} }
public Essentials getEssentialsPlugin() { public Essentials getEssentialsPlugin()
if (this.essentialsPlugin == null) { {
try { if (this.essentialsPlugin == null)
{
try
{
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials"); final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
if (essentials != null && essentials instanceof Essentials) { if (essentials != null && essentials instanceof Essentials)
this.essentialsPlugin = (Essentials)essentials; {
this.essentialsPlugin = (Essentials) essentials;
} }
} }
catch (Exception ex) { catch (Exception ex)
{
FLog.severe(ex); FLog.severe(ex);
} }
} }
return this.essentialsPlugin; return this.essentialsPlugin;
} }
public User getEssentialsUser(final String username) { public User getEssentialsUser(final String username)
try { {
try
{
final Essentials essentials = this.getEssentialsPlugin(); final Essentials essentials = this.getEssentialsPlugin();
if (essentials != null) { if (essentials != null)
{
return essentials.getUserMap().getUser(username); return essentials.getUserMap().getUser(username);
} }
} }
catch (Exception ex) { catch (Exception ex)
{
FLog.severe(ex); FLog.severe(ex);
} }
return null; return null;
} }
public void setNickname(final String username, final String nickname) { public void setNickname(final String username, final String nickname)
try { {
try
{
final User user = this.getEssentialsUser(username); final User user = this.getEssentialsUser(username);
if (user != null) { if (user != null)
{
user.setNickname(nickname); user.setNickname(nickname);
user.setDisplayNick(); user.setDisplayNick();
} }
} }
catch (Exception ex) { catch (Exception ex)
{
FLog.severe(ex); FLog.severe(ex);
} }
} }
public String getNickname(final String username) { public String getNickname(final String username)
try { {
try
{
final User user = this.getEssentialsUser(username); final User user = this.getEssentialsUser(username);
if (user != null) { if (user != null)
{
return user.getNickname(); return user.getNickname();
} }
} }
catch (Exception ex) { catch (Exception ex)
{
FLog.severe(ex); FLog.severe(ex);
} }
return null; return null;
} }
public long getLastActivity(final String username) { public long getLastActivity(final String username)
try { {
try
{
final User user = this.getEssentialsUser(username); final User user = this.getEssentialsUser(username);
if (user != null) { if (user != null)
{
return FUtil.getField(user, "lastActivity"); return FUtil.getField(user, "lastActivity");
} }
} }
catch (Exception ex) { catch (Exception ex)
{
FLog.severe(ex); FLog.severe(ex);
} }
return 0L; return 0L;
} }
public void setVanished(final String username, final boolean vanished) { public void setVanished(final String username, final boolean vanished)
try { {
try
{
final User user = this.getEssentialsUser(username); final User user = this.getEssentialsUser(username);
if (user != null) { if (user != null)
{
user.setVanished(vanished); user.setVanished(vanished);
} }
} }
catch (Exception ex) { catch (Exception ex)
{
FLog.severe(ex); FLog.severe(ex);
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onInventoryClickEvent(final InventoryClickEvent event) { public void onInventoryClickEvent(final InventoryClickEvent event)
{
Player refreshPlayer = null; Player refreshPlayer = null;
final Inventory top = event.getView().getTopInventory(); final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType(); final InventoryType type = top.getType();
final Player playerdata = (Player)event.getWhoClicked(); final Player playerdata = (Player) event.getWhoClicked();
final FPlayer fPlayer = ((TotalFreedomMod)this.plugin).pl.getPlayer(playerdata); final FPlayer fPlayer = ((TotalFreedomMod) this.plugin).pl.getPlayer(playerdata);
if (type == InventoryType.PLAYER && fPlayer.isInvsee()) { if (type == InventoryType.PLAYER && fPlayer.isInvSee())
{
final InventoryHolder invHolder = top.getHolder(); final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity) { if (invHolder != null && invHolder instanceof HumanEntity)
final Player invOwner = (Player)invHolder; {
final Rank recieverRank = ((TotalFreedomMod)this.plugin).rm.getRank(playerdata); final Player invOwner = (Player) invHolder;
final Rank playerRank = ((TotalFreedomMod)this.plugin).rm.getRank(invOwner); final Rank recieverRank = ((TotalFreedomMod) this.plugin).rm.getRank(playerdata);
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline()) { final Rank playerRank = ((TotalFreedomMod) this.plugin).rm.getRank(invOwner);
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline())
{
event.setCancelled(true); event.setCancelled(true);
refreshPlayer = playerdata; refreshPlayer = playerdata;
} }
} }
} }
if (refreshPlayer != null) { if (refreshPlayer != null)
{
final Player player = refreshPlayer; final Player player = refreshPlayer;
new BukkitRunnable() { new BukkitRunnable()
public void run() { {
@Override
public void run()
{
player.updateInventory(); player.updateInventory();
} }
}.runTaskLater((Plugin)this.plugin, 20L); }.runTaskLater((Plugin) this.plugin, 20L);
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onInventoryCloseEvent(final InventoryCloseEvent event) { public void onInventoryCloseEvent(final InventoryCloseEvent event)
{
Player refreshPlayer = null; Player refreshPlayer = null;
final Inventory top = event.getView().getTopInventory(); final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType(); final InventoryType type = top.getType();
final Player playerdata = (Player)event.getPlayer(); final Player playerdata = (Player) event.getPlayer();
final FPlayer fPlayer = ((TotalFreedomMod)this.plugin).pl.getPlayer(playerdata); final FPlayer fPlayer = ((TotalFreedomMod) this.plugin).pl.getPlayer(playerdata);
if (type == InventoryType.PLAYER && fPlayer.isInvsee()) { if (type == InventoryType.PLAYER && fPlayer.isInvSee())
fPlayer.setInvsee(false); {
fPlayer.setInvSee(false);
refreshPlayer = playerdata; refreshPlayer = playerdata;
} }
if (refreshPlayer != null) { if (refreshPlayer != null)
{
final Player player = refreshPlayer; final Player player = refreshPlayer;
new BukkitRunnable() { new BukkitRunnable()
public void run() { {
@Override
public void run()
{
player.updateInventory(); player.updateInventory();
} }
}.runTaskLater((Plugin)this.plugin, 20L); }.runTaskLater((Plugin) this.plugin, 20L);
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuitEvent(final PlayerQuitEvent event) { public void onPlayerQuitEvent(final PlayerQuitEvent event)
{
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (Command_vanish.vanished.contains(player)) { if (Command_vanish.vanished.contains(player))
{
Command_vanish.vanished.remove(player); Command_vanish.vanished.remove(player);
} }
} }
public boolean isEssentialsEnabled() { public boolean isEssentialsEnabled()
try { {
try
{
final Essentials essentials = this.getEssentialsPlugin(); final Essentials essentials = this.getEssentialsPlugin();
if (essentials != null) { if (essentials != null)
{
return essentials.isEnabled(); return essentials.isEnabled();
} }
} }
catch (Exception ex) { catch (Exception ex)
{
FLog.severe(ex); FLog.severe(ex);
} }
return false; return false;

View File

@ -1,14 +1,10 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import java.util.Iterator;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -18,91 +14,120 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandParameters(description = "Blocks all block placing for player with brute force.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "editmute") @CommandParameters(description = "Blocks all block placing for player with brute force.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "editmute")
public class Command_blockedit extends FreedomCommand public class Command_blockedit extends FreedomCommand
{ {
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole) {
if (args.length == 0) { @Override
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
{
if (args.length == 0)
{
return false; return false;
} }
if (args[0].equals("list")) {
this.msg("Block edits blocked for players:"); if (args[0].equals("list"))
{
msg("Block edits blocked for players:");
int count = 0; int count = 0;
for (final Player mp : this.server.getOnlinePlayers()) { for (Player mp : server.getOnlinePlayers())
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); {
if (info.isEditBlock()) { final FPlayer info = plugin.pl.getPlayer(mp);
this.msg("- " + mp.getName()); if (info.isEditBlocked())
{
msg("- " + mp.getName());
++count; ++count;
} }
} }
if (count == 0) {
this.msg("- none"); if (count == 0)
{
msg("- none");
} }
return true; return true;
} }
if (args[0].equals("purge")) {
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Unblocking block edits for all players.", true); FUtil.adminAction(sender.getName(), "Unblocking block edits for all players.", true);
int count = 0; int count = 0;
for (final Player mp : this.server.getOnlinePlayers()) { for (final Player mp : this.server.getOnlinePlayers())
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); {
if (info.isEditBlock()) { final FPlayer info = plugin.pl.getPlayer(mp);
if (info.isEditBlocked())
{
info.setEditBlocked(false); info.setEditBlocked(false);
++count; ++count;
} }
} }
this.msg("Unblocked all block edit for " + count + " players."); msg("Unblocked all block edit for " + count + " players.");
return true; return true;
} }
if (args[0].equals("all")) {
if (args[0].equals("all"))
{
FUtil.adminAction(sender.getName(), "Blocking block edits for all non-admins.", true); FUtil.adminAction(sender.getName(), "Blocking block edits for all non-admins.", true);
int counter = 0; int counter = 0;
for (final Player player : this.server.getOnlinePlayers()) { for (final Player player : this.server.getOnlinePlayers())
if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) { {
final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(player); if (!plugin.al.isAdmin((CommandSender) player))
{
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setEditBlocked(true); playerdata.setEditBlocked(true);
++counter; ++counter;
} }
} }
this.msg("Blocked block edits for " + counter + " players.");
msg("Blocked block edits for " + counter + " players.");
return true; return true;
} }
final boolean smite = args[0].equals("-s"); final boolean smite = args[0].equals("-s");
if (smite) { if (smite)
args = (String[])ArrayUtils.subarray((Object[])args, 1, args.length); {
if (args.length < 1) { args = (String[]) ArrayUtils.subarray((Object[]) args, 1, args.length);
if (args.length < 1)
{
return false; return false;
} }
} }
final Player player2 = this.getPlayer(args[0]);
if (player2 == null) { final Player player2 = getPlayer(args[0]);
if (player2 == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true; return true;
} }
String reason = null; String reason = null;
if (args.length > 1) { if (args.length > 1)
reason = StringUtils.join((Object[])args, " ", 1, args.length); {
reason = StringUtils.join((Object[]) args, " ", 1, args.length);
} }
final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2);
if (playerdata2.isEditBlock()) { final FPlayer playerdata2 = plugin.pl.getPlayer(player2);
if (playerdata2.isEditBlocked())
{
FUtil.adminAction(sender.getName(), "Unblocking block edits for " + player2.getName(), true); FUtil.adminAction(sender.getName(), "Unblocking block edits for " + player2.getName(), true);
playerdata2.setEditBlocked(false); playerdata2.setEditBlocked(false);
this.msg("Unblocking block edits for " + player2.getName()); msg("Unblocking block edits for " + player2.getName());
this.msg((CommandSender)player2, "Your block edits have been unblocked.", ChatColor.RED); msg(player2, "Your block edits have been unblocked.", ChatColor.RED);
} }
else { else
if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) { {
this.msg(player2.getName() + " is an admin, and cannot have their block edits blocked."); if (plugin.al.isAdmin((CommandSender) player2))
{
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
return true; return true;
} }
FUtil.adminAction(sender.getName(), "Blocking block edits for " + player2.getName(), true); FUtil.adminAction(sender.getName(), "Blocking block edits for " + player2.getName(), true);
playerdata2.setEditBlocked(true); playerdata2.setEditBlocked(true);
if (smite) {
Command_smite.smite(player2, sender); if (smite)
{
Command_smite.smite(sender, player2, reason);
} }
if (reason != null) {
this.msg((CommandSender)player2, "Your block edits have been blocked. Reason: " + reason, ChatColor.RED); msg(player2, "Your block edits have been blocked.", ChatColor.RED);
} msg("Blocked all block edits for " + player2.getName());
else {
this.msg((CommandSender)player2, "Your block edits have been blocked.", ChatColor.RED);
}
this.msg("Blocked all block edits for " + player2.getName());
} }
return true; return true;
} }

View File

@ -1,14 +1,10 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import java.util.Iterator;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -18,91 +14,120 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandParameters(description = "Toggle PVP mode for players.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode,pvpman,pvman") @CommandParameters(description = "Toggle PVP mode for players.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode,pvpman,pvman")
public class Command_blockpvp extends FreedomCommand public class Command_blockpvp extends FreedomCommand
{ {
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole) {
if (args.length == 0) { @Override
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
{
if (args.length == 0)
{
return false; return false;
} }
if (args[0].equals("list")) {
if (args[0].equals("list"))
{
this.msg("PVP is blocked for players:"); this.msg("PVP is blocked for players:");
int count = 0; int count = 0;
for (final Player mp : this.server.getOnlinePlayers()) { for (Player mp : server.getOnlinePlayers())
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); {
if (info.isPVPBlock()) { final FPlayer info = plugin.pl.getPlayer(mp);
this.msg("- " + mp.getName()); if (info.isPvpBlocked())
{
msg(" - " + mp.getName());
++count; ++count;
} }
} }
if (count == 0) {
this.msg("- none"); if (count == 0)
{
this.msg(" - none");
} }
return true; return true;
} }
if (args[0].equals("purge")) {
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true); FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
int count = 0; int count = 0;
for (final Player mp : this.server.getOnlinePlayers()) { for (Player mp : this.server.getOnlinePlayers())
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp); {
if (info.isPVPBlock()) { final FPlayer info = plugin.pl.getPlayer(mp);
info.setPVPBlock(false); if (info.isPvpBlocked())
{
info.setPvpBlocked(false);
++count; ++count;
} }
} }
this.msg("Enabled PVP for " + count + " players.");
msg("Enabled PVP for " + count + " players.");
return true; return true;
} }
if (args[0].equals("all")) {
if (args[0].equals("all"))
{
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true); FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
int counter = 0; int counter = 0;
for (final Player player : this.server.getOnlinePlayers()) { for (Player player : server.getOnlinePlayers())
if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) { {
final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(player); if (!plugin.al.isAdmin((CommandSender) player))
playerdata.setPVPBlock(true); {
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setPvpBlocked(true);
++counter; ++counter;
} }
} }
this.msg("Disabling PVP for " + counter + " players.");
msg("Disabling PVP for " + counter + " players.");
return true; return true;
} }
final boolean smite = args[0].equals("-s"); final boolean smite = args[0].equals("-s");
if (smite) { if (smite)
args = (String[])ArrayUtils.subarray((Object[])args, 1, args.length); {
if (args.length < 1) { args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1)
{
return false; return false;
} }
} }
final Player player2 = this.getPlayer(args[0]);
if (player2 == null) { final Player player2 = getPlayer(args[0]);
if (player2 == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true; return true;
} }
String reason = null; String reason = null;
if (args.length > 1) { if (args.length > 1)
reason = StringUtils.join((Object[])args, " ", 1, args.length); {
reason = StringUtils.join(args, " ", 1, args.length);
} }
final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2);
if (playerdata2.isPVPBlock()) { final FPlayer playerdata2 = plugin.pl.getPlayer(player2);
if (playerdata2.isPvpBlocked())
{
FUtil.adminAction(sender.getName(), "Enabling PVP for " + player2.getName(), true); FUtil.adminAction(sender.getName(), "Enabling PVP for " + player2.getName(), true);
playerdata2.setPVPBlock(false); playerdata2.setPvpBlocked(false);
this.msg("Enabling PVP for " + player2.getName()); msg("Enabling PVP for " + player2.getName());
this.msg((CommandSender)player2, "Your PVP have been enabled.", ChatColor.GREEN); msg((CommandSender) player2, "Your PVP have been enabled.", ChatColor.GREEN);
} }
else { else
if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) { {
if (plugin.al.isAdmin((CommandSender) player2))
{
this.msg(player2.getName() + " is an admin, and his PVP cannot be disabled."); this.msg(player2.getName() + " is an admin, and his PVP cannot be disabled.");
return true; return true;
} }
FUtil.adminAction(sender.getName(), "Disabling PVP for " + player2.getName(), true); FUtil.adminAction(sender.getName(), "Disabling PVP for " + player2.getName(), true);
playerdata2.setPVPBlock(true); playerdata2.setPvpBlocked(true);
if (smite) { if (smite)
Command_smite.smite(player2, sender); {
Command_smite.smite(sender, player2, reason);
} }
if (reason != null) {
this.msg((CommandSender)player2, "Your PVP has been disabled. Reason: " + reason, ChatColor.RED); msg(player2, "Your PVP has been disabled.", ChatColor.RED);
} msg("Disabled PVP for " + player2.getName());
else {
this.msg((CommandSender)player2, "Your PVP has been disabled.", ChatColor.RED);
}
this.msg("Disabled PVP for " + player2.getName());
} }
return true; return true;
} }

View File

@ -1,10 +1,6 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.Achievement;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.Material; import org.bukkit.Material;
@ -12,37 +8,39 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.Random;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>") @CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
public class Command_cake extends FreedomCommand public class Command_cake extends FreedomCommand
{ {
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake."; public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
private final Random random;
@Override
public Command_cake() { public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
this.random = new Random(); {
}
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) {
final StringBuilder output = new StringBuilder(); final StringBuilder output = new StringBuilder();
final String[] split;
final String[] words = split = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.".split(" "); for (final String word : CAKE_LYRICS.split(" "))
for (final String word : split) { {
output.append(FUtil.rainbowChatColor()).append(word).append(" "); output.append(FUtil.randomChatColor()).append(word).append(" ");
} }
final ItemStack heldItem = new ItemStack(Material.CAKE); final ItemStack heldItem = new ItemStack(Material.CAKE);
final ItemMeta heldItemMeta = heldItem.getItemMeta(); final ItemMeta heldItemMeta = heldItem.getItemMeta();
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie"); heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
heldItem.setItemMeta(heldItemMeta); heldItem.setItemMeta(heldItemMeta);
for (final Player player : this.server.getOnlinePlayers()) {
for (final Player player : this.server.getOnlinePlayers())
{
final int firstEmpty = player.getInventory().firstEmpty(); final int firstEmpty = player.getInventory().firstEmpty();
if (firstEmpty >= 0) { if (firstEmpty >= 0)
{
player.getInventory().setItem(firstEmpty, heldItem); player.getInventory().setItem(firstEmpty, heldItem);
} }
} }
FUtil.bcastMsg(output.toString()); FUtil.bcastMsg(output.toString());
return true; return true;
} }

View File

@ -16,9 +16,8 @@ public class Command_chestspy extends FreedomCommand
{ {
FPlayer playerdata = plugin.pl.getPlayer(playerSender); FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.setChestMonitor(!playerdata.ChestMonitorEnabled()); playerdata.setChestMonitorEnabled(!playerdata.isChestMonitorEnabled());
msg("ChestSpy " + (playerdata.ChestMonitorEnabled()? "enabled." : "disabled.")); msg("ChestSpy " + (playerdata.isChestMonitorEnabled() ? "enabled." : "disabled."));
return true; return true;
} }
} }

View File

@ -16,9 +16,8 @@ public class Command_dropspy extends FreedomCommand
{ {
FPlayer playerdata = plugin.pl.getPlayer(playerSender); FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.setDropMonitor(!playerdata.DropMonitorEnabled()); playerdata.setDropMonitorEnabled(!playerdata.isDropMonitorEnabled());
msg("DropSpy " + (playerdata.DropMonitorEnabled() ? "enabled." : "disabled.")); msg("DropSpy " + (playerdata.isDropMonitorEnabled() ? "enabled." : "disabled."));
return true; return true;
} }
} }

View File

@ -198,7 +198,7 @@ public class Command_gadmin extends FreedomCommand
} }
case SMITE: case SMITE:
{ {
Command_smite.smite(target, sender); Command_smite.smite(sender, target);
break; break;
} }

View File

@ -40,12 +40,11 @@ public class Command_invsee extends FreedomCommand
{ {
msg("You can't spy on admins!"); msg("You can't spy on admins!");
return true; return true;
} }
playerSender.closeInventory(); playerSender.closeInventory();
FPlayer fPlayer = plugin.pl.getPlayer(playerSender); FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
fPlayer.setInvsee(true); fPlayer.setInvSee(true);
Inventory playerInv = player.getInventory(); Inventory playerInv = player.getInventory();
playerSender.openInventory(playerInv); playerSender.openInventory(playerInv);
return true; return true;

View File

@ -1,7 +1,9 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
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.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -15,15 +17,9 @@ import org.bukkit.entity.Player;
public class Command_nickclean extends FreedomCommand public class Command_nickclean extends FreedomCommand
{ {
private static final ChatColor[] BLOCKED = new ChatColor[] private static final String[] BLOCK = ConfigEntry.BLOCKED_CHATCODES.getString().split(",");
{
ChatColor.MAGIC, private static final Pattern REGEX = Pattern.compile(FUtil.colorize(ChatColor.COLOR_CHAR + "[" + StringUtils.join(BLOCK, "") + "]"), Pattern.CASE_INSENSITIVE);
ChatColor.STRIKETHROUGH,
ChatColor.ITALIC,
ChatColor.UNDERLINE,
ChatColor.BLACK
};
private static final Pattern REGEX = Pattern.compile(ChatColor.COLOR_CHAR + "[" + StringUtils.join(BLOCKED, "") + "]", Pattern.CASE_INSENSITIVE);
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)

View File

@ -16,9 +16,8 @@ public class Command_potionspy extends FreedomCommand
{ {
FPlayer playerdata = plugin.pl.getPlayer(playerSender); FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.setPotionMonitor(!playerdata.PotionMonitorEnabled()); playerdata.setPotionMonitorEnabled(!playerdata.isPotionMonitorEnabled());
msg("PotionSpy " + (playerdata.PotionMonitorEnabled() ? "enabled." : "disabled.")); msg("PotionSpy " + (playerdata.isPotionMonitorEnabled() ? "enabled." : "disabled."));
return true; return true;
} }
} }

View File

@ -38,23 +38,24 @@ public class Command_smite extends FreedomCommand
return true; return true;
} }
smite(player, reason); smite(sender, player, reason);
return true; return true;
} }
public static void smite(Player player) public static void smite(CommandSender sender, Player player)
{ {
smite(player, null); smite(sender, player, null);
} }
public static void smite(Player player, String reason) public static void smite(CommandSender sender, Player player, String reason)
{ {
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED); FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
if (reason != null) if (reason != null)
{ {
FUtil.bcastMsg(" Reason: " + reason, ChatColor.YELLOW); FUtil.bcastMsg(" Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
} }
FUtil.bcastMsg(" Smited by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
// Deop // Deop
player.setOp(false); player.setOp(false);

View File

@ -130,18 +130,10 @@ public class Command_stfu extends FreedomCommand
if (smite) if (smite)
{ {
Command_smite.smite(player); Command_smite.smite(sender, player, reason);
}
if (reason != null)
{
msg(player, "You have been muted. Reason: " + reason, ChatColor.RED);
}
else
{
msg(player, "You have been muted.", ChatColor.RED);
} }
msg(player, "You have been muted.", ChatColor.RED);
msg("Muted " + player.getName()); msg("Muted " + player.getName());
} }

View File

@ -6,13 +6,13 @@ 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;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true) @CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes essentials warps", usage = "/<command>") @CommandParameters(description = "Removes essentials warps", usage = "/<command>")
public class Command_wipewarps extends FreedomCommand public class Command_wipewarps extends FreedomCommand
{ {
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
@ -21,6 +21,7 @@ public class Command_wipewarps extends FreedomCommand
msg("Essentials is not enabled on this server"); msg("Essentials is not enabled on this server");
return true; return true;
} }
Plugin essentials = server.getPluginManager().getPlugin("Essentials"); Plugin essentials = server.getPluginManager().getPlugin("Essentials");
FUtil.adminAction(sender.getName(), "Wiping Essentials Warps", true); FUtil.adminAction(sender.getName(), "Wiping Essentials Warps", true);
server.getPluginManager().disablePlugin(essentials); server.getPluginManager().disablePlugin(essentials);
@ -28,6 +29,5 @@ public class Command_wipewarps extends FreedomCommand
server.getPluginManager().enablePlugin(essentials); server.getPluginManager().enablePlugin(essentials);
msg("All warps deleted."); msg("All warps deleted.");
return true; return true;
} }
} }

View File

@ -22,6 +22,8 @@ public enum ConfigEntry
ALLOW_FIREWORK_EXPLOSION(Boolean.class, "allow.fireworks"), ALLOW_FIREWORK_EXPLOSION(Boolean.class, "allow.fireworks"),
ALLOW_FROSTWALKER(Boolean.class, "allow.frostwalker"), ALLOW_FROSTWALKER(Boolean.class, "allow.frostwalker"),
// //
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
//
MOB_LIMITER_ENABLED(Boolean.class, "moblimiter.enabled"), MOB_LIMITER_ENABLED(Boolean.class, "moblimiter.enabled"),
MOB_LIMITER_MAX(Integer.class, "moblimiter.max"), MOB_LIMITER_MAX(Integer.class, "moblimiter.max"),
MOB_LIMITER_DISABLE_DRAGON(Boolean.class, "moblimiter.disable.dragon"), MOB_LIMITER_DISABLE_DRAGON(Boolean.class, "moblimiter.disable.dragon"),
@ -185,4 +187,4 @@ public enum ConfigEntry
} }
return null; return null;
} }
} }

View File

@ -66,6 +66,24 @@ public class FPlayer
private boolean cmdspyEnabled = false; private boolean cmdspyEnabled = false;
private String tag = null; private String tag = null;
private int warningCount = 0; private int warningCount = 0;
@Getter
@Setter
private boolean dropMonitorEnabled = false;
@Getter
@Setter
private boolean potionMonitorEnabled = false;
@Getter
@Setter
private boolean editBlocked = false;
@Getter
@Setter
private boolean pvpBlocked = false;
@Getter
@Setter
private boolean chestMonitorEnabled = false;
@Getter
@Setter
private boolean invSee = false;
public FPlayer(TotalFreedomMod plugin, Player player) public FPlayer(TotalFreedomMod plugin, Player player)
{ {

View File

@ -37,7 +37,7 @@ public class FUtil
// //
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat"; public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
// See https://github.com/TotalFreedom/License - None of the listed names may be removed. // See https://github.com/TotalFreedom/License - None of the listed names may be removed.
public static final DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "aggelosQQ", "OxLemonxO", "Commodore64x", "Wild1145", "marcocorriero"); public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "aggelosQQ", "OxLemonxO", "Commodore64x", "Wild1145");
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>(); public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList( public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
@ -370,14 +370,14 @@ public class FUtil
{ {
return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size())); return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size()));
} }
public static String rainbowify(String string) public static String rainbowify(String string)
{ {
CHAT_COLOR_ITERATOR = CHAT_COLOR_POOL.iterator(); CHAT_COLOR_ITERATOR = CHAT_COLOR_POOL.iterator();
final StringBuilder newString = new StringBuilder(); final StringBuilder newString = new StringBuilder();
final char[] chars = string.toCharArray(); final char[] chars = string.toCharArray();
for (char c : chars) for (char c : chars)
{ {
if (!CHAT_COLOR_ITERATOR.hasNext()) if (!CHAT_COLOR_ITERATOR.hasNext())
@ -386,7 +386,7 @@ public class FUtil
} }
newString.append(CHAT_COLOR_ITERATOR.next()).append(c); newString.append(CHAT_COLOR_ITERATOR.next()).append(c);
} }
return newString.toString(); return newString.toString();
} }
@ -420,5 +420,4 @@ public class FUtil
String packageName = Bukkit.getServer().getClass().getPackage().getName(); String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1); return packageName.substring(packageName.lastIndexOf('.') + 1);
} }
}
}

View File

@ -335,4 +335,6 @@ overlord_ips:
- 107.191.101.27 - 107.191.101.27
- 178.62.117.94 - 178.62.117.94
- 141.101.104.243 - 141.101.104.243
# Blocked Chat Codes - Use &code,&code2,&code3 (No spaces)
blocked_chatcodes: '&0,&k,&m,&n'