From c6b6ec1a42da8e1ed18c0444bb43b372782f3918 Mon Sep 17 00:00:00 2001 From: filoghost Date: Fri, 30 Jul 2021 10:34:22 +0200 Subject: [PATCH] Rename v2 API adapter classes --- .../plugin/api/v2/V2HologramAdapter.java | 56 ++++----- .../plugin/api/v2/V2HologramLineAdapter.java | 16 +-- .../plugin/api/v2/V2ItemLineAdapter.java | 40 +++--- .../plugin/api/v2/V2PickupHandlerAdapter.java | 18 +-- .../plugin/api/v2/V2TextLineAdapter.java | 12 +- .../plugin/api/v2/V2TouchHandlerAdapter.java | 18 +-- .../plugin/api/v2/V2TouchableLineAdapter.java | 36 +++--- .../api/v2/V2VisibilityManagerAdapter.java | 26 ++-- ...apter.java => V3PickupHandlerAdapter.java} | 8 +- ...dapter.java => V3TouchHandlerAdapter.java} | 8 +- .../plugin/hologram/api/APIItemLine.java | 4 +- .../plugin/hologram/api/APITextLine.java | 2 +- .../api/v2/V2TouchableLineAdapterTest.java | 114 +++++++++--------- 13 files changed, 179 insertions(+), 179 deletions(-) rename plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/{NewPickupHandlerAdapter.java => V3PickupHandlerAdapter.java} (77%) rename plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/{NewTouchHandlerAdapter.java => V3TouchHandlerAdapter.java} (78%) diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramAdapter.java index 972cc532..94b5a1ca 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramAdapter.java @@ -18,120 +18,120 @@ import org.bukkit.inventory.ItemStack; @SuppressWarnings("deprecation") public class V2HologramAdapter implements Hologram { - private final APIHologram newHologram; + private final APIHologram v3Hologram; - public V2HologramAdapter(APIHologram newHologram) { - this.newHologram = newHologram; + public V2HologramAdapter(APIHologram v3Hologram) { + this.v3Hologram = v3Hologram; } @Override public TextLine appendTextLine(String text) { - return newHologram.appendTextLine(text).getV2Adapter(); + return v3Hologram.appendTextLine(text).getV2Adapter(); } @Override public ItemLine appendItemLine(ItemStack itemStack) { - return newHologram.appendItemLine(itemStack).getV2Adapter(); + return v3Hologram.appendItemLine(itemStack).getV2Adapter(); } @Override public TextLine insertTextLine(int index, String text) { - return newHologram.insertTextLine(index, text).getV2Adapter(); + return v3Hologram.insertTextLine(index, text).getV2Adapter(); } @Override public ItemLine insertItemLine(int index, ItemStack itemStack) { - return newHologram.insertItemLine(index, itemStack).getV2Adapter(); + return v3Hologram.insertItemLine(index, itemStack).getV2Adapter(); } @Override public HologramLine getLine(int index) { - return newHologram.getLine(index).getV2Adapter(); + return v3Hologram.getLine(index).getV2Adapter(); } @Override public void removeLine(int index) { - newHologram.removeLine(index); + v3Hologram.removeLine(index); } @Override public void clearLines() { - newHologram.clearLines(); + v3Hologram.clearLines(); } @Override public int size() { - return newHologram.getLineCount(); + return v3Hologram.getLineCount(); } @Override public double getHeight() { - return newHologram.getHeight(); + return v3Hologram.getHeight(); } @Override public void teleport(Location location) { - newHologram.teleport(location); + v3Hologram.teleport(location); } @Override public void teleport(World world, double x, double y, double z) { - newHologram.teleport(world, x, y, z); + v3Hologram.teleport(world, x, y, z); } @Override public Location getLocation() { - return newHologram.getLocation(); + return v3Hologram.getLocation(); } @Override public double getX() { - return newHologram.getX(); + return v3Hologram.getX(); } @Override public double getY() { - return newHologram.getY(); + return v3Hologram.getY(); } @Override public double getZ() { - return newHologram.getZ(); + return v3Hologram.getZ(); } @Override public World getWorld() { - return newHologram.getWorld(); + return v3Hologram.getWorld(); } @Override public VisibilityManager getVisibilityManager() { - return newHologram.getVisibilitySettings().getV2Adapter(); + return v3Hologram.getVisibilitySettings().getV2Adapter(); } @Override public long getCreationTimestamp() { - return newHologram.getCreationTimestamp(); + return v3Hologram.getCreationTimestamp(); } @Override public boolean isAllowPlaceholders() { - return newHologram.isAllowPlaceholders(); + return v3Hologram.isAllowPlaceholders(); } @Override public void setAllowPlaceholders(boolean allowPlaceholders) { - newHologram.setAllowPlaceholders(allowPlaceholders); + v3Hologram.setAllowPlaceholders(allowPlaceholders); } @Override public void delete() { - newHologram.delete(); + v3Hologram.delete(); } @Override public boolean isDeleted() { - return newHologram.isDeleted(); + return v3Hologram.isDeleted(); } @Override @@ -144,17 +144,17 @@ public class V2HologramAdapter implements Hologram { } V2HologramAdapter other = (V2HologramAdapter) obj; - return this.newHologram.equals(other.newHologram); + return this.v3Hologram.equals(other.v3Hologram); } @Override public final int hashCode() { - return newHologram.hashCode(); + return v3Hologram.hashCode(); } @Override public final String toString() { - return newHologram.toString(); + return v3Hologram.toString(); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramLineAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramLineAdapter.java index dde9bb4e..8f492e9e 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramLineAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2HologramLineAdapter.java @@ -11,20 +11,20 @@ import me.filoghost.holographicdisplays.plugin.hologram.api.APIHologramLine; @SuppressWarnings("deprecation") public abstract class V2HologramLineAdapter implements HologramLine { - private final APIHologramLine newHologramLine; + private final APIHologramLine v3HologramLine; - public V2HologramLineAdapter(APIHologramLine newHologramLine) { - this.newHologramLine = newHologramLine; + public V2HologramLineAdapter(APIHologramLine v3HologramLine) { + this.v3HologramLine = v3HologramLine; } @Override public V2HologramAdapter getParent() { - return newHologramLine.getParent().getV2Adapter(); + return v3HologramLine.getParent().getV2Adapter(); } @Override public void removeLine() { - newHologramLine.removeLine(); + v3HologramLine.removeLine(); } @Override @@ -37,17 +37,17 @@ public abstract class V2HologramLineAdapter implements HologramLine { } V2HologramLineAdapter other = (V2HologramLineAdapter) obj; - return this.newHologramLine.equals(other.newHologramLine); + return this.v3HologramLine.equals(other.v3HologramLine); } @Override public final int hashCode() { - return newHologramLine.hashCode(); + return v3HologramLine.hashCode(); } @Override public final String toString() { - return newHologramLine.toString(); + return v3HologramLine.toString(); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2ItemLineAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2ItemLineAdapter.java index 4316fce2..890a8546 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2ItemLineAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2ItemLineAdapter.java @@ -13,15 +13,15 @@ import org.bukkit.inventory.ItemStack; @SuppressWarnings("deprecation") public class V2ItemLineAdapter extends V2TouchableLineAdapter implements ItemLine { - private final APIItemLine newItemLine; + private final APIItemLine v3ItemLine; private PickupHandler v2PickupHandler; - public V2ItemLineAdapter(APIItemLine newItemLine) { - super(newItemLine); - this.newItemLine = newItemLine; + public V2ItemLineAdapter(APIItemLine v3ItemLine) { + super(v3ItemLine); + this.v3ItemLine = v3ItemLine; } - public void onNewPickupHandlerChange( + public void onV3PickupHandlerChange( me.filoghost.holographicdisplays.api.hologram.PickupHandler previous, me.filoghost.holographicdisplays.api.hologram.PickupHandler current) { if (previous != current) { @@ -32,17 +32,17 @@ public class V2ItemLineAdapter extends V2TouchableLineAdapter implements ItemLin @Override public void setPickupHandler(PickupHandler v2PickupHandler) { if (v2PickupHandler == null) { - newItemLine.setPickupHandler(null); + v3ItemLine.setPickupHandler(null); } else if (v2PickupHandler instanceof V2PickupHandlerAdapter) { - // Adapter created from the getPickupHandler() method, simply unwrap it - newItemLine.setPickupHandler(((V2PickupHandlerAdapter) v2PickupHandler).getNewPickupHandler()); + // Adapter created from the getter method, simply unwrap it + v3ItemLine.setPickupHandler(((V2PickupHandlerAdapter) v2PickupHandler).getV3PickupHandler()); } else { - me.filoghost.holographicdisplays.api.hologram.PickupHandler newPickupHandler = newItemLine.getPickupHandler(); + me.filoghost.holographicdisplays.api.hologram.PickupHandler v3PickupHandler = v3ItemLine.getPickupHandler(); // Adapt the old v2 handler to the new API, creating a new instance only if the wrapped handler changed - if (!(newPickupHandler instanceof NewPickupHandlerAdapter) - || ((NewPickupHandlerAdapter) newPickupHandler).getV2PickupHandler() != v2PickupHandler) { - newItemLine.setPickupHandler(new NewPickupHandlerAdapter(v2PickupHandler)); + if (!(v3PickupHandler instanceof V3PickupHandlerAdapter) + || ((V3PickupHandlerAdapter) v3PickupHandler).getV2PickupHandler() != v2PickupHandler) { + v3ItemLine.setPickupHandler(new V3PickupHandlerAdapter(v2PickupHandler)); } } this.v2PickupHandler = v2PickupHandler; @@ -52,16 +52,16 @@ public class V2ItemLineAdapter extends V2TouchableLineAdapter implements ItemLin public PickupHandler getPickupHandler() { // Lazy initialization if (v2PickupHandler == null) { - me.filoghost.holographicdisplays.api.hologram.PickupHandler newPickupHandler = newItemLine.getPickupHandler(); + me.filoghost.holographicdisplays.api.hologram.PickupHandler v3PickupHandler = v3ItemLine.getPickupHandler(); - if (newPickupHandler == null) { + if (v3PickupHandler == null) { // Keep it null - } else if (newPickupHandler instanceof NewPickupHandlerAdapter) { - // Adapter created from the setPickupHandler() method, simply unwrap it - v2PickupHandler = ((NewPickupHandlerAdapter) newPickupHandler).getV2PickupHandler(); + } else if (v3PickupHandler instanceof V3PickupHandlerAdapter) { + // Adapter created from the setter method, simply unwrap it + v2PickupHandler = ((V3PickupHandlerAdapter) v3PickupHandler).getV2PickupHandler(); } else { // Adapt the new handler to the old v2 API - v2PickupHandler = new V2PickupHandlerAdapter(newPickupHandler); + v2PickupHandler = new V2PickupHandlerAdapter(v3PickupHandler); } } return v2PickupHandler; @@ -69,12 +69,12 @@ public class V2ItemLineAdapter extends V2TouchableLineAdapter implements ItemLin @Override public ItemStack getItemStack() { - return newItemLine.getItemStack(); + return v3ItemLine.getItemStack(); } @Override public void setItemStack(ItemStack itemStack) { - newItemLine.setItemStack(itemStack); + v3ItemLine.setItemStack(itemStack); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2PickupHandlerAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2PickupHandlerAdapter.java index 50902048..81139951 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2PickupHandlerAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2PickupHandlerAdapter.java @@ -11,19 +11,19 @@ import org.bukkit.entity.Player; @SuppressWarnings("deprecation") class V2PickupHandlerAdapter implements com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler { - private final PickupHandler newPickupHandler; + private final PickupHandler v3PickupHandler; - V2PickupHandlerAdapter(PickupHandler newPickupHandler) { - this.newPickupHandler = newPickupHandler; + V2PickupHandlerAdapter(PickupHandler v3PickupHandler) { + this.v3PickupHandler = v3PickupHandler; } @Override public void onPickup(Player player) { - newPickupHandler.onPickup(player); + v3PickupHandler.onPickup(player); } - public PickupHandler getNewPickupHandler() { - return newPickupHandler; + public PickupHandler getV3PickupHandler() { + return v3PickupHandler; } @Override @@ -36,17 +36,17 @@ class V2PickupHandlerAdapter implements com.gmail.filoghost.holographicdisplays. } V2PickupHandlerAdapter other = (V2PickupHandlerAdapter) obj; - return this.newPickupHandler.equals(other.newPickupHandler); + return this.v3PickupHandler.equals(other.v3PickupHandler); } @Override public final int hashCode() { - return newPickupHandler.hashCode(); + return v3PickupHandler.hashCode(); } @Override public final String toString() { - return newPickupHandler.toString(); + return v3PickupHandler.toString(); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TextLineAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TextLineAdapter.java index 5560f397..52b49650 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TextLineAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TextLineAdapter.java @@ -11,21 +11,21 @@ import me.filoghost.holographicdisplays.plugin.hologram.api.APITextLine; @SuppressWarnings("deprecation") public class V2TextLineAdapter extends V2TouchableLineAdapter implements TextLine { - private final APITextLine newTextLine; + private final APITextLine v3TextLine; - public V2TextLineAdapter(APITextLine newTextLine) { - super(newTextLine); - this.newTextLine = newTextLine; + public V2TextLineAdapter(APITextLine v3TextLine) { + super(v3TextLine); + this.v3TextLine = v3TextLine; } @Override public String getText() { - return newTextLine.getText(); + return v3TextLine.getText(); } @Override public void setText(String text) { - newTextLine.setText(text); + v3TextLine.setText(text); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchHandlerAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchHandlerAdapter.java index 541acee4..81ffde27 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchHandlerAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchHandlerAdapter.java @@ -11,19 +11,19 @@ import org.bukkit.entity.Player; @SuppressWarnings("deprecation") class V2TouchHandlerAdapter implements com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler { - private final TouchHandler newTouchHandler; + private final TouchHandler v3TouchHandler; - V2TouchHandlerAdapter(TouchHandler newTouchHandler) { - this.newTouchHandler = newTouchHandler; + V2TouchHandlerAdapter(TouchHandler v3TouchHandler) { + this.v3TouchHandler = v3TouchHandler; } @Override public void onTouch(Player player) { - newTouchHandler.onTouch(player); + v3TouchHandler.onTouch(player); } - public TouchHandler getNewTouchHandler() { - return newTouchHandler; + public TouchHandler getV3TouchHandler() { + return v3TouchHandler; } @Override @@ -36,17 +36,17 @@ class V2TouchHandlerAdapter implements com.gmail.filoghost.holographicdisplays.a } V2TouchHandlerAdapter other = (V2TouchHandlerAdapter) obj; - return this.newTouchHandler.equals(other.newTouchHandler); + return this.v3TouchHandler.equals(other.v3TouchHandler); } @Override public final int hashCode() { - return newTouchHandler.hashCode(); + return v3TouchHandler.hashCode(); } @Override public final String toString() { - return newTouchHandler.toString(); + return v3TouchHandler.toString(); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java index f8cc66bd..90199b1b 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapter.java @@ -12,15 +12,15 @@ import me.filoghost.holographicdisplays.plugin.hologram.api.APITouchableLine; @SuppressWarnings("deprecation") abstract class V2TouchableLineAdapter extends V2HologramLineAdapter implements TouchableLine { - private final APITouchableLine newTouchableLine; + private final APITouchableLine v3TouchableLine; private TouchHandler v2TouchHandler; - V2TouchableLineAdapter(APITouchableLine newTouchableLine) { - super(newTouchableLine); - this.newTouchableLine = newTouchableLine; + V2TouchableLineAdapter(APITouchableLine v3TouchableLine) { + super(v3TouchableLine); + this.v3TouchableLine = v3TouchableLine; } - public void onNewTouchHandlerChange( + public void onV3TouchHandlerChange( me.filoghost.holographicdisplays.api.hologram.TouchHandler previous, me.filoghost.holographicdisplays.api.hologram.TouchHandler current) { if (previous != current) { @@ -31,17 +31,17 @@ abstract class V2TouchableLineAdapter extends V2HologramLineAdapter implements T @Override public void setTouchHandler(TouchHandler v2TouchHandler) { if (v2TouchHandler == null) { - newTouchableLine.setTouchHandler(null); + v3TouchableLine.setTouchHandler(null); } else if (v2TouchHandler instanceof V2TouchHandlerAdapter) { - // Adapter created from the getTouchHandler() method, simply unwrap it - newTouchableLine.setTouchHandler(((V2TouchHandlerAdapter) v2TouchHandler).getNewTouchHandler()); + // Adapter created from the getter method, simply unwrap it + v3TouchableLine.setTouchHandler(((V2TouchHandlerAdapter) v2TouchHandler).getV3TouchHandler()); } else { - me.filoghost.holographicdisplays.api.hologram.TouchHandler newTouchHandler = newTouchableLine.getTouchHandler(); + me.filoghost.holographicdisplays.api.hologram.TouchHandler v3TouchHandler = v3TouchableLine.getTouchHandler(); // Adapt the old v2 handler to the new API, creating a new instance only if the wrapped handler changed - if (!(newTouchHandler instanceof NewTouchHandlerAdapter) - || ((NewTouchHandlerAdapter) newTouchHandler).getV2TouchHandler() != v2TouchHandler) { - newTouchableLine.setTouchHandler(new NewTouchHandlerAdapter(v2TouchHandler)); + if (!(v3TouchHandler instanceof V3TouchHandlerAdapter) + || ((V3TouchHandlerAdapter) v3TouchHandler).getV2TouchHandler() != v2TouchHandler) { + v3TouchableLine.setTouchHandler(new V3TouchHandlerAdapter(v2TouchHandler)); } } this.v2TouchHandler = v2TouchHandler; @@ -51,16 +51,16 @@ abstract class V2TouchableLineAdapter extends V2HologramLineAdapter implements T public TouchHandler getTouchHandler() { // Lazy initialization if (v2TouchHandler == null) { - me.filoghost.holographicdisplays.api.hologram.TouchHandler newTouchHandler = newTouchableLine.getTouchHandler(); + me.filoghost.holographicdisplays.api.hologram.TouchHandler v3TouchHandler = v3TouchableLine.getTouchHandler(); - if (newTouchHandler == null) { + if (v3TouchHandler == null) { // Keep it null - } else if (newTouchHandler instanceof NewTouchHandlerAdapter) { - // Adapter created from the setTouchHandler() method, simply unwrap it - v2TouchHandler = ((NewTouchHandlerAdapter) newTouchHandler).getV2TouchHandler(); + } else if (v3TouchHandler instanceof V3TouchHandlerAdapter) { + // Adapter created from the setter method, simply unwrap it + v2TouchHandler = ((V3TouchHandlerAdapter) v3TouchHandler).getV2TouchHandler(); } else { // Adapt the new handler to the old v2 API - v2TouchHandler = new V2TouchHandlerAdapter(newTouchHandler); + v2TouchHandler = new V2TouchHandlerAdapter(v3TouchHandler); } } return v2TouchHandler; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2VisibilityManagerAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2VisibilityManagerAdapter.java index d1dce065..55f1fd1a 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2VisibilityManagerAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V2VisibilityManagerAdapter.java @@ -13,45 +13,45 @@ import org.bukkit.entity.Player; @SuppressWarnings("deprecation") public class V2VisibilityManagerAdapter implements VisibilityManager { - private final DefaultVisibilitySettings newVisibilitySettings; + private final DefaultVisibilitySettings v3VisibilitySettings; - public V2VisibilityManagerAdapter(DefaultVisibilitySettings newVisibilitySettings) { - this.newVisibilitySettings = newVisibilitySettings; + public V2VisibilityManagerAdapter(DefaultVisibilitySettings v3VisibilitySettings) { + this.v3VisibilitySettings = v3VisibilitySettings; } @Override public boolean isVisibleByDefault() { - return newVisibilitySettings.getDefaultVisibility() == Visibility.VISIBLE; + return v3VisibilitySettings.getDefaultVisibility() == Visibility.VISIBLE; } @Override public void setVisibleByDefault(boolean visibleByDefault) { - newVisibilitySettings.setDefaultVisibility(visibleByDefault ? Visibility.VISIBLE : Visibility.HIDDEN); + v3VisibilitySettings.setDefaultVisibility(visibleByDefault ? Visibility.VISIBLE : Visibility.HIDDEN); } @Override public void showTo(Player player) { - newVisibilitySettings.setIndividualVisibility(player, Visibility.VISIBLE); + v3VisibilitySettings.setIndividualVisibility(player, Visibility.VISIBLE); } @Override public void hideTo(Player player) { - newVisibilitySettings.setIndividualVisibility(player, Visibility.HIDDEN); + v3VisibilitySettings.setIndividualVisibility(player, Visibility.HIDDEN); } @Override public boolean isVisibleTo(Player player) { - return newVisibilitySettings.isVisibleTo(player); + return v3VisibilitySettings.isVisibleTo(player); } @Override public void resetVisibility(Player player) { - newVisibilitySettings.resetIndividualVisibility(player); + v3VisibilitySettings.resetIndividualVisibility(player); } @Override public void resetVisibilityAll() { - newVisibilitySettings.resetIndividualVisibilityAll(); + v3VisibilitySettings.resetIndividualVisibilityAll(); } @Override @@ -64,17 +64,17 @@ public class V2VisibilityManagerAdapter implements VisibilityManager { } V2VisibilityManagerAdapter other = (V2VisibilityManagerAdapter) obj; - return this.newVisibilitySettings.equals(other.newVisibilitySettings); + return this.v3VisibilitySettings.equals(other.v3VisibilitySettings); } @Override public final int hashCode() { - return newVisibilitySettings.hashCode(); + return v3VisibilitySettings.hashCode(); } @Override public final String toString() { - return newVisibilitySettings.toString(); + return v3VisibilitySettings.toString(); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/NewPickupHandlerAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V3PickupHandlerAdapter.java similarity index 77% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/NewPickupHandlerAdapter.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V3PickupHandlerAdapter.java index cc778fa5..fefcb79e 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/NewPickupHandlerAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V3PickupHandlerAdapter.java @@ -10,11 +10,11 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @SuppressWarnings("deprecation") -public class NewPickupHandlerAdapter implements me.filoghost.holographicdisplays.api.hologram.PickupHandler { +public class V3PickupHandlerAdapter implements me.filoghost.holographicdisplays.api.hologram.PickupHandler { private final PickupHandler v2PickupHandler; - public NewPickupHandlerAdapter(PickupHandler v2PickupHandler) { + public V3PickupHandlerAdapter(PickupHandler v2PickupHandler) { this.v2PickupHandler = v2PickupHandler; } @@ -32,11 +32,11 @@ public class NewPickupHandlerAdapter implements me.filoghost.holographicdisplays if (this == obj) { return true; } - if (!(obj instanceof NewPickupHandlerAdapter)) { + if (!(obj instanceof V3PickupHandlerAdapter)) { return false; } - NewPickupHandlerAdapter other = (NewPickupHandlerAdapter) obj; + V3PickupHandlerAdapter other = (V3PickupHandlerAdapter) obj; return this.v2PickupHandler.equals(other.v2PickupHandler); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/NewTouchHandlerAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V3TouchHandlerAdapter.java similarity index 78% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/NewTouchHandlerAdapter.java rename to plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V3TouchHandlerAdapter.java index 7c225bda..81a6d3ac 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/NewTouchHandlerAdapter.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/v2/V3TouchHandlerAdapter.java @@ -10,11 +10,11 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @SuppressWarnings("deprecation") -public class NewTouchHandlerAdapter implements me.filoghost.holographicdisplays.api.hologram.TouchHandler { +public class V3TouchHandlerAdapter implements me.filoghost.holographicdisplays.api.hologram.TouchHandler { private final TouchHandler v2TouchHandler; - public NewTouchHandlerAdapter(TouchHandler v2TouchHandler) { + public V3TouchHandlerAdapter(TouchHandler v2TouchHandler) { this.v2TouchHandler = v2TouchHandler; } @@ -32,11 +32,11 @@ public class NewTouchHandlerAdapter implements me.filoghost.holographicdisplays. if (this == obj) { return true; } - if (!(obj instanceof NewTouchHandlerAdapter)) { + if (!(obj instanceof V3TouchHandlerAdapter)) { return false; } - NewTouchHandlerAdapter other = (NewTouchHandlerAdapter) obj; + V3TouchHandlerAdapter other = (V3TouchHandlerAdapter) obj; return this.v2TouchHandler.equals(other.v2TouchHandler); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java index 58bbfb60..f5990774 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIItemLine.java @@ -34,14 +34,14 @@ public class APIItemLine extends BaseItemLine implements ItemLine, APITouchableL public void setTouchHandler(@Nullable TouchHandler touchHandler) { TouchHandler oldTouchHandler = getTouchHandler(); super.setTouchHandler(touchHandler); - v2Adapter.onNewTouchHandlerChange(oldTouchHandler, touchHandler); + v2Adapter.onV3TouchHandlerChange(oldTouchHandler, touchHandler); } @Override public void setPickupHandler(@Nullable PickupHandler pickupHandler) { PickupHandler oldPickupHandler = getPickupHandler(); super.setPickupHandler(pickupHandler); - v2Adapter.onNewPickupHandlerChange(oldPickupHandler, pickupHandler); + v2Adapter.onV3PickupHandlerChange(oldPickupHandler, pickupHandler); } @Override diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java index 94108bc1..0e1de79d 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APITextLine.java @@ -37,7 +37,7 @@ public class APITextLine extends BaseTextLine implements TextLine, APITouchableL public void setTouchHandler(@Nullable TouchHandler touchHandler) { TouchHandler oldTouchHandler = getTouchHandler(); super.setTouchHandler(touchHandler); - v2Adapter.onNewTouchHandlerChange(oldTouchHandler, touchHandler); + v2Adapter.onV3TouchHandlerChange(oldTouchHandler, touchHandler); } @Override diff --git a/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java b/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java index 0fee0bd5..56ce866b 100644 --- a/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java +++ b/plugin/src/test/java/me/filoghost/holographicdisplays/plugin/api/v2/V2TouchableLineAdapterTest.java @@ -31,28 +31,28 @@ class V2TouchableLineAdapterTest { @Test void setNullV2TouchHandler() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); - ExampleNewTouchHandler newTouchHandler = new ExampleNewTouchHandler(); + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); + ExampleV3TouchHandler v3TouchHandler = new ExampleV3TouchHandler(); - newLine.setTouchHandler(newTouchHandler); + v3Line.setTouchHandler(v3TouchHandler); v2Line.setTouchHandler(null); assertThat(v2Line.getTouchHandler()).isNull(); - assertThat(newLine.getTouchHandler()).isNull(); + assertThat(v3Line.getTouchHandler()).isNull(); } @Test - void setNullNewTouchHandler() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); + void setNullV3TouchHandler() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); v2Line.setTouchHandler(v2TouchHandler); - newLine.setTouchHandler(null); + v3Line.setTouchHandler(null); assertThat(v2Line.getTouchHandler()).isNull(); - assertThat(newLine.getTouchHandler()).isNull(); + assertThat(v3Line.getTouchHandler()).isNull(); } @Test @@ -66,33 +66,33 @@ class V2TouchableLineAdapterTest { } @Test - void setNewGetV2TouchHandler() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); - ExampleNewTouchHandler newTouchHandler = new ExampleNewTouchHandler(); + void setV3GetV2TouchHandler() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); + ExampleV3TouchHandler v3TouchHandler = new ExampleV3TouchHandler(); - newLine.setTouchHandler(newTouchHandler); + v3Line.setTouchHandler(v3TouchHandler); assertThat(v2Line.getTouchHandler()).isNotNull(); } @Test - void setV2GetNewTouchHandler() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); + void setV2GetV3TouchHandler() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); v2Line.setTouchHandler(v2TouchHandler); - assertThat(newLine.getTouchHandler()).isNotNull(); + assertThat(v3Line.getTouchHandler()).isNotNull(); } @Test void repeatedGetV2TouchHandlerShouldReturnSameInstance() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); - newLine.setTouchHandler(new ExampleNewTouchHandler()); + v3Line.setTouchHandler(new ExampleV3TouchHandler()); assertThat(v2Line.getTouchHandler()).isSameAs(v2Line.getTouchHandler()); v2Line.setTouchHandler(new ExampleV2TouchHandler()); @@ -100,83 +100,83 @@ class V2TouchableLineAdapterTest { } @Test - void repeatedSetV2TouchHandlerShouldNotChangeNewTouchHandlerInstance() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); + void repeatedSetV2TouchHandlerShouldNotChangeV3TouchHandlerInstance() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); v2Line.setTouchHandler(v2TouchHandler); - TouchHandler newTouchHandlerA = newLine.getTouchHandler(); + TouchHandler v3TouchHandlerA = v3Line.getTouchHandler(); v2Line.setTouchHandler(v2TouchHandler); - TouchHandler newTouchHandlerB = newLine.getTouchHandler(); + TouchHandler v3TouchHandlerB = v3Line.getTouchHandler(); - assertThat(newTouchHandlerA).isSameAs(newTouchHandlerB); + assertThat(v3TouchHandlerA).isSameAs(v3TouchHandlerB); } @Test - void repeatedSetNewTouchHandlerShouldNotChangeV2TouchHandlerInstance() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); - ExampleNewTouchHandler v2TouchHandler = new ExampleNewTouchHandler(); + void repeatedSetV3TouchHandlerShouldNotChangeV2TouchHandlerInstance() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); + ExampleV3TouchHandler v2TouchHandler = new ExampleV3TouchHandler(); - newLine.setTouchHandler(v2TouchHandler); + v3Line.setTouchHandler(v2TouchHandler); com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandlerA = v2Line.getTouchHandler(); - newLine.setTouchHandler(v2TouchHandler); + v3Line.setTouchHandler(v2TouchHandler); com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandlerB = v2Line.getTouchHandler(); assertThat(v2TouchHandlerA).isSameAs(v2TouchHandlerB); } @Test - void v2TouchHandlerChangesWhenNewTouchHandlerChanges() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); + void v2TouchHandlerChangesWhenV3TouchHandlerChanges() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); - newLine.setTouchHandler(new ExampleNewTouchHandler()); + v3Line.setTouchHandler(new ExampleV3TouchHandler()); com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandlerA = v2Line.getTouchHandler(); - newLine.setTouchHandler(new ExampleNewTouchHandler()); + v3Line.setTouchHandler(new ExampleV3TouchHandler()); com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandlerB = v2Line.getTouchHandler(); assertThat(v2TouchHandlerA).isNotSameAs(v2TouchHandlerB); } @Test - void newTouchHandlerChangesWhenV2TouchHandlerChanges() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); + void v3TouchHandlerChangesWhenV2TouchHandlerChanges() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); v2Line.setTouchHandler(new ExampleV2TouchHandler()); - TouchHandler newTouchHandlerA = newLine.getTouchHandler(); + TouchHandler v3TouchHandlerA = v3Line.getTouchHandler(); v2Line.setTouchHandler(new ExampleV2TouchHandler()); - TouchHandler newTouchHandlerB = newLine.getTouchHandler(); + TouchHandler v3TouchHandlerB = v3Line.getTouchHandler(); - assertThat(newTouchHandlerA).isNotSameAs(newTouchHandlerB); + assertThat(v3TouchHandlerA).isNotSameAs(v3TouchHandlerB); } @Test - void preserveTouchHandlerInstancesWhenUsingNewAPI() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); + void preserveTouchHandlerInstancesWhenUsingV3API() { + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); ExampleV2TouchHandler v2TouchHandler = new ExampleV2TouchHandler(); v2Line.setTouchHandler(v2TouchHandler); - TouchHandler newTouchHandler = newLine.getTouchHandler(); + TouchHandler v3TouchHandler = v3Line.getTouchHandler(); v2Line.setTouchHandler(null); // This also clears the adapter - newLine.setTouchHandler(newTouchHandler); // Return to the initial value + v3Line.setTouchHandler(v3TouchHandler); // Return to the initial value // Instances should be the same assertThat(v2Line.getTouchHandler()).isSameAs(v2TouchHandler); - assertThat(newLine.getTouchHandler()).isSameAs(newTouchHandler); + assertThat(v3Line.getTouchHandler()).isSameAs(v3TouchHandler); } @Test void preserveTouchHandlerInstancesWhenUsingV2API() { - APITextLine newLine = hologram.appendTextLine(""); - TextLine v2Line = newLine.getV2Adapter(); - ExampleNewTouchHandler newTouchHandler = new ExampleNewTouchHandler(); + APITextLine v3Line = hologram.appendTextLine(""); + TextLine v2Line = v3Line.getV2Adapter(); + ExampleV3TouchHandler v3TouchHandler = new ExampleV3TouchHandler(); - newLine.setTouchHandler(newTouchHandler); + v3Line.setTouchHandler(v3TouchHandler); com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler v2TouchHandler = v2Line.getTouchHandler(); v2Line.setTouchHandler(null); // This also clears the adapter @@ -184,11 +184,11 @@ class V2TouchableLineAdapterTest { // Instances should be the same assertThat(v2Line.getTouchHandler()).isSameAs(v2TouchHandler); - assertThat(newLine.getTouchHandler()).isSameAs(newTouchHandler); + assertThat(v3Line.getTouchHandler()).isSameAs(v3TouchHandler); } - private static class ExampleNewTouchHandler implements TouchHandler { + private static class ExampleV3TouchHandler implements TouchHandler { @Override public void onTouch(@NotNull Player player) {}