1. Remove marco from dev
2. Add namehistory
3. Fix grammar issues
4. Actually use CoreProtect bridge to rollback players
5.  Improve automatic wiper
This commit is contained in:
Lemon 2017-10-13 23:35:11 +05:00 committed by GitHub
parent 3c09bc7995
commit ed2f15cc54
38 changed files with 1562 additions and 461 deletions

View File

@ -114,4 +114,4 @@ public class AntiSpam extends FreedomService
} }
} }
} }

View File

@ -0,0 +1,142 @@
package me.totalfreedom.totalfreedommod;
import org.bukkit.event.EventPriority;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import java.text.DecimalFormat;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
public class ChestMonitor extends FreedomService
{
DecimalFormat df;
public ChestMonitor(TotalFreedomMod plugin)
{
super(plugin);
this.df = new DecimalFormat("#");
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public String GetMaterial(final int id)
{
return String.valueOf(Material.getMaterial(id));
}
@EventHandler(priority = EventPriority.LOW)
public final void onChestMove(final InventoryClickEvent event)
{
if (plugin.al.isAdmin(event.getWhoClicked()))
{
return;
}
final Inventory top = event.getView().getTopInventory();
final Inventory bottom = event.getView().getBottomInventory();
if (top.getType() == InventoryType.CHEST && bottom.getType() == InventoryType.PLAYER && event.getCurrentItem() != null && event.getCurrentItem().getTypeId() != 0)
{
final Player p = (Player) event.getWhoClicked();
final Location loc = p.getLocation();
final int item = event.getCurrentItem().getTypeId();
final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled())
{
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() + "'.");
}
}
}
if (top.getType() == InventoryType.DISPENSER && bottom.getType() == InventoryType.PLAYER && event.getCurrentItem() != null && event.getCurrentItem().getTypeId() != 0)
{
final Player p2 = (Player) event.getWhoClicked();
final Location loc = p2.getLocation();
final int item = event.getCurrentItem().getTypeId();
final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled())
{
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() + "'.");
}
}
}
if (top.getType() == InventoryType.HOPPER && bottom.getType() == InventoryType.PLAYER && event.getCurrentItem() != null && event.getCurrentItem().getTypeId() != 0)
{
final Player p2 = (Player) event.getWhoClicked();
final Location loc = p2.getLocation();
final int item = event.getCurrentItem().getTypeId();
final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled())
{
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() + "'.");
}
}
}
if (top.getType() == InventoryType.DROPPER && bottom.getType() == InventoryType.PLAYER && event.getCurrentItem() != null && event.getCurrentItem().getTypeId() != 0)
{
final Player p2 = (Player) event.getWhoClicked();
final Location loc = p2.getLocation();
final int item = event.getCurrentItem().getTypeId();
final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled())
{
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() + "'.");
}
}
}
if (top.getType() == InventoryType.SHULKER_BOX && bottom.getType() == InventoryType.PLAYER && event.getCurrentItem() != null && event.getCurrentItem().getTypeId() != 0)
{
final Player p2 = (Player) event.getWhoClicked();
final Location loc = p2.getLocation();
final int item = event.getCurrentItem().getTypeId();
final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled())
{
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() + "'.");
}
}
}
if (top.getType() == InventoryType.ENDER_CHEST && bottom.getType() == InventoryType.PLAYER && event.getCurrentItem() != null && event.getCurrentItem().getTypeId() != 0)
{
final Player p2 = (Player) event.getWhoClicked();
final Location loc = p2.getLocation();
final int item = event.getCurrentItem().getTypeId();
final int amount = event.getCurrentItem().getAmount();
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).ChestMonitorEnabled())
{
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

@ -12,6 +12,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable; import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable; import net.pravian.aero.base.ConfigSavable;
import net.pravian.aero.base.Validatable; import net.pravian.aero.base.Validatable;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips; import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
@ -40,6 +41,8 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
@Setter @Setter
private String loginMessage = null; private String loginMessage = null;
public static final String CONFIG_FILENAME = "admins.yml";
public Admin(Player player) public Admin(Player player)
{ {
this.configKey = player.getName().toLowerCase(); this.configKey = player.getName().toLowerCase();
@ -126,6 +129,11 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
} }
} }
public String getLoginMessage()
{
return this.loginMessage;
}
public void removeIp(String ip) public void removeIp(String ip)
{ {
if (ips.contains(ip)) if (ips.contains(ip))
@ -168,4 +176,54 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
&& !ips.isEmpty() && !ips.isEmpty()
&& lastLogin != null; && lastLogin != null;
} }
public boolean isActive()
{
return this.active;
}
public String getConfigKey()
{
return this.configKey;
}
public String getName()
{
return this.name;
}
public void setName(final String name)
{
this.name = name;
}
public Rank getRank()
{
return this.rank;
}
public void setRank(final Rank rank)
{
this.rank = rank;
}
public List<String> getIps()
{
return this.ips;
}
public Date getLastLogin()
{
return this.lastLogin;
}
public void setLastLogin(final Date lastLogin)
{
this.lastLogin = lastLogin;
}
public void setLoginMessage(final String loginMessage)
{
this.loginMessage = loginMessage;
}
} }

View File

@ -130,6 +130,16 @@ public class AdminList extends FreedomService
return admin != null && admin.isActive(); return admin != null && admin.isActive();
} }
public Map<String, Admin> getAllAdmins()
{
return this.allAdmins;
}
public Set<Admin> getActiveAdmins()
{
return this.activeAdmins;
}
public boolean isSeniorAdmin(CommandSender sender) public boolean isSeniorAdmin(CommandSender sender)
{ {
Admin admin = getAdmin(sender); Admin admin = getAdmin(sender);

View File

@ -156,6 +156,51 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
return expiryUnix > 0; return expiryUnix > 0;
} }
public String getUsername()
{
return this.username;
}
public void setUsername(final String username)
{
this.username = username;
}
public List<String> getIps()
{
return this.ips;
}
public String getBy()
{
return this.by;
}
public void setBy(final String by)
{
this.by = by;
}
public String getReason()
{
return this.reason;
}
public void setReason(final String reason)
{
this.reason = reason;
}
public long getExpiryUnix()
{
return this.expiryUnix;
}
public void setExpiryUnix(final long expiryUnix)
{
this.expiryUnix = expiryUnix;
}
public Date getExpiryDate() public Date getExpiryDate()
{ {
return FUtil.getUnixDate(expiryUnix); return FUtil.getUnixDate(expiryUnix);

View File

@ -30,6 +30,8 @@ public class BanManager extends FreedomService
private final Map<String, Ban> ipBans = Maps.newHashMap(); private final Map<String, Ban> ipBans = Maps.newHashMap();
private final Map<String, Ban> nameBans = Maps.newHashMap(); private final Map<String, Ban> nameBans = Maps.newHashMap();
private final List<String> unbannableUsernames = Lists.newArrayList(); private final List<String> unbannableUsernames = Lists.newArrayList();
public static final String CONFIG_FILENAME = "bans.yml";
// //
private final YamlConfig config; private final YamlConfig config;

View File

@ -87,4 +87,13 @@ public class PermbanList extends FreedomService
} }
public Set<String> getPermbannedNames()
{
return this.permbannedNames;
}
public Set<String> getPermbannedIps()
{
return this.permbannedIps;
}
} }

