aboutsummaryrefslogtreecommitdiff
path: root/spark-bukkit/src/main/java/me/lucko
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2019-12-03 14:35:07 +0000
committerLuck <git@lucko.me>2019-12-03 14:35:07 +0000
commit03b6f817f89275e4d5c3d5b1868c3dcc861bf146 (patch)
tree669fa3086044d5fe9662d161e67866a50734d430 /spark-bukkit/src/main/java/me/lucko
parentba1e2a04ddb56f183ac39323ca44733748cb43fd (diff)
downloadspark-03b6f817f89275e4d5c3d5b1868c3dcc861bf146.tar.gz
spark-03b6f817f89275e4d5c3d5b1868c3dcc861bf146.tar.bz2
spark-03b6f817f89275e4d5c3d5b1868c3dcc861bf146.zip
Some cleanup & refactoring
Diffstat (limited to 'spark-bukkit/src/main/java/me/lucko')
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitCommandSender.java35
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/placeholder/SparkPlaceholderApi.java6
2 files changed, 13 insertions, 28 deletions
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitCommandSender.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitCommandSender.java
index d353845..8bfc015 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitCommandSender.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitCommandSender.java
@@ -20,53 +20,40 @@
package me.lucko.spark.bukkit;
-import me.lucko.spark.common.CommandSender;
+
+import me.lucko.spark.common.command.sender.AbstractCommandSender;
import net.kyori.text.Component;
import net.kyori.text.adapter.bukkit.TextAdapter;
+import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.UUID;
-public class BukkitCommandSender implements CommandSender {
- private final org.bukkit.command.CommandSender sender;
-
- public BukkitCommandSender(org.bukkit.command.CommandSender sender) {
- this.sender = sender;
+public class BukkitCommandSender extends AbstractCommandSender<CommandSender> {
+ public BukkitCommandSender(CommandSender sender) {
+ super(sender);
}
@Override
public String getName() {
- return this.sender.getName();
+ return this.delegate.getName();
}
@Override
public UUID getUniqueId() {
- if (this.sender instanceof Player) {
- return ((Player) this.sender).getUniqueId();
+ if (super.delegate instanceof Player) {
+ return ((Player) 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;
- BukkitCommandSender that = (BukkitCommandSender) o;
- return this.sender.equals(that.sender);
- }
-
- @Override
- public int hashCode() {
- return this.sender.hashCode();
+ return super.delegate.hasPermission(permission);
}
}
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/placeholder/SparkPlaceholderApi.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/placeholder/SparkPlaceholderApi.java
index e5ada99..1eb2732 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/placeholder/SparkPlaceholderApi.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/placeholder/SparkPlaceholderApi.java
@@ -26,8 +26,6 @@ import me.lucko.spark.common.SparkPlatform;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
-import java.util.stream.Collectors;
-
public class SparkPlaceholderApi extends PlaceholderExpansion {
private final BukkitSparkPlugin plugin;
private final SparkPlatform platform;
@@ -55,12 +53,12 @@ public class SparkPlaceholderApi extends PlaceholderExpansion {
@Override
public String getAuthor() {
- return plugin.getDescription().getAuthors().stream().collect(Collectors.joining(", "));
+ return String.join(", ", this.plugin.getDescription().getAuthors());
}
@Override
public String getVersion() {
- return plugin.getVersion();
+ return this.plugin.getVersion();
}
@Override