142 lines
4.7 KiB
Diff
142 lines
4.7 KiB
Diff
From f4e6040fbdea9cd0bd43b30d1a58c9bfb5084ad1 Mon Sep 17 00:00:00 2001
|
|
From: virtualWinter <winter@catmc.club>
|
|
Date: Fri, 21 Jul 2023 06:04:59 +0300
|
|
Subject: [PATCH] Disguises
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
index 48cbaa23..def61fbc 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -168,6 +168,23 @@ public final class Bukkit {
|
|
return server.getMaxPlayers();
|
|
}
|
|
|
|
+
|
|
+ // MineHQ start
|
|
+ /**
|
|
+ * @see Server#getPlayerByDisguise(String name)
|
|
+ */
|
|
+ public static Player getPlayerByDisguise(String name) {
|
|
+ return server.getPlayerByDisguise(name);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * @see Server#getPlayerExactByDisguise(String name)
|
|
+ */
|
|
+ public static Player getPlayerExactByDisguise(String name) {
|
|
+ return server.getPlayerExactByDisguise(name);
|
|
+ }
|
|
+ // MineHQ end
|
|
+
|
|
/**
|
|
* Get the game port that the server runs on.
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
index d001e286..537c2293 100644
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
|
@@ -143,6 +143,29 @@ public interface Server extends PluginMessageRecipient {
|
|
*/
|
|
public int getMaxPlayers();
|
|
|
|
+ // MineHQ start
|
|
+ /**
|
|
+ * Gets a player object by the given disguised name.
|
|
+ * <p>
|
|
+ * This method may not return objects for disguises not in use.
|
|
+ *
|
|
+ * @param name the disguised name to look up
|
|
+ * @return a player if one was found, null otherwise
|
|
+ */
|
|
+ public Player getPlayerByDisguise(String name);
|
|
+
|
|
+ /**
|
|
+ * Gets the player with the exact given disguise name, case insensitive
|
|
+ * <p>
|
|
+ * This method may not return objects for disguises not in use.
|
|
+ *
|
|
+ * @param name the exact disguised name of a player
|
|
+ * @return a player if one was found, null otherwise
|
|
+ */
|
|
+ public Player getPlayerExactByDisguise(String name);
|
|
+ // MineHQ end
|
|
+
|
|
+
|
|
/**
|
|
* Get the game port that the server runs on.
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
|
|
index c126a1e7..4d45b52d 100644
|
|
--- a/src/main/java/org/bukkit/command/Command.java
|
|
+++ b/src/main/java/org/bukkit/command/Command.java
|
|
@@ -32,6 +32,7 @@ public abstract class Command {
|
|
protected String usageMessage;
|
|
private String permission;
|
|
private String permissionMessage;
|
|
+
|
|
public co.aikar.timings.Timing timings; // Spigot
|
|
public String getTimingName() {return getName();} // Spigot
|
|
|
|
@@ -100,7 +101,7 @@ public abstract class Command {
|
|
|
|
ArrayList<String> matchedPlayers = new ArrayList<String>();
|
|
for (Player player : sender.getServer().getOnlinePlayers()) {
|
|
- String name = player.getName();
|
|
+ String name = player.getDisguisedName(); // MineHQ - Disguises
|
|
if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, lastWord)) {
|
|
matchedPlayers.add(name);
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
|
index d02fe560..559f3357 100644
|
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
|
@@ -50,6 +50,44 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
|
|
*/
|
|
public void setDisplayName(String name);
|
|
|
|
+ // MineHQ start - Disguises
|
|
+ /**
|
|
+ * Gets the disguised name of this player, or their
|
|
+ * actual name if they're not currently disguised.
|
|
+ */
|
|
+ public String getDisguisedName();
|
|
+
|
|
+ /**
|
|
+ * Is this {@link Player} currently disguised?
|
|
+ */
|
|
+ public boolean isDisguised();
|
|
+
|
|
+ /**
|
|
+ * Disguise this {@link Player} as someone else.
|
|
+ * This will disguise their tab-list name and tab-completion
|
|
+ * should take this into account.
|
|
+ *
|
|
+ * {@link #getDisplayName()} will return the disguised name, as
|
|
+ * well as {@link #getDisguisedName()}. {@link #getName()} should
|
|
+ * only be used in situations where we absolutely need the player's
|
|
+ * real name, and should never be outputted to other players.
|
|
+ *
|
|
+ * @param name The name of the player we want to disguise as
|
|
+ * @param texture We can add custom skins by doing this.*/
|
|
+ public void disguise(String name, String texture);
|
|
+
|
|
+ /**
|
|
+ * @see #disguise(String, String)
|
|
+ * This method does not allow for a custom skin.
|
|
+ */
|
|
+ public void disguise(String name);
|
|
+
|
|
+ /**
|
|
+ * Un-disguise this player.
|
|
+ */
|
|
+ public void undisguise();
|
|
+ // MineHQ end
|
|
+
|
|
/**
|
|
* Gets the name that is shown on the player list.
|
|
*
|
|
--
|
|
2.41.0.windows.1
|
|
|