View File

@ -44,14 +44,11 @@ public class BlockBlocker extends FreedomService
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{ {
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation()))); FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
} }
else else
{ {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled."); player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
@ -62,8 +59,6 @@ public class BlockBlocker extends FreedomService
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{ {
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation()))); FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
} }
else else
{ {
@ -79,14 +74,11 @@ public class BlockBlocker extends FreedomService
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean()) if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{ {
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation()))); FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
} }
else else
{ {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled."); player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
@ -96,23 +88,13 @@ public class BlockBlocker extends FreedomService
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation()))); FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
}
else
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
event.setCancelled(true);
} }
break; break;
} }
case STRUCTURE_BLOCK: case STRUCTURE_BLOCK:
case STRUCTURE_VOID:
{ {
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled."); player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
event.setCancelled(true); event.setCancelled(true);
break; break;
} }

View File

@ -12,12 +12,16 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
@ -71,7 +75,7 @@ public class EventBlocker extends FreedomService
{ {
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
event.setCancelled(true); event.blockList().clear();
return; return;
} }
@ -107,22 +111,28 @@ public class EventBlocker extends FreedomService
event.setDroppedExp(0); event.setDroppedExp(0);
} }
} }
//deprecated (buggy)
@EventHandler(priority = EventPriority.HIGH) /* @EventHandler(priority = EventPriority.HIGH)
public void onProjectileHit(ProjectileHitEvent event) public void onProjectileHit(ProjectileHitEvent event)
{ {
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) if (ConfigEntry.MAKE_ARROW_EXPLOSIVE.getBoolean())
{ {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
if (event.getEntityType() == EntityType.ARROW) if (entity instanceof Projectile)
{ {
entity.getWorld().createExplosion(entity.getLocation(), 2F); if (event.getEntityType() == EntityType.ARROW)
{
entity.getWorld().createExplosion(entity.getLocation(), 2F);
}
} }
} }
} }*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event) public void onEntityDamage(EntityDamageEvent event
)
{ {
switch (event.getCause()) switch (event.getCause())
{ {
@ -150,7 +160,8 @@ public class EventBlocker extends FreedomService
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event) public void onPlayerDropItem(PlayerDropItemEvent event
)
{ {
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean()) if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{ {
@ -164,9 +175,47 @@ public class EventBlocker extends FreedomService
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onLeavesDecay(LeavesDecayEvent event) public void onLeavesDecay(LeavesDecayEvent event
)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(priority = EventPriority.HIGH)
public void FireworkExplodeEvent(final FireworkExplodeEvent event
)
{
if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void BlockPistonRetractEvent(final BlockPistonRetractEvent event)
{
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void BlockPistonExtendEvent(final BlockPistonExtendEvent event)
{
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void BlockRedstoneEvent(final BlockRedstoneEvent event)
{
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{
event.setNewCurrent(0);
}
}
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Ghast;
import org.bukkit.entity.Giant; import org.bukkit.entity.Giant;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
@ -65,40 +66,47 @@ public class MobBlocker extends FreedomService
return; return;
} }
} }
else if (spawned instanceof Giant) else if (spawned instanceof Wither)
{ {
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean()) if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (spawned instanceof Giant)
else if (spawned instanceof Bat)
{
event.setCancelled(true);
return;
}
int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger();
if (mobLimiterMax <= 0)
{
return;
}
int mobcount = 0;
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
{
if (!(entity instanceof HumanEntity))
{ {
mobcount++; if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Bat)
{
event.setCancelled(true);
return;
}
int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger();
if (mobLimiterMax <= 0)
{
return;
}
int mobcount = 0;
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
{
if (!(entity instanceof HumanEntity))
{
mobcount++;
}
}
if (mobcount > mobLimiterMax)
{
event.setCancelled(true);
} }
} }
if (mobcount > mobLimiterMax)
{
event.setCancelled(true);
}
} }
} }

View File

@ -20,36 +20,49 @@ public class CommandBlockerEntry
private final String subCommand; private final String subCommand;
@Getter @Getter
private final String message; private final String message;
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message) public CommandBlockerEntry(final CommandBlockerRank rank, final CommandBlockerAction action, final String command, final String message) {
{
this(rank, action, command, null, message); this(rank, action, command, null, message);
} }
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String subCommand, String message) public CommandBlockerEntry(final CommandBlockerRank rank, final CommandBlockerAction action, final String command, final String subCommand, final String message) {
{
this.rank = rank; this.rank = rank;
this.action = action; this.action = action;
this.command = command; this.command = command;
this.subCommand = (subCommand == null ? null : subCommand.toLowerCase().trim()); this.subCommand = ((subCommand == null) ? null : subCommand.toLowerCase().trim());
this.message = (message == null || message.equals("_") ? "That command is blocked." : message); this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
} }
public void doActions(CommandSender sender) public void doActions(final CommandSender sender) {
{ if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player) {
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player) TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + this.command);
{
TotalFreedomMod.plugin().ae.autoEject((Player) sender, "You used a prohibited command: " + command);
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED); FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
return; return;
} }
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN) {
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
{
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET); FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
return; return;
} }
FUtil.playerMsg(sender, FUtil.colorize(this.message));
FUtil.playerMsg(sender, FUtil.colorize(message)); }
public CommandBlockerRank getRank() {
return this.rank;
}
public CommandBlockerAction getAction() {
return this.action;
}
public String getCommand() {
return this.command;
}
public String getSubCommand() {
return this.subCommand;
}
public String getMessage() {
return this.message;
} }
} }

View File

@ -0,0 +1,259 @@
package me.totalfreedom.totalfreedommod.bridge;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import net.coreprotect.CoreProtect;
import net.coreprotect.CoreProtectAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.plugin.Plugin;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.plugin.PluginManager;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.io.File;
import java.util.List;
import java.util.Arrays;
import me.totalfreedom.totalfreedommod.util.FUtil;
public class CoreProtectBridge extends FreedomService
{
private CoreProtectAPI coreProtectAPI = null;
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
private BukkitTask wiper;
public CoreProtectBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
if (ConfigEntry.COREPROTECT_AUTO_WIPING_ENABLED.getBoolean() && getCoreProtect() != null)
{
createAutomaticWiper();
}
}
@Override
protected void onStop()
{
}
public CoreProtect getCoreProtect()
{
CoreProtect coreProtect = null;
try
{
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
if (coreProtectPlugin != null && coreProtectPlugin instanceof CoreProtect)
{
coreProtect = (CoreProtect)coreProtectPlugin;
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return coreProtect;
}
public CoreProtectAPI getCoreProtectAPI()
{
if (coreProtectAPI == null)
{
try
{
final CoreProtect coreProtect = getCoreProtect();
coreProtectAPI = coreProtect.getAPI();
// Check if the plugin or api is not enabled, if so, return null
if (!coreProtect.isEnabled() || !coreProtectAPI.isEnabled())
{
return null;
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return coreProtectAPI;
}
public boolean isEnabled()
{
final CoreProtect coreProtect = getCoreProtect();
return coreProtect != null && coreProtect.isEnabled();
}
// Rollback the specifed player's edits that were in the last 24 hours.
public void rollback(final String name)
{
final CoreProtectAPI coreProtect = getCoreProtectAPI();
if (!isEnabled())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
coreProtect.performRollback(86400, Arrays.asList(name), null, null, null, null, 0, null);
}
}.runTaskAsynchronously(plugin);
}
// Reverts a rollback for the specifed player's edits that were in the last 24 hours.
public void undoRollback(final String name)
{
final CoreProtectAPI coreProtect = getCoreProtectAPI();
if (!isEnabled())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
coreProtect.performRestore(86400, Arrays.asList(name), null, null, null, null, 0, null);
}
}.runTaskAsynchronously(plugin);
}
public File getDatabase()
{
if (!isEnabled())
{
return null;
}
return(new File(getCoreProtect().getDataFolder(), "database.db"));
}
private void createAutomaticWiper()
{
final long interval = 10 * 20L;
final File databaseFile = getDatabase();
wiper = new BukkitRunnable()
{
@Override
public void run()
{
final CoreProtect coreProtect = getCoreProtect();
if (getDBSize() > ConfigEntry.COREPROTECT_FILE_LIMIT.getInteger())
{
FLog.info("The CoreProtect log file has grown too big for the server to cope, the data is being wiped!");
FUtil.bcastMsg("The CoreProtect log file has grown too big for the server to cope, the data is being wiped!", ChatColor.RED);
PluginManager pluginManager = server.getPluginManager();
pluginManager.disablePlugin(coreProtect);
for(World world : Bukkit.getWorlds())
{
if(!world.equals(plugin.wm.adminworld.getWorld()))
{
clearDatabase(world);
}
}
//check if still too big, if so delete all data
if(getDBSize() > ConfigEntry.COREPROTECT_FILE_LIMIT.getInteger())
{
FUtil.deleteFolder(databaseFile);
}
pluginManager.enablePlugin(coreProtect);
}
}
}.runTaskTimer(plugin, interval, interval);
}
public double getDBSize()
{
double bytes = getDatabase().length();
double kilobytes = (bytes / 1024);
double megabytes = (kilobytes / 1024);
return (megabytes / 1024);
}
// Wipes DB for the specified world
public void clearDatabase(World world)
{
clearDatabase(world, false);
}
// Wipes DB for the specified world
public void clearDatabase(World world, Boolean shutdown)
{
final CoreProtect coreProtect = getCoreProtect();
if (coreProtect == null)
{
return;
}
/* As CoreProtect doesn't have an api method for deleting all of the data for a specific world
we have to do this manually via sql */
File databaseFile = getDatabase();
Connection connection = null;
try
{
connection = DriverManager.getConnection("jdbc:sqlite:" + databaseFile);
final Statement statement = connection.createStatement();
statement.setQueryTimeout(30);
// Obtain world ID from CoreProtect database
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'");
String worldID = null;
while (resultSet.next())
{
worldID = String.valueOf(resultSet.getInt("id"));
}
// Ensure the world ID is not null
if (worldID == null)
{
FLog.warning("Failed to obtain the world ID for the " + world.getName());
return;
}
// Iterate through each table and delete their data if the world ID matches
for (String table : tables)
{
statement.executeUpdate("DELETE FROM " + table + " WHERE wid = " + worldID);
}
// This shrinks down the file size
statement.executeUpdate("VACUUM");
connection.close();
}
catch (SQLException e)
{
FLog.warning("Failed to delete the CoreProtect data for the " + world.getName());
}
// This exits for flatlands wipes
if (shutdown)
{
server.shutdown();
}
}
}

