mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Add more component name methods (#6578)
This commit is contained in:
parent
3e736b8525
commit
7ab005b9c2
2 changed files with 136 additions and 0 deletions
|
@ -1266,12 +1266,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
// Spigot end
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the name of this command sender
|
||||
+ *
|
||||
+ * @return Name of the sender
|
||||
+ */
|
||||
+ public @NotNull Component name();
|
||||
+
|
||||
+ @Override
|
||||
+ default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
|
||||
+ this.sendMessage(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(message));
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/command/MessageCommandSender.java b/src/main/java/org/bukkit/command/MessageCommandSender.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/command/MessageCommandSender.java
|
||||
+++ b/src/main/java/org/bukkit/command/MessageCommandSender.java
|
||||
@@ -0,0 +0,0 @@ public interface MessageCommandSender extends CommandSender {
|
||||
default String getName() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ default net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
|
||||
+ throw new NotImplementedException();
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
default boolean isOp() {
|
||||
diff --git a/src/main/java/org/bukkit/command/ProxiedCommandSender.java b/src/main/java/org/bukkit/command/ProxiedCommandSender.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/command/ProxiedCommandSender.java
|
||||
|
@ -1361,6 +1385,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
// Spigot end
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the entity's display name formatted with their team prefix/suffix and
|
||||
+ * the entity's default hover/click events.
|
||||
+ *
|
||||
+ * @return the team display name
|
||||
+ */
|
||||
+ @NotNull net.kyori.adventure.text.Component teamDisplayName();
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) {
|
||||
|
|
|
@ -2060,10 +2060,42 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
public static Component[] sanitizeLines(String[] lines) {
|
||||
Component[] components = new Component[4];
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java
|
||||
@@ -0,0 +0,0 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
|
||||
return this.block.getTextName();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component name() {
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.block.getDisplayName());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
|
||||
@@ -0,0 +0,0 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
|
||||
return "CONSOLE";
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component name() {
|
||||
+ return net.kyori.adventure.text.Component.text(this.getName());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
@@ -0,0 +0,0 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
|
||||
public boolean isConversing() {
|
||||
return this.conversationTracker.isConversing();
|
||||
|
@ -2076,6 +2108,42 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
|
||||
@@ -0,0 +0,0 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
|
||||
return "Rcon";
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component name() {
|
||||
+ return net.kyori.adventure.text.Component.text(this.getName());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java
|
||||
@@ -0,0 +0,0 @@ public class ProxiedNativeCommandSender implements ProxiedCommandSender {
|
||||
return this.getCallee().getName();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component name() {
|
||||
+ return this.getCallee().name();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean isPermissionSet(String name) {
|
||||
return this.getCaller().isPermissionSet(name);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
||||
|
@ -2117,6 +2185,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
@Override
|
||||
public void setCustomName(String name) {
|
||||
// sane limit for name length
|
||||
@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
public String getName() {
|
||||
return CraftChatMessage.fromComponent(this.getHandle().getName());
|
||||
}
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getName());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component teamDisplayName() {
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getDisplayName());
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String name) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
|
@ -2151,6 +2237,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
player.containerMenu = container;
|
||||
player.initMenu(container);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
@@ -0,0 +0,0 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
|
||||
return CraftChatMessage.fromComponent(this.getHandle().getCommandBlock().getName());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getCommandBlock().getName());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
|
|
Loading…
Reference in a new issue