mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-02-22 17:49:36 +01:00
fix: replace (removed) constants with backwards compatible alternatives
This commit is contained in:
parent
1192bf2b33
commit
bdb339905a
@ -42,9 +42,11 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
|
|||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.PlotFlagUtil;
|
import com.plotsquared.core.util.PlotFlagUtil;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.util.Enums;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -78,10 +80,14 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class EntityEventListener implements Listener {
|
public class EntityEventListener implements Listener {
|
||||||
|
|
||||||
|
private static final NamespacedKey TNT_MINECART = NamespacedKey.minecraft("tnt_minecart");
|
||||||
|
private static final Particle EXPLOSION_HUGE = Objects.requireNonNull(Enums.findByValue(Particle.class, "EXPLOSION_EMITTER", "EXPLOSION_HUGE"));
|
||||||
|
|
||||||
private final BukkitPlatform platform;
|
private final BukkitPlatform platform;
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
@ -152,8 +158,8 @@ public class EntityEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "REINFORCEMENTS", "NATURAL", "MOUNT", "PATROL", "RAID", "SHEARED", "SILVERFISH_BLOCK", "ENDER_PEARL",
|
case "REINFORCEMENTS", "NATURAL", "MOUNT", "PATROL", "RAID", "SHEARED", "SILVERFISH_BLOCK", "ENDER_PEARL",
|
||||||
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
|
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
|
||||||
"FROZEN", "SPELL", "DEFAULT" -> {
|
"FROZEN", "SPELL", "DEFAULT" -> {
|
||||||
if (!area.isMobSpawning()) {
|
if (!area.isMobSpawning()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -314,7 +320,7 @@ public class EntityEventListener implements Listener {
|
|||||||
if (this.lastRadius != 0) {
|
if (this.lastRadius != 0) {
|
||||||
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
|
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
|
||||||
for (Entity near : nearby) {
|
for (Entity near : nearby) {
|
||||||
if (near instanceof TNTPrimed || near.getType().equals(EntityType.MINECART_TNT)) {
|
if (near instanceof TNTPrimed || near.getType().getKey().equals(TNT_MINECART)) {
|
||||||
if (!near.hasMetadata("plot")) {
|
if (!near.hasMetadata("plot")) {
|
||||||
near.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
near.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
||||||
}
|
}
|
||||||
@ -338,7 +344,7 @@ public class EntityEventListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
//Spawn Explosion Particles when enabled in settings
|
//Spawn Explosion Particles when enabled in settings
|
||||||
if (Settings.General.ALWAYS_SHOW_EXPLOSIONS) {
|
if (Settings.General.ALWAYS_SHOW_EXPLOSIONS) {
|
||||||
event.getLocation().getWorld().spawnParticle(Particle.EXPLOSION_HUGE, event.getLocation(), 0);
|
event.getLocation().getWorld().spawnParticle(EXPLOSION_HUGE, event.getLocation(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +371,8 @@ public class EntityEventListener implements Listener {
|
|||||||
// Burning player evaporating powder snow. Use same checks as
|
// Burning player evaporating powder snow. Use same checks as
|
||||||
// trampling farmland
|
// trampling farmland
|
||||||
BlockType blockType = BukkitAdapter.asBlockType(type);
|
BlockType blockType = BukkitAdapter.asBlockType(type);
|
||||||
if (!this.eventDispatcher.checkPlayerBlockEvent(pp,
|
if (!this.eventDispatcher.checkPlayerBlockEvent(
|
||||||
|
pp,
|
||||||
PlayerBlockEventType.TRIGGER_PHYSICAL, location, blockType, true
|
PlayerBlockEventType.TRIGGER_PHYSICAL, location, blockType, true
|
||||||
)) {
|
)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -28,6 +28,7 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
@ -54,6 +55,9 @@ import java.util.List;
|
|||||||
|
|
||||||
public class EntitySpawnListener implements Listener {
|
public class EntitySpawnListener implements Listener {
|
||||||
|
|
||||||
|
private static final NamespacedKey ITEM = NamespacedKey.minecraft("item");
|
||||||
|
private static final NamespacedKey END_CRYSTAL = NamespacedKey.minecraft("end_crystal");
|
||||||
|
|
||||||
private static final String KEY = "P2";
|
private static final String KEY = "P2";
|
||||||
private static boolean ignoreTP = false;
|
private static boolean ignoreTP = false;
|
||||||
private static boolean hasPlotArea = false;
|
private static boolean hasPlotArea = false;
|
||||||
@ -132,7 +136,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
Plot plot = location.getOwnedPlotAbs();
|
Plot plot = location.getOwnedPlotAbs();
|
||||||
EntityType type = entity.getType();
|
EntityType type = entity.getType();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (type == EntityType.DROPPED_ITEM) {
|
if (type.getKey().equals(ITEM)) {
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -154,7 +158,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (type == EntityType.ENDER_CRYSTAL || type == EntityType.ARMOR_STAND) {
|
if (type.getKey().equals(END_CRYSTAL) || type == EntityType.ARMOR_STAND) {
|
||||||
if (BukkitEntityUtil.checkEntity(entity, plot)) {
|
if (BukkitEntityUtil.checkEntity(entity, plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -80,6 +81,9 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class PaperListener implements Listener {
|
public class PaperListener implements Listener {
|
||||||
|
|
||||||
|
private static final NamespacedKey ITEM = NamespacedKey.minecraft("item");
|
||||||
|
private static final NamespacedKey FISHING_BOBBER = NamespacedKey.minecraft("fishing_bobber");
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
private Chunk lastChunk;
|
private Chunk lastChunk;
|
||||||
|
|
||||||
@ -228,7 +232,7 @@ public class PaperListener implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
EntityType type = event.getType();
|
EntityType type = event.getType();
|
||||||
// PreCreatureSpawnEvent **should** not be called for DROPPED_ITEM, just for the sake of consistency
|
// PreCreatureSpawnEvent **should** not be called for DROPPED_ITEM, just for the sake of consistency
|
||||||
if (type == EntityType.DROPPED_ITEM) {
|
if (type.getKey().equals(ITEM)) {
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -354,7 +358,7 @@ public class PaperListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (entity.getType().equals(EntityType.FISHING_HOOK)) {
|
if (entity.getType().getKey().equals(FISHING_BOBBER)) {
|
||||||
if (plot.getFlag(FishingFlag.class)) {
|
if (plot.getFlag(FishingFlag.class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ import org.bukkit.block.data.Waterlogged;
|
|||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Boat;
|
import org.bukkit.entity.Boat;
|
||||||
|
import org.bukkit.entity.ChestBoat;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
@ -376,7 +377,8 @@ public class PlayerEventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) {
|
public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) {
|
||||||
if (e.getVehicle().getType() == EntityType.BOAT) {
|
final Class<? extends Entity> clazz = e.getVehicle().getType().getEntityClass();
|
||||||
|
if (clazz != null && (Boat.class.isAssignableFrom(clazz) || ChestBoat.class.isAssignableFrom(clazz))) {
|
||||||
Location location = BukkitUtil.adapt(e.getEntity().getLocation());
|
Location location = BukkitUtil.adapt(e.getEntity().getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
if (e.getEntity() instanceof Player) {
|
if (e.getEntity() instanceof Player) {
|
||||||
|
@ -34,6 +34,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
|
|||||||
import com.plotsquared.core.util.PlotFlagUtil;
|
import com.plotsquared.core.util.PlotFlagUtil;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -54,6 +55,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class ProjectileEventListener implements Listener {
|
public class ProjectileEventListener implements Listener {
|
||||||
|
|
||||||
|
private static final NamespacedKey FISHING_BOBBER = NamespacedKey.minecraft("fishing_bobber");
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -134,7 +137,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (entity.getType().equals(EntityType.FISHING_HOOK)) {
|
if (entity.getType().getKey().equals(FISHING_BOBBER)) {
|
||||||
if (plot.getFlag(FishingFlag.class)) {
|
if (plot.getFlag(FishingFlag.class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -194,7 +197,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(
|
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(
|
||||||
ProjectilesFlag.class) || (entity.getType().equals(EntityType.FISHING_HOOK) && plot.getFlag(
|
ProjectilesFlag.class) || (entity.getType().getKey().equals(FISHING_BOBBER) && plot.getFlag(
|
||||||
FishingFlag.class))) {
|
FishingFlag.class))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -59,6 +60,8 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class BukkitEntityUtil {
|
public class BukkitEntityUtil {
|
||||||
|
|
||||||
|
private static final NamespacedKey FIREWORK_ROCKET = NamespacedKey.minecraft("firework_rocket");
|
||||||
|
|
||||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
||||||
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||||
|
|
||||||
@ -342,7 +345,7 @@ public class BukkitEntityUtil {
|
|||||||
//disable the firework damage. too much of a headache to support at the moment.
|
//disable the firework damage. too much of a headache to support at the moment.
|
||||||
if (vplot != null) {
|
if (vplot != null) {
|
||||||
if (EntityDamageEvent.DamageCause.ENTITY_EXPLOSION == cause
|
if (EntityDamageEvent.DamageCause.ENTITY_EXPLOSION == cause
|
||||||
&& damager.getType() == EntityType.FIREWORK) {
|
&& damager.getType().getKey().equals(FIREWORK_ROCKET)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user