Skip to content

Commit de93fda

Browse files
committed
Merge branch 'update/1.21.5' of github.com:PaperMC/Paper into update/1.21.5
2 parents 740abe1 + 34dfd5e commit de93fda

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public static Permission registerPermissions(Permission parent) {
8282
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "team", "Allows the user to control teams", PermissionDefault.OP, commands);
8383
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "teammsg", "Allows the user to specify the message to send to team", PermissionDefault.TRUE, commands); // defaults to all players
8484
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "tellraw", "Allows the user to display a JSON message to players", PermissionDefault.OP, commands);
85+
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "test", "Allows the user to manage and execute GameTests", PermissionDefault.OP, commands);
8586
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "time", "Allows the user to change or query the world's game time", PermissionDefault.OP, commands);
8687
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "tick", "Allows the user to control the tick rate of the server", PermissionDefault.OP, commands);
8788
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "title", "Allows the user to manage screen titles", PermissionDefault.OP, commands);

paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java

+9-11
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@
3535
import net.minecraft.nbt.NbtOps;
3636
import net.minecraft.nbt.Tag;
3737
import net.minecraft.network.chat.ComponentSerialization;
38-
import net.minecraft.resources.RegistryOps;
3938
import net.minecraft.resources.ResourceLocation;
4039
import net.minecraft.world.item.ItemStack;
4140
import net.minecraft.world.item.Items;
42-
import org.apache.commons.lang3.RandomStringUtils;
4341
import org.bukkit.support.RegistryHelper;
4442
import org.bukkit.support.environment.VanillaFeature;
4543
import org.junit.jupiter.api.Test;
@@ -85,7 +83,7 @@ class AdventureCodecsTest {
8583
void testTextColor() {
8684
final TextColor color = color(0x1d38df);
8785
final Tag result = TEXT_COLOR_CODEC.encodeStart(NbtOps.INSTANCE, color).result().orElseThrow();
88-
assertEquals(color.asHexString(), result.getAsString());
86+
assertEquals("\"" + color.asHexString() + "\"", result.toString());
8987
final net.minecraft.network.chat.TextColor nms = net.minecraft.network.chat.TextColor.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst();
9088
assertEquals(color.value(), nms.getValue());
9189
}
@@ -94,7 +92,7 @@ void testTextColor() {
9492
void testNamedTextColor() {
9593
final NamedTextColor color = NamedTextColor.BLUE;
9694
final Tag result = TEXT_COLOR_CODEC.encodeStart(NbtOps.INSTANCE, color).result().orElseThrow();
97-
assertEquals(NamedTextColor.NAMES.keyOrThrow(color), result.getAsString());
95+
assertEquals("\"" + NamedTextColor.NAMES.keyOrThrow(color) + "\"", result.toString());
9896
final net.minecraft.network.chat.TextColor nms = net.minecraft.network.chat.TextColor.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst();
9997
assertEquals(color.value(), nms.getValue());
10098
}
@@ -103,18 +101,18 @@ void testNamedTextColor() {
103101
void testKey() {
104102
final Key key = key("hello", "there");
105103
final Tag result = KEY_CODEC.encodeStart(NbtOps.INSTANCE, key).result().orElseThrow();
106-
assertEquals(key.asString(), result.getAsString());
104+
assertEquals("\"" + key.asString() + "\"", result.toString());
107105
final ResourceLocation location = ResourceLocation.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst();
108106
assertEquals(key.asString(), location.toString());
109107
}
110108

111109
@ParameterizedTest(name = PARAMETERIZED_NAME)
112110
@EnumSource(value = ClickEvent.Action.class, mode = EnumSource.Mode.EXCLUDE, names = {"OPEN_FILE"})
113111
void testClickEvent(final ClickEvent.Action action) {
114-
final ClickEvent event = ClickEvent.clickEvent(action, RandomStringUtils.randomAlphanumeric(20));
112+
final ClickEvent event = ClickEvent.clickEvent(action, "1337");
115113
final Tag result = CLICK_EVENT_CODEC.encodeStart(NbtOps.INSTANCE, event).result().orElseThrow();
116114
final net.minecraft.network.chat.ClickEvent nms = net.minecraft.network.chat.ClickEvent.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst();
117-
assertEquals(event.action().toString(), nms.getAction().getSerializedName());
115+
assertEquals(event.action().toString(), nms.action().getSerializedName());
118116
assertEquals(event.value(), nms.getValue());
119117
}
120118

@@ -123,7 +121,7 @@ void testShowTextHoverEvent() {
123121
final HoverEvent<Component> hoverEvent = HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, text("hello"));
124122
final Tag result = HOVER_EVENT_CODEC.encodeStart(NbtOps.INSTANCE, hoverEvent).result().orElseThrow();
125123
final net.minecraft.network.chat.HoverEvent nms = net.minecraft.network.chat.HoverEvent.CODEC.decode(NbtOps.INSTANCE, result).result().orElseThrow().getFirst();
126-
assertEquals(hoverEvent.action().toString(), nms.getAction().getSerializedName());
124+
assertEquals(hoverEvent.action().toString(), nms.action().getSerializedName());
127125
assertNotNull(nms.getValue(net.minecraft.network.chat.HoverEvent.Action.SHOW_TEXT));
128126
}
129127

@@ -136,7 +134,7 @@ void testShowItemHoverEvent() throws IOException {
136134
final DataResult<Pair<net.minecraft.network.chat.HoverEvent, Tag>> dataResult = net.minecraft.network.chat.HoverEvent.CODEC.decode(NbtOps.INSTANCE, result);
137135
assertTrue(dataResult.result().isPresent(), () -> dataResult + " result is not present");
138136
final net.minecraft.network.chat.HoverEvent nms = dataResult.result().orElseThrow().getFirst();
139-
assertEquals(hoverEvent.action().toString(), nms.getAction().getSerializedName());
137+
assertEquals(hoverEvent.action().toString(), nms.action().getSerializedName());
140138
final net.minecraft.network.chat.HoverEvent.ItemStackInfo value = nms.getValue(net.minecraft.network.chat.HoverEvent.Action.SHOW_ITEM);
141139
assertNotNull(value);
142140
assertEquals(hoverEvent.value().count(), value.count);
@@ -152,11 +150,11 @@ void testShowEntityHoverEvent() {
152150
final DataResult<Pair<net.minecraft.network.chat.HoverEvent, Tag>> dataResult = net.minecraft.network.chat.HoverEvent.CODEC.decode(NbtOps.INSTANCE, result);
153151
assertTrue(dataResult.result().isPresent(), () -> dataResult + " result is not present");
154152
final net.minecraft.network.chat.HoverEvent nms = dataResult.result().orElseThrow().getFirst();
155-
assertEquals(hoverEvent.action().toString(), nms.getAction().getSerializedName());
153+
assertEquals(hoverEvent.action().toString(), nms.action().getSerializedName());
156154
final net.minecraft.network.chat.HoverEvent.EntityTooltipInfo value = nms.getValue(net.minecraft.network.chat.HoverEvent.Action.SHOW_ENTITY);
157155
assertNotNull(value);
158156
assertEquals(hoverEvent.value().type().asString(), BuiltInRegistries.ENTITY_TYPE.getKey(value.type).toString());
159-
assertEquals(hoverEvent.value().id(), value.id);
157+
assertEquals(hoverEvent.value().id(), value.uuid);
160158
assertEquals("NAME", value.name.orElseThrow().getString());
161159
}
162160

paper-server/src/test/java/org/bukkit/ChatTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void testColors() {
2828
public void testURLJsonConversion() {
2929
Component[] components;
3030
components = CraftChatMessage.fromString("https://spigotmc.org/test Test Message");
31-
assertEquals("{\"text\":\"\",\"extra\":[{\"text\":\"https://spigotmc.org/test\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://spigotmc.org/test\"}},\" Test Message\"]}",
31+
assertEquals("{\"text\":\"\",\"extra\":[{\"text\":\"https://spigotmc.org/test\",\"click_event\":{\"url\":\"https://spigotmc.org/test\",\"action\":\"open_url\"}},\" Test Message\"]}",
3232
CraftChatMessage.toJSON(components[0]));
3333

3434
components = CraftChatMessage.fromString("123 " + ChatColor.GOLD + "https://spigotmc.org " + ChatColor.BOLD + "test");

paper-server/src/test/java/org/bukkit/craftbukkit/inventory/PlayerInventoryTest.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.junit.jupiter.api.Assertions.*;
44

55
import net.minecraft.world.entity.player.Inventory;
6+
import net.minecraft.world.entity.player.PlayerEquipment;
67
import net.minecraft.world.item.ItemStack;
78
import net.minecraft.world.item.Items;
89
import org.bukkit.support.environment.Normal;
@@ -20,8 +21,8 @@ public void testCanHold() throws Exception {
2021
ItemStack itemStack64Coal = new ItemStack(Items.COAL, 64);
2122

2223
// keep one slot empty
23-
Inventory inventory = new Inventory(null);
24-
for (int i = 0; i < inventory.items.size() - 1; i++) {
24+
Inventory inventory = new Inventory(null, new PlayerEquipment(null));
25+
for (int i = 0; i < inventory.getNonEquipmentItems().size() - 1; i++) {
2526
inventory.setItem(i, itemStackApple);
2627
}
2728

@@ -31,46 +32,46 @@ public void testCanHold() throws Exception {
3132
assertEquals(64, inventory.canHold(itemStack64Coal));
3233

3334
// no free space with a stack of the item to check in the inventory
34-
inventory.setItem(inventory.items.size() - 1, itemStack64Coal);
35+
inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack64Coal);
3536

3637
assertEquals(0, inventory.canHold(itemStack1Coal));
3738
assertEquals(0, inventory.canHold(itemStack32Coal));
3839
assertEquals(0, inventory.canHold(itemStack64Coal));
3940

4041
// no free space without a stack of the item to check in the inventory
41-
inventory.setItem(inventory.items.size() - 1, itemStackApple);
42+
inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStackApple);
4243

4344
assertEquals(0, inventory.canHold(itemStack1Coal));
4445
assertEquals(0, inventory.canHold(itemStack32Coal));
4546
assertEquals(0, inventory.canHold(itemStack64Coal));
4647

4748
// free space for 32 items in one slot
48-
inventory.setItem(inventory.items.size() - 1, itemStack32Coal);
49+
inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack32Coal);
4950

5051
assertEquals(1, inventory.canHold(itemStack1Coal));
5152
assertEquals(32, inventory.canHold(itemStack32Coal));
5253
assertEquals(32, inventory.canHold(itemStack64Coal));
5354

5455
// free space for 1 item in two slots
55-
inventory.setItem(inventory.items.size() - 1, itemStack63Coal);
56-
inventory.setItem(inventory.items.size() - 2, itemStack63Coal);
56+
inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack63Coal);
57+
inventory.setItem(inventory.getNonEquipmentItems().size() - 2, itemStack63Coal);
5758

5859
assertEquals(1, inventory.canHold(itemStack1Coal));
5960
assertEquals(2, inventory.canHold(itemStack32Coal));
6061
assertEquals(2, inventory.canHold(itemStack64Coal));
6162

6263
// free space for 32 items in non-empty off-hand slot
63-
inventory.setItem(inventory.items.size() - 1, itemStackApple);
64-
inventory.setItem(inventory.items.size() - 2, itemStackApple);
65-
inventory.setItem(inventory.items.size() + inventory.armor.size(), itemStack32Coal);
64+
inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStackApple);
65+
inventory.setItem(inventory.getNonEquipmentItems().size() - 2, itemStackApple);
66+
inventory.setItem(inventory.getNonEquipmentItems().size() + inventory.getArmorContents().size(), itemStack32Coal);
6667

6768
assertEquals(1, inventory.canHold(itemStack1Coal));
6869
assertEquals(32, inventory.canHold(itemStack32Coal));
6970
assertEquals(32, inventory.canHold(itemStack64Coal));
7071

7172
// free space for 1 item in non-empty off-hand slot and another slot
72-
inventory.setItem(inventory.items.size() - 1, itemStack63Coal);
73-
inventory.setItem(inventory.items.size() + inventory.armor.size(), itemStack63Coal);
73+
inventory.setItem(inventory.getNonEquipmentItems().size() - 1, itemStack63Coal);
74+
inventory.setItem(inventory.getNonEquipmentItems().size() + inventory.getArmorContents().size(), itemStack63Coal);
7475

7576
assertEquals(1, inventory.canHold(itemStack1Coal));
7677
assertEquals(2, inventory.canHold(itemStack32Coal));

0 commit comments

Comments
 (0)