Skip to content

Commit

Permalink
1.16.5 removal part 2: references and version bars
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 1, 2023
1 parent bb2f2bd commit 25c4dcd
Show file tree
Hide file tree
Showing 31 changed files with 120 additions and 303 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -3,7 +3,7 @@ The Denizen Scripting Language - Spigot Impl

An implementation of the Denizen Scripting Language for Spigot servers, with strong Citizens interlinks to emphasize the power of using Denizen with NPCs!

**Version 1.2.6**: Compatible with Spigot 1.16.5, 1.17.1, 1.18.2, and 1.19.3!
**Version 1.2.6**: Compatible with Spigot 1.17.1, 1.18.2, and 1.19.3!

**Learn about Denizen from the Beginner's guide:** https://guide.denizenscript.com/guides/background/index.html

Expand Down
6 changes: 0 additions & 6 deletions dist/pom.xml
Expand Up @@ -26,12 +26,6 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.denizenscript</groupId>
<artifactId>denizen-v1_16</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.denizenscript</groupId>
<artifactId>denizen-v1_17</artifactId>
Expand Down
@@ -1,7 +1,5 @@
package com.denizenscript.denizen.paper.properties;

import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.EntityFormObject;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.LocationTag;
Expand Down Expand Up @@ -170,7 +168,6 @@ public void adjust(Mechanism mechanism) {
// Causes a goat to ram the specified entity.
// -->
if (mechanism.matches("goat_ram") && mechanism.requireObject(EntityTag.class)
&& NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)
&& entity.getBukkitEntity() instanceof Goat) {
((Goat) entity.getBukkitEntity()).ram(mechanism.valueAsType(EntityTag.class).getLivingEntity());
}
Expand Down
7 changes: 1 addition & 6 deletions plugin/src/main/java/com/denizenscript/denizen/Denizen.java
Expand Up @@ -4,7 +4,6 @@
import com.denizenscript.denizen.events.bukkit.SavesReloadEvent;
import com.denizenscript.denizen.events.server.ServerPrestartScriptEvent;
import com.denizenscript.denizen.events.server.ServerStartScriptEvent;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.InventoryTag;
import com.denizenscript.denizen.objects.NPCTag;
import com.denizenscript.denizen.objects.PlayerTag;
Expand Down Expand Up @@ -42,7 +41,6 @@
import com.denizenscript.denizen.npc.TraitRegistry;
import com.denizenscript.denizen.npc.DenizenNPCHelper;
import com.denizenscript.denizen.utilities.packets.NetworkInterceptHelper;
import com.denizenscript.denizen.utilities.world.VoidGenerator;
import com.denizenscript.denizen.utilities.world.VoidGenerator1_17;
import com.denizenscript.denizencore.DenizenCore;
import com.denizenscript.denizencore.objects.ObjectFetcher;
Expand Down Expand Up @@ -608,10 +606,7 @@ private boolean suggestClosestModifier(CommandSender sender, String command, Str
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
if (CoreUtilities.toLowerCase(id).equals("void")) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
return new VoidGenerator1_17();
}
return new VoidGenerator();
return new VoidGenerator1_17();
}
return null;
}
Expand Down
Expand Up @@ -646,7 +646,7 @@ public static boolean runFlaggedCheck(ScriptPath path, String switchName, Abstra
}

