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

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

View File

@ -12,12 +12,16 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent;
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.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
@ -71,7 +75,7 @@ public class EventBlocker extends FreedomService
{
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
event.setCancelled(true);
event.blockList().clear();
return;
}
@ -107,22 +111,28 @@ public class EventBlocker extends FreedomService
event.setDroppedExp(0);
}
}
//deprecated (buggy)
@EventHandler(priority = EventPriority.HIGH)
/* @EventHandler(priority = EventPriority.HIGH)
public void onProjectileHit(ProjectileHitEvent event)
{
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
if (ConfigEntry.MAKE_ARROW_EXPLOSIVE.getBoolean())
{
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)
public void onEntityDamage(EntityDamageEvent event)
public void onEntityDamage(EntityDamageEvent event
)
{
switch (event.getCause())
{
@ -150,7 +160,8 @@ public class EventBlocker extends FreedomService
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event)
public void onPlayerDropItem(PlayerDropItemEvent event
)
{
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
@ -164,9 +175,47 @@ public class EventBlocker extends FreedomService
}
@EventHandler(priority = EventPriority.NORMAL)
public void onLeavesDecay(LeavesDecayEvent event)
public void onLeavesDecay(LeavesDecayEvent event
)
{
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.HumanEntity;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
@ -65,40 +66,47 @@ public class MobBlocker extends FreedomService
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);
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))
else if (spawned instanceof Giant)
{
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;
@Getter
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);
}
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.action = action;
this.command = command;
this.subCommand = (subCommand == null ? null : subCommand.toLowerCase().trim());
this.message = (message == null || message.equals("_") ? "That command is blocked." : message);
this.subCommand = ((subCommand == null) ? null : subCommand.toLowerCase().trim());
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
}
public void doActions(CommandSender sender)
{
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TotalFreedomMod.plugin().ae.autoEject((Player) sender, "You used a prohibited command: " + command);
public void doActions(final CommandSender sender) {
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player) {
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + this.command);
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
return;
}
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
{
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN) {
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
return;
}
FUtil.playerMsg(sender, FUtil.colorize(message));
FUtil.playerMsg(sender, FUtil.colorize(this.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;
}
}