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();
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() + "'.");
}
@ -68,7 +68,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount();
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() + "'.");
}
@ -83,7 +83,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount();
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() + "'.");
}
@ -98,7 +98,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount();
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() + "'.");
}
@ -114,7 +114,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount();
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() + "'.");
}
@ -130,7 +130,7 @@ public class ChestMonitor extends FreedomService
final int amount = event.getCurrentItem().getAmount();
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() + "'.");
}

View File

@ -46,7 +46,7 @@ public class DropMonitor extends FreedomService
final Location loc = event.getPlayer().getLocation();
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() + "'.");
}

View File

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

View File

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

View File

@ -58,13 +58,11 @@ public class PotionMonitorer extends FreedomService
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() + "'.");
}
}
}
@EventHandler(priority = EventPriority.LOW)
@ -87,12 +85,10 @@ public class PotionMonitorer extends FreedomService
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() + "'.");
}
}
}
}

View File

@ -48,14 +48,14 @@ public class PvPBlocker extends FreedomService
}
}
if (fPlayer == null || !fPlayer.isPVPBlock())
if (fPlayer == null || !fPlayer.isPvpBlocked())
{
return;
}
if (plugin.al.isAdminSync(event.getDamager()))
{
fPlayer.setPVPBlock(false);
fPlayer.setPvpBlocked(false);
return;
}

View File

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

View File

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

View File