View File

@ -1,137 +1,191 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
import com.earth2me.essentials.Essentials; import org.bukkit.event.player.PlayerQuitEvent;
import com.earth2me.essentials.User; import org.bukkit.event.inventory.InventoryCloseEvent;
import me.totalfreedom.totalfreedommod.FreedomService; import org.bukkit.event.EventPriority;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import org.bukkit.event.EventHandler;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.inventory.InventoryHolder;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.inventory.Inventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit; import com.earth2me.essentials.User;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Bukkit;
import me.totalfreedom.totalfreedommod.command.Command_vanish;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import com.earth2me.essentials.Essentials;
import me.totalfreedom.totalfreedommod.FreedomService;
public class EssentialsBridge extends FreedomService public class EssentialsBridge extends FreedomService
{ {
private Essentials essentialsPlugin;
private Essentials essentialsPlugin = null;
public EssentialsBridge(final TotalFreedomMod plugin) {
public EssentialsBridge(TotalFreedomMod plugin)
{
super(plugin); super(plugin);
this.essentialsPlugin = null;
} }
@Override protected void onStart() {
protected void onStart()
{
} }
@Override protected void onStop() {
protected void onStop() Command_vanish.vanished.clear();
{
} }
public Essentials getEssentialsPlugin() public Essentials getEssentialsPlugin() {
{ if (this.essentialsPlugin == null) {
if (essentialsPlugin == null) try {
{
try
{
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials"); final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
if (essentials != null) if (essentials != null && essentials instanceof Essentials) {
{ this.essentialsPlugin = (Essentials)essentials;
if (essentials instanceof Essentials)
{
essentialsPlugin = (Essentials) essentials;
}
} }
} }
catch (Exception ex) catch (Exception ex) {
{
FLog.severe(ex); FLog.severe(ex);
} }
} }
return essentialsPlugin; return this.essentialsPlugin;
} }
public User getEssentialsUser(String username) public User getEssentialsUser(final String username) {
{ try {
try final Essentials essentials = this.getEssentialsPlugin();
{ if (essentials != null) {
final Essentials essentials = getEssentialsPlugin();
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(String username, String nickname) public void setNickname(final String username, final String nickname) {
{ try {
try final User user = this.getEssentialsUser(username);
{ if (user != null) {
final User user = getEssentialsUser(username);
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(String username) public String getNickname(final String username) {
{ try {
try final User user = this.getEssentialsUser(username);
{ if (user != null) {
final User user = getEssentialsUser(username);
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(String username) public long getLastActivity(final String username) {
{ try {
try final User user = this.getEssentialsUser(username);
{ if (user != null) {
final User user = getEssentialsUser(username); return FUtil.getField(user, "lastActivity");
if (user != null)
{
return FUtil.<Long>getField(user, "lastActivity"); // This is weird
} }
} }
catch (Exception ex) catch (Exception ex) {
{
FLog.severe(ex); FLog.severe(ex);
} }
return 0L; return 0L;
} }
public boolean isEssentialsEnabled() public void setVanished(final String username, final boolean vanished) {
{ try {
try final User user = this.getEssentialsUser(username);
{ if (user != null) {
final Essentials essentials = getEssentialsPlugin(); user.setVanished(vanished);
if (essentials != null) }
{ }
catch (Exception ex) {
FLog.severe(ex);
}
}
@EventHandler(priority = EventPriority.MONITOR)
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 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()) {
event.setCancelled(true);
refreshPlayer = playerdata;
}
}
}
if (refreshPlayer != null) {
final Player player = refreshPlayer;
new BukkitRunnable() {
public void run() {
player.updateInventory();
}
}.runTaskLater((Plugin)this.plugin, 20L);
}
}
@EventHandler(priority = EventPriority.MONITOR)
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);
refreshPlayer = playerdata;
}
if (refreshPlayer != null) {
final Player player = refreshPlayer;
new BukkitRunnable() {
public void run() {
player.updateInventory();
}
}.runTaskLater((Plugin)this.plugin, 20L);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuitEvent(final PlayerQuitEvent event) {
final Player player = event.getPlayer();
if (Command_vanish.vanished.contains(player)) {
Command_vanish.vanished.remove(player);
}
}
public boolean isEssentialsEnabled() {
try {
final Essentials essentials = this.getEssentialsPlugin();
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,8 +1,8 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
//import me.libraryaddict.disguise.DisallowedDisguises; import me.libraryaddict.disguise.DisallowedDisguises;
//import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.DisguiseAPI;
//import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
@ -13,7 +13,7 @@ import org.bukkit.plugin.Plugin;
public class LibsDisguisesBridge extends FreedomService public class LibsDisguisesBridge extends FreedomService
{ {
// private LibsDisguises libsDisguisesPlugin = null; private LibsDisguises libsDisguisesPlugin = null;
public LibsDisguisesBridge(TotalFreedomMod plugin) public LibsDisguisesBridge(TotalFreedomMod plugin)
{ {
@ -29,7 +29,7 @@ public class LibsDisguisesBridge extends FreedomService
protected void onStop() protected void onStop()
{ {
} }
/*
public LibsDisguises getLibsDisguisesPlugin() public LibsDisguises getLibsDisguisesPlugin()
{ {
if (libsDisguisesPlugin == null) if (libsDisguisesPlugin == null)
@ -134,5 +134,5 @@ public class LibsDisguisesBridge extends FreedomService
} }
return ld.isEnabled(); return ld.isEnabled();
}*/ }
} }

View File

@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.caging;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import me.totalfreedom.totalfreedommod.command.Command_cage;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -187,7 +188,7 @@ public class CageData
block.setType(Material.SKULL); block.setType(Material.SKULL);
final Skull skull = (Skull) block.getState(); final Skull skull = (Skull) block.getState();
skull.setSkullType(SkullType.PLAYER); skull.setSkullType(SkullType.PLAYER);
skull.setOwner("Prozza"); skull.setOwner(Command_cage.playerSkullName);
skull.update(); skull.update();
} }
} }
@ -195,6 +196,26 @@ public class CageData
} }
} }
public boolean isCaged()
{
return this.caged;
}
public Location getLocation()
{
return this.location;
}
public Material getOuterMaterial()
{
return this.outerMaterial;
}
public Material getInnerMaterial()
{
return this.innerMaterial;
}
private static class BlockData private static class BlockData
{ {

View File

@ -10,4 +10,4 @@ public class CommandFailException extends RuntimeException
super(message); super(message);
} }
} }

View File

@ -42,4 +42,4 @@ public class CommandLoader extends FreedomService
handler.clearCommands(); handler.clearCommands();
} }
} }

View File

@ -12,4 +12,4 @@ public @interface CommandParameters
String usage(); String usage();
String aliases() default ""; // "alias1,alias2,alias3" - no spaces String aliases() default ""; // "alias1,alias2,alias3" - no spaces
} }

View File

@ -13,4 +13,4 @@ public @interface CommandPermissions
SourceType source(); SourceType source();
boolean blockHostConsole() default false; boolean blockHostConsole() default false;
} }

