mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Merge branch 'v6' into feature/v6/slf4j
This commit is contained in:
@ -22,10 +22,12 @@ dependencies {
|
||||
implementation(project(":PlotSquared-Core"))
|
||||
compile("org.bstats:bstats-bukkit:1.7")
|
||||
compile(project(":PlotSquared-Core"))
|
||||
compile("com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT")
|
||||
//implementation 'com.onarandombox.multiversecore:Multiverse-Core:3.0.0-SNAPSHOT'
|
||||
implementation("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
|
||||
compile(group: "com.sk89q.worldedit", name: "worldedit-bukkit", version: "7.0.1")
|
||||
compile("com.destroystokyo.paper:paper-api:1.16.1-R0.1-SNAPSHOT")
|
||||
implementation("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
|
||||
compile(group: "com.sk89q.worldedit", name: "worldedit-bukkit", version: "7.1.0") {
|
||||
exclude(module: "bukkit")
|
||||
|
||||
}
|
||||
compile("io.papermc:paperlib:1.0.2")
|
||||
implementation("net.kyori:text-adapter-bukkit:3.0.3")
|
||||
compile("com.github.MilkBowl:VaultAPI:1.7") {
|
||||
@ -33,7 +35,9 @@ dependencies {
|
||||
}
|
||||
implementation("me.clip:placeholderapi:2.10.6")
|
||||
implementation("net.luckperms:api:5.1")
|
||||
implementation("net.ess3:EssentialsX:2.17.2")
|
||||
implementation("net.ess3:EssentialsX:2.17.2") {
|
||||
exclude(group: "io.papermc", module: "paperlib")
|
||||
}
|
||||
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
|
||||
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
|
||||
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
|
||||
|
@ -21,20 +21,26 @@
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<version>5.12.2</version>
|
||||
<version>5.12.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.1</version>
|
||||
<version>7.1.0</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>*</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
@ -131,7 +137,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -157,6 +163,12 @@
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.17.2</version>
|
||||
<scope>runtime</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<groupId>io.papermc</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.alpenblock</groupId>
|
||||
|
@ -45,6 +45,7 @@ import com.plotsquared.bukkit.util.BukkitChatManager;
|
||||
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
||||
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitPermHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitRegionManager;
|
||||
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
||||
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
||||
@ -94,6 +95,7 @@ import com.plotsquared.core.util.ConsoleColors;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.InventoryUtil;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.PermHandler;
|
||||
import com.plotsquared.core.util.PlatformWorldManager;
|
||||
import com.plotsquared.core.util.PlayerManager;
|
||||
import com.plotsquared.core.util.PremiumVerification;
|
||||
@ -181,6 +183,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
@Getter private BackupManager backupManager;
|
||||
@Getter private PlatformWorldManager<World> worldManager;
|
||||
private final BukkitPlayerManager playerManager = new BukkitPlayerManager();
|
||||
private EconHandler econ;
|
||||
private PermHandler perm;
|
||||
|
||||
@Override public int[] getServerVersion() {
|
||||
if (this.version == null) {
|
||||
@ -343,7 +347,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
}
|
||||
|
||||
impromptuPipeline.storeImmediately("*", DBFunc.EVERYONE);
|
||||
this.startUuidCatching(sqLiteUUIDService, cacheUUIDService);
|
||||
|
||||
if (Settings.UUID.BACKGROUND_CACHING_ENABLED) {
|
||||
this.startUuidCaching(sqLiteUUIDService, cacheUUIDService);
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new Placeholders().register();
|
||||
@ -476,7 +483,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
}
|
||||
}
|
||||
|
||||
private void startUuidCatching(@NotNull final SQLiteUUIDService sqLiteUUIDService,
|
||||
private void startUuidCaching(@NotNull final SQLiteUUIDService sqLiteUUIDService,
|
||||
@NotNull final CacheUUIDService cacheUUIDService) {
|
||||
// Load all uuids into a big chunky boi queue
|
||||
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>();
|
||||
@ -613,46 +620,46 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
Iterator<Entity> iterator = entities.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = iterator.next();
|
||||
switch (entity.getType()) {
|
||||
case EGG:
|
||||
case FISHING_HOOK:
|
||||
case ENDER_SIGNAL:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case EXPERIENCE_ORB:
|
||||
case LEASH_HITCH:
|
||||
case FIREWORK:
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
case PLAYER:
|
||||
switch (entity.getType().toString()) {
|
||||
case "EGG":
|
||||
case "FISHING_HOOK":
|
||||
case "ENDER_SIGNAL":
|
||||
case "AREA_EFFECT_CLOUD":
|
||||
case "EXPERIENCE_ORB":
|
||||
case "LEASH_HITCH":
|
||||
case "FIREWORK":
|
||||
case "LIGHTNING":
|
||||
case "WITHER_SKULL":
|
||||
case "UNKNOWN":
|
||||
case "PLAYER":
|
||||
// non moving / unmovable
|
||||
continue;
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case SPLASH_POTION:
|
||||
case SNOWBALL:
|
||||
case SHULKER_BULLET:
|
||||
case SPECTRAL_ARROW:
|
||||
case ENDER_PEARL:
|
||||
case ARROW:
|
||||
case LLAMA_SPIT:
|
||||
case TRIDENT:
|
||||
case "THROWN_EXP_BOTTLE":
|
||||
case "SPLASH_POTION":
|
||||
case "SNOWBALL":
|
||||
case "SHULKER_BULLET":
|
||||
case "SPECTRAL_ARROW":
|
||||
case "ENDER_PEARL":
|
||||
case "ARROW":
|
||||
case "LLAMA_SPIT":
|
||||
case "TRIDENT":
|
||||
// managed elsewhere | projectile
|
||||
continue;
|
||||
case ITEM_FRAME:
|
||||
case PAINTING:
|
||||
case "ITEM_FRAME":
|
||||
case "PAINTING":
|
||||
// Not vehicles
|
||||
continue;
|
||||
case ARMOR_STAND:
|
||||
case "ARMOR_STAND":
|
||||
// Temporarily classify as vehicle
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case ENDER_CRYSTAL:
|
||||
case MINECART_TNT:
|
||||
case BOAT:
|
||||
case "MINECART":
|
||||
case "MINECART_CHEST":
|
||||
case "MINECART_COMMAND":
|
||||
case "MINECART_FURNACE":
|
||||
case "MINECART_HOPPER":
|
||||
case "MINECART_MOB_SPAWNER":
|
||||
case "ENDER_CRYSTAL":
|
||||
case "MINECART_TNT":
|
||||
case "BOAT":
|
||||
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||
com.plotsquared.core.location.Location location =
|
||||
BukkitUtil.getLocation(entity.getLocation());
|
||||
@ -681,10 +688,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
}
|
||||
}
|
||||
continue;
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case DRAGON_FIREBALL:
|
||||
case DROPPED_ITEM:
|
||||
case "SMALL_FIREBALL":
|
||||
case "FIREBALL":
|
||||
case "DRAGON_FIREBALL":
|
||||
case "DROPPED_ITEM":
|
||||
if (Settings.Enabled_Components.KILL_ROAD_ITEMS && plotArea
|
||||
.getOwnedPlotAbs(BukkitUtil.getLocation(entity.getLocation()))
|
||||
== null) {
|
||||
@ -692,11 +699,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
}
|
||||
// dropped item
|
||||
continue;
|
||||
case PRIMED_TNT:
|
||||
case FALLING_BLOCK:
|
||||
case "PRIMED_TNT":
|
||||
case "FALLING_BLOCK":
|
||||
// managed elsewhere
|
||||
continue;
|
||||
case SHULKER:
|
||||
case "SHULKER":
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
List<MetadataValue> meta = entity.getMetadata("shulkerPlot");
|
||||
@ -744,71 +751,75 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
}
|
||||
}
|
||||
continue;
|
||||
case LLAMA:
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case ZOMBIE_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
case HUSK:
|
||||
case ELDER_GUARDIAN:
|
||||
case WITHER_SKELETON:
|
||||
case STRAY:
|
||||
case ZOMBIE_VILLAGER:
|
||||
case EVOKER:
|
||||
case EVOKER_FANGS:
|
||||
case VEX:
|
||||
case VINDICATOR:
|
||||
case POLAR_BEAR:
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
case CAVE_SPIDER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
case CREEPER:
|
||||
case ENDERMAN:
|
||||
case ENDERMITE:
|
||||
case ENDER_DRAGON:
|
||||
case GHAST:
|
||||
case GIANT:
|
||||
case GUARDIAN:
|
||||
case HORSE:
|
||||
case IRON_GOLEM:
|
||||
case MAGMA_CUBE:
|
||||
case MUSHROOM_COW:
|
||||
case OCELOT:
|
||||
case PIG:
|
||||
case PIG_ZOMBIE:
|
||||
case RABBIT:
|
||||
case SHEEP:
|
||||
case SILVERFISH:
|
||||
case SKELETON:
|
||||
case SLIME:
|
||||
case SNOWMAN:
|
||||
case SPIDER:
|
||||
case SQUID:
|
||||
case VILLAGER:
|
||||
case WITCH:
|
||||
case WITHER:
|
||||
case WOLF:
|
||||
case ZOMBIE:
|
||||
case PARROT:
|
||||
case SALMON:
|
||||
case DOLPHIN:
|
||||
case TROPICAL_FISH:
|
||||
case DROWNED:
|
||||
case COD:
|
||||
case TURTLE:
|
||||
case PUFFERFISH:
|
||||
case PHANTOM:
|
||||
case ILLUSIONER:
|
||||
case CAT:
|
||||
case PANDA:
|
||||
case FOX:
|
||||
case PILLAGER:
|
||||
case TRADER_LLAMA:
|
||||
case WANDERING_TRADER:
|
||||
case RAVAGER:
|
||||
//case BEE:
|
||||
case "ZOMBIFIED_PIGLIN":
|
||||
case "LLAMA":
|
||||
case "DONKEY":
|
||||
case "MULE":
|
||||
case "ZOMBIE_HORSE":
|
||||
case "SKELETON_HORSE":
|
||||
case "HUSK":
|
||||
case "ELDER_GUARDIAN":
|
||||
case "WITHER_SKELETON":
|
||||
case "STRAY":
|
||||
case "ZOMBIE_VILLAGER":
|
||||
case "EVOKER":
|
||||
case "EVOKER_FANGS":
|
||||
case "VEX":
|
||||
case "VINDICATOR":
|
||||
case "POLAR_BEAR":
|
||||
case "BAT":
|
||||
case "BLAZE":
|
||||
case "CAVE_SPIDER":
|
||||
case "CHICKEN":
|
||||
case "COW":
|
||||
case "CREEPER":
|
||||
case "ENDERMAN":
|
||||
case "ENDERMITE":
|
||||
case "ENDER_DRAGON":
|
||||
case "GHAST":
|
||||
case "GIANT":
|
||||
case "GUARDIAN":
|
||||
case "HORSE":
|
||||
case "IRON_GOLEM":
|
||||
case "MAGMA_CUBE":
|
||||
case "MUSHROOM_COW":
|
||||
case "OCELOT":
|
||||
case "PIG":
|
||||
case "PIG_ZOMBIE":
|
||||
case "RABBIT":
|
||||
case "SHEEP":
|
||||
case "SILVERFISH":
|
||||
case "SKELETON":
|
||||
case "SLIME":
|
||||
case "SNOWMAN":
|
||||
case "SPIDER":
|
||||
case "SQUID":
|
||||
case "VILLAGER":
|
||||
case "WITCH":
|
||||
case "WITHER":
|
||||
case "WOLF":
|
||||
case "ZOMBIE":
|
||||
case "PARROT":
|
||||
case "SALMON":
|
||||
case "DOLPHIN":
|
||||
case "TROPICAL_FISH":
|
||||
case "DROWNED":
|
||||
case "COD":
|
||||
case "TURTLE":
|
||||
case "PUFFERFISH":
|
||||
case "PHANTOM":
|
||||
case "ILLUSIONER":
|
||||
case "CAT":
|
||||
case "PANDA":
|
||||
case "FOX":
|
||||
case "PILLAGER":
|
||||
case "TRADER_LLAMA":
|
||||
case "WANDERING_TRADER":
|
||||
case "RAVAGER":
|
||||
case "BEE":
|
||||
case "HOGLIN":
|
||||
case "PIGLIN":
|
||||
case "ZOGLIN":
|
||||
default: {
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||
Location location = entity.getLocation();
|
||||
@ -889,8 +900,16 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
}
|
||||
|
||||
@Override public EconHandler getEconomyHandler() {
|
||||
if (econ != null) {
|
||||
if (econ.init() /* is inited */) {
|
||||
return econ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
BukkitEconHandler econ = new BukkitEconHandler();
|
||||
econ = new BukkitEconHandler();
|
||||
if (econ.init()) {
|
||||
return econ;
|
||||
}
|
||||
@ -899,6 +918,26 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public PermHandler getPermissionHandler() {
|
||||
if (perm != null) {
|
||||
if (perm.init() /* is inited */) {
|
||||
return perm;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
perm = new BukkitPermHandler();
|
||||
if (perm.init()) {
|
||||
return perm;
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
PlotSquared.debug("No permissions detected!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public QueueProvider initBlockQueue() {
|
||||
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
@ -74,6 +75,7 @@ public class FancyMessage
|
||||
private static Constructor<?> nmsPacketPlayOutChatConstructor;
|
||||
// The ChatSerializer's instance of Gson
|
||||
private static Object nmsChatSerializerGsonInstance;
|
||||
private static Object chatMessageType;
|
||||
private static Method fromJsonMethod;
|
||||
private static JsonParser _stringParser = new JsonParser();
|
||||
|
||||
@ -101,8 +103,16 @@ public class FancyMessage
|
||||
dirty = false;
|
||||
if (nmsPacketPlayOutChatConstructor == null) {
|
||||
try {
|
||||
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
|
||||
.getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
|
||||
Class<?> componentClass = Reflection.getNMSClass("IChatBaseComponent");
|
||||
if (!Reflection.getVersion().startsWith("v1_16")) { // < 1.16 TODO needs to be fixed before 1.17 :P
|
||||
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
|
||||
.getDeclaredConstructor(componentClass);
|
||||
} else {
|
||||
Class<Enum> chatMessageTypeClass = (Class<Enum>) Reflection.getNMSClass("ChatMessageType");
|
||||
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
|
||||
.getDeclaredConstructor(componentClass, chatMessageTypeClass, UUID.class);
|
||||
chatMessageType = Enum.valueOf(chatMessageTypeClass, "SYSTEM");
|
||||
}
|
||||
nmsPacketPlayOutChatConstructor.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Bukkit.getLogger()
|
||||
@ -773,7 +783,7 @@ public class FancyMessage
|
||||
Reflection.getField(handle.getClass(), "playerConnection").get(handle);
|
||||
Reflection
|
||||
.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet"))
|
||||
.invoke(connection, createChatPacket(jsonString));
|
||||
.invoke(connection, createChatPacket(jsonString, ((Player) sender).getUniqueId()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
@ -790,7 +800,7 @@ public class FancyMessage
|
||||
}
|
||||
}
|
||||
|
||||
private Object createChatPacket(String json)
|
||||
private Object createChatPacket(String json, UUID receiver)
|
||||
throws IllegalArgumentException, IllegalAccessException, InstantiationException,
|
||||
InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
|
||||
if (nmsChatSerializerGsonInstance == null) {
|
||||
@ -838,7 +848,11 @@ public class FancyMessage
|
||||
Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json,
|
||||
Reflection.getNMSClass("IChatBaseComponent"));
|
||||
|
||||
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
|
||||
if (!Reflection.getVersion().startsWith("v1_16")) {
|
||||
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
|
||||
} else {
|
||||
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent, chatMessageType, receiver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,51 +107,51 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
if (!entity.hasGravity()) {
|
||||
this.noGravity = true;
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
case BOAT:
|
||||
switch (entity.getType().toString()) {
|
||||
case "BOAT":
|
||||
Boat boat = (Boat) entity;
|
||||
this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType());
|
||||
return;
|
||||
case ARROW:
|
||||
case EGG:
|
||||
case ENDER_CRYSTAL:
|
||||
case ENDER_PEARL:
|
||||
case ENDER_SIGNAL:
|
||||
case EXPERIENCE_ORB:
|
||||
case FALLING_BLOCK:
|
||||
case FIREBALL:
|
||||
case FIREWORK:
|
||||
case FISHING_HOOK:
|
||||
case LEASH_HITCH:
|
||||
case LIGHTNING:
|
||||
case MINECART:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
case PLAYER:
|
||||
case PRIMED_TNT:
|
||||
case SLIME:
|
||||
case SMALL_FIREBALL:
|
||||
case SNOWBALL:
|
||||
case MINECART_FURNACE:
|
||||
case SPLASH_POTION:
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
case SPECTRAL_ARROW:
|
||||
case SHULKER_BULLET:
|
||||
case DRAGON_FIREBALL:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case TRIDENT:
|
||||
case LLAMA_SPIT:
|
||||
case "ARROW":
|
||||
case "EGG":
|
||||
case "ENDER_CRYSTAL":
|
||||
case "ENDER_PEARL":
|
||||
case "ENDER_SIGNAL":
|
||||
case "EXPERIENCE_ORB":
|
||||
case "FALLING_BLOCK":
|
||||
case "FIREBALL":
|
||||
case "FIREWORK":
|
||||
case "FISHING_HOOK":
|
||||
case "LEASH_HITCH":
|
||||
case "LIGHTNING":
|
||||
case "MINECART":
|
||||
case "MINECART_COMMAND":
|
||||
case "MINECART_MOB_SPAWNER":
|
||||
case "MINECART_TNT":
|
||||
case "PLAYER":
|
||||
case "PRIMED_TNT":
|
||||
case "SLIME":
|
||||
case "SMALL_FIREBALL":
|
||||
case "SNOWBALL":
|
||||
case "MINECART_FURNACE":
|
||||
case "SPLASH_POTION":
|
||||
case "THROWN_EXP_BOTTLE":
|
||||
case "WITHER_SKULL":
|
||||
case "UNKNOWN":
|
||||
case "SPECTRAL_ARROW":
|
||||
case "SHULKER_BULLET":
|
||||
case "DRAGON_FIREBALL":
|
||||
case "AREA_EFFECT_CLOUD":
|
||||
case "TRIDENT":
|
||||
case "LLAMA_SPIT":
|
||||
// Do this stuff later
|
||||
return;
|
||||
// MISC //
|
||||
case DROPPED_ITEM:
|
||||
case "DROPPED_ITEM":
|
||||
Item item = (Item) entity;
|
||||
this.stack = item.getItemStack();
|
||||
return;
|
||||
case ITEM_FRAME:
|
||||
case "ITEM_FRAME":
|
||||
this.x = Math.floor(this.x);
|
||||
this.y = Math.floor(this.y);
|
||||
this.z = Math.floor(this.z);
|
||||
@ -159,7 +159,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
this.dataByte = getOrdinal(Rotation.values(), itemFrame.getRotation());
|
||||
this.stack = itemFrame.getItem().clone();
|
||||
return;
|
||||
case PAINTING:
|
||||
case "PAINTING":
|
||||
this.x = Math.floor(this.x);
|
||||
this.y = Math.floor(this.y);
|
||||
this.z = Math.floor(this.z);
|
||||
@ -174,18 +174,18 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
return;
|
||||
// END MISC //
|
||||
// INVENTORY HOLDER //
|
||||
case MINECART_CHEST:
|
||||
case MINECART_HOPPER:
|
||||
case "MINECART_CHEST":
|
||||
case "MINECART_HOPPER":
|
||||
storeInventory((InventoryHolder) entity);
|
||||
return;
|
||||
// START LIVING ENTITY //
|
||||
// START AGEABLE //
|
||||
// START TAMEABLE //
|
||||
case HORSE:
|
||||
case DONKEY:
|
||||
case LLAMA:
|
||||
case MULE:
|
||||
case SKELETON_HORSE:
|
||||
case "HORSE":
|
||||
case "DONKEY":
|
||||
case "LLAMA":
|
||||
case "MULE":
|
||||
case "SKELETON_HORSE":
|
||||
AbstractHorse horse = (AbstractHorse) entity;
|
||||
this.horse = new HorseStats();
|
||||
this.horse.jump = horse.getJumpStrength();
|
||||
@ -203,15 +203,15 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
storeInventory(horse);
|
||||
return;
|
||||
// END INVENTORY HOLDER //
|
||||
case WOLF:
|
||||
case OCELOT:
|
||||
case "WOLF":
|
||||
case "OCELOT":
|
||||
storeTameable((Tameable) entity);
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
// END TAMEABLE //
|
||||
//todo fix sheep
|
||||
case SHEEP:
|
||||
case "SHEEP":
|
||||
Sheep sheep = (Sheep) entity;
|
||||
if (sheep.isSheared()) {
|
||||
this.dataByte = (byte) 1;
|
||||
@ -222,23 +222,23 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
storeAgeable(sheep);
|
||||
storeLiving(sheep);
|
||||
return;
|
||||
case VILLAGER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
case MUSHROOM_COW:
|
||||
case PIG:
|
||||
case TURTLE:
|
||||
case POLAR_BEAR:
|
||||
case "VILLAGER":
|
||||
case "CHICKEN":
|
||||
case "COW":
|
||||
case "MUSHROOM_COW":
|
||||
case "PIG":
|
||||
case "TURTLE":
|
||||
case "POLAR_BEAR":
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
case RABBIT:
|
||||
case "RABBIT":
|
||||
this.dataByte = getOrdinal(Rabbit.Type.values(), ((Rabbit) entity).getRabbitType());
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
// END AGEABLE //
|
||||
case ARMOR_STAND:
|
||||
case "ARMOR_STAND":
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
this.inventory =
|
||||
new ItemStack[] {stand.getItemInHand().clone(), stand.getHelmet().clone(),
|
||||
@ -290,42 +290,45 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
this.stand.small = true;
|
||||
}
|
||||
return;
|
||||
case ENDERMITE:
|
||||
case "ENDERMITE":
|
||||
return;
|
||||
case BAT:
|
||||
case "BAT":
|
||||
if (((Bat) entity).isAwake()) {
|
||||
this.dataByte = (byte) 1;
|
||||
} else {
|
||||
this.dataByte = (byte) 0;
|
||||
}
|
||||
return;
|
||||
case ENDER_DRAGON:
|
||||
case "ENDER_DRAGON":
|
||||
EnderDragon entity1 = (EnderDragon) entity;
|
||||
this.dataByte = (byte) entity1.getPhase().ordinal();
|
||||
return;
|
||||
case SKELETON:
|
||||
case WITHER_SKELETON:
|
||||
case GUARDIAN:
|
||||
case ELDER_GUARDIAN:
|
||||
case GHAST:
|
||||
case MAGMA_CUBE:
|
||||
case SQUID:
|
||||
case PIG_ZOMBIE:
|
||||
case ZOMBIE:
|
||||
case WITHER:
|
||||
case WITCH:
|
||||
case SPIDER:
|
||||
case CAVE_SPIDER:
|
||||
case SILVERFISH:
|
||||
case GIANT:
|
||||
case ENDERMAN:
|
||||
case CREEPER:
|
||||
case BLAZE:
|
||||
case SHULKER:
|
||||
case SNOWMAN:
|
||||
case "SKELETON":
|
||||
case "WITHER_SKELETON":
|
||||
case "GUARDIAN":
|
||||
case "ELDER_GUARDIAN":
|
||||
case "GHAST":
|
||||
case "MAGMA_CUBE":
|
||||
case "SQUID":
|
||||
case "PIG_ZOMBIE":
|
||||
case "HOGLIN":
|
||||
case "ZOMBIFIED_PIGLIN":
|
||||
case "PIGLIN":
|
||||
case "ZOMBIE":
|
||||
case "WITHER":
|
||||
case "WITCH":
|
||||
case "SPIDER":
|
||||
case "CAVE_SPIDER":
|
||||
case "SILVERFISH":
|
||||
case "GIANT":
|
||||
case "ENDERMAN":
|
||||
case "CREEPER":
|
||||
case "BLAZE":
|
||||
case "SHULKER":
|
||||
case "SNOWMAN":
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
case IRON_GOLEM:
|
||||
case "IRON_GOLEM":
|
||||
if (((IronGolem) entity).isPlayerCreated()) {
|
||||
this.dataByte = (byte) 1;
|
||||
} else {
|
||||
@ -464,16 +467,16 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
return null;
|
||||
}
|
||||
Entity entity;
|
||||
switch (this.getType()) {
|
||||
case DROPPED_ITEM:
|
||||
switch (this.getType().toString()) {
|
||||
case "DROPPED_ITEM":
|
||||
return world.dropItem(location, this.stack);
|
||||
case PLAYER:
|
||||
case LEASH_HITCH:
|
||||
case "PLAYER":
|
||||
case "LEASH_HITCH":
|
||||
return null;
|
||||
case ITEM_FRAME:
|
||||
case "ITEM_FRAME":
|
||||
entity = world.spawn(location, ItemFrame.class);
|
||||
break;
|
||||
case PAINTING:
|
||||
case "PAINTING":
|
||||
entity = world.spawn(location, Painting.class);
|
||||
break;
|
||||
default:
|
||||
@ -505,73 +508,73 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
if (this.noGravity) {
|
||||
entity.setGravity(false);
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
case BOAT:
|
||||
switch (entity.getType().toString()) {
|
||||
case "BOAT":
|
||||
Boat boat = (Boat) entity;
|
||||
boat.setWoodType(TreeSpecies.values()[dataByte]);
|
||||
return entity;
|
||||
case SLIME:
|
||||
case "SLIME":
|
||||
((Slime) entity).setSize(this.dataByte);
|
||||
return entity;
|
||||
case ARROW:
|
||||
case EGG:
|
||||
case ENDER_CRYSTAL:
|
||||
case ENDER_PEARL:
|
||||
case ENDER_SIGNAL:
|
||||
case DROPPED_ITEM:
|
||||
case EXPERIENCE_ORB:
|
||||
case FALLING_BLOCK:
|
||||
case FIREBALL:
|
||||
case FIREWORK:
|
||||
case FISHING_HOOK:
|
||||
case LEASH_HITCH:
|
||||
case LIGHTNING:
|
||||
case MINECART:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
case PLAYER:
|
||||
case PRIMED_TNT:
|
||||
case SMALL_FIREBALL:
|
||||
case SNOWBALL:
|
||||
case SPLASH_POTION:
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case SPECTRAL_ARROW:
|
||||
case SHULKER_BULLET:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case DRAGON_FIREBALL:
|
||||
case WITHER_SKULL:
|
||||
case MINECART_FURNACE:
|
||||
case LLAMA_SPIT:
|
||||
case TRIDENT:
|
||||
case UNKNOWN:
|
||||
case "ARROW":
|
||||
case "EGG":
|
||||
case "ENDER_CRYSTAL":
|
||||
case "ENDER_PEARL":
|
||||
case "ENDER_SIGNAL":
|
||||
case "DROPPED_ITEM":
|
||||
case "EXPERIENCE_ORB":
|
||||
case "FALLING_BLOCK":
|
||||
case "FIREBALL":
|
||||
case "FIREWORK":
|
||||
case "FISHING_HOOK":
|
||||
case "LEASH_HITCH":
|
||||
case "LIGHTNING":
|
||||
case "MINECART":
|
||||
case "MINECART_COMMAND":
|
||||
case "MINECART_MOB_SPAWNER":
|
||||
case "MINECART_TNT":
|
||||
case "PLAYER":
|
||||
case "PRIMED_TNT":
|
||||
case "SMALL_FIREBALL":
|
||||
case "SNOWBALL":
|
||||
case "SPLASH_POTION":
|
||||
case "THROWN_EXP_BOTTLE":
|
||||
case "SPECTRAL_ARROW":
|
||||
case "SHULKER_BULLET":
|
||||
case "AREA_EFFECT_CLOUD":
|
||||
case "DRAGON_FIREBALL":
|
||||
case "WITHER_SKULL":
|
||||
case "MINECART_FURNACE":
|
||||
case "LLAMA_SPIT":
|
||||
case "TRIDENT":
|
||||
case "UNKNOWN":
|
||||
// Do this stuff later
|
||||
return entity;
|
||||
// MISC //
|
||||
case ITEM_FRAME:
|
||||
case "ITEM_FRAME":
|
||||
ItemFrame itemframe = (ItemFrame) entity;
|
||||
itemframe.setRotation(Rotation.values()[this.dataByte]);
|
||||
itemframe.setItem(this.stack);
|
||||
return entity;
|
||||
case PAINTING:
|
||||
case "PAINTING":
|
||||
Painting painting = (Painting) entity;
|
||||
painting.setFacingDirection(BlockFace.values()[this.dataByte], true);
|
||||
painting.setArt(Art.getByName(this.dataString), true);
|
||||
return entity;
|
||||
// END MISC //
|
||||
// INVENTORY HOLDER //
|
||||
case MINECART_CHEST:
|
||||
case MINECART_HOPPER:
|
||||
case "MINECART_CHEST":
|
||||
case "MINECART_HOPPER":
|
||||
restoreInventory((InventoryHolder) entity);
|
||||
return entity;
|
||||
// START LIVING ENTITY //
|
||||
// START AGEABLE //
|
||||
// START TAMEABLE //
|
||||
case HORSE:
|
||||
case LLAMA:
|
||||
case SKELETON_HORSE:
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case "HORSE":
|
||||
case "LLAMA":
|
||||
case "SKELETON_HORSE":
|
||||
case "DONKEY":
|
||||
case "MULE":
|
||||
AbstractHorse horse = (AbstractHorse) entity;
|
||||
horse.setJumpStrength(this.horse.jump);
|
||||
if (horse instanceof ChestedHorse) {
|
||||
@ -587,14 +590,14 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
restoreInventory(horse);
|
||||
return entity;
|
||||
// END INVENTORY HOLDER //
|
||||
case WOLF:
|
||||
case OCELOT:
|
||||
case "WOLF":
|
||||
case "OCELOT":
|
||||
restoreTameable((Tameable) entity);
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
// END AGEABLE //
|
||||
case SHEEP:
|
||||
case "SHEEP":
|
||||
Sheep sheep = (Sheep) entity;
|
||||
if (this.dataByte == 1) {
|
||||
sheep.setSheared(true);
|
||||
@ -605,25 +608,25 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
restoreAgeable(sheep);
|
||||
restoreLiving(sheep);
|
||||
return sheep;
|
||||
case VILLAGER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
case TURTLE:
|
||||
case POLAR_BEAR:
|
||||
case MUSHROOM_COW:
|
||||
case PIG:
|
||||
case "VILLAGER":
|
||||
case "CHICKEN":
|
||||
case "COW":
|
||||
case "TURTLE":
|
||||
case "POLAR_BEAR":
|
||||
case "MUSHROOM_COW":
|
||||
case "PIG":
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
// END AGEABLE //
|
||||
case RABBIT:
|
||||
case "RABBIT":
|
||||
if (this.dataByte != 0) {
|
||||
((Rabbit) entity).setRabbitType(Rabbit.Type.values()[this.dataByte]);
|
||||
}
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case ARMOR_STAND:
|
||||
case "ARMOR_STAND":
|
||||
// CHECK positions
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
if (this.inventory[0] != null) {
|
||||
@ -689,42 +692,45 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
}
|
||||
restoreLiving(stand);
|
||||
return stand;
|
||||
case BAT:
|
||||
case "BAT":
|
||||
if (this.dataByte != 0) {
|
||||
((Bat) entity).setAwake(true);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case ENDER_DRAGON:
|
||||
case "ENDER_DRAGON":
|
||||
if (this.dataByte != 0) {
|
||||
((EnderDragon) entity).setPhase(EnderDragon.Phase.values()[this.dataByte]);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case ENDERMITE:
|
||||
case GHAST:
|
||||
case MAGMA_CUBE:
|
||||
case SQUID:
|
||||
case PIG_ZOMBIE:
|
||||
case ZOMBIE:
|
||||
case WITHER:
|
||||
case WITCH:
|
||||
case SPIDER:
|
||||
case CAVE_SPIDER:
|
||||
case SILVERFISH:
|
||||
case GIANT:
|
||||
case ENDERMAN:
|
||||
case CREEPER:
|
||||
case BLAZE:
|
||||
case SNOWMAN:
|
||||
case SHULKER:
|
||||
case GUARDIAN:
|
||||
case ELDER_GUARDIAN:
|
||||
case SKELETON:
|
||||
case WITHER_SKELETON:
|
||||
case "ENDERMITE":
|
||||
case "GHAST":
|
||||
case "MAGMA_CUBE":
|
||||
case "SQUID":
|
||||
case "PIG_ZOMBIE":
|
||||
case "HOGLIN":
|
||||
case "PIGLIN":
|
||||
case "ZOMBIFIED_PIGLIN":
|
||||
case "ZOMBIE":
|
||||
case "WITHER":
|
||||
case "WITCH":
|
||||
case "SPIDER":
|
||||
case "CAVE_SPIDER":
|
||||
case "SILVERFISH":
|
||||
case "GIANT":
|
||||
case "ENDERMAN":
|
||||
case "CREEPER":
|
||||
case "BLAZE":
|
||||
case "SNOWMAN":
|
||||
case "SHULKER":
|
||||
case "GUARDIAN":
|
||||
case "ELDER_GUARDIAN":
|
||||
case "SKELETON":
|
||||
case "WITHER_SKELETON":
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case IRON_GOLEM:
|
||||
case "IRON_GOLEM":
|
||||
if (this.dataByte != 0) {
|
||||
((IronGolem) entity).setPlayerCreated(true);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotHandler;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.PlotInventory;
|
||||
import com.plotsquared.core.plot.flag.FlagContainer;
|
||||
import com.plotsquared.core.plot.flag.implementations.AnimalAttackFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.AnimalCapFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.AnimalInteractFlag;
|
||||
@ -226,10 +227,9 @@ import java.util.regex.Pattern;
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE
|
||||
= new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
||||
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
private float lastRadius;
|
||||
// To prevent recursion
|
||||
private boolean tmpTeleport = true;
|
||||
@ -342,6 +342,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (area.isRoadFlags() && area.getRoadFlag(RedstoneFlag.class)) {
|
||||
event.setNewCurrent(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||
@ -361,7 +364,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
disable = PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()) == null;
|
||||
disable =
|
||||
PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs())
|
||||
== null;
|
||||
}
|
||||
}
|
||||
if (disable) {
|
||||
@ -373,7 +378,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
if (disable) {
|
||||
event.setNewCurrent(0);
|
||||
plot.debug("Redstone event was cancelled because no trusted player was in the plot");
|
||||
plot.debug(
|
||||
"Redstone event was cancelled because no trusted player was in the plot");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -464,7 +470,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||
if (!plot.equals(newPlot)) {
|
||||
event.setCancelled(true);
|
||||
plot.debug("Prevented piston update because of invalid edge piston detection");
|
||||
plot.debug(
|
||||
"Prevented piston update because of invalid edge piston detection");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -569,11 +576,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plot == null) {
|
||||
if (plot == null && !area.isRoadFlags()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> blockedCommands = plot.getFlag(BlockedCmdsFlag.class);
|
||||
List<String> blockedCommands = plot != null ?
|
||||
plot.getFlag(BlockedCmdsFlag.class) :
|
||||
area.getFlag(BlockedCmdsFlag.class);
|
||||
if (!blockedCommands.isEmpty() && !Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
String part = parts[0];
|
||||
@ -618,10 +627,10 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
if (pattern.matcher(msg).matches()) {
|
||||
String perm;
|
||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (plot != null && plot.isAdded(plotPlayer.getUUID())) {
|
||||
perm = "plots.admin.command.blocked-cmds.shared";
|
||||
} else {
|
||||
perm = "plots.admin.command.blocked-cmds.other";
|
||||
perm = "plots.admin.command.blocked-cmds.road";
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, perm)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.COMMAND_BLOCKED);
|
||||
@ -638,11 +647,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
final UUID uuid;
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
if (Settings.UUID.FORCE_LOWERCASE) {
|
||||
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" +
|
||||
event.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
uuid = UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + event.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
} else {
|
||||
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" +
|
||||
event.getName()).getBytes(Charsets.UTF_8));
|
||||
uuid = UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
} else {
|
||||
uuid = event.getUniqueId();
|
||||
@ -812,7 +821,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
|
||||
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
||||
}
|
||||
// Set last location
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||
@ -872,7 +883,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
|
||||
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
||||
}
|
||||
// Set last location
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||
@ -1329,8 +1342,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return;
|
||||
}
|
||||
plot.debug(player.getName() + " could not break " + block.getType() +
|
||||
" because it was not in the break flag");
|
||||
plot.debug(player.getName() + " could not break " + block.getType()
|
||||
+ " because it was not in the break flag");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1390,6 +1403,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case BUBBLE_CORAL_FAN:
|
||||
case FIRE_CORAL_FAN:
|
||||
case HORN_CORAL_FAN:
|
||||
case BRAIN_CORAL_WALL_FAN:
|
||||
case BUBBLE_CORAL_WALL_FAN:
|
||||
case FIRE_CORAL_WALL_FAN:
|
||||
case HORN_CORAL_WALL_FAN:
|
||||
case TUBE_CORAL_WALL_FAN:
|
||||
if (!plot.getFlag(CoralDryFlag.class)) {
|
||||
plot.debug("Coral could not dry because coral-dry = false");
|
||||
event.setCancelled(true);
|
||||
@ -1434,7 +1452,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||
plot.debug(event.getBlock().getType() + " could not update because disable-physics = true");
|
||||
plot.debug(event.getBlock().getType()
|
||||
+ " could not update because disable-physics = true");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1495,7 +1514,63 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) {
|
||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(),
|
||||
relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
||||
.isPlotArea()) {
|
||||
// Prevent pistons from extending if they are: bordering a plot
|
||||
// area, facing inside plot area, and not pushing any blocks
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(
|
||||
bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!plot.equals(area.getOwnedPlot(location.add(
|
||||
relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||
// This branch is only necessary to prevent pistons from extending
|
||||
// if they are: on a plot edge, facing outside the plot, and not
|
||||
// pushing any blocks
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
BlockFace face = event.getDirection();
|
||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
||||
return;
|
||||
}
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(),
|
||||
relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1522,87 +1597,39 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
||||
return;
|
||||
}
|
||||
if (this.pistonBlocks) {
|
||||
try {
|
||||
for (Block pulled : event.getBlocks()) {
|
||||
location = BukkitUtil.getLocation(pulled.getLocation());
|
||||
if (location.isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
this.pistonBlocks = false;
|
||||
}
|
||||
}
|
||||
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
|
||||
BlockFace dir = event.getDirection();
|
||||
location = BukkitUtil.getLocation(block.getLocation()
|
||||
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
||||
if (location.isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
BlockFace dir = event.getDirection();
|
||||
// Location head = location.add(-dir.getModX(), -dir.getModY(), -dir.getModZ());
|
||||
//
|
||||
// if (!Objects.equals(plot, area.getOwnedPlot(head))) {
|
||||
// // FIXME: cancelling the event doesn't work here. See issue #1484
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
if (this.pistonBlocks) {
|
||||
try {
|
||||
for (Block pulled : event.getBlocks()) {
|
||||
Location from = BukkitUtil.getLocation(
|
||||
pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ()));
|
||||
Location to = BukkitUtil.getLocation(pulled.getLocation());
|
||||
if (!area.contains(to.getX(), to.getZ())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Plot fromPlot = area.getOwnedPlot(from);
|
||||
Plot toPlot = area.getOwnedPlot(to);
|
||||
if (!Objects.equals(fromPlot, toPlot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
this.pistonBlocks = false;
|
||||
}
|
||||
}
|
||||
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
|
||||
location = BukkitUtil.getLocation(
|
||||
block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
||||
if (!area.contains(location)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Plot newPlot = area.getOwnedPlot(location);
|
||||
if (!Objects.equals(plot, newPlot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDispense(BlockDispenseEvent event) {
|
||||
Material type = event.getItem().getType();
|
||||
switch (type) {
|
||||
case SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case CARVED_PUMPKIN:
|
||||
case WITHER_SKELETON_SKULL:
|
||||
case FLINT_AND_STEEL:
|
||||
case BONE_MEAL:
|
||||
case SHEARS:
|
||||
case GLASS_BOTTLE:
|
||||
case GLOWSTONE:
|
||||
case COD_BUCKET:
|
||||
case PUFFERFISH_BUCKET:
|
||||
case SALMON_BUCKET:
|
||||
case TROPICAL_FISH_BUCKET:
|
||||
case BUCKET:
|
||||
case WATER_BUCKET:
|
||||
case LAVA_BUCKET: {
|
||||
if (event.getBlock().getType() == Material.DROPPER) {
|
||||
@ -1715,13 +1742,24 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
if (event.getClick() == ClickType.CREATIVE) {
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
if (plot != null &&
|
||||
plot.getFlag(PreventCreativeCopyFlag.class) &&
|
||||
!plot.isAdded(player.getUniqueId()) &&
|
||||
!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
final ItemStack newStack = new ItemStack(newItem.getType(), newItem.getAmount());
|
||||
event.setCursor(newStack);
|
||||
plot.debug(player.getName() + " could not creative-copy an item because prevent-creative-copy = true");
|
||||
if (plot != null) {
|
||||
if (plot.getFlag(PreventCreativeCopyFlag.class) && !plot
|
||||
.isAdded(player.getUniqueId()) && !Permissions
|
||||
.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
final ItemStack newStack =
|
||||
new ItemStack(newItem.getType(), newItem.getAmount());
|
||||
event.setCursor(newStack);
|
||||
plot.debug(player.getName()
|
||||
+ " could not creative-copy an item because prevent-creative-copy = true");
|
||||
}
|
||||
} else {
|
||||
PlotArea area = pp.getPlotAreaAbs();
|
||||
if (area != null && area.isRoadFlags() && area
|
||||
.getRoadFlag(PreventCreativeCopyFlag.class)) {
|
||||
final ItemStack newStack =
|
||||
new ItemStack(newItem.getType(), newItem.getAmount());
|
||||
event.setCursor(newStack);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1838,7 +1876,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Plot plot = location.getPlotAbs();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
|
||||
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
|
||||
.hasPermission(pp, "plots.admin.interact.road")) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -1869,7 +1908,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.interact.other");
|
||||
e.setCancelled(true);
|
||||
plot.debug(pp.getName() + " could not interact with " + entity.getType() + " bcause misc-interact = false");
|
||||
plot.debug(pp.getName() + " could not interact with " + entity.getType()
|
||||
+ " bcause misc-interact = false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2201,7 +2241,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null || !plot.getFlag(BlockBurnFlag.class)) {
|
||||
plot.debug("Block burning was cancelled because block-burn = false");
|
||||
if (plot != null) {
|
||||
plot.debug("Block burning was cancelled because block-burn = false");
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -2505,7 +2547,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
plot.debug(p.getName() + " could not break hanging entity because hanging-break = false");
|
||||
plot.debug(p.getName()
|
||||
+ " could not break hanging entity because hanging-break = false");
|
||||
}
|
||||
}
|
||||
} else if (remover instanceof Projectile) {
|
||||
@ -2534,7 +2577,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
plot.debug(player.getName() + " could not break hanging entity because hanging-break = false");
|
||||
plot.debug(player.getName()
|
||||
+ " could not break hanging entity because hanging-break = false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2555,57 +2599,66 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Player p = event.getPlayer();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (plot == null && !area.isRoadFlags()) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_INTERACT_ROAD);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.hasOwner()) {
|
||||
} else if (plot != null && !plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
} else if ((plot != null && !plot.isAdded(pp.getUUID())) || (plot == null && area
|
||||
.isRoadFlags())) {
|
||||
final Entity entity = event.getRightClicked();
|
||||
final com.sk89q.worldedit.world.entity.EntityType entityType =
|
||||
BukkitAdapter.adapt(entity.getType());
|
||||
|
||||
if (EntityCategories.HOSTILE.contains(entityType) && plot
|
||||
.getFlag(HostileInteractFlag.class)) {
|
||||
FlagContainer flagContainer;
|
||||
if (plot == null) {
|
||||
flagContainer = area.getRoadFlagContainer();
|
||||
} else {
|
||||
flagContainer = plot.getFlagContainer();
|
||||
}
|
||||
|
||||
if (EntityCategories.HOSTILE.contains(entityType) && flagContainer
|
||||
.getFlag(HostileInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.ANIMAL.contains(entityType) && plot
|
||||
.getFlag(AnimalInteractFlag.class)) {
|
||||
if (EntityCategories.ANIMAL.contains(entityType) && flagContainer
|
||||
.getFlag(AnimalInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This actually makes use of the interface, so we don't use the
|
||||
// category
|
||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
|
||||
.getFlag(TamedInteractFlag.class)) {
|
||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && flagContainer
|
||||
.getFlag(TamedInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.VEHICLE.contains(entityType) && plot
|
||||
.getFlag(VehicleUseFlag.class)) {
|
||||
if (EntityCategories.VEHICLE.contains(entityType) && flagContainer
|
||||
.getFlag(VehicleUseFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.PLAYER.contains(entityType) && plot
|
||||
.getFlag(PlayerInteractFlag.class)) {
|
||||
if (EntityCategories.PLAYER.contains(entityType) && flagContainer
|
||||
.getFlag(PlayerInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.VILLAGER.contains(entityType) && plot
|
||||
.getFlag(VillagerInteractFlag.class)) {
|
||||
if (EntityCategories.VILLAGER.contains(entityType) && flagContainer
|
||||
.getFlag(VillagerInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((EntityCategories.HANGING.contains(entityType) || EntityCategories.OTHER
|
||||
.contains(entityType)) && plot.getFlag(MiscInteractFlag.class)) {
|
||||
.contains(entityType)) && flagContainer.getFlag(MiscInteractFlag.class)
|
||||
.getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2653,7 +2706,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.vehicle.break.other");
|
||||
event.setCancelled(true);
|
||||
plot.debug(pp.getName() + " could not break vehicle because vehicle-break = false");
|
||||
plot.debug(pp.getName()
|
||||
+ " could not break vehicle because vehicle-break = false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2755,12 +2809,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
Plot plot;
|
||||
String stub;
|
||||
boolean isPlot = true;
|
||||
if (dplot == null && vplot == null) {
|
||||
if (dArea == null) {
|
||||
return true;
|
||||
}
|
||||
plot = null;
|
||||
stub = "road";
|
||||
isPlot = false;
|
||||
} else {
|
||||
// Prioritize plots for close to seamless pvp zones
|
||||
if (victim.getTicksLived() > damager.getTicksLived()) {
|
||||
@ -2790,6 +2846,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
stub = "unowned";
|
||||
}
|
||||
}
|
||||
boolean roadFlags = vArea != null ? vArea.isRoadFlags() : dArea.isRoadFlags();
|
||||
PlotArea area = vArea != null ? vArea : dArea;
|
||||
|
||||
Player player;
|
||||
if (damager instanceof Player) { // attacker is player
|
||||
@ -2823,8 +2881,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
if (EntityCategories.HANGING.contains(entityType)) { // hanging
|
||||
if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
if (plot != null && (plot.getFlag(HangingBreakFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
if (!Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
@ -2849,47 +2907,63 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.destroy." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not break armor stand because misc-break = false");
|
||||
plot.debug(player.getName()
|
||||
+ " could not break armor stand because misc-break = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.HOSTILE.contains(entityType)) {
|
||||
if (plot != null && (plot.getFlag(HostileAttackFlag.class) || plot
|
||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(HostileAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && (area.getRoadFlag(HostileAttackFlag.class) || area
|
||||
.getFlag(PveFlag.class))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR hostile-attack = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false OR hostile-attack = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.TAMEABLE.contains(entityType)) { // victim is tameable
|
||||
if (plot != null && (plot.getFlag(TamedAttackFlag.class) || plot
|
||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(TamedAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && (area.getRoadFlag(TamedAttackFlag.class) || area
|
||||
.getFlag(PveFlag.class))) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR tamned-attack = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false OR tamned-attack = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.PLAYER.contains(entityType)) {
|
||||
if (plot != null) {
|
||||
if (isPlot) {
|
||||
if (!plot.getFlag(PvpFlag.class) && !Permissions
|
||||
.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pvp." + stub);
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && area.getRoadFlag(PvpFlag.class)) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
@ -2897,29 +2971,38 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
} else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal
|
||||
if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot
|
||||
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR animal-attack = false");
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
return false;
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false OR animal-attack = false");
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && (area.getRoadFlag(AnimalAttackFlag.class) || area
|
||||
.getFlag(PveFlag.class))) {
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (EntityCategories.VEHICLE
|
||||
.contains(entityType)) { // Vehicles are managed in vehicle destroy event
|
||||
return true;
|
||||
} else { // victim is something else
|
||||
if (plot != null && (plot.getFlag(PveFlag.class) || plot
|
||||
.isAdded(plotPlayer.getUUID()))) {
|
||||
if (isPlot) {
|
||||
if (plot.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
} else if (roadFlags && area.getRoadFlag(PveFlag.class)) {
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
|
||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
||||
"plots.admin.pve." + stub);
|
||||
if (plot != null) {
|
||||
plot.debug(player.getName() + " could not attack " + entityType + " because pve = false");
|
||||
plot.debug(player.getName() + " could not attack " + entityType
|
||||
+ " because pve = false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2936,6 +3019,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (vplot == null && roadFlags && area.getRoadFlag(PveFlag.class)) {
|
||||
return true;
|
||||
}
|
||||
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
|
||||
&& !(victim instanceof Creature)));
|
||||
}
|
||||
@ -3025,7 +3111,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Block block = event.getBlockPlaced();
|
||||
if (block.getType().hasGravity()) {
|
||||
sendBlockChange(block.getLocation(), block.getBlockData());
|
||||
plot.debug(event.getBlock().getType() + " did not fall because of disable-physics = true");
|
||||
plot.debug(event.getBlock().getType()
|
||||
+ " did not fall because of disable-physics = true");
|
||||
}
|
||||
}
|
||||
} else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
@ -3039,12 +3126,21 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
Plot plot = BukkitUtil.getLocation(event.getEntity()).getOwnedPlot();
|
||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (area.isRoadFlags() && area.getRoadFlag(InvincibleFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(InvincibleFlag.class)) {
|
||||
plot.debug(event.getEntity().getName() + " could not take damage because invincible = true");
|
||||
plot.debug(
|
||||
event.getEntity().getName() + " could not take damage because invincible = true");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -3052,8 +3148,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
Location location = pp.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (area.isRoadFlags() && !area.getRoadFlag(ItemDropFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
@ -3070,24 +3174,46 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (ent instanceof Player) {
|
||||
Player player = (Player) ent;
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
Location location = pp.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (area.isRoadFlags() && area.getRoadFlag(DropProtectionFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
|
||||
plot.debug(player.getName() + " could not pick up item because of drop-protection = true");
|
||||
plot.debug(
|
||||
player.getName() + " could not pick up item because of drop-protection = true");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler public void onDeath(final PlayerDeathEvent event) {
|
||||
final Plot plot = BukkitUtil.getPlayer(event.getEntity()).getCurrentPlot();
|
||||
if (plot != null && plot.getFlag(KeepInventoryFlag.class)) {
|
||||
plot.debug(event.getEntity().getName() + " kept their inventory because of keep-inventory = true");
|
||||
event.setKeepInventory(true);
|
||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (area.isRoadFlags() && area.getRoadFlag(KeepInventoryFlag.class)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (plot.getFlag(KeepInventoryFlag.class)) {
|
||||
if (plot.getFlag(KeepInventoryFlag.class)) {
|
||||
plot.debug(event.getEntity().getName()
|
||||
+ " kept their inventory because of keep-inventory = true");
|
||||
event.setKeepInventory(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,15 +26,16 @@
|
||||
package com.plotsquared.bukkit.placeholder;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Placeholders extends PlaceholderExpansion {
|
||||
@ -59,7 +60,7 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
@Override public String getVersion() {
|
||||
return "2.4";
|
||||
return "2.5";
|
||||
}
|
||||
|
||||
@Override public String onPlaceholderRequest(Player p, String identifier) {
|
||||
@ -70,20 +71,20 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
if (identifier.startsWith("has_plot_")) {
|
||||
if (identifier.split("has_plot_").length != 2)
|
||||
identifier = identifier.substring("has_plot_".length());
|
||||
if (identifier.isEmpty())
|
||||
return "";
|
||||
|
||||
identifier = identifier.split("has_plot_")[1];
|
||||
return pl.getPlotCount(identifier) > 0 ?
|
||||
PlaceholderAPIPlugin.booleanTrue() :
|
||||
PlaceholderAPIPlugin.booleanFalse();
|
||||
}
|
||||
|
||||
if (identifier.startsWith("plot_count_")) {
|
||||
if (identifier.split("plot_count_").length != 2)
|
||||
identifier = identifier.substring("plot_count_".length());
|
||||
if (identifier.isEmpty())
|
||||
return "";
|
||||
|
||||
identifier = identifier.split("plot_count_")[1];
|
||||
return String.valueOf(pl.getPlotCount(identifier));
|
||||
}
|
||||
|
||||
@ -115,23 +116,16 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
return plot.getAlias();
|
||||
}
|
||||
case "currentplot_owner": {
|
||||
final Set<UUID> o = plot.getOwners();
|
||||
if (o == null || o.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
final UUID uid = (UUID) o.toArray()[0];
|
||||
if (uid == null) {
|
||||
final UUID plotOwner = plot.getOwnerAbs();
|
||||
if (plotOwner == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String name = PlotSquared.get().getImpromptuUUIDPipeline() .getSingle(uid,
|
||||
Settings.UUID.BLOCKING_TIMEOUT);
|
||||
try {
|
||||
return MainUtil.getName(plotOwner, false);
|
||||
} catch (final Exception ignored) {}
|
||||
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
name = Bukkit.getOfflinePlayer(uid).getName();
|
||||
final String name = Bukkit.getOfflinePlayer(plotOwner).getName();
|
||||
return name != null ? name : "unknown";
|
||||
}
|
||||
case "currentplot_members": {
|
||||
@ -181,6 +175,39 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (identifier.startsWith("currentplot_localflag_")) {
|
||||
return getFlagValue(plot, identifier.substring("currentplot_localflag_".length()),
|
||||
false);
|
||||
}
|
||||
if (identifier.startsWith("currentplot_flag_")) {
|
||||
return getFlagValue(plot, identifier.substring("currentplot_flag_".length()), true);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the flag value from its name on the current plot.
|
||||
* If the flag doesn't exist it returns an empty string.
|
||||
* If the flag exists but it is not set on current plot and the parameter inherit is set to true,
|
||||
* it returns the default value.
|
||||
*
|
||||
* @param plot Current plot where the player is
|
||||
* @param flagName Name of flag to get from current plot
|
||||
* @param inherit Define if it returns only the flag set on currentplot or also inherited flag
|
||||
* @return The value of flag serialized in string
|
||||
*/
|
||||
private String getFlagValue(final Plot plot, final String flagName, final boolean inherit) {
|
||||
if (flagName.isEmpty())
|
||||
return "";
|
||||
final PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(flagName);
|
||||
if (flag == null)
|
||||
return "";
|
||||
|
||||
if (inherit) {
|
||||
return plot.getFlag(flag).toString();
|
||||
} else {
|
||||
final PlotFlag<?, ?> plotFlag = plot.getFlagContainer().queryLocal(flag.getClass());
|
||||
return (plotFlag != null) ? plotFlag.getValue().toString() : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
|
||||
@Override public boolean hasPermission(final String permission) {
|
||||
if (this.offline && EconHandler.manager != null) {
|
||||
return EconHandler.manager.hasPermission(getName(), permission);
|
||||
if (this.offline && EconHandler.getEconHandler() != null) {
|
||||
return EconHandler.getEconHandler().hasPermission(getName(), permission);
|
||||
}
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
@ -27,49 +27,39 @@ package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.bukkit.player.BukkitOfflinePlayer;
|
||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.player.OfflinePlotPlayer;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.PermHandler;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class BukkitEconHandler extends EconHandler {
|
||||
|
||||
private Economy econ;
|
||||
private Permission perms;
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
if (this.econ == null || this.perms == null) {
|
||||
setupPermissions();
|
||||
if (this.econ == null) {
|
||||
setupEconomy();
|
||||
}
|
||||
return this.econ != null && this.perms != null;
|
||||
return this.econ != null;
|
||||
}
|
||||
|
||||
private boolean setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider =
|
||||
Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
this.perms = permissionProvider.getProvider();
|
||||
}
|
||||
return this.perms != null;
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
private void setupEconomy() {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
RegisteredServiceProvider<Economy> economyProvider =
|
||||
Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (economyProvider != null) {
|
||||
this.econ = economyProvider.getProvider();
|
||||
}
|
||||
return this.econ != null;
|
||||
}
|
||||
|
||||
@Override public double getMoney(PlotPlayer player) {
|
||||
@Override public double getMoney(PlotPlayer<?> player) {
|
||||
double bal = super.getMoney(player);
|
||||
if (Double.isNaN(bal)) {
|
||||
return this.econ.getBalance(((BukkitPlayer) player).player);
|
||||
@ -77,11 +67,11 @@ public class BukkitEconHandler extends EconHandler {
|
||||
return bal;
|
||||
}
|
||||
|
||||
@Override public void withdrawMoney(PlotPlayer player, double amount) {
|
||||
@Override public void withdrawMoney(PlotPlayer<?> player, double amount) {
|
||||
this.econ.withdrawPlayer(((BukkitPlayer) player).player, amount);
|
||||
}
|
||||
|
||||
@Override public void depositMoney(PlotPlayer player, double amount) {
|
||||
@Override public void depositMoney(PlotPlayer<?> player, double amount) {
|
||||
this.econ.depositPlayer(((BukkitPlayer) player).player, amount);
|
||||
}
|
||||
|
||||
@ -89,20 +79,19 @@ public class BukkitEconHandler extends EconHandler {
|
||||
this.econ.depositPlayer(((BukkitOfflinePlayer) player).player, amount);
|
||||
}
|
||||
|
||||
@Override public boolean hasPermission(String world, String player, String perm) {
|
||||
return this.perms.playerHas(world, Bukkit.getOfflinePlayer(player), perm);
|
||||
}
|
||||
|
||||
@Override public double getBalance(PlotPlayer player) {
|
||||
return this.econ.getBalance(player.getName());
|
||||
}
|
||||
|
||||
public void setPermission(String world, String player, String perm, boolean value) {
|
||||
if (value) {
|
||||
this.perms.playerAdd(world, player, perm);
|
||||
/**
|
||||
* @deprecated Use {@link PermHandler#hasPermission(String, String, String)} instead
|
||||
*/
|
||||
@Deprecated @Override public boolean hasPermission(String world, String player, String perm) {
|
||||
if (PlotSquared.imp().getPermissionHandler() != null) {
|
||||
return PlotSquared.imp().getPermissionHandler().hasPermission(world, player, perm);
|
||||
} else {
|
||||
this.perms.playerRemove(world, player, perm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public double getBalance(PlotPlayer<?> player) {
|
||||
return this.econ.getBalance(player.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2020 IntellectualSites
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.core.util.PermHandler;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class BukkitPermHandler extends PermHandler {
|
||||
|
||||
private Permission perms;
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
if (this.perms == null) {
|
||||
setupPermissions();
|
||||
}
|
||||
return this.perms != null;
|
||||
}
|
||||
|
||||
private void setupPermissions() {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return;
|
||||
}
|
||||
RegisteredServiceProvider<Permission> permissionProvider =
|
||||
Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
this.perms = permissionProvider.getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean hasPermission(String world, String player, String perm) {
|
||||
return this.perms.playerHas(world, Bukkit.getOfflinePlayer(player), perm);
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.location.PlotLoc;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||
@ -110,6 +111,10 @@ public class BukkitRegionManager extends RegionManager {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@Override public boolean handleClear(Plot plot, Runnable whenDone, PlotManager manager) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public int[] countEntities(Plot plot) {
|
||||
int[] existing = (int[]) plot.getMeta("EntityCount");
|
||||
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime")
|
||||
|
@ -26,6 +26,8 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.plotsquared.core.uuid.UUIDService;
|
||||
import com.sk89q.squirrelid.Profile;
|
||||
@ -35,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -65,8 +68,27 @@ public class SquirrelIdUUIDService implements UUIDService {
|
||||
final List<UUIDMapping> results = new ArrayList<>(uuids.size());
|
||||
this.rateLimiter.acquire(uuids.size());
|
||||
try {
|
||||
for (final Profile profile : this.profileService.findAllById(uuids)) {
|
||||
results.add(new UUIDMapping(profile.getUniqueId(), profile.getName()));
|
||||
try {
|
||||
for (final Profile profile : this.profileService.findAllById(uuids)) {
|
||||
results.add(new UUIDMapping(profile.getUniqueId(), profile.getName()));
|
||||
}
|
||||
} catch (final IllegalArgumentException illegalArgumentException) {
|
||||
//
|
||||
// This means that the UUID was invalid for whatever reason, we'll try to
|
||||
// go through them one by one
|
||||
//
|
||||
if (uuids.size() >= 2) {
|
||||
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID in batch. Will try each UUID individually.");
|
||||
for (final UUID uuid : uuids) {
|
||||
final List<UUIDMapping> result = this.getNames(Collections.singletonList(uuid));
|
||||
if (result.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
results.add(result.get(0));
|
||||
}
|
||||
} else if (uuids.size() == 1) {
|
||||
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID: " + uuids.get(0));
|
||||
}
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
Reference in New Issue
Block a user