Lots of formatting fixes and removal of useless things (#10)

This commit is contained in:
Seth 2017-12-27 22:50:39 -07:00 committed by Lemon
parent b931cce3bb
commit 1871451ed6
20 changed files with 355 additions and 738 deletions

View File

@ -1,142 +0,0 @@
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).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() + "'.");
}
}
}
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).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() + "'.");
}
}
}
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).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() + "'.");
}
}
}
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).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() + "'.");
}
}
}
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).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() + "'.");
}
}
}
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).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

@ -1,55 +0,0 @@
package me.totalfreedom.totalfreedommod;
import org.bukkit.event.EventPriority;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import java.text.DecimalFormat;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.entity.Player;
public class DropMonitor extends FreedomService
{
DecimalFormat df;
public DropMonitor(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.MONITOR)
public void onPlayerItemDrop(final PlayerDropItemEvent event)
{
if (plugin.al.isAdmin(event.getPlayer()))
{
return;
}
final int dropeditem = event.getItemDrop().getItemStack().getTypeId();
final Location loc = event.getPlayer().getLocation();
for (Player player : server.getOnlinePlayers())
{
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

@ -1,94 +0,0 @@
package me.totalfreedom.totalfreedommod;
import java.text.DecimalFormat;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.projectiles.ProjectileSource;
public class PotionMonitorer extends FreedomService
{
DecimalFormat df;
public PotionMonitorer(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 void LingeringPotionSplashEvent(LingeringPotionSplashEvent event)
{
ProjectileSource source = event.getEntity().getShooter();
if (!(source instanceof Player))
{
return;
}
Player player = (Player) source;
if (plugin.al.isAdmin((Player) event.getEntity().getShooter()))
{
return;
}
final int dropeditem = event.getEntity().getItem().getTypeId();
final Location loc = player.getLocation();
for (Player player2 : server.getOnlinePlayers())
{
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)
public void PotionSplashEvent(PotionSplashEvent event)
{
ProjectileSource source = event.getEntity().getShooter();
if (!(source instanceof Player))
{
return;
}
Player player = (Player) source;
if (plugin.al.isAdmin((Player) event.getEntity().getShooter()))
{
return;
}
final int dropeditem = event.getPotion().getItem().getTypeId();
final Location loc = player.getLocation();
for (Player player2 : server.getOnlinePlayers())
{
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

@ -1,67 +0,0 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.projectiles.ProjectileSource;
public class PvPBlocker extends FreedomService
{
public PvPBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOW)
public void EntityDamageByEntityEvent(EntityDamageByEntityEvent event)
{
Entity damager = event.getDamager();
FPlayer fPlayer = null;
if (damager instanceof Player)
{
fPlayer = plugin.pl.getPlayerSync((Player) damager);
}
if (damager instanceof Projectile)
{
ProjectileSource ps = ((Projectile) damager).getShooter();
if (ps instanceof Player)
{
fPlayer = plugin.pl.getPlayerSync((Player) ps);
}
}
if (fPlayer == null || !fPlayer.isPvpBlocked())
{
return;
}
if (plugin.al.isAdminSync(event.getDamager()))
{
fPlayer.setPvpBlocked(false);
return;
}
Player player = (Player) damager;
event.setCancelled(true);
FSync.playerMsg(player, ChatColor.RED + "You have been disallowed from PvPing!");
}
}

View File

@ -1,89 +0,0 @@
package me.totalfreedom.totalfreedommod;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.projectiles.ProjectileSource;
public class PvpMonitor extends FreedomService {
public PvpMonitor(TotalFreedomMod plugin) {
super(plugin);
}
@Override
protected void onStart() {
}
@Override
protected void onStop() {
}
@EventHandler(priority = EventPriority.LOW)
public void hit(final EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity entity = event.getEntity();
// This checks if the player is actually hitting a other player with any item , it filters his gamemode.
if (damager instanceof Player && entity instanceof Player) {
final Player player = (Player) damager;
// Bypasses the block if Player is actually a Supered-Admin.
if (plugin.al.isAdmin((player))) {
return;
}
// Checks 4 cases
if (player.getGameMode() == GameMode.CREATIVE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on creative and god mode on.
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP with God Mode and creative!");
event.setCancelled(true);
} else if (player.getGameMode() == GameMode.CREATIVE && !plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on creative and god mode off.
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP in creative!");
event.setCancelled(true);
} else if (player.getGameMode() == GameMode.SURVIVAL && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on survival with god mode on.
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
} else if (player.getGameMode() == GameMode.ADVENTURE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on Adventure with god mode on.
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
}
}
// IF player shoots an arrow this prevents the damage if player is on creative or with godmode on.
if (damager instanceof Projectile && entity instanceof Player) {
ProjectileSource ps = ((Projectile) damager).getShooter();
Player player = (Player) ps;
// Bypasses the block if Player is actually a Supered-Admin.
if (plugin.al.isAdmin((player))) {
return;
}
if (player.getGameMode() == GameMode.CREATIVE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on creative and god mode on.
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP with God Mode and creative!");
event.setCancelled(true);
} else if (player.getGameMode() == GameMode.CREATIVE && !plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on creative and god mode off.
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP in creative!");
event.setCancelled(true);
} else if (player.getGameMode() == GameMode.SURVIVAL && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on survival with god mode on.
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
} else if (player.getGameMode() == GameMode.ADVENTURE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { // This checks if player is on Adventure with god mode on.
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
}
}
}
}

View File

@ -32,7 +32,7 @@ public class ServerInterface extends FreedomService
public static void warnVersion()
{
final String nms = FUtil.getNmsVersion();
final String nms = FUtil.getNMSVersion();
if (!COMPILE_NMS_VERSION.equals(nms))
{

View File

@ -9,12 +9,15 @@ import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.banning.BanManager;
import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
import me.totalfreedom.totalfreedommod.blocking.PVPBlocker;
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
import me.totalfreedom.totalfreedommod.blocking.SignBlocker;
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
@ -66,16 +69,12 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public CommandLoader cl;
public CommandBlocker cb;
public EventBlocker eb;
public ChestMonitor cmon;
public BlockBlocker bb;
public MobBlocker mb;
public InteractBlocker ib;
public PotionBlocker pb;
public LoginProcess lp;
public AntiNuke nu;
public PotionMonitorer pmn;
public DropMonitor dmn;
public PvpMonitor pvp;
public AntiSpam as;
public PlayerList pl;
public Announcer an;
@ -89,7 +88,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public Cager ca;
public Freezer fm;
public EditBlocker ebl;
public PvPBlocker pbl;
public PVPBlocker pbl;
public Orbiter or;
public Muter mu;
public Fuckoff fo;
@ -105,7 +104,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public Jumppads jp;
public Trailer tr;
public HTTPDaemon hd;
public SignPatch snp;
public SignBlocker snp;
//
// Bridges
public ServiceManager<TotalFreedomMod> bridges;
@ -182,24 +181,20 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
pa = services.registerService(ProtectArea.class);
gr = services.registerService(GameRuleHandler.class);
snp = services.registerService(SignPatch.class);
snp = services.registerService(SignBlocker.class);
// Single admin utils
rb = services.registerService(RollbackManager.class);
pmn = services.registerService(PotionMonitorer.class);
cs = services.registerService(CommandSpy.class);
ca = services.registerService(Cager.class);
fm = services.registerService(Freezer.class);
or = services.registerService(Orbiter.class);
mu = services.registerService(Muter.class);
ebl = services.registerService(EditBlocker.class);
pbl = services.registerService(PvPBlocker.class);
pbl = services.registerService(PVPBlocker.class);
fo = services.registerService(Fuckoff.class);
ak = services.registerService(AutoKick.class);
ae = services.registerService(AutoEject.class);
dmn = services.registerService(DropMonitor.class);
cmon = services.registerService(ChestMonitor.class);
pvp = services.registerService(PvpMonitor.class);
mv = services.registerService(MovementValidator.class);

View File

@ -1,5 +1,7 @@
package me.totalfreedom.totalfreedommod;
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
@ -27,7 +29,7 @@ public class EditBlocker extends FreedomService
}
@EventHandler(priority = EventPriority.LOW)
public void BlockPlaceEvent(BlockPlaceEvent event)
public void onBlockPlace(BlockPlaceEvent event)
{
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
if (!fPlayer.isEditBlocked())
@ -46,7 +48,7 @@ public class EditBlocker extends FreedomService
}
@EventHandler(priority = EventPriority.LOW)
public void BlockBreakEvent(BlockBreakEvent event)
public void onBlockBreak(BlockBreakEvent event)
{
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
if (!fPlayer.isEditBlocked())

View File

@ -0,0 +1,139 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.projectiles.ProjectileSource;
public class PVPBlocker extends FreedomService
{
public PVPBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOW)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{
Entity damager = event.getDamager();
FPlayer fPlayer = null;
if (damager instanceof Player)
{
fPlayer = plugin.pl.getPlayerSync((Player) damager);
}
if (damager instanceof Projectile)
{
ProjectileSource projectileSource = ((Projectile) damager).getShooter();
if (projectileSource instanceof Player)
{
fPlayer = plugin.pl.getPlayerSync((Player) projectileSource);
}
}
if (fPlayer == null || !fPlayer.isPvpBlocked())
{
return;
}
if (plugin.al.isAdminSync(event.getDamager()))
{
fPlayer.setPvpBlocked(false);
return;
}
Player player = (Player) damager;
event.setCancelled(true);
FSync.playerMsg(player, ChatColor.RED + "You are forbidden to engage in PVP combat.");
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerAttack(final EntityDamageByEntityEvent event)
{
final Entity damager = event.getDamager();
final Entity entity = event.getEntity();
if (damager instanceof Player && entity instanceof Player)
{
final Player player = (Player) damager;
if (plugin.al.isAdmin((player)))
{
return;
}
if (player.getGameMode() == GameMode.CREATIVE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP with God Mode and creative!");
event.setCancelled(true);
}
else if (player.getGameMode() == GameMode.CREATIVE && !plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP in creative!");
event.setCancelled(true);
}
else if (player.getGameMode() == GameMode.SURVIVAL && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
}
else if (player.getGameMode() == GameMode.ADVENTURE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
}
}
if (damager instanceof Projectile && entity instanceof Player)
{
ProjectileSource projectileSource = ((Projectile) damager).getShooter();
Player player = (Player) projectileSource;
if (plugin.al.isAdmin((player)))
{
return;
}
if (player.getGameMode() == GameMode.CREATIVE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP with God Mode and creative!");
event.setCancelled(true);
}
else if (player.getGameMode() == GameMode.CREATIVE && !plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You cannot PVP in creative!");
event.setCancelled(true);
}
else if (player.getGameMode() == GameMode.SURVIVAL && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
}
else if (player.getGameMode() == GameMode.ADVENTURE && plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
{
player.sendMessage(ChatColor.RED + "Hey! You can't PVP with godmode!");
event.setCancelled(true);
}
}
}
}

View File

@ -1,5 +1,7 @@
package me.totalfreedom.totalfreedommod;
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -13,10 +15,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class SignPatch extends FreedomService
public class SignBlocker extends FreedomService
{
public SignPatch(TotalFreedomMod plugin)
public SignBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@ -32,7 +34,7 @@ public class SignPatch extends FreedomService
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayePlaceBlock(BlockPlaceEvent event)
public void onPlayerPlaceBlock(BlockPlaceEvent event)
{
final Player player = event.getPlayer();

View File

@ -11,7 +11,7 @@ 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")
@CommandParameters(description = "Restricts/unrestricts block modification abilities", usage = "/<command> [[-s] <player> [reason] | list | purge | all]")
public class Command_blockedit extends FreedomCommand
{
@ -25,14 +25,14 @@ public class Command_blockedit extends FreedomCommand
if (args[0].equals("list"))
{
msg("Block edits blocked for players:");
msg("The following have block modification abilities restricted:");
int count = 0;
for (Player mp : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
final FPlayer info = plugin.pl.getPlayer(player);
if (info.isEditBlocked())
{
msg("- " + mp.getName());
msg("- " + player.getName());
++count;
}
}
@ -46,24 +46,24 @@ public class Command_blockedit extends FreedomCommand
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Unblocking block edits for all players.", true);
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
int count = 0;
for (final Player mp : this.server.getOnlinePlayers())
for (final Player player : this.server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
final FPlayer info = plugin.pl.getPlayer(player);
if (info.isEditBlocked())
{
info.setEditBlocked(false);
++count;
}
}
msg("Unblocked all block edit for " + count + " players.");
msg("Unblocked all block modification abilities for " + count + " players.");
return true;
}
if (args[0].equals("all"))
{
FUtil.adminAction(sender.getName(), "Blocking block edits for all non-admins.", true);
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins.", true);
int counter = 0;
for (final Player player : this.server.getOnlinePlayers())
{
@ -75,7 +75,7 @@ public class Command_blockedit extends FreedomCommand
}
}
msg("Blocked block edits for " + counter + " players.");
msg("Blocked block modification abilities for " + counter + " players.");
return true;
}
@ -102,13 +102,13 @@ public class Command_blockedit extends FreedomCommand
reason = StringUtils.join((Object[]) args, " ", 1, args.length);
}
final FPlayer playerdata2 = plugin.pl.getPlayer(player2);
if (playerdata2.isEditBlocked())
final FPlayer pd = plugin.pl.getPlayer(player2);
if (pd.isEditBlocked())
{
FUtil.adminAction(sender.getName(), "Unblocking block edits for " + player2.getName(), true);
playerdata2.setEditBlocked(false);
msg("Unblocking block edits for " + player2.getName());
msg(player2, "Your block edits have been unblocked.", ChatColor.RED);
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
pd.setEditBlocked(false);
msg("Unblocking block modification abilities for " + player2.getName());
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
}
else
{
@ -118,16 +118,16 @@ public class Command_blockedit extends FreedomCommand
return true;
}
FUtil.adminAction(sender.getName(), "Blocking block edits for " + player2.getName(), true);
playerdata2.setEditBlocked(true);
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
pd.setEditBlocked(true);
if (smite)
{
Command_smite.smite(sender, player2, reason);
}
msg(player2, "Your block edits have been blocked.", ChatColor.RED);
msg("Blocked all block edits for " + player2.getName());
msg(player2, "Your block modification abilities have been blocked.", ChatColor.RED);
msg("Blocked all block modification abilities for " + player2.getName());
}
return true;
}

View File

@ -11,7 +11,7 @@ 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")
@CommandParameters(description = "Toggle PVP mode for players.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode")
public class Command_blockpvp extends FreedomCommand
{
@ -25,21 +25,21 @@ public class Command_blockpvp extends FreedomCommand
if (args[0].equals("list"))
{
this.msg("PVP is blocked for players:");
msg("PVP is blocked for players:");
int count = 0;
for (Player mp : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
final FPlayer info = plugin.pl.getPlayer(player);
if (info.isPvpBlocked())
{
msg(" - " + mp.getName());
msg(" - " + player.getName());
++count;
}
}
if (count == 0)
{
this.msg(" - none");
msg(" - none");
}
return true;
}
@ -48,9 +48,9 @@ public class Command_blockpvp extends FreedomCommand
{
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
int count = 0;
for (Player mp : this.server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
final FPlayer info = plugin.pl.getPlayer(mp);
final FPlayer info = plugin.pl.getPlayer(player);
if (info.isPvpBlocked())
{
info.setPvpBlocked(false);
@ -90,8 +90,8 @@ public class Command_blockpvp extends FreedomCommand
}
}
final Player player2 = getPlayer(args[0]);
if (player2 == null)
final Player p = getPlayer(args[0]);
if (p == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
@ -103,31 +103,31 @@ public class Command_blockpvp extends FreedomCommand
reason = StringUtils.join(args, " ", 1, args.length);
}
final FPlayer playerdata2 = plugin.pl.getPlayer(player2);
if (playerdata2.isPvpBlocked())
final FPlayer pd = plugin.pl.getPlayer(p);
if (pd.isPvpBlocked())
{
FUtil.adminAction(sender.getName(), "Enabling PVP for " + player2.getName(), true);
playerdata2.setPvpBlocked(false);
msg("Enabling PVP for " + player2.getName());
msg((CommandSender) player2, "Your PVP have been enabled.", ChatColor.GREEN);
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
pd.setPvpBlocked(false);
msg("Enabling PVP for " + p.getName());
msg((CommandSender) p, "Your PVP have been enabled.", ChatColor.GREEN);
}
else
{
if (plugin.al.isAdmin((CommandSender) player2))
if (plugin.al.isAdmin((CommandSender) p))
{
this.msg(player2.getName() + " is an admin, and his PVP cannot be disabled.");
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
return true;
}
FUtil.adminAction(sender.getName(), "Disabling PVP for " + player2.getName(), true);
playerdata2.setPvpBlocked(true);
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
pd.setPvpBlocked(true);
if (smite)
{
Command_smite.smite(sender, player2, reason);
Command_smite.smite(sender, p, reason);
}
msg(player2, "Your PVP has been disabled.", ChatColor.RED);
msg("Disabled PVP for " + player2.getName());
msg(p, "Your PVP has been disabled.", ChatColor.RED);
msg("Disabled PVP for " + p.getName());
}
return true;
}

View File

@ -1,23 +0,0 @@
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.setChestMonitorEnabled(!playerdata.isChestMonitorEnabled());
msg("ChestSpy " + (playerdata.isChestMonitorEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -1,23 +0,0 @@
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.setDropMonitorEnabled(!playerdata.isDropMonitorEnabled());
msg("DropSpy " + (playerdata.isDropMonitorEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -1,10 +1,10 @@
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;
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>")

View File

@ -1,23 +0,0 @@
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 potions", usage = "/<command>", aliases = "potspy")
public class Command_potionspy 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.setPotionMonitorEnabled(!playerdata.isPotionMonitorEnabled());
msg("PotionSpy " + (playerdata.isPotionMonitorEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -10,16 +10,19 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Unloads chunks not currently in use", usage = "/<command>", aliases = "rc")
public class Command_unloadchunks extends FreedomCommand {
@CommandParameters(description = "Unloads chunks not currently in use", usage = "/<command>", aliases = "uc")
public class Command_unloadchunks extends FreedomCommand
{
@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)
{
FUtil.adminAction(sender.getName(), "Unloading unused chunks", false);
int numChunks = 0;
for (World world : server.getWorlds()) {
for (World world : server.getWorlds())
{
numChunks += unloadUnusedChunks(world);
}
@ -27,14 +30,15 @@ public class Command_unloadchunks extends FreedomCommand {
return true;
}
private int unloadUnusedChunks(World world) {
private int unloadUnusedChunks(World world)
{
int numChunks = 0;
for (Chunk loadedChunk : world.getLoadedChunks()) {
if (!world.isChunkInUse(loadedChunk.getX(), loadedChunk.getZ())) {
if (world.unloadChunk(loadedChunk)) {
numChunks++;
}
for (Chunk loadedChunk : world.getLoadedChunks())
{
if (!world.isChunkInUse(loadedChunk.getX(), loadedChunk.getZ()) && world.unloadChunk(loadedChunk))
{
numChunks++;
}
}

View File

@ -68,21 +68,12 @@ public class FPlayer
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

@ -415,7 +415,7 @@ public class FUtil
return date.getTime() / 1000L;
}
public static String getNmsVersion()
public static String getNMSVersion()
{
String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1);

View File

@ -19,7 +19,7 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
public class History
{
public static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static void reportHistory(final CommandSender sender, final String username)
{
@ -74,7 +74,7 @@ public class History
for (int i = 1; i < oldNames.length; i++)
{
Date date = new Date(oldNames[i].getChangedToAt());
String formattedDate = df.format(date);
String formattedDate = dateFormat.format(date);
FSync.playerMsg(sender, ChatColor.BLUE + formattedDate + ChatColor.GOLD + " changed to " + ChatColor.GREEN + oldNames[i].getName());
}
}