View File

@ -11,7 +11,8 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Go to the AdminWorld.", @CommandParameters(description = "Go to the AdminWorld.",
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]") usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]",
aliases = "aw")
public class Command_adminworld extends FreedomCommand public class Command_adminworld extends FreedomCommand
{ {

View File

@ -68,7 +68,7 @@ public class Command_blockcmd extends FreedomCommand
if (isAdmin(player)) if (isAdmin(player))
{ {
msg(player.getName() + " is a Superadmin, and cannot have their commands blocked."); msg(player.getName() + " is an admin, and cannot have their commands blocked.");
return true; return true;
} }

View File

@ -0,0 +1,109 @@
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;
import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@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) {
return false;
}
if (args[0].equals("list")) {
this.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());
++count;
}
}
if (count == 0) {
this.msg("- none");
}
return true;
}
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()) {
info.setEditBlocked(false);
++count;
}
}
this.msg("Unblocked all block edit for " + count + " players.");
return true;
}
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);
playerdata.setEditBlocked(true);
++counter;
}
}
this.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) {
return false;
}
}
final Player player2 = this.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);
}
final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2);
if (playerdata2.isEditBlock()) {
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);
}
else {
if (((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) {
this.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 (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());
}
return true;
}
}

View File

@ -0,0 +1,109 @@
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;
import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@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) {
return false;
}
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());
++count;
}
}
if (count == 0) {
this.msg("- none");
}
return true;
}
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);
++count;
}
}
this.msg("Enabled PVP for " + count + " players.");
return true;
}
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);
++counter;
}
}
this.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) {
return false;
}
}
final Player player2 = this.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);
}
final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2);
if (playerdata2.isPVPBlock()) {
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);
}
else {
if (((TotalFreedomMod)this.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);
}
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());
}
return true;
}
}