public boolean runLocationFlaggedCheck(ScriptPath path, String switchName, Location location) {
if (!path.switches.containsKey(switchName)) { // NOTE: opti to avoid 'getFlagTracker' call, also prevents pre-1.16 borks
if (!path.switches.containsKey(switchName)) { // NOTE: opti to avoid 'getFlagTracker' call
return true;
}
return runFlaggedCheck(path, switchName, location == null ? null : new LocationTag(location).getFlagTracker());
Expand Down
Expand Up @@ -12,8 +12,6 @@
import com.denizenscript.denizen.events.server.*;
import com.denizenscript.denizen.events.vehicle.*;
import com.denizenscript.denizen.events.world.*;
import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.utilities.depends.Depends;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.events.ScriptEventCouldMatcher;
Expand Down Expand Up @@ -78,9 +76,7 @@ public static void registerMainEvents() {
ScriptEvent.registerScriptEvent(BrewsScriptEvent.class);
ScriptEvent.registerScriptEvent(CauldronLevelChangeScriptEvent.class);
ScriptEvent.registerScriptEvent(FurnaceBurnsItemScriptEvent.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
ScriptEvent.registerScriptEvent(FurnaceStartsSmeltingScriptEvent.class);
}
ScriptEvent.registerScriptEvent(FurnaceStartsSmeltingScriptEvent.class);
ScriptEvent.registerScriptEvent(LeafDecaysScriptEvent.class);
ScriptEvent.registerScriptEvent(LiquidLevelChangeScriptEvent.class);
ScriptEvent.registerScriptEvent(LiquidSpreadScriptEvent.class);
Expand Down Expand Up @@ -262,17 +258,11 @@ public static void registerMainEvents() {
ScriptEvent.registerScriptEvent(VehicleMoveScriptEvent.class);

// World events
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
ScriptEvent.registerScriptEvent(ChunkLoadEntitiesScriptEvent.class);
}
ScriptEvent.registerScriptEvent(ChunkLoadEntitiesScriptEvent.class);
ScriptEvent.registerScriptEvent(ChunkLoadScriptEvent.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
ScriptEvent.registerScriptEvent(ChunkUnloadEntitiesScriptEvent.class);
}
ScriptEvent.registerScriptEvent(ChunkUnloadEntitiesScriptEvent.class);
ScriptEvent.registerScriptEvent(ChunkUnloadScriptEvent.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
ScriptEvent.registerScriptEvent(GenericGameEventScriptEvent.class);
}
ScriptEvent.registerScriptEvent(GenericGameEventScriptEvent.class);
ScriptEvent.registerScriptEvent(LightningStrikesScriptEvent.class);
ScriptEvent.registerScriptEvent(LingeringPotionSplashScriptEvent.class);
ScriptEvent.registerScriptEvent(LootGenerateScriptEvent.class);
Expand Down
@@ -1,15 +1,12 @@
package com.denizenscript.denizen.events.player;

import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.ItemTag;
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -89,7 +86,7 @@ public void onPlayerPlacesHanging(HangingPlaceEvent event) {
EntityTag.rememberEntity(hangingEntity);
hanging = new EntityTag(hangingEntity);
location = new LocationTag(event.getBlock().getLocation());
item = NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) ? new ItemTag(event.getItemStack()) : new ItemTag(Material.AIR);
item = new ItemTag(event.getItemStack());
this.event = event;
fire(event);
EntityTag.forgetEntity(hangingEntity);
Expand Down
Expand Up @@ -56,9 +56,6 @@ public static boolean initialize(JavaPlugin plugin) {
if (NMSHandler.class.isAssignableFrom(clazz)) {
// Found and loaded - good to go!
instance = (NMSHandler) clazz.newInstance();
if (version.isAtMost(NMSVersion.v1_16)) {
enchantmentHelper = new EnchantmentHelper();
}
return true;
}
}
Expand Down
Expand Up @@ -3,7 +3,6 @@
public enum NMSVersion {

NOT_SUPPORTED,
v1_16,
v1_17,
v1_18,
v1_19;
Expand Down
Expand Up @@ -2,12 +2,10 @@

import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.utilities.Utilities;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.util.PlayerAnimation;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.data.type.Bed;
Expand Down Expand Up @@ -59,12 +57,7 @@ else if (npc.getEntity() instanceof Player) {
((Player) npc.getEntity()).sleep(bedLocation.clone(), true);
}
else {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
NMSHandler.entityHelper.setPose(npc.getEntity(), Pose.SLEEPING);
}
else {
PlayerAnimation.SLEEP.play((Player) npc.getEntity());
}
NMSHandler.entityHelper.setPose(npc.getEntity(), Pose.SLEEPING);
}
}
else {
Expand Down Expand Up @@ -130,12 +123,7 @@ public void wakeUp() {
if (((Player) npc.getEntity()).isSleeping()) {
((Player) npc.getEntity()).wakeup(false);
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
NMSHandler.entityHelper.setPose(npc.getEntity(), Pose.STANDING);
}
else {
PlayerAnimation.STOP_SLEEPING.play((Player) npc.getEntity());
}
NMSHandler.entityHelper.setPose(npc.getEntity(), Pose.STANDING);
}
bedLocation = null;
}
Expand Down
@@ -1,6 +1,5 @@
package com.denizenscript.denizen.objects;

import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizencore.DenizenCore;
import com.denizenscript.denizencore.flags.AbstractFlagTracker;
import com.denizenscript.denizencore.flags.FlaggableObject;
Expand Down Expand Up @@ -98,14 +97,12 @@ public static boolean matches(String arg) {
/////////////

public BiomeTag(Biome biome) {
String key = biome.name();
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
if (biome.getKey().getNamespace().equals("minecraft")) {
key = biome.getKey().getKey();
}
else {
key = biome.getKey().toString();
}
String key;
if (biome.getKey().getNamespace().equals("minecraft")) {
key = biome.getKey().getKey();
}
else {
key = biome.getKey().toString();
}
this.biome = NMSHandler.instance.getBiomeNMS(Bukkit.getWorlds().get(0), key);
}
Expand Down
Expand Up @@ -469,12 +469,10 @@ public static void register() {
// -->
tagProcessor.registerTag(CuboidTag.class, "cuboid", (attribute, object) -> {
int yMin = 0, yMax = 255;
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
World world = object.getBukkitWorld();
if (world != null) {
yMin = world.getMinHeight();
yMax = world.getMaxHeight();
}
World world = object.getBukkitWorld();
if (world != null) {
yMin = world.getMinHeight();
yMax = world.getMaxHeight();
}
return new CuboidTag(new LocationTag(object.getWorldName(), object.getX() * 16, yMin, object.getZ() * 16, 0, 0),
new LocationTag(object.getWorldName(), object.getX() * 16 + 15, yMax, object.getZ() * 16 + 15, 0, 0));
Expand Down
Expand Up @@ -2,7 +2,6 @@

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.nms.abstracts.BiomeNMS;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.flags.WorldFlagHandler;
Expand Down Expand Up @@ -953,14 +952,13 @@ else if (time >= 12500) {
// By default, automatically checks the playersSleepingPercentage gamerule,
// but this can optionally be overridden by specifying a percentage integer.
// Any integer above 100 will always yield 'false'. Requires at least one player to be sleeping to return 'true'.
// NOTE: In 1.16, input is ignored and assumed to be 100%.
// -->
registerTag(ElementTag.class, "enough_sleeping", (attribute, world) -> {
int percentage = 100;
int percentage;
if (attribute.hasParam()) {
percentage = attribute.getIntParam();
}
else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
else {
percentage = world.getGameRuleOrDefault(GameRule.PLAYERS_SLEEPING_PERCENTAGE);
}
return new ElementTag(NMSHandler.worldHelper.areEnoughSleeping(world.getWorld(), percentage));
Expand All @@ -975,14 +973,13 @@ else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
// By default, automatically checks the playersSleepingPercentage gamerule,
// but this can optionally be overridden by specifying a percentage integer.
// Any integer above 100 will always yield 'false'. Requires at least one player to be sleeping to return 'true'.
// NOTE: In 1.16, input is ignored and assumed to be 100%.
// -->
registerTag(ElementTag.class, "enough_deep_sleeping", (attribute, world) -> {
int percentage = 100;
int percentage;
if (attribute.hasParam()) {
percentage = attribute.getIntParam();
}
else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
else {
percentage = world.getGameRuleOrDefault(GameRule.PLAYERS_SLEEPING_PERCENTAGE);
}
return new ElementTag(NMSHandler.worldHelper.areEnoughDeepSleeping(world.getWorld(), percentage));
Expand Down
Expand Up @@ -53,25 +53,19 @@ public static void registerMainProperties() {
PropertyParser.registerProperty(EntityCritical.class, EntityTag.class);
PropertyParser.registerProperty(EntityCustomName.class, EntityTag.class);
PropertyParser.registerProperty(EntityCustomNameVisible.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
PropertyParser.registerProperty(EntityDarkDuration.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityDarkDuration.class, EntityTag.class);
PropertyParser.registerProperty(EntityDirection.class, EntityTag.class);
PropertyParser.registerProperty(EntityDisabledSlots.class, EntityTag.class);
PropertyParser.registerProperty(EntityPotionEffects.class, EntityTag.class);
PropertyParser.registerProperty(EntityEquipment.class, EntityTag.class);
PropertyParser.registerProperty(EntityExplosionFire.class, EntityTag.class);
PropertyParser.registerProperty(EntityExplosionRadius.class, EntityTag.class);
PropertyParser.registerProperty(EntityFirework.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
PropertyParser.registerProperty(EntityFireworkLifetime.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityFireworkLifetime.class, EntityTag.class);
PropertyParser.registerProperty(EntityFixed.class, EntityTag.class);
PropertyParser.registerProperty(EntityFlags.class, EntityTag.class);
PropertyParser.registerProperty(EntityFlower.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
PropertyParser.registerProperty(EntityFreezeDuration.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityFreezeDuration.class, EntityTag.class);
PropertyParser.registerProperty(EntityFramed.class, EntityTag.class);
PropertyParser.registerProperty(EntityGravity.class, EntityTag.class);
PropertyParser.registerProperty(EntityHasNectar.class, EntityTag.class);
Expand All @@ -84,9 +78,7 @@ public static void registerMainProperties() {
PropertyParser.registerProperty(EntityImmune.class, EntityTag.class);
PropertyParser.registerProperty(EntityInventory.class, EntityTag.class);
PropertyParser.registerProperty(EntityInvulnerable.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
PropertyParser.registerProperty(EntityInWaterTime.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityInWaterTime.class, EntityTag.class);
PropertyParser.registerProperty(EntityIsShowingBottom.class, EntityTag.class);
PropertyParser.registerProperty(EntityItem.class, EntityTag.class);
PropertyParser.registerProperty(EntityItemInHand.class, EntityTag.class);
Expand All @@ -101,9 +93,7 @@ public static void registerMainProperties() {
PropertyParser.registerProperty(EntityPatrolTarget.class, EntityTag.class);
PropertyParser.registerProperty(EntityPickupStatus.class, EntityTag.class);
PropertyParser.registerProperty(EntityPlayerCreated.class, EntityTag.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
PropertyParser.registerProperty(EntityPlayingDead.class, EntityTag.class);
}
PropertyParser.registerProperty(EntityPlayingDead.class, EntityTag.class);
PropertyParser.registerProperty(EntityPotion.class, EntityTag.class);
PropertyParser.registerProperty(EntityPowered.class, EntityTag.class);
PropertyParser.registerProperty(EntityProfession.class, EntityTag.class);
Expand Down
@@ -1,7 +1,5 @@
package com.denizenscript.denizen.objects.properties.entity;

import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
Expand All @@ -21,7 +19,7 @@ public static boolean describes(ObjectTag object) {
Entity entity = ((EntityTag) object).getBukkitEntity();
return entity instanceof WitherSkull
|| entity instanceof Vex
|| (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && entity instanceof Guardian);
|| entity instanceof Guardian;
}

public static EntityCharged getFrom(ObjectTag entity) {
Expand Down Expand Up @@ -107,7 +105,7 @@ public boolean isVex() {
}

public boolean isGuardian() {
return NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && entity.getBukkitEntity() instanceof Guardian;
return entity.getBukkitEntity() instanceof Guardian;
}

public WitherSkull getWitherSkull() {
Expand Down

0 comments on commit 25c4dcd

Please sign in to comment.