diff options
author | Luck <git@lucko.me> | 2019-12-03 14:35:07 +0000 |
---|---|---|
committer | Luck <git@lucko.me> | 2019-12-03 14:35:07 +0000 |
commit | 03b6f817f89275e4d5c3d5b1868c3dcc861bf146 (patch) | |
tree | 669fa3086044d5fe9662d161e67866a50734d430 /spark-velocity/src/main | |
parent | ba1e2a04ddb56f183ac39323ca44733748cb43fd (diff) | |
download | spark-03b6f817f89275e4d5c3d5b1868c3dcc861bf146.tar.gz spark-03b6f817f89275e4d5c3d5b1868c3dcc861bf146.tar.bz2 spark-03b6f817f89275e4d5c3d5b1868c3dcc861bf146.zip |
Some cleanup & refactoring
Diffstat (limited to 'spark-velocity/src/main')
-rw-r--r-- | spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityCommandSender.java | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityCommandSender.java b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityCommandSender.java index e9b4474..e49e802 100644 --- a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityCommandSender.java +++ b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityCommandSender.java @@ -23,57 +23,42 @@ package me.lucko.spark.velocity; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.ConsoleCommandSource; import com.velocitypowered.api.proxy.Player; -import me.lucko.spark.common.CommandSender; +import me.lucko.spark.common.command.sender.AbstractCommandSender; import net.kyori.text.Component; import java.util.UUID; -public class VelocityCommandSender implements CommandSender { - private final CommandSource source; - +public class VelocityCommandSender extends AbstractCommandSender<CommandSource> { public VelocityCommandSender(CommandSource source) { - this.source = source; + super(source); } @Override public String getName() { - if (this.source instanceof Player) { - return ((Player) this.source).getUsername(); - } else if (this.source instanceof ConsoleCommandSource) { + if (super.delegate instanceof Player) { + return ((Player) super.delegate).getUsername(); + } else if (super.delegate instanceof ConsoleCommandSource) { return "Console"; } else { - return "unknown:" + this.source.getClass().getSimpleName(); + return "unknown:" + super.delegate.getClass().getSimpleName(); } } @Override public UUID getUniqueId() { - if (this.source instanceof Player) { - return ((Player) this.source).getUniqueId(); + if (super.delegate instanceof Player) { + return ((Player) super.delegate).getUniqueId(); } return null; } @Override public void sendMessage(Component message) { - this.source.sendMessage(message); + super.delegate.sendMessage(message); } @Override public boolean hasPermission(String permission) { - return this.source.hasPermission(permission); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - VelocityCommandSender that = (VelocityCommandSender) o; - return this.source.equals(that.source); - } - - @Override - public int hashCode() { - return this.source.hashCode(); + return super.delegate.hasPermission(permission); } } |