View File

@ -0,0 +1,42 @@
package me.totalfreedom.totalfreedommod.command;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender;
import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
public class Command_blockredstone extends FreedomCommand
{
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
{
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
FUtil.adminAction(sender.getName(), "Blocking all redstone", true);
new BukkitRunnable()
{
public void run()
{
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{
FUtil.adminAction("TotalFreedom", "Unblocking all redstone", false);
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
}
}
}.runTaskLater((Plugin) this.plugin, 6000L);
}
else
{
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);
}
return true;
}
}

View File

@ -1,8 +1,10 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
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.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -11,100 +13,77 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [outermaterial] [innermaterial]>") @CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [skull | block] [blockname | skullname]")
public class Command_cage extends FreedomCommand public class Command_cage extends FreedomCommand
{ {
public static String playerSkullName;
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) {
{ if (args.length == 0) {
if (args.length == 0)
{
return false; return false;
} }
if ("off".equals(args[0]) && sender instanceof Player) {
if ("off".equals(args[0]) && sender instanceof Player)
{
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true); FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
FPlayer playerdata = plugin.pl.getPlayer(playerSender); final FPlayer playerdata = ((TotalFreedomMod)this.plugin).pl.getPlayer(playerSender);
playerdata.getCageData().setCaged(false); playerdata.getCageData().setCaged(false);
return true; return true;
} }
else if ("purge".equals(args[0])) if ("purge".equals(args[0])) {
{
FUtil.adminAction(sender.getName(), "Uncaging all players", true); FUtil.adminAction(sender.getName(), "Uncaging all players", true);
for (final Player player : this.server.getOnlinePlayers()) {
for (Player player : server.getOnlinePlayers()) final FPlayer playerdata2 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player);
{ playerdata2.getCageData().setCaged(false);
FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.getCageData().setCaged(false);
} }
return true; return true;
} }
final Player player2 = this.getPlayer(args[0]);
final Player player = getPlayer(args[0]); if (player2 == null) {
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true; return true;
} }
final FPlayer playerdata3 = ((TotalFreedomMod)this.plugin).pl.getPlayer(player2);
FPlayer playerdata = plugin.pl.getPlayer(player);
Material outerMaterial = Material.GLASS; Material outerMaterial = Material.GLASS;
Material innerMaterial = Material.AIR; Material innerMaterial = Material.AIR;
if (args.length >= 2 && null != args[1]) {
if (args.length >= 2) final String s = args[1];
{ switch (s) {
if ("off".equals(args[1])) case "off": {
{ FUtil.adminAction(sender.getName(), "Uncaging " + player2.getName(), true);
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true); playerdata3.getCageData().setCaged(false);
playerdata.getCageData().setCaged(false); return true;
return true;
}
else
{
if ("darth".equalsIgnoreCase(args[1]))
{
outerMaterial = Material.SKULL;
} }
else if (Material.matchMaterial(args[1]) != null) case "skull": {
{ outerMaterial = Material.SKULL;
outerMaterial = Material.matchMaterial(args[1]); Command_cage.playerSkullName = args[2];
break;
}
case "block": {
if (Material.matchMaterial(args[2]) != null) {
outerMaterial = Material.matchMaterial(args[2]);
break;
}
sender.sendMessage(ChatColor.RED + "Invalid block!");
break;
} }
} }
} }
if (args.length >= 3) {
if (args.length >= 3) if (args[2].equalsIgnoreCase("water")) {
{
if (args[2].equalsIgnoreCase("water"))
{
innerMaterial = Material.STATIONARY_WATER; innerMaterial = Material.STATIONARY_WATER;
} }
else if (args[2].equalsIgnoreCase("lava")) else if (args[2].equalsIgnoreCase("lava")) {
{
innerMaterial = Material.STATIONARY_LAVA; innerMaterial = Material.STATIONARY_LAVA;
} }
} }
final Location targetPos = player2.getLocation().clone().add(0.0, 1.0, 0.0);
Location targetPos = player.getLocation().clone().add(0, 1, 0); playerdata3.getCageData().cage(targetPos, outerMaterial, innerMaterial);
playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial); player2.setGameMode(GameMode.SURVIVAL);
if (outerMaterial != Material.SKULL) {
player.setGameMode(GameMode.SURVIVAL); FUtil.adminAction(sender.getName(), "Caging " + player2.getName(), true);
if (outerMaterial != Material.SKULL)
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
} }
else else {
{ FUtil.adminAction(sender.getName(), "Caging " + player2.getName() + " in " + Command_cage.playerSkullName, true);
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
} }
return true; return true;
} }
} }

View File

@ -1,54 +1,49 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.Random; import java.util.Iterator;
import me.totalfreedom.totalfreedommod.rank.Rank; import org.bukkit.inventory.meta.ItemMeta;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Achievement; import org.bukkit.Achievement;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.Material;
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) @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 = new Random(); private final Random random;
@Override public Command_cake() {
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, 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 = CAKE_LYRICS.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 : words) for (final String word : split) {
{ output.append(FUtil.rainbowChatColor()).append(word).append(" ");
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).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((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString()); 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 : 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);
} }
player.awardAchievement(Achievement.BAKE_CAKE);
} }
FUtil.bcastMsg(output.toString()); FUtil.bcastMsg(output.toString());
return true; return true;
} }
} }

