use of org.bukkit.Location in project TotalFreedomMod by TotalFreedom.
the class ProtectArea method isInProtectedArea.
public boolean isInProtectedArea(final Vector min, final Vector max, final String worldName) {
boolean doSave = false;
boolean inProtectedArea = false;
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
while (it.hasNext()) {
final SerializableProtectedRegion region = it.next().getValue();
Location regionCenter = null;
try {
regionCenter = region.getLocation();
} catch (SerializableProtectedRegion.CantFindWorldException ex) {
it.remove();
doSave = true;
continue;
}
if (regionCenter != null) {
if (worldName.equals(regionCenter.getWorld().getName())) {
if (cubeIntersectsSphere(min, max, regionCenter.toVector(), region.getRadius())) {
inProtectedArea = true;
break;
}
}
}
}
if (doSave) {
save();
}
return inProtectedArea;
}
use of org.bukkit.Location in project TotalFreedomMod by TotalFreedom.
the class ProtectArea method onBlockBreak.
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockBreak(BlockBreakEvent event) {
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean()) {
return;
}
final Player player = event.getPlayer();
if (plugin.al.isAdmin(player)) {
return;
}
final Location location = event.getBlock().getLocation();
if (isInProtectedArea(location)) {
event.setCancelled(true);
}
}
use of org.bukkit.Location in project TotalFreedomMod by TotalFreedom.
the class AntiNuke method onBlockPlace.
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) {
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean()) {
return;
}
Player player = event.getPlayer();
Location blockLocation = event.getBlock().getLocation();
FPlayer fPlayer = plugin.pl.getPlayer(player);
Location playerLocation = player.getLocation();
double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
boolean outOfRange = false;
if (!playerLocation.getWorld().equals(blockLocation.getWorld())) {
outOfRange = true;
} else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange)) {
outOfRange = true;
}
if (outOfRange) {
if (fPlayer.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger()) {
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
plugin.ae.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
fPlayer.resetFreecamPlaceCount();
event.setCancelled(true);
return;
}
}
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger()) {
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
plugin.ae.autoEject(player, "You are placing blocks too fast.");
fPlayer.resetBlockPlaceCount();
event.setCancelled(true);
}
}
use of org.bukkit.Location in project TotalFreedomMod by TotalFreedom.
the class Command_dispfill method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length == 2) {
int radius;
try {
radius = Math.max(5, Math.min(25, Integer.parseInt(args[0])));
} catch (NumberFormatException ex) {
sender.sendMessage("Invalid radius.");
return true;
}
final List<ItemStack> items = new ArrayList<>();
final String[] itemsRaw = StringUtils.split(args[1], ",");
for (final String searchItem : itemsRaw) {
Material material = Material.matchMaterial(searchItem);
if (material == null) {
try {
material = DepreciationAggregator.getMaterial(Integer.parseInt(searchItem));
} catch (NumberFormatException ex) {
}
}
if (material != null) {
items.add(new ItemStack(material, 64));
} else {
sender.sendMessage("Skipping invalid item: " + searchItem);
}
}
final ItemStack[] itemsArray = items.toArray(new ItemStack[items.size()]);
int affected = 0;
final Location centerLocation = playerSender.getLocation();
final Block centerBlock = centerLocation.getBlock();
for (int xOffset = -radius; xOffset <= radius; xOffset++) {
for (int yOffset = -radius; yOffset <= radius; yOffset++) {
for (int zOffset = -radius; zOffset <= radius; zOffset++) {
final Block targetBlock = centerBlock.getRelative(xOffset, yOffset, zOffset);
if (targetBlock.getLocation().distanceSquared(centerLocation) < (radius * radius)) {
if (targetBlock.getType().equals(Material.DISPENSER)) {
sender.sendMessage("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
setDispenserContents(targetBlock, itemsArray);
affected++;
}
}
}
}
}
sender.sendMessage("Done. " + affected + " dispenser(s) filled.");
} else {
return false;
}
return true;
}
use of org.bukkit.Location in project TotalFreedomMod by TotalFreedom.
the class Command_gtfo method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length == 0) {
return false;
}
final Player player = getPlayer(args[0]);
if (player == null) {
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
String reason = null;
if (args.length >= 2) {
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Undo WorldEdits
try {
plugin.web.undo(player, 15);
} catch (NoClassDefFoundError ex) {
}
// Rollback
plugin.rb.rollback(player.getName());
// Deop
player.setOp(false);
// Gamemode suvival
player.setGameMode(GameMode.SURVIVAL);
// Clear inventory
player.getInventory().clear();
// Strike with lightning
final Location targetPos = player.getLocation();
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
targetPos.getWorld().strikeLightning(strike_pos);
}
}
String ip = FUtil.getFuzzyIp(Ips.getIp(player));
// Broadcast
final StringBuilder bcast = new StringBuilder().append(ChatColor.RED).append("Banning: ").append(player.getName()).append(", IP: ").append(ip);
if (reason != null) {
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
}
FUtil.bcastMsg(bcast.toString());
// Ban player
plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason));
// Kick player
player.kickPlayer(ChatColor.RED + "GTFO");
return true;
}
Aggregations