Remove unnecessary interfaces

This commit is contained in:
filoghost 2022-05-22 12:11:14 +02:00
parent 323998845b
commit 525622b59a
11 changed files with 82 additions and 127 deletions

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.core.api.current;
import me.filoghost.holographicdisplays.api.beta.hologram.line.ClickableHologramLine;
import me.filoghost.holographicdisplays.api.beta.hologram.line.HologramLineClickListener;
import me.filoghost.holographicdisplays.core.base.ClickCallbackProvider;
import org.bukkit.entity.Player;
interface APIClickableHologramLine extends ClickableHologramLine, APIHologramLine, ClickCallbackProvider {
@Override
default boolean hasClickCallback() {
return getClickListener() != null;
}
@Override
default void invokeClickCallback(Player player) {
HologramLineClickListener clickListener = getClickListener();
if (clickListener != null) {
clickListener.onClick(new SimpleHologramLineClickEvent(player));
}
}
}

View File

@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
class APIItemHologramLine extends BaseItemHologramLine implements ItemHologramLine, APIClickableHologramLine {
class APIItemHologramLine extends BaseItemHologramLine implements ItemHologramLine, APIHologramLine {
private HologramLinePickupListener pickupListener;
private HologramLineClickListener clickListener;
@ -39,6 +39,18 @@ class APIItemHologramLine extends BaseItemHologramLine implements ItemHologramLi
return clickListener;
}
@Override
public boolean hasPickupCallback() {
return pickupListener != null;
}
@Override
protected void invokePickupCallback(Player player) {
if (pickupListener != null) {
pickupListener.onPickup(new SimpleHologramLinePickupEvent(player));
}
}
@Override
public void setClickListener(@Nullable HologramLineClickListener clickListener) {
checkNotDeleted();
@ -47,14 +59,14 @@ class APIItemHologramLine extends BaseItemHologramLine implements ItemHologramLi
}
@Override
public boolean hasPickupCallback() {
return pickupListener != null;
public boolean hasClickCallback() {
return clickListener != null;
}
@Override
public void invokePickupCallback(Player player) {
if (pickupListener != null) {
pickupListener.onPickup(new SimpleHologramLinePickupEvent(player));
protected void invokeClickCallback(Player player) {
if (clickListener != null) {
clickListener.onClick(new SimpleHologramLineClickEvent(player));
}
}

View File

@ -9,9 +9,10 @@ import me.filoghost.holographicdisplays.api.beta.hologram.PlaceholderSetting;
import me.filoghost.holographicdisplays.api.beta.hologram.line.HologramLineClickListener;
import me.filoghost.holographicdisplays.api.beta.hologram.line.TextHologramLine;
import me.filoghost.holographicdisplays.core.base.BaseTextHologramLine;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
class APITextHologramLine extends BaseTextHologramLine implements TextHologramLine, APIClickableHologramLine {
class APITextHologramLine extends BaseTextHologramLine implements TextHologramLine, APIHologramLine {
private final APIHologram hologram;
@ -39,4 +40,16 @@ class APITextHologramLine extends BaseTextHologramLine implements TextHologramLi
return clickListener;
}
@Override
public boolean hasClickCallback() {
return clickListener != null;
}
@Override
protected void invokeClickCallback(Player player) {
if (clickListener != null) {
clickListener.onClick(new SimpleHologramLineClickEvent(player));
}
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.core.api.v2;
import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
import com.gmail.filoghost.holographicdisplays.api.line.CollectableLine;
import me.filoghost.holographicdisplays.core.base.PickupCallbackProvider;
import org.bukkit.entity.Player;
interface V2CollectableLine extends CollectableLine, V2HologramLine, PickupCallbackProvider {
@Override
default boolean hasPickupCallback() {
return getPickupHandler() != null;
}
@Override
default void invokePickupCallback(Player player) {
PickupHandler pickupListener = getPickupHandler();
if (pickupListener != null) {
pickupListener.onPickup(player);
}
}
}

View File

@ -9,10 +9,11 @@ import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
import me.filoghost.holographicdisplays.core.base.BaseItemHologramLine;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@SuppressWarnings("deprecation")
class V2ItemLine extends BaseItemHologramLine implements ItemLine, V2CollectableLine, V2TouchableLine {
class V2ItemLine extends BaseItemHologramLine implements ItemLine, V2HologramLine {
private final V2Hologram hologram;
@ -39,6 +40,18 @@ class V2ItemLine extends BaseItemHologramLine implements ItemLine, V2Collectable
return touchHandler;
}
@Override
public boolean hasClickCallback() {
return touchHandler != null;
}
@Override
protected void invokeClickCallback(Player player) {
if (touchHandler != null) {
touchHandler.onTouch(player);
}
}
@Override
public void setPickupHandler(PickupHandler pickupHandler) {
this.pickupHandler = pickupHandler;
@ -49,4 +62,16 @@ class V2ItemLine extends BaseItemHologramLine implements ItemLine, V2Collectable
return pickupHandler;
}
@Override
public boolean hasPickupCallback() {
return pickupHandler != null;
}
@Override
protected void invokePickupCallback(Player player) {
if (pickupHandler != null) {
pickupHandler.onPickup(player);
}
}
}

View File

@ -8,9 +8,10 @@ package me.filoghost.holographicdisplays.core.api.v2;
import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
import me.filoghost.holographicdisplays.core.base.BaseTextHologramLine;
import org.bukkit.entity.Player;
@SuppressWarnings("deprecation")
class V2TextLine extends BaseTextHologramLine implements TextLine, V2TouchableLine {
class V2TextLine extends BaseTextHologramLine implements TextLine, V2HologramLine {
private final V2Hologram hologram;
@ -41,4 +42,16 @@ class V2TextLine extends BaseTextHologramLine implements TextLine, V2TouchableLi
return touchHandler;
}
@Override
public boolean hasClickCallback() {
return touchHandler != null;
}
@Override
protected void invokeClickCallback(Player player) {
if (touchHandler != null) {
touchHandler.onTouch(player);
}
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.core.api.v2;
import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
import com.gmail.filoghost.holographicdisplays.api.line.TouchableLine;
import me.filoghost.holographicdisplays.core.base.ClickCallbackProvider;
import org.bukkit.entity.Player;
interface V2TouchableLine extends TouchableLine, V2HologramLine, ClickCallbackProvider {
@Override
default boolean hasClickCallback() {
return getTouchHandler() != null;
}
@Override
default void invokeClickCallback(Player player) {
TouchHandler touchHandler = getTouchHandler();
if (touchHandler != null) {
touchHandler.onTouch(player);
}
}
}

View File

@ -10,7 +10,7 @@ import me.filoghost.holographicdisplays.common.PositionCoordinates;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public abstract class BaseClickableHologramLine extends BaseHologramLine implements ClickCallbackProvider {
public abstract class BaseClickableHologramLine extends BaseHologramLine {
protected BaseClickableHologramLine(BaseHologram hologram) {
super(hologram);
@ -27,6 +27,10 @@ public abstract class BaseClickableHologramLine extends BaseHologramLine impleme
}
}
public abstract boolean hasClickCallback();
protected abstract void invokeClickCallback(Player player);
private boolean isInClickRange(Player player) {
Location playerLocation = player.getLocation();
PositionCoordinates position = this.getPosition();

View File

@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
public abstract class BaseItemHologramLine extends BaseClickableHologramLine implements PickupCallbackProvider {
public abstract class BaseItemHologramLine extends BaseClickableHologramLine {
private ItemStack itemStack;
@ -39,6 +39,10 @@ public abstract class BaseItemHologramLine extends BaseClickableHologramLine imp
}
}
public abstract boolean hasPickupCallback();
protected abstract void invokePickupCallback(Player player);
public @Nullable ItemStack getItemStack() {
return clone(itemStack);
}

View File

@ -1,16 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.core.base;
import org.bukkit.entity.Player;
public interface ClickCallbackProvider {
boolean hasClickCallback();
void invokeClickCallback(Player player);
}

View File

@ -1,16 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.core.base;
import org.bukkit.entity.Player;
public interface PickupCallbackProvider {
boolean hasPickupCallback();
void invokePickupCallback(Player player);
}