From 001717ae452ef3b160e4ea4f187a527ae2087b0c Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Sat, 18 May 2024 13:59:15 +0200 Subject: [PATCH] Revert "Merge upstream" --- NookureStaff-API/build.gradle.kts | 3 +- .../staff/api/util/LocationWrapper.java | 96 ------------------- .../staff/paper/StaffPaperPlayerWrapper.java | 11 +-- .../staff/paper/data/StaffModeDataRecord.java | 9 +- .../freeze/OnFreezePlayerInteract.java | 13 +-- build.gradle.kts | 1 - 6 files changed, 13 insertions(+), 120 deletions(-) delete mode 100644 NookureStaff-API/src/main/java/com/nookure/staff/api/util/LocationWrapper.java diff --git a/NookureStaff-API/build.gradle.kts b/NookureStaff-API/build.gradle.kts index 78c91082f..b0525d989 100644 --- a/NookureStaff-API/build.gradle.kts +++ b/NookureStaff-API/build.gradle.kts @@ -92,8 +92,7 @@ tasks { "https://google.github.io/guice/api-docs/${libs.guice.get().version}/javadoc/", "https://docs.oracle.com/en/java/javase/17/docs/api/", "https://jd.advntr.dev/api/${libs.adventureApi.get().version}/", - "https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine", - "https://jd.papermc.io/paper/1.20.6/" + "https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine" ) } } diff --git a/NookureStaff-API/src/main/java/com/nookure/staff/api/util/LocationWrapper.java b/NookureStaff-API/src/main/java/com/nookure/staff/api/util/LocationWrapper.java deleted file mode 100644 index af6ce7188..000000000 --- a/NookureStaff-API/src/main/java/com/nookure/staff/api/util/LocationWrapper.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.nookure.staff.api.util; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.Serializable; -import java.util.Objects; - -/** - * Represents a location serializable object. - */ -public final class LocationWrapper implements Serializable { - private final double x; - private final double y; - private final double z; - private final float yaw; - private final float pitch; - private final String world; - - /** - * Constructor for LocationWrapper. - * - * @param x the x coordinate - * @param y the y coordinate - * @param z the z coordinate - * @param yaw the yaw - * @param pitch the pitch - * @param world the world - */ - public LocationWrapper(double x, double y, double z, float yaw, float pitch, String world) { - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.world = world; - } - - /** - * Constructor for LocationWrapper. - * - * @param location the location - */ - public LocationWrapper(org.bukkit.Location location) { - this.x = location.getX(); - this.y = location.getY(); - this.z = location.getZ(); - this.yaw = location.getYaw(); - this.pitch = location.getPitch(); - this.world = location.getWorld().getName(); - } - - public double getX() { - return x; - } - - public double getY() { - return y; - } - - public double getZ() { - return z; - } - - public float getYaw() { - return yaw; - } - - public float getPitch() { - return pitch; - } - - public String getWorld() { - return world; - } - - @Nullable - public static org.bukkit.Location toLocation(@NotNull LocationWrapper locationWrapper) { - Objects.requireNonNull(locationWrapper, "LocationWrapper cannot be null."); - - org.bukkit.World world = org.bukkit.Bukkit.getWorld(locationWrapper.getWorld()); - - if (world == null) { - return null; - } - - return new org.bukkit.Location( - org.bukkit.Bukkit.getWorld(locationWrapper.getWorld()), - locationWrapper.getX(), - locationWrapper.getY(), - locationWrapper.getZ(), - locationWrapper.getYaw(), - locationWrapper.getPitch() - ); - } -} diff --git a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/StaffPaperPlayerWrapper.java b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/StaffPaperPlayerWrapper.java index 07f3c29d7..ebe1a2f71 100644 --- a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/StaffPaperPlayerWrapper.java +++ b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/StaffPaperPlayerWrapper.java @@ -22,7 +22,10 @@ import com.nookure.staff.api.model.StaffDataModel; import com.nookure.staff.api.util.Scheduler; import com.nookure.staff.paper.data.StaffModeData; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; @@ -255,9 +258,7 @@ public void saveLocation() { } public void loadPreviousLocation() { - Location location = staffModeData.record().enabledLocation(); - if (location == null) return; - player.teleport(location); + player.teleport(staffModeData.record().enabledLocation()); } private void writeVanishState(boolean state) { @@ -359,8 +360,6 @@ private void checkStaffModeState() { } if (staffDataModel.isStaffMode()) { - saveInventory(); - saveLocation(); enableStaffMode(true); } diff --git a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/data/StaffModeDataRecord.java b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/data/StaffModeDataRecord.java index dff006220..5846d0cde 100644 --- a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/data/StaffModeDataRecord.java +++ b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/data/StaffModeDataRecord.java @@ -1,6 +1,5 @@ package com.nookure.staff.paper.data; -import com.nookure.staff.api.util.LocationWrapper; import org.bukkit.Location; import org.bukkit.inventory.ItemStack; @@ -15,7 +14,7 @@ public class StaffModeDataRecord implements Serializable { private ItemStack[] playerInventoryArmor; private ItemStack[] staffVault; private boolean staffMode; - private LocationWrapper enabledLocation; + private Location enabledLocation; public StaffModeDataRecord( ItemStack[] playerInventory, @@ -28,7 +27,7 @@ public StaffModeDataRecord( this.playerInventoryArmor = playerInventoryArmor; this.staffVault = staffVault; this.staffMode = staffMode; - this.enabledLocation = new LocationWrapper(enabledLocation); + this.enabledLocation = enabledLocation; } public ItemStack[] playerInventory() { @@ -64,11 +63,11 @@ public void staffMode(boolean staffMode) { } public Location enabledLocation() { - return LocationWrapper.toLocation(enabledLocation); + return enabledLocation; } public void enabledLocation(Location enabledLocation) { - this.enabledLocation = new LocationWrapper(enabledLocation); + this.enabledLocation = enabledLocation; } @Override diff --git a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/listener/freeze/OnFreezePlayerInteract.java b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/listener/freeze/OnFreezePlayerInteract.java index e49b944b4..cd4f44fe2 100644 --- a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/listener/freeze/OnFreezePlayerInteract.java +++ b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/listener/freeze/OnFreezePlayerInteract.java @@ -4,7 +4,6 @@ import com.nookure.staff.api.manager.FreezeManager; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -13,16 +12,12 @@ public class OnFreezePlayerInteract implements Listener { @Inject private FreezeManager freezeManager; - @EventHandler( - priority = EventPriority.HIGHEST - ) + @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (freezeManager.isFrozen(event.getPlayer())) event.setCancelled(true); } - @EventHandler( - priority = EventPriority.HIGHEST - ) + @EventHandler public void onPlayerAttack(EntityDamageByEntityEvent event) { if (!(event.getDamager() instanceof Player player)) { return; @@ -31,9 +26,7 @@ public void onPlayerAttack(EntityDamageByEntityEvent event) { if (freezeManager.isFrozen(player)) event.setCancelled(true); } - @EventHandler( - priority = EventPriority.HIGHEST - ) + @EventHandler public void onPlayerDamage(EntityDamageEvent event) { if (!(event.getEntity() instanceof Player player)) { return; diff --git a/build.gradle.kts b/build.gradle.kts index f1668fbba..15c156938 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,6 @@ val minor: String by project val patch: String by project group = "com.nookure.staff" - val versionCode = "${major}.${minor}.${patch}" version = "${versionCode}-${grgit.head().abbreviatedId}"