mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-17 12:56:11 +00:00
ed2f15cc54
1. Remove marco from dev 2. Add namehistory 3. Fix grammar issues 4. Actually use CoreProtect bridge to rollback players 5. Improve automatic wiper
105 lines
3.6 KiB
Java
105 lines
3.6 KiB
Java
package me.totalfreedom.totalfreedommod.blocking;
|
|
|
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.EventPriority;
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
public class BlockBlocker extends FreedomService
|
|
{
|
|
|
|
public BlockBlocker(TotalFreedomMod plugin)
|
|
{
|
|
super(plugin);
|
|
}
|
|
|
|
@Override
|
|
protected void onStart()
|
|
{
|
|
}
|
|
|
|
@Override
|
|
protected void onStop()
|
|
{
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onBlockPlace(BlockPlaceEvent event)
|
|
{
|
|
final Player player = event.getPlayer();
|
|
|
|
switch (event.getBlockPlaced().getType())
|
|
{
|
|
case LAVA:
|
|
case STATIONARY_LAVA:
|
|
{
|
|
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
|
{
|
|
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
}
|
|
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;
|
|
}
|
|
case WATER:
|
|
case STATIONARY_WATER:
|
|
{
|
|
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
|
{
|
|
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
}
|
|
else
|
|
{
|
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
|
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
|
|
|
event.setCancelled(true);
|
|
}
|
|
break;
|
|
}
|
|
case FIRE:
|
|
{
|
|
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
|
{
|
|
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
}
|
|
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;
|
|
}
|
|
case TNT:
|
|
{
|
|
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
{
|
|
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
}
|
|
break;
|
|
}
|
|
case STRUCTURE_BLOCK:
|
|
{
|
|
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
|
event.setCancelled(true);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|