@ -1,14 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
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")
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;
}
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;
for (final Player mp : this.server.getOnlinePlayers()) {
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp);
if (info.isEditBlock()) {
this.msg("- " + mp.getName());
for (Player mp : server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
if (info.isEditBlocked())
{
msg("- " + mp.getName());
++count;
}
}
if (count == 0) {
this.msg("- none");
if (count == 0)
{
msg("- none");
}
return true;
}
if (args[0].equals("purge")) {
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Unblocking block edits for all players.", true);
int count = 0;
for (final Player mp : this.server.getOnlinePlayers()) {
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp);
if (info.isEditBlock()) {
for (final Player mp : this.server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
if (info.isEditBlocked())
{
info.setEditBlocked(false);
++count;
}
}
this.msg("Unblocked all block edit for " + count + " players.");
msg("Unblocked all block edit for " + count + " players.");
return true;
}
if (args[0].equals("all")) {
if (args[0].equals("all"))
{
FUtil.adminAction(sender.getName(), "Blocking block edits for all non-admins.", true);
int counter = 0;
for (final Player player : this.server.getOnlinePlayers()) {
if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) {
final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(player);
for (final Player player : this.server.getOnlinePlayers())
{
if (!plugin.al.isAdmin((CommandSender) player))
{
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setEditBlocked(true);
++counter;
}
}
this.msg("Blocked block edits for " + counter + " players.");
msg("Blocked block edits for " + counter + " players.");
return true;
}
final boolean smite = args[0].equals("-s");
if (smite) {
args = (String[])ArrayUtils.subarray((Object[])args, 1, args.length);
if (args.length < 1) {
if (smite)
{
args = (String[]) ArrayUtils.subarray((Object[]) args, 1, args.length);
if (args.length < 1)
{
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);
return true;
}
String reason = null;
if (args.length > 1) {
reason = StringUtils.join((Object[])args, " ", 1, args.length);
if (args.length > 1)
{
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);
playerdata2.setEditBlocked(false);
this.msg("Unblocking block edits for " + player2.getName());
this.msg((CommandSender)player2, "Your block edits have been unblocked.", ChatColor.RED);
msg("Unblocking block edits for " + player2.getName());
msg(player2, "Your block edits have been unblocked.", ChatColor.RED);
}
else {
if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) {
this.msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
else
{
if (plugin.al.isAdmin((CommandSender) player2))
{
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
return true;
}
FUtil.adminAction(sender.getName(), "Blocking block edits for " + player2.getName(), 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);
}
else {
this.msg((CommandSender)player2, "Your block edits have been blocked.", ChatColor.RED);
}
this.msg("Blocked all block edits for " + player2.getName());
msg(player2, "Your block edits have been blocked.", ChatColor.RED);
msg("Blocked all block edits for " + player2.getName());
}
return true;
}

View File

@ -1,14 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
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")
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;
}
if (args[0].equals("list")) {
if (args[0].equals("list"))
{
this.msg("PVP is blocked for players:");
int count = 0;
for (final Player mp : this.server.getOnlinePlayers()) {
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp);
if (info.isPVPBlock()) {
this.msg("- " + mp.getName());
for (Player mp : server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
if (info.isPvpBlocked())
{
msg(" - " + mp.getName());
++count;
}
}
if (count == 0) {
this.msg("- none");
if (count == 0)
{
this.msg(" - none");
}
return true;
}
if (args[0].equals("purge")) {
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
int count = 0;
for (final Player mp : this.server.getOnlinePlayers()) {
final FPlayer info = ((TotalFreedomMod)this.plugin).pl.getPlayer(mp);
if (info.isPVPBlock()) {
info.setPVPBlock(false);
for (Player mp : this.server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
if (info.isPvpBlocked())
{
info.setPvpBlocked(false);
++count;
}
}
this.msg("Enabled PVP for " + count + " players.");
msg("Enabled PVP for " + count + " players.");
return true;
}
if (args[0].equals("all")) {
if (args[0].equals("all"))
{
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
int counter = 0;
for (final Player player : this.server.getOnlinePlayers()) {
if (!((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player)) {
final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(player);
playerdata.setPVPBlock(true);
for (Player player : server.getOnlinePlayers())
{
if (!plugin.al.isAdmin((CommandSender) player))
{
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setPvpBlocked(true);
++counter;
}
}
this.msg("Disabling PVP for " + counter + " players.");
msg("Disabling PVP for " + counter + " players.");
return true;
}
final boolean smite = args[0].equals("-s");
if (smite) {
args = (String[])ArrayUtils.subarray((Object[])args, 1, args.length);
if (args.length < 1) {
if (smite)
{
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1)
{
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);
return true;
}
String reason = null;
if (args.length > 1) {
reason = StringUtils.join((Object[])args, " ", 1, args.length);
if (args.length > 1)
{
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);
playerdata2.setPVPBlock(false);
this.msg("Enabling PVP for " + player2.getName());
this.msg((CommandSender)player2, "Your PVP have been enabled.", ChatColor.GREEN);
playerdata2.setPvpBlocked(false);
msg("Enabling PVP for " + player2.getName());
msg((CommandSender) player2, "Your PVP have been enabled.", ChatColor.GREEN);
}
else {
if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) {
else
{
if (plugin.al.isAdmin((CommandSender) player2))
{
this.msg(player2.getName() + " is an admin, and his PVP cannot be disabled.");
return true;
}
FUtil.adminAction(sender.getName(), "Disabling PVP for " + player2.getName(), true);
playerdata2.setPVPBlock(true);
if (smite) {
Command_smite.smite(player2, sender);
playerdata2.setPvpBlocked(true);
if (smite)
{
Command_smite.smite(sender, player2, reason);
}
if (reason != null) {
this.msg((CommandSender)player2, "Your PVP has been disabled. Reason: " + reason, ChatColor.RED);
}
else {
this.msg((CommandSender)player2, "Your PVP has been disabled.", ChatColor.RED);
}
this.msg("Disabled PVP for " + player2.getName());
msg(player2, "Your PVP has been disabled.", ChatColor.RED);
msg("Disabled PVP for " + player2.getName());
}
return true;
}

View File

@ -1,10 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.Achievement;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
@ -12,37 +8,39 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender;
import java.util.Random;
import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
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.";
private final Random random;
public Command_cake() {
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) {
@Override
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 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 : split) {
output.append(FUtil.rainbowChatColor()).append(word).append(" ");
for (final String word : CAKE_LYRICS.split(" "))
{
output.append(FUtil.randomChatColor()).append(word).append(" ");
}
final ItemStack heldItem = new ItemStack(Material.CAKE);
final ItemMeta heldItemMeta = heldItem.getItemMeta();
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
heldItem.setItemMeta(heldItemMeta);
for (final Player player : this.server.getOnlinePlayers()) {
for (final Player player : this.server.getOnlinePlayers())
{
final int firstEmpty = player.getInventory().firstEmpty();
if (firstEmpty >= 0) {
if (firstEmpty >= 0)
{
player.getInventory().setItem(firstEmpty, heldItem);
}
}
FUtil.bcastMsg(output.toString());
return true;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
@ -15,15 +17,9 @@ import org.bukkit.entity.Player;
public class Command_nickclean extends FreedomCommand
{
private static final ChatColor[] BLOCKED = new ChatColor[]
{
ChatColor.MAGIC,
ChatColor.STRIKETHROUGH,
ChatColor.ITALIC,
ChatColor.UNDERLINE,
ChatColor.BLACK
};
private static final Pattern REGEX = Pattern.compile(ChatColor.COLOR_CHAR + "[" + StringUtils.join(BLOCKED, "") + "]", Pattern.CASE_INSENSITIVE);
private static final String[] BLOCK = ConfigEntry.BLOCKED_CHATCODES.getString().split(",");
private static final Pattern REGEX = Pattern.compile(FUtil.colorize(ChatColor.COLOR_CHAR + "[" + StringUtils.join(BLOCK, "") + "]"), Pattern.CASE_INSENSITIVE);
@Override
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);
playerdata.setPotionMonitor(!playerdata.PotionMonitorEnabled());
msg("PotionSpy " + (playerdata.PotionMonitorEnabled() ? "enabled." : "disabled."));
playerdata.setPotionMonitorEnabled(!playerdata.isPotionMonitorEnabled());
msg("PotionSpy " + (playerdata.isPotionMonitorEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -38,23 +38,24 @@ public class Command_smite extends FreedomCommand
return true;
}
smite(player, reason);
smite(sender, player, reason);
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);
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
player.setOp(false);

View File

@ -130,18 +130,10 @@ public class Command_stfu extends FreedomCommand
if (smite)
{
Command_smite.smite(player);
}
if (reason != null)
{
msg(player, "You have been muted. Reason: " + reason, ChatColor.RED);
}
else
{
msg(player, "You have been muted.", ChatColor.RED);
Command_smite.smite(sender, player, reason);
}
msg(player, "You have been muted.", ChatColor.RED);
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.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes essentials warps", usage = "/<command>")
public class Command_wipewarps extends FreedomCommand
{
@Override
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");
return true;
}
Plugin essentials = server.getPluginManager().getPlugin("Essentials");
FUtil.adminAction(sender.getName(), "Wiping Essentials Warps", true);
server.getPluginManager().disablePlugin(essentials);
@ -28,6 +29,5 @@ public class Command_wipewarps extends FreedomCommand
server.getPluginManager().enablePlugin(essentials);
msg("All warps deleted.");
return true;
}
}

View File

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

View File

@ -66,6 +66,24 @@ public class FPlayer
private boolean cmdspyEnabled = false;
private String tag = null;
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)
{

View File

@ -37,7 +37,7 @@ public class FUtil
//
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
// 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 final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
@ -420,5 +420,4 @@ public class FUtil
String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1);
}
}

View File

@ -336,3 +336,5 @@ overlord_ips:
- 178.62.117.94
- 141.101.104.243
# Blocked Chat Codes - Use &code,&code2,&code3 (No spaces)
blocked_chatcodes: '&0,&k,&m,&n'