even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even even

more work
This commit is contained in:
Spottedleaf 2021-06-12 02:17:20 -07:00 committed by MiniDigger | Martin
parent 1753b33104
commit d9210c3ee7
5 changed files with 34 additions and 25 deletions

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Add configuration option to prevent player names from being
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 7b3a0c958b4b4bffb6c19a0e4d3bf4824f8db237..e2052baa65ed3525a89b26c065b3e2a58916ab99 100644
index 55cd39f1e3787bcd34c6d528738122590ec580ec..14786ce10f43cd203544750a073c5efaf8b21348 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1768,6 +1768,16 @@ public final class Bukkit {
@ -27,7 +27,7 @@ index 7b3a0c958b4b4bffb6c19a0e4d3bf4824f8db237..e2052baa65ed3525a89b26c065b3e2a5
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 6f4817af249e258905c97f4dac3d2f33804bdfc5..8fd026e4ffcdf009365ae04b87f7559bed32c7d3 100644
index 08f451c392682cc0147ba14759c6b7edf7ff533f..7c44e23a5c370537d5163fd6ea6a1dea4d19d2b7 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1553,4 +1553,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

View File

@ -11,10 +11,10 @@ to make books with as much data as they want. Do not use this without
limiting incoming data from packets in some other way.
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
index a592d4a286a775a61192dde2a4d21a0681090415..80397e223990f11c9aa413f3f4ebd7c1b8ce1cff 100644
index a33dd184ea51df7e59ed08e5e2b0ea4ed9dadff5..1d94d285951faa98ff1f70c3c5330dfaa77cb691 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
@@ -43,6 +43,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -42,6 +42,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
static final int MAX_PAGES = 100;
static final int MAX_PAGE_LENGTH = 320; // 256 limit + 64 characters to allow for psuedo colour codes
static final int MAX_TITLE_LENGTH = 32;
@ -22,30 +22,30 @@ index a592d4a286a775a61192dde2a4d21a0681090415..80397e223990f11c9aa413f3f4ebd7c1
protected String title;
protected String author;
@@ -245,7 +246,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -244,7 +245,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
if (title == null) {
this.title = null;
return true;
- } else if (title.length() > MAX_TITLE_LENGTH) {
+ } else if (title.length() > MAX_TITLE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override
- } else if (title.length() > CraftMetaBook.MAX_TITLE_LENGTH) {
+ } else if (title.length() > CraftMetaBook.MAX_TITLE_LENGTH && !CraftMetaBook.OVERRIDE_CHECKS) { // Paper - Add override
return false;
}
@@ -442,7 +443,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -441,7 +442,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
String validatePage(String page) {
if (page == null) {
page = "";
- } else if (page.length() > MAX_PAGE_LENGTH) {
+ } else if (page.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override
- } else if (page.length() > CraftMetaBook.MAX_PAGE_LENGTH) {
+ } else if (page.length() > CraftMetaBook.MAX_PAGE_LENGTH && !CraftMetaBook.OVERRIDE_CHECKS) { // Paper - Add override
page = page.substring(0, MAX_PAGE_LENGTH);
}
return page;
@@ -452,7 +453,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
@@ -451,7 +452,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
// asserted: page != null
if (this.pages == null) {
this.pages = new ArrayList<String>();
- } else if (this.pages.size() >= MAX_PAGES) {
+ } else if (this.pages.size() >= MAX_PAGES && !OVERRIDE_CHECKS) {// Paper - Add override
- } else if (this.pages.size() >= CraftMetaBook.MAX_PAGES) {
+ } else if (this.pages.size() >= CraftMetaBook.MAX_PAGES && !CraftMetaBook.OVERRIDE_CHECKS) { // Paper - Add override
return;
}
this.pages.add(page);

View File

@ -26,33 +26,42 @@ index c611b5a63498f5ad1f50a75ccd5d7299e27df7e3..9d1cddc6038f0fd0286e4a32013ae98f
+ }
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ecc393ad94332ec2a59d29f30bd60bade4e1f18e..6a922e3522ac99a8e317a5f5f51fbb597baaf63e 100644
index 624776a85a3e3268665571635f0b837cb810a62e..acee61af1b01c7e66c3b5c7e164ddd9a88e53606 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2051,6 +2051,13 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -2056,6 +2056,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
switch (packet.getAction()) {
case PRESS_SHIFT_KEY:
this.player.setShiftKeyDown(true);
+
+ // Paper start - Hang on!
+ if (this.player.level.paperConfig.parrotsHangOnBetter) {
+ this.player.removeEntitiesOnShoulder();
+ }
+ // Paper end
+ // Paper start - Hang on!
+ if (this.player.level.paperConfig.parrotsHangOnBetter) {
+ this.player.removeEntitiesOnShoulder();
+ }
+ // Paper end
+
break;
case RELEASE_SHIFT_KEY:
this.player.setShiftKeyDown(false);
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index c11d5aa115d10e3c12863cf9d42c60194d63b690..ae10c531ae69eaf6b78a342dcedb89c39fd8dbcc 100644
index e8768625e55f849cd31784cb46e67293bcd93abf..73277b04a45444edce02cce3e033741ebaf2ad0c 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -529,7 +529,7 @@ public abstract class Player extends LivingEntity {
@@ -579,7 +579,7 @@ public abstract class Player extends LivingEntity {
this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft());
this.playShoulderEntityAmbientSound(this.getShoulderEntityRight());
if (!this.level.isClientSide && (this.fallDistance > 0.5F || this.isInWater()) || this.abilities.flying || this.isSleeping()) {
if (!this.level.isClientSide && (this.fallDistance > 0.5F || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) {
- this.removeEntitiesOnShoulder();
+ if (!this.level.paperConfig.parrotsHangOnBetter) this.removeEntitiesOnShoulder(); // Paper - Hang on!
}
}
@@ -1939,7 +1939,7 @@ public abstract class Player extends LivingEntity {
}
}
- protected void removeEntitiesOnShoulder() {
+ public void removeEntitiesOnShoulder() { // Paper - protected -> public
if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) {
// CraftBukkit start
if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) {

View File

@ -20,10 +20,10 @@ index 4e2f243faa209925dcb7c3ef89df3ed875c5ff78..48319aaf1c525c6fb7bdee5c2f570a0d
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 9365fd2bcf74755c90c4ae9b550969e97a22c639..d198dad80e0fb41a5bde66944d0e41509a9c1c43 100644
index f7b37aff1aa4e8b2f185dcf6a302e9d5e7e0b0a9..654ad4a6a92b11fbed84b091ca4b6e99131b4a20 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2300,5 +2300,10 @@ public final class CraftServer implements Server {
@@ -2299,5 +2299,10 @@ public final class CraftServer implements Server {
commandMap.registerServerAliases();
return true;
}