From 03b6f817f89275e4d5c3d5b1868c3dcc861bf146 Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 3 Dec 2019 14:35:07 +0000 Subject: Some cleanup & refactoring --- .../spark/bungeecord/BungeeCordCommandSender.java | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'spark-bungeecord/src') diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java index 193b38a..dcafcaa 100644 --- a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java +++ b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java @@ -20,53 +20,40 @@ package me.lucko.spark.bungeecord; -import me.lucko.spark.common.CommandSender; + +import me.lucko.spark.common.command.sender.AbstractCommandSender; import net.kyori.text.Component; import net.kyori.text.adapter.bungeecord.TextAdapter; +import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.UUID; -public class BungeeCordCommandSender implements CommandSender { - private final net.md_5.bungee.api.CommandSender sender; - - public BungeeCordCommandSender(net.md_5.bungee.api.CommandSender sender) { - this.sender = sender; +public class BungeeCordCommandSender extends AbstractCommandSender { + public BungeeCordCommandSender(CommandSender sender) { + super(sender); } @Override public String getName() { - return this.sender.getName(); + return super.delegate.getName(); } @Override public UUID getUniqueId() { - if (this.sender instanceof ProxiedPlayer) { - return ((ProxiedPlayer) this.sender).getUniqueId(); + if (super.delegate instanceof ProxiedPlayer) { + return ((ProxiedPlayer) super.delegate).getUniqueId(); } return null; } @Override public void sendMessage(Component message) { - TextAdapter.sendComponent(this.sender, message); + TextAdapter.sendComponent(super.delegate, message); } @Override public boolean hasPermission(String permission) { - return this.sender.hasPermission(permission); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - BungeeCordCommandSender that = (BungeeCordCommandSender) o; - return this.sender.equals(that.sender); - } - - @Override - public int hashCode() { - return this.sender.hashCode(); + return super.delegate.hasPermission(permission); } } -- cgit