mirror of
https://github.com/aikar/commands.git
synced 2026-06-06 00:52:16 +00:00
add hashcodes/equals to command issuers
This commit is contained in:
@@ -27,6 +27,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BukkitCommandIssuer implements CommandIssuer {
|
||||
private final BukkitCommandManager manager;
|
||||
private final CommandSender sender;
|
||||
@@ -61,4 +63,17 @@ public class BukkitCommandIssuer implements CommandIssuer {
|
||||
public boolean hasPermission(String name) {
|
||||
return sender.hasPermission(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BukkitCommandIssuer that = (BukkitCommandIssuer) o;
|
||||
return Objects.equals(sender, that.sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(sender);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BungeeCommandIssuer implements CommandIssuer{
|
||||
private final BungeeCommandManager manager;
|
||||
private final CommandSender sender;
|
||||
@@ -62,4 +64,18 @@ public class BungeeCommandIssuer implements CommandIssuer{
|
||||
public boolean hasPermission(String name) {
|
||||
return sender.hasPermission(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BungeeCommandIssuer that = (BungeeCommandIssuer) o;
|
||||
return Objects.equals(sender, that.sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(sender);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.format.TextColors;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SpongeCommandIssuer implements CommandIssuer {
|
||||
|
||||
private final SpongeCommandManager manager;
|
||||
@@ -64,4 +66,18 @@ public class SpongeCommandIssuer implements CommandIssuer {
|
||||
public boolean hasPermission(final 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;
|
||||
SpongeCommandIssuer that = (SpongeCommandIssuer) o;
|
||||
return Objects.equals(source, that.source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(source);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user