mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-01-19 16:59:36 +01:00
Cleanup
This commit is contained in:
parent
c09c5b048e
commit
ec80151cd9
@ -30,11 +30,13 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
|||||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.listeners.ChunkListener;
|
import com.intellectualcrafters.plot.listeners.ChunkListener;
|
||||||
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
||||||
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
||||||
|
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
||||||
import com.intellectualcrafters.plot.listeners.TNTListener;
|
import com.intellectualcrafters.plot.listeners.TNTListener;
|
||||||
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
||||||
@ -107,13 +109,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
} else {
|
} else {
|
||||||
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
|
||||||
|
|
||||||
// Experimental
|
|
||||||
if (Settings.CHUNK_PROCESSOR) {
|
|
||||||
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<World> worlds = Bukkit.getWorlds();
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
if (worlds.size() > 0) {
|
if (worlds.size() > 0) {
|
||||||
UUIDHandler.cacheAll(worlds.get(0).getName());
|
UUIDHandler.cacheAll(worlds.get(0).getName());
|
||||||
@ -398,4 +393,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
public void unregister(PlotPlayer player) {
|
public void unregister(PlotPlayer player) {
|
||||||
BukkitUtil.removePlayer(player.getName());
|
BukkitUtil.removePlayer(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public APlotListener initPlotListener() {
|
||||||
|
return new PlotListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerChunkProcessor() {
|
||||||
|
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerWorldEvents() {
|
||||||
|
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import net.milkbowl.vault.economy.Economy;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -61,4 +62,10 @@ public interface IPlotMain {
|
|||||||
public void unregister(PlotPlayer player);
|
public void unregister(PlotPlayer player);
|
||||||
|
|
||||||
public ChunkGenerator getGenerator(String world, String name);
|
public ChunkGenerator getGenerator(String world, String name);
|
||||||
|
|
||||||
|
public APlotListener initPlotListener();
|
||||||
|
|
||||||
|
public void registerChunkProcessor();
|
||||||
|
|
||||||
|
public void registerWorldEvents();
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
||||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
@ -528,6 +529,10 @@ public class PlotSquared {
|
|||||||
IMP.registerPlotPlusEvents();
|
IMP.registerPlotPlusEvents();
|
||||||
IMP.registerForceFieldEvents();
|
IMP.registerForceFieldEvents();
|
||||||
IMP.registerWorldEditEvents();
|
IMP.registerWorldEditEvents();
|
||||||
|
IMP.registerWorldEvents();
|
||||||
|
if (Settings.CHUNK_PROCESSOR) {
|
||||||
|
IMP.registerChunkProcessor();
|
||||||
|
}
|
||||||
// create UUIDWrapper
|
// create UUIDWrapper
|
||||||
UUIDHandler.uuidWrapper = IMP.initUUIDHandler();
|
UUIDHandler.uuidWrapper = IMP.initUUIDHandler();
|
||||||
// create event util class
|
// create event util class
|
||||||
@ -540,6 +545,9 @@ public class PlotSquared {
|
|||||||
BlockManager.manager = IMP.initBlockManager();
|
BlockManager.manager = IMP.initBlockManager();
|
||||||
// Set chunk
|
// Set chunk
|
||||||
ChunkManager.manager = IMP.initChunkManager();
|
ChunkManager.manager = IMP.initChunkManager();
|
||||||
|
// Plot listener
|
||||||
|
APlotListener.manager = IMP.initPlotListener();
|
||||||
|
|
||||||
// PlotMe
|
// PlotMe
|
||||||
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.flag.AbstractFlag;
|
|||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -125,7 +125,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||||
PlotListener.plotEntry(player, plot);
|
APlotListener.manager.plotEntry(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "remove": {
|
case "remove": {
|
||||||
@ -163,7 +163,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||||
PlotListener.plotEntry(player, plot);
|
APlotListener.manager.plotEntry(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "add": {
|
case "add": {
|
||||||
@ -203,7 +203,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||||
PlotListener.plotEntry(player, plot);
|
APlotListener.manager.plotEntry(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "list": {
|
case "list": {
|
||||||
|
@ -23,12 +23,9 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
@ -42,7 +39,6 @@ import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
|||||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
public class SchematicCmd extends SubCommand {
|
public class SchematicCmd extends SubCommand {
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
|
@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
@ -90,8 +90,6 @@ public class Set extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TODO: Implement option */
|
|
||||||
// final boolean advanced_permissions = true;
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.set." + args[0].toLowerCase())) {
|
if (!Permissions.hasPermission(plr, "plots.set." + args[0].toLowerCase())) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
|
||||||
return false;
|
return false;
|
||||||
@ -127,7 +125,7 @@ public class Set extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.FLAG_REMOVED);
|
MainUtil.sendMessage(plr, C.FLAG_REMOVED);
|
||||||
PlotListener.plotEntry(plr, plot);
|
APlotListener.manager.plotEntry(plr, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -144,7 +142,7 @@ public class Set extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.FLAG_ADDED);
|
MainUtil.sendMessage(plr, C.FLAG_ADDED);
|
||||||
PlotListener.plotEntry(plr, plot);
|
APlotListener.manager.plotEntry(plr, plot);
|
||||||
return true;
|
return true;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
MainUtil.sendMessage(plr, "&c" + e.getMessage());
|
MainUtil.sendMessage(plr, "&c" + e.getMessage());
|
||||||
|
@ -22,9 +22,7 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.listeners.worldedit.WEListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.worldedit.WEManager;
|
import com.intellectualcrafters.plot.listeners.worldedit.WEManager;
|
||||||
import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
@ -95,15 +95,21 @@ public class SQLManager implements AbstractDB {
|
|||||||
// schedule reconnect
|
// schedule reconnect
|
||||||
if (PlotSquared.getMySQL() != null) {
|
if (PlotSquared.getMySQL() != null) {
|
||||||
TaskManager.runTaskRepeat(new Runnable() {
|
TaskManager.runTaskRepeat(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
System.out.print("CONNECTIN");
|
||||||
SQLManager.this.connection = PlotSquared.getMySQL().forceConnection();
|
SQLManager.this.connection = PlotSquared.getMySQL().forceConnection();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 11000);
|
});
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,18 @@ public class FlagManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
|
||||||
|
final Flag flag = FlagManager.getPlotFlag(plot, key);
|
||||||
|
if (flag == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
final Object value = flag.getValue();
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return (boolean) value;
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of a flag for a plot (respects flag defaults)
|
* Get the value of a flag for a plot (respects flag defaults)
|
||||||
* @param plot
|
* @param plot
|
||||||
|
@ -2,8 +2,8 @@ package com.intellectualcrafters.plot.generator;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.intellectualcrafters.plot.listeners;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
public abstract class APlotListener {
|
||||||
|
|
||||||
|
public static APlotListener manager;
|
||||||
|
|
||||||
|
public abstract void plotExit(final PlotPlayer player, final Plot plot);
|
||||||
|
|
||||||
|
public abstract void plotEntry(final PlotPlayer player, final Plot plot);
|
||||||
|
}
|
@ -3,14 +3,11 @@ package com.intellectualcrafters.plot.listeners;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
@ -105,7 +105,7 @@ public class ForceFieldListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
||||||
if (!PlotListener.booleanFlag(plot, "forcefield", false)) {
|
if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
|
||||||
final UUID uuid = pp.getUUID();
|
final UUID uuid = pp.getUUID();
|
||||||
if (plot.isAdded(uuid)) {
|
if (plot.isAdded(uuid)) {
|
||||||
final Set<Player> players = getNearbyPlayers(player, plot);
|
final Set<Player> players = getNearbyPlayers(player, plot);
|
||||||
|
@ -19,15 +19,10 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.entity.Fireball;
|
|
||||||
import org.bukkit.entity.FishHook;
|
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.LargeFireball;
|
|
||||||
import org.bukkit.entity.Monster;
|
import org.bukkit.entity.Monster;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.SmallFireball;
|
|
||||||
import org.bukkit.entity.Snowball;
|
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.ThrownPotion;
|
import org.bukkit.entity.ThrownPotion;
|
||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
@ -86,7 +81,6 @@ import com.intellectualcrafters.plot.config.Settings;
|
|||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.listeners.worldedit.WEListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.worldedit.WEManager;
|
import com.intellectualcrafters.plot.listeners.worldedit.WEManager;
|
||||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
@ -115,10 +109,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|||||||
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onRedstoneEvent(BlockRedstoneEvent event) {
|
public void onRedstoneEvent(BlockRedstoneEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
if (!isPlotWorld(loc.getWorld())) {
|
if (!PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = MainUtil.getPlot(loc);
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
@ -129,7 +123,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (redstone == null || (Boolean) redstone.getValue()) {
|
if (redstone == null || (Boolean) redstone.getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isPlotArea(loc)) {
|
if (!MainUtil.isPlotArea(plot)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
@ -166,10 +160,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onPhysicsEvent(BlockPhysicsEvent event) {
|
public void onPhysicsEvent(BlockPhysicsEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
if (!isPlotWorld(loc.getWorld())) {
|
if (!PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
@ -183,7 +177,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (redstone == null || (Boolean) redstone.getValue()) {
|
if (redstone == null || (Boolean) redstone.getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isPlotArea(loc)) {
|
if (!MainUtil.isPlotArea(plot)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -196,11 +190,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
public void onProjectileHit(ProjectileHitEvent event) {
|
public void onProjectileHit(ProjectileHitEvent event) {
|
||||||
Projectile entity = (Projectile) event.getEntity();
|
Projectile entity = (Projectile) event.getEntity();
|
||||||
Location loc = BukkitUtil.getLocation(entity);
|
Location loc = BukkitUtil.getLocation(entity);
|
||||||
if (!isPlotWorld(loc.getWorld())) {
|
if (!PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = MainUtil.getPlot(loc);
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
if (!isPlotArea(loc)) {
|
if (!MainUtil.isPlotArea(loc)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProjectileSource shooter = entity.getShooter();
|
ProjectileSource shooter = entity.getShooter();
|
||||||
@ -252,7 +246,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onChunkLoad(final ChunkLoadEvent event) {
|
public void onChunkLoad(final ChunkLoadEvent event) {
|
||||||
final String worldname = event.getWorld().getName();
|
final String worldname = event.getWorld().getName();
|
||||||
final Chunk chunk = event.getChunk();
|
final Chunk chunk = event.getChunk();
|
||||||
if (MainUtil.worldBorder.containsKey(worldname)) {
|
if (MainUtil.worldBorder.containsKey(worldname)) {
|
||||||
@ -266,7 +260,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onJoin(final PlayerJoinEvent event) {
|
public void onJoin(final PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (!player.hasPlayedBefore()) {
|
if (!player.hasPlayedBefore()) {
|
||||||
player.saveData();
|
player.saveData();
|
||||||
@ -289,7 +283,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public static void PlayerMove(final PlayerMoveEvent event) {
|
public void PlayerMove(final PlayerMoveEvent event) {
|
||||||
final Location f = BukkitUtil.getLocation(event.getFrom());
|
final Location f = BukkitUtil.getLocation(event.getFrom());
|
||||||
final Location t = BukkitUtil.getLocation(event.getTo());
|
final Location t = BukkitUtil.getLocation(event.getTo());
|
||||||
if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) {
|
if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) {
|
||||||
@ -298,7 +292,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
TaskManager.TELEPORT_QUEUE.remove(player.getName());
|
TaskManager.TELEPORT_QUEUE.remove(player.getName());
|
||||||
}
|
}
|
||||||
final String worldname = t.getWorld();
|
final String worldname = t.getWorld();
|
||||||
if (!isPlotWorld(worldname)) {
|
if (!PlotSquared.isPlotWorld(worldname)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MainUtil.worldBorder.containsKey(worldname)) {
|
if (MainUtil.worldBorder.containsKey(worldname)) {
|
||||||
@ -322,7 +316,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Plot plot = getCurrentPlot(t);
|
Plot plot = MainUtil.getPlot(t);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (plot.denied.size() > 0) {
|
if (plot.denied.size() > 0) {
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
@ -334,22 +328,22 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.equals(getCurrentPlot(f))) {
|
if (!plot.equals(MainUtil.getPlot(f))) {
|
||||||
plotEntry(player, plot);
|
plotEntry(player, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (leftPlot(f, t)) {
|
else if (MainUtil.leftPlot(f, t)) {
|
||||||
plot = getCurrentPlot(f);
|
plot = MainUtil.getPlot(f);
|
||||||
plotExit(player, plot);
|
plotExit(BukkitUtil.getPlayer(player), plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public static void onChat(final AsyncPlayerChatEvent event) {
|
public void onChat(final AsyncPlayerChatEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||||
@ -357,7 +351,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(player);
|
final Location loc = BukkitUtil.getLocation(player);
|
||||||
final Plot plot = getCurrentPlot(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -368,7 +362,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
final Set<Player> recipients = event.getRecipients();
|
final Set<Player> recipients = event.getRecipients();
|
||||||
recipients.clear();
|
recipients.clear();
|
||||||
for (final Player p : Bukkit.getOnlinePlayers()) {
|
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if (getCurrentPlot(BukkitUtil.getLocation(p)) == plot) {
|
if (MainUtil.getPlot(BukkitUtil.getLocation(p)) == plot) {
|
||||||
recipients.add(p);
|
recipients.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,14 +372,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public static void BlockDestroy(final BlockBreakEvent event) {
|
public void BlockDestroy(final BlockBreakEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||||
final Plot plot = getCurrentPlot(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (event.getBlock().getY() == 0) {
|
if (event.getBlock().getY() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -420,7 +414,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) {
|
if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -428,32 +422,32 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onBigBoom(final EntityExplodeEvent event) {
|
public void onBigBoom(final EntityExplodeEvent event) {
|
||||||
Location loc = BukkitUtil.getLocation(event.getLocation());
|
Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||||
final String world = loc.getWorld();
|
final String world = loc.getWorld();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Plot plot = getCurrentPlot(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
if ((plot != null) && plot.hasOwner()) {
|
if ((plot != null) && plot.hasOwner()) {
|
||||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||||
final Iterator<Block> iter = event.blockList().iterator();
|
final Iterator<Block> iter = event.blockList().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
final Block b = iter.next();
|
final Block b = iter.next();
|
||||||
if (!plot.equals(getCurrentPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
final Iterator<Block> iter = event.blockList().iterator();
|
final Iterator<Block> iter = event.blockList().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
iter.next();
|
iter.next();
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,7 +455,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onWorldChanged(final PlayerChangedWorldEvent event) {
|
public void onWorldChanged(final PlayerChangedWorldEvent event) {
|
||||||
final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer());
|
final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer());
|
||||||
if (PlotSquared.worldEdit != null) {
|
if (PlotSquared.worldEdit != null) {
|
||||||
WEManager.bypass.remove(player.getName());
|
WEManager.bypass.remove(player.getName());
|
||||||
@ -471,9 +465,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) {
|
public void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) {
|
||||||
final String world = event.getBlock().getWorld().getName();
|
final String world = event.getBlock().getWorld().getName();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Entity e = event.getEntity();
|
final Entity e = event.getEntity();
|
||||||
@ -486,16 +480,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
final Block b = event.getBlock();
|
final Block b = event.getBlock();
|
||||||
final Player p = (Player) e;
|
final Player p = (Player) e;
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (!isInPlot(loc)) {
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot == null) {
|
||||||
|
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(loc);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned");
|
||||||
@ -506,7 +502,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!plot.isAdded(pp.getUUID())) {
|
if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -519,63 +515,57 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onEntityBlockForm(final EntityBlockFormEvent e) {
|
public void onEntityBlockForm(final EntityBlockFormEvent e) {
|
||||||
final String world = e.getBlock().getWorld().getName();
|
final String world = e.getBlock().getWorld().getName();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((!(e.getEntity() instanceof Player))) {
|
if ((!(e.getEntity() instanceof Player))) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
if (MainUtil.isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onBS(final BlockSpreadEvent e) {
|
public void onBS(final BlockSpreadEvent e) {
|
||||||
final Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
if (!isInPlot(loc)) {
|
if (MainUtil.isPlotRoad(loc)) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onBF(final BlockFormEvent e) {
|
public void onBF(final BlockFormEvent e) {
|
||||||
final Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
if (!isInPlot(loc)) {
|
if (MainUtil.isPlotRoad(loc)) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onBD(final BlockDamageEvent event) {
|
public void onBD(final BlockDamageEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
if (!isInPlot(loc)) {
|
if (MainUtil.isPlotRoad(loc)) {
|
||||||
if (isPlotArea(loc)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||||
final Plot plot = getCurrentPlot(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (event.getBlock().getY() == 0) {
|
if (event.getBlock().getY() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -610,7 +600,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) {
|
if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -618,46 +608,40 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onFade(final BlockFadeEvent e) {
|
public void onFade(final BlockFadeEvent e) {
|
||||||
final Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
if (!isInPlot(loc)) {
|
if (MainUtil.isPlotRoad(loc)) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onChange(final BlockFromToEvent e) {
|
public void onChange(final BlockFromToEvent e) {
|
||||||
final Block b = e.getToBlock();
|
final Block b = e.getToBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
if (!isInPlot(loc)) {
|
if (MainUtil.isPlotRoad(loc)) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onGrow(final BlockGrowEvent e) {
|
public void onGrow(final BlockGrowEvent e) {
|
||||||
final Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
if (!isInPlot(loc)) {
|
if (MainUtil.isPlotRoad(loc)) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public static void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
String world = loc.getWorld();
|
String world = loc.getWorld();
|
||||||
@ -671,7 +655,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
for (final Block b : blocks) {
|
for (final Block b : blocks) {
|
||||||
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
|
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
|
||||||
Plot newPlot = MainUtil.getPlot(bloc);
|
Plot newPlot = MainUtil.getPlot(bloc);
|
||||||
if (MainUtil.equals(plot, newPlot)) {
|
if (!MainUtil.equals(plot, newPlot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -698,23 +682,41 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean pistonBlocks = true;
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public static void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
String world = loc.getWorld();
|
String world = loc.getWorld();
|
||||||
if (!PlotSquared.isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_MOVING_PIECE) {
|
if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_BASE && block.getType() != Material.PISTON_MOVING_PIECE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plot plot = MainUtil.getPlot(loc);
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot != null) {
|
|
||||||
|
if (pistonBlocks) {
|
||||||
|
try {
|
||||||
|
for (Block pulled : event.getBlocks()) {
|
||||||
|
Plot other = MainUtil.getPlot(BukkitUtil.getLocation(pulled.getLocation()));
|
||||||
|
if (!MainUtil.equals(plot, other)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
pistonBlocks = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!pistonBlocks && block.getType() != Material.PISTON_BASE) {
|
||||||
BlockFace dir = event.getDirection();
|
BlockFace dir = event.getDirection();
|
||||||
Location bloc = BukkitUtil.getLocation(block.getLocation().subtract(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
Location bloc = BukkitUtil.getLocation(block.getLocation().subtract(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
||||||
Plot newPlot = MainUtil.getPlot(bloc);
|
Plot newPlot = MainUtil.getPlot(bloc);
|
||||||
if (!plot.equals(newPlot)) {
|
if (!MainUtil.equals(plot, newPlot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -722,8 +724,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onStructureGrow(final StructureGrowEvent e) {
|
public void onStructureGrow(final StructureGrowEvent e) {
|
||||||
if (!isPlotWorld(e.getWorld().getName())) {
|
if (!PlotSquared.isPlotWorld(e.getWorld().getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<BlockState> blocks = e.getBlocks();
|
final List<BlockState> blocks = e.getBlocks();
|
||||||
@ -734,15 +736,15 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
BlockState start = blocks.get(0);
|
BlockState start = blocks.get(0);
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
||||||
final Plot plot = getCurrentPlot(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
if (MainUtil.equals(plot, origin)) {
|
if (!MainUtil.equals(plot, origin)) {
|
||||||
e.getBlocks().remove(i);
|
e.getBlocks().remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onInteract(final PlayerInteractEvent event) {
|
public void onInteract(final PlayerInteractEvent event) {
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
if (action == Action.LEFT_CLICK_BLOCK) {
|
if (action == Action.LEFT_CLICK_BLOCK) {
|
||||||
return;
|
return;
|
||||||
@ -753,12 +755,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(event.getClickedBlock().getLocation());
|
final Location loc = BukkitUtil.getLocation(event.getClickedBlock().getLocation());
|
||||||
if (isInPlot(loc)) {
|
|
||||||
final Plot plot = getCurrentPlot(loc);
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot != null) {
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
if (Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
if (Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
||||||
@ -791,7 +794,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
if (Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
if (action != Action.PHYSICAL) {
|
if (action != Action.PHYSICAL) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
|
||||||
}
|
}
|
||||||
@ -801,17 +804,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void MobSpawn(final CreatureSpawnEvent event) {
|
public void MobSpawn(final CreatureSpawnEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||||
final String world = loc.getWorld();
|
final String world = loc.getWorld();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isPlotArea(loc)) {
|
if (!MainUtil.isPlotArea(loc)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotWorld pW = PlotSquared.getPlotWorld(world);
|
final PlotWorld pW = PlotSquared.getPlotWorld(world);
|
||||||
@ -893,7 +896,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onBlockIgnite(final BlockIgniteEvent e) {
|
public void onBlockIgnite(final BlockIgniteEvent e) {
|
||||||
final Player player = e.getPlayer();
|
final Player player = e.getPlayer();
|
||||||
final Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
final Location loc;
|
final Location loc;
|
||||||
@ -922,7 +925,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) {
|
if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) {
|
||||||
@ -930,22 +933,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
if (!isInPlot(loc)) {
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot == null) {
|
||||||
|
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(loc);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned");
|
||||||
@ -956,7 +961,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!plot.isAdded(pp.getUUID())) {
|
if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -968,7 +973,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onTeleport(final PlayerTeleportEvent event) {
|
public void onTeleport(final PlayerTeleportEvent event) {
|
||||||
if (event.getTo() == null || event.getFrom() == null) {
|
if (event.getTo() == null || event.getFrom() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -976,26 +981,26 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
final Location t = BukkitUtil.getLocation(event.getTo());
|
final Location t = BukkitUtil.getLocation(event.getTo());
|
||||||
final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ());
|
final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ());
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (isPlotWorld(q)) {
|
if (PlotSquared.isPlotWorld(q.getWorld())) {
|
||||||
final Plot plot = getCurrentPlot(q);
|
final Plot plot = MainUtil.getPlot(q);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
if (plot.isDenied(pp.getUUID())) {
|
if (plot.isDenied(pp.getUUID())) {
|
||||||
if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) {
|
if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED);
|
MainUtil.sendMessage(pp, C.YOU_BE_DENIED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (enteredPlot(f, t)) {
|
if (MainUtil.enteredPlot(f, t)) {
|
||||||
plotEntry(player, plot);
|
plotEntry(player, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (leftPlot(f, t)) {
|
if (MainUtil.leftPlot(f, t)) {
|
||||||
final Plot plot2 = getCurrentPlot(f);
|
final Plot plot2 = MainUtil.getPlot(f);
|
||||||
plotExit(player, plot2);
|
APlotListener.manager.plotExit(BukkitUtil.getPlayer(player), plot2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
|
if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
|
||||||
@ -1006,22 +1011,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onBucketEmpty(final PlayerBucketEmptyEvent e) {
|
public void onBucketEmpty(final PlayerBucketEmptyEvent e) {
|
||||||
final BlockFace bf = e.getBlockFace();
|
final BlockFace bf = e.getBlockFace();
|
||||||
final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
|
final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||||
if (!isInPlot(loc)) {
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot == null) {
|
||||||
|
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||||
if (Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
if (Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(loc);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1036,7 +1043,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
if (Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1047,7 +1054,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public static void onInventoryClick(final InventoryClickEvent event) {
|
public void onInventoryClick(final InventoryClickEvent event) {
|
||||||
if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) {
|
if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1055,7 +1062,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onLeave(final PlayerQuitEvent event) {
|
public void onLeave(final PlayerQuitEvent event) {
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||||
EventUtil.unregisterPlayer(pp);
|
EventUtil.unregisterPlayer(pp);
|
||||||
if (PlotSquared.worldEdit != null) {
|
if (PlotSquared.worldEdit != null) {
|
||||||
@ -1074,22 +1081,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onBucketFill(final PlayerBucketFillEvent e) {
|
public void onBucketFill(final PlayerBucketFillEvent e) {
|
||||||
final Block b = e.getBlockClicked();
|
final Block b = e.getBlockClicked();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!isInPlot(loc)) {
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot == null) {
|
||||||
|
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||||
if (Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
if (Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(loc);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1105,7 +1114,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
if (Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1116,21 +1125,23 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onHangingPlace(final HangingPlaceEvent e) {
|
public void onHangingPlace(final HangingPlaceEvent e) {
|
||||||
final Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (isPlotWorld(loc)) {
|
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!isInPlot(loc)) {
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot == null) {
|
||||||
|
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(loc);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -1141,7 +1152,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.build.other")) {
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotArea(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1153,22 +1164,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) {
|
public void onHangingBreakByEntity(final HangingBreakByEntityEvent e) {
|
||||||
final Entity r = e.getRemover();
|
final Entity r = e.getRemover();
|
||||||
if (r instanceof Player) {
|
if (r instanceof Player) {
|
||||||
final Player p = (Player) r;
|
final Player p = (Player) r;
|
||||||
final Location l = BukkitUtil.getLocation(e.getEntity());
|
final Location l = BukkitUtil.getLocation(e.getEntity());
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (isPlotWorld(l)) {
|
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||||
if (!isInPlot(l)) {
|
Plot plot = MainUtil.getPlot(l);
|
||||||
|
if (plot == null) {
|
||||||
|
if (MainUtil.isPlotAreaAbs(l)) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.destroy.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(l);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.unowned");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -1179,7 +1192,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.destroy.other")) {
|
||||||
if (isPlotArea(l)) {
|
if (MainUtil.isPlotArea(l)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1192,13 +1205,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
|
public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
|
||||||
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
|
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
|
||||||
if (isPlotWorld(l)) {
|
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!isInPlot(l)) {
|
Plot plot = MainUtil.getPlot(l);
|
||||||
if (!isPlotArea(l)) {
|
if (plot == null) {
|
||||||
|
if (!MainUtil.isPlotAreaAbs(l)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||||
@ -1207,8 +1221,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(l);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -1229,7 +1242,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
|
||||||
if (isPlotArea(l)) {
|
if (MainUtil.isPlotArea(l)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1241,23 +1254,26 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onVehicleDestroy(final VehicleDestroyEvent e) {
|
public void onVehicleDestroy(final VehicleDestroyEvent e) {
|
||||||
final Location l = BukkitUtil.getLocation(e.getVehicle());
|
final Location l = BukkitUtil.getLocation(e.getVehicle());
|
||||||
if (isPlotWorld(l)) {
|
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||||
final Entity d = e.getAttacker();
|
final Entity d = e.getAttacker();
|
||||||
if (d instanceof Player) {
|
if (d instanceof Player) {
|
||||||
final Player p = (Player) d;
|
final Player p = (Player) d;
|
||||||
PlotSquared.getPlotWorld(l.getWorld());
|
PlotSquared.getPlotWorld(l.getWorld());
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!isInPlot(l)) {
|
Plot plot = MainUtil.getPlot(l);
|
||||||
|
if (plot == null) {
|
||||||
|
if (!MainUtil.isPlotAreaAbs(l)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(l);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -1270,7 +1286,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
|
||||||
if (isPlotArea(l)) {
|
if (MainUtil.isPlotArea(l)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1283,7 +1299,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) {
|
public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) {
|
||||||
final Location l = BukkitUtil.getLocation(e.getEntity());
|
final Location l = BukkitUtil.getLocation(e.getEntity());
|
||||||
final Entity damager = e.getDamager();
|
final Entity damager = e.getDamager();
|
||||||
final Entity victim = e.getEntity();
|
final Entity victim = e.getEntity();
|
||||||
@ -1294,7 +1310,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isPlotWorld(l)) {
|
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||||
Player p = null;
|
Player p = null;
|
||||||
Projectile projectile = null;
|
Projectile projectile = null;
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
@ -1339,7 +1355,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
} else if (aPlr && pW.PVP) {
|
} else if (aPlr && pW.PVP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isInPlot(l)) {
|
Plot plot = MainUtil.getPlot(l);
|
||||||
|
if (plot == null) {
|
||||||
|
if (!MainUtil.isPlotAreaAbs(l)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.pve.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.pve.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.road");
|
||||||
@ -1347,8 +1367,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(l);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.pve.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.pve.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.unowned");
|
||||||
@ -1358,10 +1377,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (aPlr && booleanFlag(plot, "pvp", false)) {
|
} else if (aPlr && FlagManager.isBooleanFlag(plot, "pvp", false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!aPlr && booleanFlag(plot, "pve", false)) {
|
if (!aPlr && FlagManager.isBooleanFlag(plot, "pve", false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
@ -1377,7 +1396,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.pve.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.pve.other")) {
|
||||||
if (isPlotArea(l)) {
|
if (MainUtil.isPlotArea(l)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.other");
|
||||||
if (projectile != null) {
|
if (projectile != null) {
|
||||||
projectile.remove();
|
projectile.remove();
|
||||||
@ -1390,27 +1409,30 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((damager instanceof Arrow) && isPlotArea(l) && (!(victim instanceof Creature))) {
|
if ((damager instanceof Arrow) && MainUtil.isPlotArea(l) && (!(victim instanceof Creature))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public static void onPlayerEggThrow(final PlayerEggThrowEvent e) {
|
public void onPlayerEggThrow(final PlayerEggThrowEvent e) {
|
||||||
final Location l = BukkitUtil.getLocation(e.getEgg().getLocation());
|
final Location l = BukkitUtil.getLocation(e.getEgg().getLocation());
|
||||||
if (isPlotWorld(l)) {
|
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
if (!isInPlot(l)) {
|
Plot plot = MainUtil.getPlot(l);
|
||||||
|
if (plot == null) {
|
||||||
|
if (!MainUtil.isPlotAreaAbs(l)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.road");
|
||||||
e.setHatching(false);
|
e.setHatching(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Plot plot = getCurrentPlot(l);
|
if (!plot.hasOwner()) {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.unowned");
|
||||||
e.setHatching(false);
|
e.setHatching(false);
|
||||||
@ -1418,7 +1440,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) {
|
||||||
if (isPlotArea(l)) {
|
if (MainUtil.isPlotArea(l)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.other");
|
||||||
e.setHatching(false);
|
e.setHatching(false);
|
||||||
return;
|
return;
|
||||||
@ -1433,7 +1455,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
public void BlockCreate(final BlockPlaceEvent event) {
|
public void BlockCreate(final BlockPlaceEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String world = player.getWorld().getName();
|
final String world = player.getWorld().getName();
|
||||||
if (!isPlotWorld(world)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
@ -1441,8 +1463,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||||
if (isInPlot(loc)) {
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
final Plot plot = getCurrentPlot(loc);
|
if (plot != null) {
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) {
|
||||||
return;
|
return;
|
||||||
@ -1465,8 +1487,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
else if (!Permissions.hasPermission(pp, "plots.admin.build.road")) {
|
||||||
if (isPlotArea(loc)) {
|
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
@ -25,29 +26,32 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
|
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
|
||||||
if (isPlotWorld(l)) {
|
String world = l.getWorld();
|
||||||
e.getPlayer();
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
return;
|
||||||
if (!isInPlot(l)) {
|
}
|
||||||
if (!isPlotArea(l)) {
|
Plot plot = MainUtil.getPlot(l);
|
||||||
|
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||||
|
if (plot == null) {
|
||||||
|
if (!MainUtil.isPlotArea(l)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
final Plot plot = MainUtil.getPlot(l);
|
else {
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
final UUID uuid = pp.getUUID();
|
final UUID uuid = pp.getUUID();
|
||||||
if (!plot.isAdded(uuid)) {
|
if (!plot.isAdded(uuid)) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
|
||||||
if (isPlotArea(l)) {
|
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -55,6 +59,4 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -37,56 +37,23 @@ import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
|||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlotListener {
|
public class PlotListener extends APlotListener {
|
||||||
public static void textures(final Player p) {
|
public void textures(final Player p) {
|
||||||
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld().getName())) {
|
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PlotSquared.isPlotWorld(p.getWorld().getName())) {
|
||||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean booleanFlag(final Plot plot, final String key, final boolean defaultValue) {
|
private String getName(final UUID id) {
|
||||||
final Flag flag = FlagManager.getPlotFlag(plot, key);
|
|
||||||
if (flag == null) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
final Object value = flag.getValue();
|
|
||||||
if (value instanceof Boolean) {
|
|
||||||
return (boolean) value;
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isInPlot(final String world, final int x, final int y, final int z) {
|
|
||||||
return (MainUtil.getPlot(new Location(world, x, y, z)) != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPlotWorld(final String world) {
|
|
||||||
return PlotSquared.isPlotWorld(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPlotArea(final Location location) {
|
|
||||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
|
||||||
if (plotworld.TYPE == 2) {
|
|
||||||
return ClusterManager.getCluster(location) != null;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getName(final UUID id) {
|
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
@ -97,39 +64,7 @@ public class PlotListener {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getUUID(final String name) {
|
private WeatherType getWeatherType(String str) {
|
||||||
return UUIDHandler.getUUID(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean enteredPlot(final Location l1, final Location l2) {
|
|
||||||
final PlotId p1 = MainUtil.getPlotId(l1);
|
|
||||||
final PlotId p2 = MainUtil.getPlotId(l2);
|
|
||||||
return (p2 != null) && ((p1 == null) || !p1.equals(p2));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean leftPlot(final Location l1, final Location l2) {
|
|
||||||
final PlotId p1 = MainUtil.getPlotId(l1);
|
|
||||||
final PlotId p2 = MainUtil.getPlotId(l2);
|
|
||||||
return (p1 != null) && ((p2 == null) || !p1.equals(p2));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPlotWorld(final Location l) {
|
|
||||||
return PlotSquared.isPlotWorld(l.getWorld());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isInPlot(final Location loc) {
|
|
||||||
return getCurrentPlot(loc) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Plot getCurrentPlot(final Location loc) {
|
|
||||||
final PlotId id = MainUtil.getPlotId(loc);
|
|
||||||
if (id == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return MainUtil.getPlot(loc.getWorld(), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static WeatherType getWeatherType(String str) {
|
|
||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
if (str.equals("rain")) {
|
if (str.equals("rain")) {
|
||||||
return WeatherType.DOWNFALL;
|
return WeatherType.DOWNFALL;
|
||||||
@ -138,7 +73,7 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GameMode getGameMode(final String str) {
|
private GameMode getGameMode(final String str) {
|
||||||
switch (str) {
|
switch (str) {
|
||||||
case "creative":
|
case "creative":
|
||||||
return GameMode.CREATIVE;
|
return GameMode.CREATIVE;
|
||||||
@ -151,11 +86,12 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void plotEntry(final PlotPlayer player, final Plot plot) {
|
public void plotEntry(final PlotPlayer player, final Plot plot) {
|
||||||
plotEntry(((BukkitPlayer) player).player, plot);
|
plotEntry(((BukkitPlayer) player).player, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void plotEntry(final Player player, final Plot plot) {
|
public void plotEntry(final Player pp, final Plot plot) {
|
||||||
|
Player player = ((BukkitPlayer) pp).player;
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode");
|
final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode");
|
||||||
if (gamemodeFlag != null) {
|
if (gamemodeFlag != null) {
|
||||||
@ -178,7 +114,7 @@ public class PlotListener {
|
|||||||
if (weatherFlag != null) {
|
if (weatherFlag != null) {
|
||||||
player.setPlayerWeather(getWeatherType(weatherFlag.getValueString()));
|
player.setPlayerWeather(getWeatherType(weatherFlag.getValueString()));
|
||||||
}
|
}
|
||||||
if ((booleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
|
if ((FlagManager.isBooleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
|
||||||
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "");
|
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "");
|
||||||
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
|
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
|
||||||
if (AbstractTitle.TITLE_CLASS != null) {
|
if (AbstractTitle.TITLE_CLASS != null) {
|
||||||
@ -192,11 +128,10 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void plotExit(final Player player, final Plot plot) {
|
public void plotExit(final PlotPlayer pp, final Plot plot) {
|
||||||
{
|
Player player = ((BukkitPlayer) pp).player;
|
||||||
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
||||||
Bukkit.getPluginManager().callEvent(callEvent);
|
Bukkit.getPluginManager().callEvent(callEvent);
|
||||||
}
|
|
||||||
if (FlagManager.getPlotFlag(plot, "fly") != null) {
|
if (FlagManager.getPlotFlag(plot, "fly") != null) {
|
||||||
player.setAllowFlight(Bukkit.getAllowFlight());
|
player.setAllowFlight(Bukkit.getAllowFlight());
|
||||||
}
|
}
|
||||||
@ -211,7 +146,7 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getFlagValue(final String value) {
|
public boolean getFlagValue(final String value) {
|
||||||
return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase());
|
return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (booleanFlag(plot, "instabreak", false)) {
|
if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
|
||||||
event.getBlock().breakNaturally();
|
event.getBlock().breakNaturally();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (booleanFlag(plot, "invincible", false)) {
|
if (FlagManager.isBooleanFlag(plot, "invincible", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final UUID uuid = pp.getUUID();
|
final UUID uuid = pp.getUUID();
|
||||||
if (plot.isAdded(uuid) && booleanFlag(plot, "drop-protection", false)) {
|
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final UUID uuid = pp.getUUID();
|
final UUID uuid = pp.getUUID();
|
||||||
if (plot.isAdded(uuid) && booleanFlag(plot, "item-drop", false)) {
|
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
if (FlagManager.getPlotFlag(plot, "greeting") != null) {
|
if (FlagManager.getPlotFlag(plot, "greeting") != null) {
|
||||||
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString()));
|
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString()));
|
||||||
}
|
}
|
||||||
if (booleanFlag(plot, "notify-enter", false)) {
|
if (FlagManager.isBooleanFlag(plot, "notify-enter", false)) {
|
||||||
final Player trespasser = event.getPlayer();
|
final Player trespasser = event.getPlayer();
|
||||||
final PlotPlayer pt = BukkitUtil.getPlayer(trespasser);
|
final PlotPlayer pt = BukkitUtil.getPlayer(trespasser);
|
||||||
if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) {
|
if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) {
|
||||||
@ -265,7 +265,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
if (healRunnable.containsKey(leaver)) {
|
if (healRunnable.containsKey(leaver)) {
|
||||||
healRunnable.remove(leaver);
|
healRunnable.remove(leaver);
|
||||||
}
|
}
|
||||||
if (booleanFlag(plot, "notify-leave", false)) {
|
if (FlagManager.isBooleanFlag(plot, "notify-leave", false)) {
|
||||||
if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) {
|
if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ package com.intellectualcrafters.plot.listeners.worldedit;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@ -16,26 +14,14 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
|
||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
|
||||||
|
|
||||||
public class WEListener implements Listener {
|
public class WEListener implements Listener {
|
||||||
|
|
||||||
|
@ -142,8 +142,8 @@ public class ClusterManager {
|
|||||||
return getCluster(plot.world, plot.id);
|
return getCluster(plot.world, plot.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlotCluster getCluster(final Location loc) {
|
public static PlotCluster getClusterAbs(final Location loc) {
|
||||||
final String world = loc.getWorld();
|
String world = loc.getWorld();
|
||||||
if ((last != null) && last.world.equals(world)) {
|
if ((last != null) && last.world.equals(world)) {
|
||||||
if (contains(last, loc)) {
|
if (contains(last, loc)) {
|
||||||
return last;
|
return last;
|
||||||
@ -165,6 +165,16 @@ public class ClusterManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlotCluster getCluster(final Location loc) {
|
||||||
|
final String world = loc.getWorld();
|
||||||
|
PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
|
PlotId id = manager.getPlotIdAbs(PlotSquared.getPlotWorld(world), loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
if (id != null) {
|
||||||
|
return getCluster(world, id);
|
||||||
|
}
|
||||||
|
return getClusterAbs(loc);
|
||||||
|
}
|
||||||
|
|
||||||
public static PlotCluster getCluster(final String world, final PlotId id) {
|
public static PlotCluster getCluster(final String world, final PlotId id) {
|
||||||
if ((last != null) && last.world.equals(world)) {
|
if ((last != null) && last.world.equals(world)) {
|
||||||
if (contains(last, id)) {
|
if (contains(last, id)) {
|
||||||
|
@ -58,6 +58,54 @@ public class MainUtil {
|
|||||||
public static HashMap<String, Integer> worldBorder = new HashMap<>();
|
public static HashMap<String, Integer> worldBorder = new HashMap<>();
|
||||||
static PseudoRandom random = new PseudoRandom();
|
static PseudoRandom random = new PseudoRandom();
|
||||||
|
|
||||||
|
public static boolean isPlotArea(final Location location) {
|
||||||
|
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||||
|
if (plotworld.TYPE == 2) {
|
||||||
|
return ClusterManager.getCluster(location) != null;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPlotAreaAbs(final Location location) {
|
||||||
|
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||||
|
if (plotworld.TYPE == 2) {
|
||||||
|
return ClusterManager.getClusterAbs(location) != null;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPlotRoad(final Location location) {
|
||||||
|
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||||
|
if (plotworld.TYPE == 2) {
|
||||||
|
PlotCluster cluster = ClusterManager.getCluster(location);
|
||||||
|
if (cluster == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotManager manager = PlotSquared.getPlotManager(location.getWorld());
|
||||||
|
return manager.getPlotId(plotworld, location.getX(), location.getY(), location.getZ()) == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPlotArea(final Plot plot) {
|
||||||
|
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||||
|
if (plotworld.TYPE == 2) {
|
||||||
|
return ClusterManager.getCluster(plot) != null;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean enteredPlot(final Location l1, final Location l2) {
|
||||||
|
final PlotId p1 = MainUtil.getPlotId(l1);
|
||||||
|
final PlotId p2 = MainUtil.getPlotId(l2);
|
||||||
|
return (p2 != null) && ((p1 == null) || !p1.equals(p2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean leftPlot(final Location l1, final Location l2) {
|
||||||
|
final PlotId p1 = MainUtil.getPlotId(l1);
|
||||||
|
final PlotId p2 = MainUtil.getPlotId(l2);
|
||||||
|
return (p1 != null) && ((p2 == null) || !p1.equals(p2));
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
||||||
|
|
||||||
final Plot plot1 = PlotSquared.getPlots(world).get(pos1);
|
final Plot plot1 = PlotSquared.getPlots(world).get(pos1);
|
||||||
|
@ -25,7 +25,6 @@ import com.intellectualcrafters.jnbt.NBTOutputStream;
|
|||||||
import com.intellectualcrafters.jnbt.ShortTag;
|
import com.intellectualcrafters.jnbt.ShortTag;
|
||||||
import com.intellectualcrafters.jnbt.Tag;
|
import com.intellectualcrafters.jnbt.Tag;
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.commands.SchematicCmd;
|
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
@ -7,7 +7,6 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
|
|
||||||
public class SetBlockQueue {
|
public class SetBlockQueue {
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
|
||||||
|
@ -46,13 +46,14 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.BukkitMain;
|
import com.intellectualcrafters.plot.BukkitMain;
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.entity.EntityWrapper;
|
import com.intellectualcrafters.plot.object.entity.EntityWrapper;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -771,8 +772,9 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (plot.id.equals(id)) {
|
if (plot.id.equals(id)) {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
final Player player = (Player) entity;
|
final Player player = (Player) entity;
|
||||||
BukkitUtil.getPlayer(player).teleport(MainUtil.getDefaultHome(plot));
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
PlotListener.plotExit(player, plot);
|
pp.teleport(MainUtil.getDefaultHome(plot));
|
||||||
|
APlotListener.manager.plotExit(pp, plot);
|
||||||
} else {
|
} else {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user