mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Various changes
Plot class is now more reliable as most fields are private Cleanup some classes. Fixes #955 makes progress on #953
This commit is contained in:
@ -12,23 +12,74 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotQueue;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
||||
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.plotsquared.bukkit.listeners.*;
|
||||
import com.plotsquared.bukkit.listeners.ChunkListener;
|
||||
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
|
||||
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
||||
import com.plotsquared.bukkit.titles.DefaultTitle_19;
|
||||
import com.plotsquared.bukkit.util.*;
|
||||
import com.plotsquared.bukkit.util.block.*;
|
||||
import com.plotsquared.bukkit.uuid.*;
|
||||
import com.plotsquared.bukkit.util.BukkitChatManager;
|
||||
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
||||
import com.plotsquared.bukkit.util.BukkitCommand;
|
||||
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitEventUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
|
||||
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
||||
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.Metrics;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import com.plotsquared.bukkit.util.SetGenCB;
|
||||
import com.plotsquared.bukkit.util.block.FastQueue_1_7;
|
||||
import com.plotsquared.bukkit.util.block.FastQueue_1_8;
|
||||
import com.plotsquared.bukkit.util.block.FastQueue_1_8_3;
|
||||
import com.plotsquared.bukkit.util.block.FastQueue_1_9;
|
||||
import com.plotsquared.bukkit.util.block.SlowQueue;
|
||||
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.FileUUIDHandler;
|
||||
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -42,7 +93,11 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@ -87,9 +142,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
if (message == null) {
|
||||
return;
|
||||
}
|
||||
if ((THIS != null) && (Bukkit.getServer().getConsoleSender() != null)) {
|
||||
try {
|
||||
message = C.color(message);
|
||||
|
@ -27,16 +27,6 @@ import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -52,11 +42,13 @@ import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
@ -115,6 +107,17 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Player Events involving plots
|
||||
*
|
||||
@ -1307,9 +1310,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
|
||||
public boolean checkEntity(final Entity entity, final Plot plot) {
|
||||
if (plot == null || plot.owner == null || plot.settings == null || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS
|
||||
.isEmpty
|
||||
()) {
|
||||
if (plot == null || plot.owner == null || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
@ -1324,6 +1325,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
case SNOWBALL:
|
||||
case ENDER_PEARL:
|
||||
case ARROW:
|
||||
case TIPPED_ARROW:
|
||||
case SPECTRAL_ARROW:
|
||||
case SHULKER_BULLET:
|
||||
case DRAGON_FIREBALL:
|
||||
// projectile
|
||||
case PRIMED_TNT:
|
||||
case FALLING_BLOCK:
|
||||
@ -1336,6 +1341,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
case LEASH_HITCH:
|
||||
case FIREWORK:
|
||||
case WEATHER:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
@ -1360,7 +1366,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
case MUSHROOM_COW:
|
||||
case OCELOT:
|
||||
case PIG:
|
||||
case HORSE:
|
||||
case SQUID:
|
||||
case VILLAGER:
|
||||
case IRON_GOLEM:
|
||||
@ -1389,26 +1394,30 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
case WITCH:
|
||||
case WITHER:
|
||||
case ZOMBIE:
|
||||
case SHULKER:
|
||||
// monster
|
||||
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
|
||||
case HORSE:
|
||||
Horse horse = ((Horse) entity);
|
||||
if (horse.getVariant().equals(Horse.Variant.SKELETON_HORSE) && entity.getPassenger() instanceof Skeleton) {
|
||||
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
|
||||
}
|
||||
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
|
||||
default:
|
||||
String[] types;
|
||||
if (entity instanceof LivingEntity) {
|
||||
if (entity instanceof Animals) {
|
||||
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
|
||||
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
|
||||
} else if (entity instanceof Monster) {
|
||||
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };
|
||||
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
|
||||
} else {
|
||||
types = new String[] { "entity-cap", "mob-cap" };
|
||||
return checkEntity(plot, "entity-cap", "mob-cap");
|
||||
}
|
||||
} else if (entity instanceof Vehicle) {
|
||||
types = new String[] { "entity-cap", "vehicle-cap" };
|
||||
return checkEntity(plot, "entity-cap", "vehicle-cap");
|
||||
} else if (entity instanceof Hanging) {
|
||||
types = new String[] { "entity-cap", "misc-cap" };
|
||||
} else {
|
||||
types = new String[] { "entity-cap" };
|
||||
return checkEntity(plot, "entity-cap", "misc-cap");
|
||||
}
|
||||
return checkEntity(plot, types);
|
||||
return checkEntity(plot, "entity-cap");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1423,12 +1432,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final Entity ent = e.getIgnitingEntity();
|
||||
if (ent != null) {
|
||||
loc = BukkitUtil.getLocation(ent);
|
||||
} else if (player != null) {
|
||||
loc = BukkitUtil.getLocation(player);
|
||||
} else {
|
||||
if (player != null) {
|
||||
loc = BukkitUtil.getLocation(player);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
PlotArea area = loc.getPlotArea();
|
||||
@ -1511,24 +1518,22 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, now) && tmp_teleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
} else if (!plotEntry(pp, now) && tmp_teleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(from);
|
||||
tmp_teleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(from);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
tmp_teleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
tmp_teleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
final Integer border = area.getBorder();
|
||||
if (tmp_teleport) {
|
||||
@ -1583,24 +1588,22 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, now) && tmp_teleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
} else if (!plotEntry(pp, now) && tmp_teleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(from);
|
||||
tmp_teleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(from);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
tmp_teleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
tmp_teleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
final Integer border = area.getBorder();
|
||||
if (tmp_teleport) {
|
||||
@ -1638,24 +1641,22 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
|
||||
e.setCancelled(true);
|
||||
} else {
|
||||
if (!plot.hasOwner()) {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
e.setCancelled(true);
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
|
||||
if (use != null && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
|
||||
return;
|
||||
}
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
e.setCancelled(true);
|
||||
} else if (!plot.hasOwner()) {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
e.setCancelled(true);
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
|
||||
if (use != null && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
|
||||
return;
|
||||
}
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user