View File

@ -0,0 +1,24 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spy on Chest Movements", usage = "/<command>", aliases = "chspy")
public class Command_chestspy extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.setChestMonitor(!playerdata.ChestMonitorEnabled());
msg("ChestSpy " + (playerdata.ChestMonitorEnabled()? "enabled." : "disabled."));
return true;
}
}

View File

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
//import me.libraryaddict.disguise.DisallowedDisguises; //import me.libraryaddict.disguise.DisallowedDisguises;
import me.libraryaddict.disguise.DisallowedDisguises;
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.bukkit.command.Command; import org.bukkit.command.Command;
@ -15,7 +16,7 @@ public class Command_disguisetoggle 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)
{/* {
if (!plugin.ldb.isPluginEnabled()) if (!plugin.ldb.isPluginEnabled())
{ {
msg(ChatColor.RED + "LibsDisguises is not enabled."); msg(ChatColor.RED + "LibsDisguises is not enabled.");
@ -23,7 +24,7 @@ public class Command_disguisetoggle extends FreedomCommand
} }
FUtil.adminAction(sender.getName(), (DisallowedDisguises.disabled ? "Enabling" : "Disabling") + " " + FUtil.adminAction(sender.getName(), (DisallowedDisguises.disabled ? "Enabling" : "Disabling") + " " +
"Disguises", false); "disguises.", false);
if (plugin.ldb.isDisguisesEnabled()) if (plugin.ldb.isDisguisesEnabled())
{ {
@ -38,10 +39,5 @@ public class Command_disguisetoggle extends FreedomCommand
msg("Disguises are now " + (!DisallowedDisguises.disabled ? "enabled." : "disabled.")); msg("Disguises are now " + (!DisallowedDisguises.disabled ? "enabled." : "disabled."));
return true; return true;
*/
msg("This command has been disabled for technical reasons. Contact a developer for additional information.");
return true;
} }
} }

View File

@ -83,7 +83,7 @@ public class Command_doom extends FreedomCommand
public void run() public void run()
{ {
// strike lightning // strike lightning
player.getWorld().strikeLightning(player.getLocation()); player.getWorld().strikeLightningEffect(player.getLocation());
// kill (if not done already) // kill (if not done already)
player.setHealth(0.0); player.setHealth(0.0);

View File

@ -0,0 +1,24 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spy on Dropped Items", usage = "/<command>", aliases = "dropspy")
public class Command_dropspy extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.setDropMonitor(!playerdata.DropMonitorEnabled());
msg("DropSpy " + (playerdata.DropMonitorEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

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

View File

@ -11,8 +11,10 @@ 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;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans or unbans any player, even those who are not logged in anymore.", usage = "/<command> <purge | ban <username> [reason] | unban <username>>") @CommandParameters(description = "Bans or unbans any player, even those who are not logged in anymore.", usage = "/<command> <ban <username> [reason] | unban <username> | banip <ip> <reason> | unbanip <ip> | nameban <name> | unbanname <name>>")
public class Command_glist extends FreedomCommand public class Command_glist extends FreedomCommand
{ {
@ -38,78 +40,158 @@ public class Command_glist extends FreedomCommand
return false; return false;
} }
if (args.length < 2) if (args.length < 2)
{
return false;
}
String username;
final List<String> ips = new ArrayList<>();
final Player player = getPlayer(args[1]);
if (player == null)
{
final PlayerData entry = plugin.pl.getData(args[1]);
if (entry == null)
{
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
return true;
}
username = entry.getUsername();
ips.addAll(entry.getIps());
}
else
{
final PlayerData entry = plugin.pl.getData(player);
username = player.getName();
ips.addAll(entry.getIps());
}
if ("ban".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
final String reason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban ban = Ban.forPlayerName(username, sender, null, reason);
for (String ip : ips)
{
ban.addIp(ip);
ban.addIp(FUtil.getFuzzyIp(ip));
}
plugin.bm.addBan(ban);
if (player != null)
{
player.kickPlayer(ban.bakeKickMessage());
}
return true;
}
if ("unban".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
plugin.bm.removeBan(plugin.bm.getByUsername(username));
for (String ip : ips)
{
Ban ban = plugin.bm.getByIp(ip);
if (ban != null)
{ {
plugin.bm.removeBan(ban); return false;
} }
ban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
if (ban != null) String username = null;
final List<String> ips = new ArrayList<>();
boolean usingIp = false;
String banIp = null;
if (args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$") || args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([*])\\.([*])$"))
{ {
plugin.bm.removeBan(ban); usingIp = true;
banIp = args[1];
}
final Player player = getPlayer(args[1]);
if (!usingIp)
{
if (player == null)
{
final PlayerData entry = plugin.pl.getData(args[1]);
if (entry == null)
{
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
return true;
}
username = entry.getUsername();
ips.addAll(entry.getIps());
}
else
{
final PlayerData entry = plugin.pl.getData(player);
username = entry.getUsername();
ips.addAll(entry.getIps());
}
}
switch (args[0])
{
case "ban":
case "gtfo":
if (usingIp)
{
msg("Please specify a player, not an ip.");
return true;
}
final String playerBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban playerBan = Ban.forPlayerName(username, sender, null, playerBanReason);
for (String ip : ips)
{
playerBan.addIp(ip);
playerBan.addIp(FUtil.getFuzzyIp(ip));
}
FUtil.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
plugin.bm.addBan(playerBan);
if (player != null)
{
player.kickPlayer(playerBan.bakeKickMessage());
}
return true;
case "unban":
case "pardon":
if (usingIp)
{
msg("Please specify a player, not an ip.");
return true;
}
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
plugin.bm.removeBan(plugin.bm.getByUsername(username));
for (String ip : ips)
{
Ban playerUnban = plugin.bm.getByIp(ip);
if (playerUnban != null)
{
plugin.bm.removeBan(playerUnban);
}
playerUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
if (playerUnban != null)
{
plugin.bm.removeBan(playerUnban);
}
}
return true;
case "nameban":
case "banname":
if (usingIp)
{
msg("Please specify a name, not an ip.");
return true;
}
final String nameBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban nameBan = Ban.forPlayerName(username, sender, null, nameBanReason);
FUtil.adminAction(sender.getName(), "Banning IGN: " + username, true);
plugin.bm.addBan(nameBan);
if (player != null)
{
player.kickPlayer(nameBan.bakeKickMessage());
}
return true;
case "unbanname":
case "nameunban":
if (usingIp)
{
msg("Please specify a name, not an ip.");
return true;
}
FUtil.adminAction(sender.getName(), "Unbanning IGN: " + username, true);
plugin.bm.removeBan(plugin.bm.getByUsername(username));
return true;
case "banip":
case "ipban":
if (!usingIp)
{
msg("Please specify an IP.");
return true;
}
final String ipBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban ipBan = Ban.forPlayerIp(banIp, sender, null, ipBanReason);
plugin.bm.addBan(ipBan);
FUtil.adminAction(sender.getName(), "Banning IP: " + banIp, true);
return true;
case "unbanip":
case "pardonip":
if (!usingIp)
{
msg("Please specify an IP.");
return true;
}
FUtil.adminAction(sender.getName(), "Unbanning IP: " + banIp, true);
Ban ipUnban = plugin.bm.getByIp(banIp);
if (ipUnban != null)
{
plugin.bm.removeBan(ipUnban);
plugin.bm.unbanIp(banIp);
}
ipUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(banIp));
if (ipUnban != null)
{
plugin.bm.removeBan(ipUnban);
plugin.bm.unbanIp(banIp);
}
return true;
default:
return false;
} }
} }
return true;
} }
return false;
}
}

