This commit is contained in:
Jason Penilla 2021-06-14 20:50:26 -07:00
parent b23eec8be4
commit d15e006a8c
12 changed files with 154 additions and 202 deletions

View file

@ -114,6 +114,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ DUPLICATE_LOGIN,
+
+ RESOURCE_PACK_REJECTION,
+
+ /**
+ * Spigot's restart command
+ */

View file

@ -1,26 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Wed, 26 May 2021 17:09:07 -0400
Subject: [PATCH] Add BellRevealRaiderEvent
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Position;
import net.minecraft.core.particles.ParticleTypes;
+import net.minecraft.server.MCUtil;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.EntityTypeTags;
@@ -0,0 +0,0 @@ public class BellBlockEntity extends BlockEntity implements TickableBlockEntity
}
private void glow(LivingEntity entity) {
+ if (!new io.papermc.paper.event.block.BellRevealRaiderEvent(level.getWorld().getBlockAt(MCUtil.toLocation(level, worldPosition)), entity.getBukkitEntity()).callEvent()) return; // Paper - BellRevealRaiderEvent
entity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 60));
}
}

View file

@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Wed, 26 May 2021 17:09:07 -0400
Subject: [PATCH] Add BellRevealRaiderEvent
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
@@ -0,0 +0,0 @@ public class BellBlockEntity extends BlockEntity {
private static void makeRaidersGlow(Level world, BlockPos pos, List<LivingEntity> hearingEntities) {
hearingEntities.stream().filter((livingEntity) -> {
return isRaiderWithinRange(pos, livingEntity);
- }).forEach(BellBlockEntity::glow);
+ }).forEach(entity -> glow(entity, pos)); // Paper - pass BlockPos
}
private static void showBellParticles(Level world, BlockPos pos, List<LivingEntity> hearingEntities) {
@@ -0,0 +0,0 @@ public class BellBlockEntity extends BlockEntity {
return entity.isAlive() && !entity.isRemoved() && pos.closerThan(entity.position(), 48.0D) && entity.getType().is(EntityTypeTags.RAIDERS);
}
- private static void glow(LivingEntity entity) {
+ // Paper start
+ private static void glow(LivingEntity entity) { glow(entity, null); }
+ private static void glow(LivingEntity entity, BlockPos pos) {
+ if (pos != null && !new io.papermc.paper.event.block.BellRevealRaiderEvent(entity.level.getWorld().getBlockAt(net.minecraft.server.MCUtil.toLocation(entity.level, pos)), entity.getBukkitEntity()).callEvent()) return;
+ // Paper end
entity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 60));
}

View file

@ -15,9 +15,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent(getBukkitEntity(), entityplayer.getBukkitEntity()).callEvent()) { // Paper - Add Guardian Appearance Event
if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) {
entityplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F));
entityplayer.addEffect(new MobEffectInstance(mobeffectlist, 6000, 2), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
entityplayer.addEffect(new MobEffectInstance(mobeffectlist, 6000, 2), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
+ } // Paper - Add Guardian Appearance Event
+ } // Paper - Add Guardian Appearance Event
}
}

View file

