2018-08-06 01:46:43 +02:00
|
|
|
From 2a36c0293be0e894d2fb7531a905844308ce4a32 Mon Sep 17 00:00:00 2001
|
2016-12-27 21:06:14 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Tue, 27 Dec 2016 15:02:42 -0500
|
|
|
|
Subject: [PATCH] String based Action Bar API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
2018-08-06 01:46:43 +02:00
|
|
|
index 70cdc3f102..381542e0d2 100644
|
2016-12-27 21:06:14 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
|
|
|
@@ -1,10 +1,13 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
|
+import org.apache.commons.lang.exception.ExceptionUtils;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
+import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
|
|
import org.spigotmc.AsyncCatcher;
|
|
|
|
|
|
|
|
+import javax.annotation.Nonnull;
|
|
|
|
import javax.annotation.Nullable;
|
2018-07-22 06:45:49 +02:00
|
|
|
import java.util.Queue;
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
@@ -21,6 +24,24 @@ public final class MCUtil {
|
2016-12-27 21:06:14 +01:00
|
|
|
|
|
|
|
private MCUtil() {}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Quickly generate a stack trace for current location
|
|
|
|
+ *
|
|
|
|
+ * @return Stacktrace
|
|
|
|
+ */
|
|
|
|
+ public static String stack() {
|
|
|
|
+ return ExceptionUtils.getFullStackTrace(new Throwable());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Quickly generate a stack trace for current location with message
|
|
|
|
+ *
|
|
|
|
+ * @param str
|
|
|
|
+ * @return Stacktrace
|
|
|
|
+ */
|
|
|
|
+ public static String stack(String str) {
|
|
|
|
+ return ExceptionUtils.getFullStackTrace(new Throwable(str));
|
|
|
|
+ }
|
|
|
|
|
2018-07-22 06:45:49 +02:00
|
|
|
public static boolean isMainThread() {
|
|
|
|
return MinecraftServer.getServer().isMainThread();
|
2018-07-23 01:39:56 +02:00
|
|
|
@@ -289,4 +310,13 @@ public final class MCUtil {
|
2016-12-27 21:06:14 +01:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Nonnull
|
|
|
|
+ public static World getNMSWorld(@Nonnull org.bukkit.World world) {
|
|
|
|
+ return ((CraftWorld) world).getHandle();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static World getNMSWorld(@Nonnull org.bukkit.entity.Entity entity) {
|
|
|
|
+ return getNMSWorld(entity.getWorld());
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2018-08-06 01:46:43 +02:00
|
|
|
index 6f23ef5b81..63341ec778 100644
|
2016-12-27 21:06:14 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2018-07-29 18:42:07 +02:00
|
|
|
@@ -209,6 +209,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2018-03-10 14:07:40 +01:00
|
|
|
}
|
2016-12-27 21:06:14 +01:00
|
|
|
|
|
|
|
// Paper start
|
2018-03-10 14:07:40 +01:00
|
|
|
+ @Override
|
2016-12-27 21:06:14 +01:00
|
|
|
+ public void sendActionBar(String message) {
|
|
|
|
+ if (getHandle().playerConnection == null || message == null || message.isEmpty()) return;
|
2018-07-19 06:42:43 +02:00
|
|
|
+ getHandle().playerConnection.sendPacket(new PacketPlayOutChat(new net.minecraft.server.ChatComponentText(message), net.minecraft.server.ChatMessageType.GAME_INFO));
|
2016-12-27 21:06:14 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendActionBar(char alternateChar, String message) {
|
|
|
|
+ if (message == null || message.isEmpty()) return;
|
|
|
|
+ sendActionBar(org.bukkit.ChatColor.translateAlternateColorCodes(alternateChar, message));
|
|
|
|
+ }
|
|
|
|
+
|
2018-03-10 14:07:40 +01:00
|
|
|
@Override
|
2016-12-27 21:06:14 +01:00
|
|
|
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
|
|
|
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
|
|
|
|
--
|
2018-07-04 09:55:24 +02:00
|
|
|
2.18.0
|
2016-12-27 21:06:14 +01:00
|
|
|
|