View File

@ -6,6 +6,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips; import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import static org.bukkit.Bukkit.getServer;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -21,7 +22,6 @@ public class Command_gtfo 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)
{ {
if (args.length == 0) if (args.length == 0)
{ {
return false; return false;
@ -43,17 +43,26 @@ public class Command_gtfo extends FreedomCommand
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Undo WorldEdits //checks if there is CoreProtect loaded and installed , if not it skips the rollback and uses coreprotect directly
try if (!getServer().getPluginManager().isPluginEnabled("CoreProtect"))
{ {
plugin.web.undo(player, 15); // Undo WorldEdits
} try
catch (NoClassDefFoundError ex) {
{ plugin.web.undo(player, 15);
} }
catch (NoClassDefFoundError ex)
{
}
// Rollback // Rollback
plugin.rb.rollback(player.getName()); plugin.rb.rollback(player.getName());
}
else
{
plugin.cpb.rollback(player.getName());
}
// Deop // Deop
player.setOp(false); player.setOp(false);
@ -71,7 +80,7 @@ public class Command_gtfo extends FreedomCommand
for (int z = -1; z <= 1; z++) for (int z = -1; z <= 1; z++)
{ {
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z); final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
targetPos.getWorld().strikeLightning(strike_pos); targetPos.getWorld().strikeLightningEffect(strike_pos);
} }
} }
@ -86,16 +95,19 @@ public class Command_gtfo extends FreedomCommand
.append(ip); .append(ip);
if (reason != null) if (reason != null)
{ {
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason); bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.colorize(reason));
} }
FUtil.bcastMsg(bcast.toString()); FUtil.bcastMsg(bcast.toString());
// Ban player // Ban player
plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason)); plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason));
// Kill player
player.setHealth(0.0);
// Kick player // Kick player
player.kickPlayer(ChatColor.RED + "GTFO"); player.kickPlayer(ChatColor.RED + "GTFO");
return true; return true;
} }
} }

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Shows (and optionally clears) invisisible players", usage = "/<command> [clear]") @CommandParameters(description = "Shows (optionally clears) invisisible players", usage = "/<command> (clear)")
public class Command_invis extends FreedomCommand public class Command_invis extends FreedomCommand
{ {
@ -19,11 +19,12 @@ public class Command_invis extends FreedomCommand
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)
{ {
boolean clear = false; boolean clear = false;
if (args.length >= 1) if (args.length >= 1)
{ {
if (args[0].equalsIgnoreCase("clear")) if (args[0].equalsIgnoreCase("clear"))
{ {
FUtil.adminAction(sender.getName(), "Clearing invisibility for all players", false); FUtil.adminAction(sender.getName(), "Clearing all invis potion effect from all players", true);
clear = true; clear = true;
} }
else else
@ -32,7 +33,7 @@ public class Command_invis extends FreedomCommand
} }
} }
List<String> players = new ArrayList<>(); List<String> players = new ArrayList<String>();
int clears = 0; int clears = 0;
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
@ -42,7 +43,7 @@ public class Command_invis extends FreedomCommand
players.add(player.getName()); players.add(player.getName());
if (clear && !plugin.al.isAdmin(player)) if (clear && !plugin.al.isAdmin(player))
{ {
player.removePotionEffect(PotionEffectType.INVISIBILITY); player.removePotionEffect((PotionEffectType.INVISIBILITY));
clears++; clears++;
} }
} }
@ -50,17 +51,16 @@ public class Command_invis extends FreedomCommand
if (players.isEmpty()) if (players.isEmpty())
{ {
msg("There are no invisible players"); sender.sendMessage("There are no invisible players");
return true; return true;
} }
if (clear) if (clear)
{ {
msg("Cleared invisibility effect from " + clears + " players"); sender.sendMessage("Cleared " + clears + " players");
} }
else else
{ {
msg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", ")); sender.sendMessage("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
} }
return true; return true;

View File

@ -0,0 +1,54 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = " Look into another player's inventory, optionally take items out.", usage = "/<command> <player>", aliases = "inv,insee")
public class Command_invsee extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
msg("You need to specify a player.");
return false;
}
Player player = getPlayer(args[0]);
if (player == null)
{
msg("This player is not online.");
return false;
}
if (playerSender == player)
{
msg("You cannot invsee yourself.");
return true;
}
if (plugin.al.isAdmin(player) && !plugin.al.isAdmin(playerSender))
{
msg("You can't spy on admins!");
return true;
}
playerSender.closeInventory();
FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
fPlayer.setInvsee(true);
Inventory playerInv = player.getInventory();
playerSender.openInventory(playerInv);
return true;
}
}

View File