@ -22,11 +22,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/commands/BanIpCommands.java
+++ b/src/main/java/net/minecraft/server/commands/BanIpCommands.java
@@ -0,0 +0,0 @@ public class BanIpCommands {
while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
}
- entityplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.ip_banned"));
+ entityplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.ip_banned"), org.bukkit.event.player.PlayerKickEvent.Cause.IP_BANNED); // Paper - kick event cause
for(ServerPlayer serverPlayer : list) {
- serverPlayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.ip_banned"));
+ serverPlayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.ip_banned"), org.bukkit.event.player.PlayerKickEvent.Cause.IP_BANNED); // Paper - kick event cause
}
return list.size();
@ -35,11 +35,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java
+++ b/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java
@@ -0,0 +0,0 @@ public class BanPlayerCommands {
ServerPlayer entityplayer = source.getServer().getPlayerList().getPlayer(gameprofile.getId());
if (entityplayer != null) {
- entityplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.banned"));
+ entityplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.banned"), org.bukkit.event.player.PlayerKickEvent.Cause.BANNED); // Paper - kick event cause
source.sendSuccess(new TranslatableComponent("commands.ban.success", ComponentUtils.getDisplayName(gameProfile), userBanListEntry.getReason()), true);
ServerPlayer serverPlayer = source.getServer().getPlayerList().getPlayer(gameProfile.getId());
if (serverPlayer != null) {
- serverPlayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.banned"));
+ serverPlayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.banned"), org.bukkit.event.player.PlayerKickEvent.Cause.BANNED); // Paper - kick event cause
}
}
}
@ -48,19 +48,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/commands/KickCommand.java
+++ b/src/main/java/net/minecraft/server/commands/KickCommand.java
@@ -0,0 +0,0 @@ public class KickCommand {
while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
- entityplayer.connection.disconnect(reason);
+ entityplayer.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK_COMMAND); // Paper - kick event cause
source.sendSuccess(new TranslatableComponent("commands.kick.success", new Object[]{entityplayer.getDisplayName(), reason}), true);
private static int kickPlayers(CommandSourceStack source, Collection<ServerPlayer> targets, Component reason) {
for(ServerPlayer serverPlayer : targets) {
- serverPlayer.connection.disconnect(reason);
+ serverPlayer.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK_COMMAND); // Paper - kick event cause
source.sendSuccess(new TranslatableComponent("commands.kick.success", serverPlayer.getDisplayName(), reason), true);
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
if (this.clientIsFloating && !this.player.isSleeping()) {
if (++this.aboveGroundTickCount > 80) {
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString());
@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return;
}
} else {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
if (this.clientVehicleIsFloating && this.player.getRootVehicle().getControllingPassenger() == this.player) {
if (++this.aboveGroundVehicleTickCount > 80) {
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString());
@ -78,8 +78,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return;
}
} else {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
if (this.isPendingPing()) {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
if (this.keepAlivePending) {
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
- this.disconnect(new TranslatableComponent("disconnect.timeout", new Object[0]));
@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
} else {
if (elapsedTime >= 15000L) { // 15 seconds
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) {
this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
@ -96,7 +96,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
public void disconnect(String s) {
// Paper start
@ -122,28 +122,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end
// CraftBukkit start - fire PlayerKickEvent
if (this.processedDisconnect) {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}
net.kyori.adventure.text.Component leaveMessage = net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, this.player.getBukkitEntity().displayName()); // Paper - Adventure
- PlayerKickEvent event = new PlayerKickEvent(this.craftServer.getPlayer(this.player), reason, leaveMessage); // Paper - Adventure
+ PlayerKickEvent event = new PlayerKickEvent(this.craftServer.getPlayer(this.player), reason, leaveMessage, cause); // Paper - Adventure & kick event reason
- PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), reason, leaveMessage); // Paper - Adventure
+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), reason, leaveMessage, cause); // Paper - Adventure & kick event reason
if (this.craftServer.getServer().isRunning()) {
this.craftServer.getPluginManager().callEvent(event);
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
if (this.cserver.getServer().isRunning()) {
this.cserver.getPluginManager().callEvent(event);
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (containsInvalidValues(packet)) {
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(), packet.getY(), packet.getZ(), packet.getYRot(), packet.getXRot())) {
- this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_vehicle_movement"));
+ this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_vehicle_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_VEHICLE_MOVEMENT); // Paper - kick event cause
} else {
Entity entity = this.player.getRootVehicle();
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
// PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async
// CraftBukkit start
if (tabSpamLimiter.addAndGet(com.destroystokyo.paper.PaperConfig.tabSpamIncrement) > com.destroystokyo.paper.PaperConfig.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable
if (this.chatSpamTickCount.addAndGet(com.destroystokyo.paper.PaperConfig.tabSpamIncrement) > com.destroystokyo.paper.PaperConfig.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable
- server.scheduleOnMain(() -> this.disconnect(new TranslatableComponent("disconnect.spam", new Object[0]))); // Paper
+ server.scheduleOnMain(() -> this.disconnect(new TranslatableComponent("disconnect.spam", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause
return;
@ -156,16 +156,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return;
}
// Paper end
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
// Paper start - validate pick item position
if (!(packet.getSlot() >= 0 && packet.getSlot() < this.player.inventory.items.size())) {
if (!(packet.getSlot() >= 0 && packet.getSlot() < this.player.getInventory().items.size())) {
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
- this.disconnect("Invalid hotbar selection (Hacking?)");
+ this.disconnect("Invalid hotbar selection (Hacking?)", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
return;
}
this.player.inventory.pickSlot(packet.getSlot()); // Paper - Diff above if changed
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
ListTag pageList = testStack.getTag().getList("pages", 8);
if (pageList.size() > 100) {
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with too many pages");
@ -174,7 +174,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return;
}
long byteTotal = 0;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
if (byteLength > 256 * 4) {
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!");
@ -183,7 +183,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return;
}
byteTotal += byteLength;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
if (byteTotal > byteAllowed) {
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size());
@ -200,25 +200,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return;
}
this.lastBookTick = MinecraftServer.currentTick;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
public void handleMovePlayer(ServerboundMovePlayerPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (containsInvalidValues(packet)) {
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(0.0D), packet.getY(0.0D), packet.getZ(0.0D), packet.getYRot(0.0F), packet.getXRot(0.0F))) {
- this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_player_movement"));
+ this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause
} else {
ServerLevel worldserver = this.player.getLevel();
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
this.dropCount++;
if (this.dropCount >= 20) {
LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
- this.disconnect("You dropped your items too quickly (Hacking?)");
+ this.disconnect("You dropped your items too quickly (Hacking?)", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
return;
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (packet.getAction() == ServerboundResourcePackPacket.Action.DECLINED && this.server.isResourcePackRequired()) {
ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
- this.disconnect(new TranslatableComponent("multiplayer.requiredTexturePrompt.disconnect"));
+ this.disconnect(new TranslatableComponent("multiplayer.requiredTexturePrompt.disconnect"), org.bukkit.event.player.PlayerKickEvent.Cause.RESOURCE_PACK_REJECTION); // Paper - add cause
}
// Paper start
PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()];
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
this.player.resetLastActionTime();
} else {
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -227,25 +236,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
- ServerGamePacketListenerImpl.this.disconnect(new TranslatableComponent("multiplayer.disconnect.illegal_characters"));
+ ServerGamePacketListenerImpl.this.disconnect(new TranslatableComponent("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - kick event cause
return null;
}
};
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
throw new RuntimeException(e);
}
} else {
- this.disconnect(new TranslatableComponent("multiplayer.disconnect.illegal_characters"));
+ this.disconnect(new TranslatableComponent("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - kick event cause
}
// CraftBukkit end
return;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
- this.disconnect(new TranslatableComponent("multiplayer.disconnect.illegal_characters"));
+ this.disconnect(new TranslatableComponent("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add cause
return;
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
Waitable waitable = new Waitable() {
@Override
protected Object evaluate() {
@ -254,7 +254,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return null;
}
};
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
throw new RuntimeException(e);
}
} else {
@ -263,43 +263,43 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
// CraftBukkit end
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
// Spigot Start
if ( entity == player && !player.isSpectator() )
if ( entity == this.player && !this.player.isSpectator() )
{
- disconnect( "Cannot interact with self!" );
+ disconnect( "Cannot interact with self!", org.bukkit.event.player.PlayerKickEvent.Cause.SELF_INTERACTION ); // Paper - kick event cause
- this.disconnect( "Cannot interact with self!" );
+ this.disconnect( "Cannot interact with self!", org.bukkit.event.player.PlayerKickEvent.Cause.SELF_INTERACTION ); // Paper - add cause
return;
}
// Spigot End
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
// CraftBukkit end
} else if (packet.getAction() == ServerboundInteractPacket.Action.ATTACK) {
if (entity instanceof ItemEntity || entity instanceof ExperienceOrb || entity instanceof AbstractArrow || (entity == this.player && !player.isSpectator())) { // CraftBukkit
- this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_entity_attacked"));
+ this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_entity_attacked"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_ENTITY_ATTACKED); // Paper - kick event cause
ServerGamePacketListenerImpl.LOGGER.warn("Player {} tried to attack an invalid entity", this.player.getName().getString());
return;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}
// CraftBukkit end
} else {
- ServerGamePacketListenerImpl.this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_entity_attacked"));
+ ServerGamePacketListenerImpl.this.disconnect(new TranslatableComponent("multiplayer.disconnect.invalid_entity_attacked"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_ENTITY_ATTACKED); // Paper - add cause
ServerGamePacketListenerImpl.LOGGER.warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getName().getString());
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
// Paper start
if (!Bukkit.isPrimaryThread()) {
if (recipeSpamPackets.addAndGet(PaperConfig.autoRecipeIncrement) > PaperConfig.autoRecipeLimit) {
if (!org.bukkit.Bukkit.isPrimaryThread()) {
if (recipeSpamPackets.addAndGet(com.destroystokyo.paper.PaperConfig.autoRecipeIncrement) > com.destroystokyo.paper.PaperConfig.autoRecipeLimit) {
- server.scheduleOnMain(() -> this.disconnect(new TranslatableComponent("disconnect.spam", new Object[0]))); // Paper
+ server.scheduleOnMain(() -> this.disconnect(new TranslatableComponent("disconnect.spam", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause
return;
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
} else if (!this.isSingleplayerOwner()) {
// Paper start - This needs to be handled on the main thread for plugins
server.scheduleOnMain(() -> {
server.submit(() -> {
- this.disconnect(new TranslatableComponent("disconnect.timeout"));
+ this.disconnect(new TranslatableComponent("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
});
// Paper end
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex);
@ -308,7 +308,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
} else if (packet.identifier.equals(CUSTOM_UNREGISTER)) {
try {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t unregister custom payload", ex);
@ -317,8 +317,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
} else {
try {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
craftServer.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packet.identifier.toString(), data);
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data);
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
- this.disconnect("Invalid custom payload!");
@ -333,14 +333,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class PlayerList {
while (iterator.hasNext()) {
entityplayer = (ServerPlayer) iterator.next();
save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
this.save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
- entityplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login", new Object[0]));
+ entityplayer.connection.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.DUPLICATE_LOGIN); // Paper - kick event cause
}
// Instead of kicking then returning, we need to store the kick reason
@@ -0,0 +0,0 @@ public abstract class PlayerList {
public void shutdown(boolean isRestarting) {
// Paper end
// CraftBukkit start - disconnect safely
for (ServerPlayer player : this.players) {
- if (isRestarting) player.connection.disconnect(org.spigotmc.SpigotConfig.restartMessage); else // Paper
@ -356,10 +356,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot
if (getHandle().connection == null) return;
if (this.getHandle().connection == null) return;
- getHandle().connection.disconnect(message == null ? "" : message);
+ getHandle().connection.disconnect(message == null ? "" : message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause
- this.getHandle().connection.disconnect(message == null ? "" : message);
+ this.getHandle().connection.disconnect(message == null ? "" : message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause
}
// Paper start
@ -377,7 +377,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause);
}
}
// Paper end
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/spigotmc/RestartCommand.java

View file

@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ fixItemsMergingThroughWalls = getBoolean("fix-items-merging-through-walls", fixItemsMergingThroughWalls);
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@ -35,5 +36,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper End
this.tryToMerge(entityitem);
if (this.removed) {
if (this.isRemoved()) {
break;

View file

@ -9,29 +9,30 @@ diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/j
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/BucketItem.java
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java
@@ -0,0 +0,0 @@ public class BucketItem extends Item {
@@ -0,0 +0,0 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
public class BucketItem extends Item implements DispensibleContainerItem {
+ private static ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper
+
public final Fluid content;
public BucketItem(Fluid fluid, Item.Properties settings) {
@@ -0,0 +0,0 @@ public class BucketItem extends Item implements DispensibleContainerItem {
}
protected ItemStack getEmptySuccessItem(ItemStack stack, Player player) {
+ // Paper
public static ItemStack getEmptySuccessItem(ItemStack stack, Player player) {
+ // Paper start
+ if (itemLeftInHandAfterPlayerBucketEmptyEvent != null) {
+ ItemStack itemInHand = itemLeftInHandAfterPlayerBucketEmptyEvent;
+ itemLeftInHandAfterPlayerBucketEmptyEvent = null;
+ return itemInHand;
+ }
+ // Paper
return !player.abilities.instabuild ? new ItemStack(Items.BUCKET) : stack;
+ // Paper end
return !player.getAbilities().instabuild ? new ItemStack(Items.BUCKET) : stack;
}
@@ -0,0 +0,0 @@ public class BucketItem extends Item {
return a(player, world, pos, movingobjectpositionblock, null, null, null, null);
}
+ private ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper
public boolean a(Player entityhuman, Level world, BlockPos blockposition, @Nullable BlockHitResult movingobjectpositionblock, Direction enumdirection, BlockPos clicked, ItemStack itemstack, InteractionHand enumhand) {
// Paper end
// CraftBukkit end
@@ -0,0 +0,0 @@ public class BucketItem extends Item {
@@ -0,0 +0,0 @@ public class BucketItem extends Item implements DispensibleContainerItem {
((ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
return false;
}

View file

@ -10,23 +10,11 @@ and will result in all kinds of dupes.
Move the tick logic into the post tick, where portaling was
designed to happen in the first place.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
return b(destination, TeleportCause.UNKNOWN);
}
+ @Nullable public final Entity changeDimension(ServerLevel worldserver, PlayerTeleportEvent.TeleportCause cause) { return this.b(worldserver, cause); } // Paper - OBFHELPER
@Nullable
public Entity b(ServerLevel worldserver, PlayerTeleportEvent.TeleportCause cause) {
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}
// Paper end - optimise entity tracking
@ -63,8 +51,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
this.passengers = Lists.newArrayList();
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
this.passengers = ImmutableList.of();
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}
this.processPortalCooldown();
@ -76,14 +64,6 @@ diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
@@ -0,0 +0,0 @@ package net.minecraft.world.level.block;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
-import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
@@ -0,0 +0,0 @@ public class EndPortalBlock extends BaseEntityBlock {
// return; // CraftBukkit - always fire event in case plugins wish to change it
}
@ -93,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- world.getCraftServer().getPluginManager().callEvent(event);
-
- if (entity instanceof ServerPlayer) {
- ((ServerPlayer) entity).b(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
- ((ServerPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
- return;
- }
- // CraftBukkit end

View file

@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ fixInvulnerableEndCrystalExploit = getBoolean("unsupported-settings.fix-invulnerable-end-crystal-exploit", fixInvulnerableEndCrystalExploit);
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
@ -48,18 +49,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
}
@@ -0,0 +0,0 @@ public class EndCrystal extends Entity {
}
tag.putBoolean("ShowBottom", this.showsBottom());
+ if (this.generatedByDragonFight) tag.putBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals
}
@Override
@@ -0,0 +0,0 @@ public class EndCrystal extends Entity {
if (tag.contains("ShowBottom", 1)) {
this.setShowBottom(tag.getBoolean("ShowBottom"));
if (nbt.contains("ShowBottom", 1)) {
this.setShowBottom(nbt.getBoolean("ShowBottom"));
}
+ if (tag.contains("Paper.GeneratedByDragonFight", 1)) this.generatedByDragonFight = tag.getBoolean("Paper.GeneratedByDragonFight"); // Paper - Fix invulnerable end crystals
@ -70,36 +66,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
@@ -0,0 +0,0 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
return (List) SpikeFeature.SPIKE_CACHE.getUnchecked(i);
}
- public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, SpikeConfiguration config) {
- List<SpikeFeature.EndSpike> list = config.getSpikes();
+ public boolean generate(WorldGenLevel generatoraccessseed, ChunkGenerator chunkgenerator, Random random, BlockPos blockposition, SpikeConfiguration worldgenfeatureendspikeconfiguration) { // Paper - decompile fix
+ List<SpikeFeature.EndSpike> list = worldgenfeatureendspikeconfiguration.getSpikes();
if (list.isEmpty()) {
- list = getSpikesForLevel(world);
+ list = getSpikesForLevel(generatoraccessseed);
}
Iterator iterator = list.iterator();
@@ -0,0 +0,0 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
while (iterator.hasNext()) {
SpikeFeature.EndSpike worldgenender_spike = (SpikeFeature.EndSpike) iterator.next();
- if (worldgenender_spike.isCenterWithinChunk(pos)) {
- this.placeSpike(world, random, config, worldgenender_spike);
+ if (worldgenender_spike.isCenterWithinChunk(blockposition)) {
+ this.placeSpike(generatoraccessseed, random, worldgenfeatureendspikeconfiguration, worldgenender_spike);
}
}
@@ -0,0 +0,0 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
entityendercrystal.setBeamTarget(config.getCrystalBeamTarget());
entityendercrystal.setInvulnerable(config.isCrystalInvulnerable());
entityendercrystal.moveTo((double) spike.getCenterX() + 0.5D, (double) (spike.getHeight() + 1), (double) spike.getCenterZ() + 0.5D, random.nextFloat() * 360.0F, 0.0F);
+ entityendercrystal.generatedByDragonFight = true;
world.addFreshEntity(entityendercrystal);
endCrystal.setBeamTarget(config.getCrystalBeamTarget());
endCrystal.setInvulnerable(config.isCrystalInvulnerable());
endCrystal.moveTo((double)spike.getCenterX() + 0.5D, (double)(spike.getHeight() + 1), (double)spike.getCenterZ() + 0.5D, random.nextFloat() * 360.0F, 0.0F);
+ endCrystal.generatedByDragonFight = true; // Paper
world.addFreshEntity(endCrystal);
this.setBlock(world, new BlockPos(spike.getCenterX(), spike.getHeight(), spike.getCenterZ()), Blocks.BEDROCK.defaultBlockState());
}

View file

@ -23,16 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
+
public void onOpen(CraftHumanEntity who) {
transaction.add(who);
this.transaction.add(who);
}
@@ -0,0 +0,0 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
return itemstack;
}
+ public ItemStack addItem(ItemStack itemstack) { return addItem(itemstack); } // Paper - OBFHELPER
public ItemStack addItem(ItemStack stack) {
ItemStack itemstack1 = stack.copy();
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
@ -59,4 +51,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // ItemStack itemstack1 = inventorysubcontainer.a(itemstack); // Paper - moved up
if (itemstack1.isEmpty()) {
item.remove();
item.discard();