Add BaseComponent sendMessage methods to CommandSender

This commit is contained in:
kashike 2016-03-08 13:16:54 -08:00
parent 986fb3e9c9
commit 9a9033c6c1
3 changed files with 77 additions and 13 deletions

View file

@ -0,0 +1,64 @@
From c86b4710176897c1c3cffa381cc212ff53c0fe4a Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Tue, 8 Mar 2016 13:05:59 -0800
Subject: [PATCH] Add BaseComponent sendMessage methods to CommandSender
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
index 148756b..4ad0028 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -32,4 +32,30 @@ public interface CommandSender extends Permissible {
* @return Name of the sender
*/
public String getName();
+
+ // Paper start
+ /**
+ * Sends the component to the sender
+ *
+ * <p>If this sender does not support sending full components then
+ * the component will be sent as legacy text.</p>
+ *
+ * @param component the component to send
+ */
+ default void sendMessage(net.md_5.bungee.api.chat.BaseComponent component) {
+ this.sendMessage(component.toLegacyText());
+ }
+
+ /**
+ * Sends an array of components as a single message to the sender
+ *
+ * <p>If this sender does not support sending full components then
+ * the components will be sent as legacy text.</p>
+ *
+ * @param components the components to send
+ */
+ default void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components) {
+ this.sendMessage(new net.md_5.bungee.api.chat.TextComponent(components).toLegacyText());
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 8124c71..b9c9af0 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -338,6 +338,7 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
*
* @param component the components to send
*/
+ @Override
public void sendMessage(net.md_5.bungee.api.chat.BaseComponent component);
/**
@@ -345,6 +346,7 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
*
* @param components the components to send
*/
+ @Override
public void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components);
/**
--
2.7.2

View file

@ -1,4 +1,4 @@
From 8720ceb09eaf96052ee087a76ecb1782fbda6d27 Mon Sep 17 00:00:00 2001 From 919039afb553383de586fa3c5eecd56dab683712 Mon Sep 17 00:00:00 2001
From: Sudzzy <originmc@outlook.com> From: Sudzzy <originmc@outlook.com>
Date: Wed, 2 Mar 2016 14:48:03 -0600 Date: Wed, 2 Mar 2016 14:48:03 -0600
Subject: [PATCH] Disable explosion knockback Subject: [PATCH] Disable explosion knockback
@ -19,10 +19,10 @@ index 8d6e0a2..6b5067a 100644
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index b410f3b..8d91f7c 100644 index 0248a9e..2e671fd 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java --- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -851,12 +851,14 @@ public abstract class EntityLiving extends Entity { @@ -852,12 +852,14 @@ public abstract class EntityLiving extends Entity {
} }
} }
@ -37,7 +37,7 @@ index b410f3b..8d91f7c 100644
this.world.broadcastEntityEffect(this, (byte) 2); this.world.broadcastEntityEffect(this, (byte) 2);
} }
@@ -880,6 +882,8 @@ public abstract class EntityLiving extends Entity { @@ -881,6 +883,8 @@ public abstract class EntityLiving extends Entity {
} }
} }

View file

@ -1,4 +1,4 @@
From 9b6ecd5ca11fa76650e3b1a20b2002afdb5478e6 Mon Sep 17 00:00:00 2001 From 109e5cd2ebdbd397a04cc135c465e1e655adea0a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 04:00:11 -0600 Date: Thu, 3 Mar 2016 04:00:11 -0600
Subject: [PATCH] Timings v2 Subject: [PATCH] Timings v2
@ -290,7 +290,7 @@ index dd3abb8..a0186ef 100644
import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent; import org.bukkit.event.server.RemoteServerCommandEvent;
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 768b6e7..2406968 100644 index a6c1136..c2771e7 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -24,7 +24,8 @@ import org.bukkit.block.BlockFace; @@ -24,7 +24,8 @@ import org.bukkit.block.BlockFace;
@ -329,7 +329,7 @@ index 768b6e7..2406968 100644
public void recalcPosition() { public void recalcPosition() {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index aef9cb7..847dafd 100644 index 2e671fd..b10475f 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java --- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -23,7 +23,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; @@ -23,7 +23,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
@ -341,7 +341,7 @@ index aef9cb7..847dafd 100644
public abstract class EntityLiving extends Entity { public abstract class EntityLiving extends Entity {
@@ -1685,7 +1685,6 @@ public abstract class EntityLiving extends Entity { @@ -1686,7 +1686,6 @@ public abstract class EntityLiving extends Entity {
} }
public void m() { public void m() {
@ -349,7 +349,7 @@ index aef9cb7..847dafd 100644
super.m(); super.m();
this.cu(); this.cu();
if (!this.world.isClientSide) { if (!this.world.isClientSide) {
@@ -1758,9 +1757,7 @@ public abstract class EntityLiving extends Entity { @@ -1759,9 +1758,7 @@ public abstract class EntityLiving extends Entity {
} }
} }
@ -359,7 +359,7 @@ index aef9cb7..847dafd 100644
double d0 = this.locX - this.lastX; double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ; double d1 = this.locZ - this.lastZ;
float f = (float) (d0 * d0 + d1 * d1); float f = (float) (d0 * d0 + d1 * d1);
@@ -1829,8 +1826,6 @@ public abstract class EntityLiving extends Entity { @@ -1830,8 +1827,6 @@ public abstract class EntityLiving extends Entity {
} else { } else {
this.bo = 0; this.bo = 0;
} }
@ -368,7 +368,7 @@ index aef9cb7..847dafd 100644
} }
protected float h(float f, float f1) { protected float h(float f, float f1) {
@@ -1895,7 +1890,6 @@ public abstract class EntityLiving extends Entity { @@ -1896,7 +1891,6 @@ public abstract class EntityLiving extends Entity {
} }
this.world.methodProfiler.a("ai"); this.world.methodProfiler.a("ai");
@ -376,7 +376,7 @@ index aef9cb7..847dafd 100644
if (this.cf()) { if (this.cf()) {
this.bc = false; this.bc = false;
this.bd = 0.0F; this.bd = 0.0F;
@@ -1906,7 +1900,6 @@ public abstract class EntityLiving extends Entity { @@ -1907,7 +1901,6 @@ public abstract class EntityLiving extends Entity {
this.doTick(); this.doTick();
this.world.methodProfiler.b(); this.world.methodProfiler.b();
} }
@ -384,7 +384,7 @@ index aef9cb7..847dafd 100644
this.world.methodProfiler.b(); this.world.methodProfiler.b();
this.world.methodProfiler.a("jump"); this.world.methodProfiler.a("jump");
@@ -1929,14 +1922,10 @@ public abstract class EntityLiving extends Entity { @@ -1930,14 +1923,10 @@ public abstract class EntityLiving extends Entity {
this.be *= 0.98F; this.be *= 0.98F;
this.bf *= 0.9F; this.bf *= 0.9F;
this.r(); this.r();