@ -1,120 +1,119 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList; import me.totalfreedom.totalfreedommod.rank.Displayable;
import java.util.Iterator;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Displayable; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender;
import me.totalfreedom.totalfreedommod.rank.Rank;
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH) @CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i | -f]", aliases = "who") @CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i | -f]", aliases = "who")
public class Command_list extends FreedomCommand public class Command_list extends FreedomCommand
{ {
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) {
private static enum ListFilter if (args.length > 1) {
{
PLAYERS,
ADMINS,
FAMOUS_PLAYERS,
IMPOSTORS;
}
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 1)
{
return false; return false;
} }
if (FUtil.isFromHostConsole(sender.getName())) {
if (FUtil.isFromHostConsole(sender.getName())) final List<String> names = new ArrayList<String>();
{ for (final Player player : this.server.getOnlinePlayers()) {
final List<String> names = new ArrayList<>();
for (Player player : server.getOnlinePlayers())
{
names.add(player.getName()); names.add(player.getName());
} }
msg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE); this.msg("There are " + names.size() + "/" + this.server.getMaxPlayers() + " players online:\n" + StringUtils.join((Iterable)names, ", "), ChatColor.WHITE);
return true; return true;
} }
ListFilter listFilter = null;
final ListFilter listFilter; if (args.length == 1) {
if (args.length == 1) final String s = args[0];
{ switch (s) {
switch (args[0]) case "-a": {
{
case "-a":
listFilter = ListFilter.ADMINS; listFilter = ListFilter.ADMINS;
break; break;
case "-i": }
case "-v": {
listFilter = ListFilter.VANISHED_ADMINS;
break;
}
case "-i": {
listFilter = ListFilter.IMPOSTORS; listFilter = ListFilter.IMPOSTORS;
break; break;
case "-f": }
case "-f": {
listFilter = ListFilter.FAMOUS_PLAYERS; listFilter = ListFilter.FAMOUS_PLAYERS;
break; break;
default: }
default: {
return false; return false;
}
} }
} }
else else {
{
listFilter = ListFilter.PLAYERS; listFilter = ListFilter.PLAYERS;
} }
if (listFilter == ListFilter.VANISHED_ADMINS && !((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)playerSender)) {
this.msg("/list [-a | -i | -f ]", ChatColor.WHITE);
return true;
}
final StringBuilder onlineStats = new StringBuilder(); final StringBuilder onlineStats = new StringBuilder();
final StringBuilder onlineUsers = new StringBuilder(); final StringBuilder onlineUsers = new StringBuilder();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(this.server.getOnlinePlayers().size() - Command_vanish.vanished.size());
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size()); onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(this.server.getMaxPlayers());
onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
onlineStats.append(ChatColor.BLUE).append(" players online."); onlineStats.append(ChatColor.BLUE).append(" players online.");
final List<String> names2 = new ArrayList<String>();
final List<String> names = new ArrayList<>(); for (final Player player2 : this.server.getOnlinePlayers()) {
for (Player player : server.getOnlinePlayers()) if (listFilter == ListFilter.ADMINS && !((TotalFreedomMod)this.plugin).al.isAdmin((CommandSender)player2)) {
{
if (listFilter == ListFilter.ADMINS && !plugin.al.isAdmin(player))
{
continue; continue;
} }
if (listFilter == ListFilter.ADMINS && Command_vanish.vanished.contains(player2)) {
if (listFilter == ListFilter.IMPOSTORS && !plugin.al.isAdminImpostor(player))
{
continue; continue;
} }
if (listFilter == ListFilter.VANISHED_ADMINS && !Command_vanish.vanished.contains(player2)) {
if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(player.getName().toLowerCase()))
{
continue; continue;
} }
if (listFilter == ListFilter.IMPOSTORS && !((TotalFreedomMod)this.plugin).al.isAdminImpostor(player2)) {
Displayable display = plugin.rm.getDisplay(player); continue;
}
names.add(display.getColoredTag() + player.getName()); if (listFilter == ListFilter.FAMOUS_PLAYERS && !ConfigEntry.FAMOUS_PLAYERS.getList().contains(player2.getName().toLowerCase())) {
continue;
}
if (listFilter == ListFilter.PLAYERS && Command_vanish.vanished.contains(player2)) {
continue;
}
final Displayable display = ((TotalFreedomMod)this.plugin).rm.getDisplay((CommandSender)player2);
names2.add(display.getColoredTag() + player2.getName());
} }
final String playerType = (listFilter == null) ? "players" : listFilter.toString().toLowerCase().replace('_', ' ');
String playerType = listFilter == null ? "players" : listFilter.toString().toLowerCase().replace('_', ' ');
onlineUsers.append("Connected "); onlineUsers.append("Connected ");
onlineUsers.append(playerType + ": "); onlineUsers.append(playerType + ": ");
onlineUsers.append(StringUtils.join(names, ChatColor.WHITE + ", ")); onlineUsers.append(StringUtils.join((Iterable)names2, ChatColor.WHITE + ", "));
if (senderIsConsole) {
if (senderIsConsole)
{
sender.sendMessage(ChatColor.stripColor(onlineStats.toString())); sender.sendMessage(ChatColor.stripColor(onlineStats.toString()));
sender.sendMessage(ChatColor.stripColor(onlineUsers.toString())); sender.sendMessage(ChatColor.stripColor(onlineUsers.toString()));
} }
else else {
{
sender.sendMessage(onlineStats.toString()); sender.sendMessage(onlineStats.toString());
sender.sendMessage(onlineUsers.toString()); sender.sendMessage(onlineUsers.toString());
} }
names2.clear();
return true; return true;
} }
private enum ListFilter
{
PLAYERS,
ADMINS,
VANISHED_ADMINS,
FAMOUS_PLAYERS,
IMPOSTORS;
}
} }

View File

@ -0,0 +1,24 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.totalfreedom.totalfreedommod.util.History;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Check name history of username.", usage = "/<command> <username>")
public class Command_namehistory extends FreedomCommand
{
@Override
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
History.reportHistory(sender, args[0]);
return true;
}
}

View File

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -43,29 +44,27 @@ public class Command_onlinemode extends FreedomCommand
return false; return false;
} }
// try try
// { {
// plugin.si.setOnlineMode(onlineMode); plugin.si.setOnlineMode(onlineMode);
//
// if (onlineMode)
// {
// for (Player player : server.getOnlinePlayers())
// {
// player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
// }
// }
//
// FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true);
//
// server.reload();
// }
// catch (Exception ex)
// {
// FLog.severe(ex);
// }
FUtil.adminAction(sender.getName(), "Online-Mode toggling is temporarily disabled.", true);
}
if (onlineMode)
{
for (Player player : server.getOnlinePlayers())
{
player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
}
}
FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true);
server.reload();
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return true; return true;
} }
} }