Upstream Paper
This commit is contained in:
@@ -1478,6 +1478,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
return false;
|
||||
}
|
||||
|
||||
public void runKillTrigger(Entity entity, int kills, DamageSource damageSource) { this.a(entity, kills, damageSource); } // Paper - OBFHELPER
|
||||
public void a(Entity entity, int i, DamageSource damagesource) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
CriterionTriggers.c.a((EntityPlayer) entity, this, damagesource);
|
||||
@@ -2274,6 +2275,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
|
||||
}
|
||||
|
||||
public void onKill(EntityLiving entityLiving) { this.b(entityLiving); } // Paper - OBFHELPER
|
||||
public void b(EntityLiving entityliving) {}
|
||||
|
||||
protected boolean i(double d0, double d1, double d2) {
|
||||
@@ -2972,6 +2974,7 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper
|
||||
return EnumPistonReaction.NORMAL;
|
||||
}
|
||||
|
||||
public SoundCategory getDeathSoundCategory() { return bK();} // Paper - OBFHELPER
|
||||
public SoundCategory bK() {
|
||||
return SoundCategory.NEUTRAL;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
// Paper end
|
||||
private int containerUpdateDelay; // Paper
|
||||
// Paper start - cancellable death event
|
||||
public boolean queueHealthUpdatePacket = false;
|
||||
public net.minecraft.server.PacketPlayOutUpdateHealth queuedHealthUpdatePacket;
|
||||
// Paper end
|
||||
|
||||
// CraftBukkit start
|
||||
public String displayName;
|
||||
@@ -441,9 +445,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
public void die(DamageSource damagesource) {
|
||||
boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
|
||||
|
||||
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
|
||||
//this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag)); // Paper - moved down for cancellable death event
|
||||
// CraftBukkit start - fire PlayerDeathEvent
|
||||
if (this.dead) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag)); // Paper - moved down for cancellable death event
|
||||
return;
|
||||
}
|
||||
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.inventory.getSize());
|
||||
@@ -461,6 +466,16 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
String deathmessage = chatmessage.toPlainText();
|
||||
org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
|
||||
// Paper start - cancellable death event
|
||||
if (event.isCancelled()) {
|
||||
// make compatible with plugins that might have already set the health in an event listener
|
||||
if (this.getHealth() <= 0) {
|
||||
this.setHealth((float) event.getReviveHealth());
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
|
||||
// Paper end
|
||||
|
||||
String deathMessage = event.getDeathMessage();
|
||||
|
||||
@@ -614,7 +629,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
}
|
||||
|
||||
return super.damageEntity(damagesource, f);
|
||||
// Paper start - cancellable death events
|
||||
//return super.damageEntity(damagesource, f);
|
||||
this.queueHealthUpdatePacket = true;
|
||||
boolean damaged = super.damageEntity(damagesource, f);
|
||||
this.queueHealthUpdatePacket = false;
|
||||
if (this.queuedHealthUpdatePacket != null) {
|
||||
this.playerConnection.sendPacket(this.queuedHealthUpdatePacket);
|
||||
this.queuedHealthUpdatePacket = null;
|
||||
}
|
||||
return damaged;
|
||||
// Paper end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Doubles;
|
||||
import com.google.common.primitives.Floats;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
|
||||
import io.akarin.api.internal.Akari;
|
||||
import io.akarin.server.core.AkarinGlobalConfig;
|
||||
@@ -10,6 +12,8 @@ import io.netty.util.concurrent.GenericFutureListener;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -382,10 +386,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
}
|
||||
|
||||
entity.setLocation(d3, d4, d5, f, f1);
|
||||
Location curPos = getPlayer().getLocation(); // Paper
|
||||
player.setLocation(d3, d4, d5, f, f1); // Paper
|
||||
boolean flag2 = worldserver.getCubes(entity, entity.getBoundingBox().shrink(0.0625D)).isEmpty();
|
||||
|
||||
if (flag && (flag1 || !flag2)) {
|
||||
entity.setLocation(d0, d1, d2, f, f1);
|
||||
player.setLocation(d0, d1, d2, f, f1); // Paper
|
||||
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
}
|
||||
@@ -395,7 +402,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
// Spigot Start
|
||||
if ( !hasMoved )
|
||||
{
|
||||
Location curPos = player.getLocation();
|
||||
//Location curPos = player.getLocation(); // Paper - move up
|
||||
lastPosX = curPos.getX();
|
||||
lastPosY = curPos.getY();
|
||||
lastPosZ = curPos.getZ();
|
||||
@@ -2310,32 +2317,26 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
buffer, isCommand, blockpos != null ? MCUtil.toLocation(player.world, blockpos) : null);
|
||||
event.callEvent();
|
||||
completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions();
|
||||
if (event.isCancelled() || event.isHandled()) {
|
||||
// Still fire sync event with the provided completions, if someone is listening
|
||||
if (!event.isCancelled() && org.bukkit.event.server.TabCompleteEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
java.util.List<String> finalCompletions = completions;
|
||||
Waitable<java.util.List<String>> syncCompletions = new Waitable<java.util.List<String>>() {
|
||||
@Override
|
||||
protected java.util.List<String> evaluate() {
|
||||
org.bukkit.event.server.TabCompleteEvent syncEvent = new org.bukkit.event.server.TabCompleteEvent(PlayerConnection.this.getPlayer(), buffer, finalCompletions, isCommand, blockpos != null ? MCUtil.toLocation(player.world, blockpos) : null);
|
||||
return syncEvent.callEvent() ? syncEvent.getCompletions() : com.google.common.collect.ImmutableList.of();
|
||||
}
|
||||
};
|
||||
server.getServer().processQueue.add(syncCompletions);
|
||||
try {
|
||||
completions = syncCompletions.get();
|
||||
} catch (InterruptedException | ExecutionException e1) {
|
||||
e1.printStackTrace();
|
||||
if (!event.isHandled()) {
|
||||
// If the event isn't handled, we can assume that we have no completions, and so we'll ask the server
|
||||
|
||||
Waitable<java.util.List<String>> syncCompletions = new Waitable<java.util.List<String>>() {
|
||||
@Override
|
||||
protected java.util.List<String> evaluate() {
|
||||
return minecraftServer.tabCompleteCommand(player, buffer, blockpos, isCommand);
|
||||
}
|
||||
};
|
||||
server.getServer().processQueue.add(syncCompletions);
|
||||
try {
|
||||
completions = syncCompletions.get();
|
||||
} catch (InterruptedException | ExecutionException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutTabComplete(completions.toArray(new String[completions.size()])));
|
||||
return;
|
||||
} else if (!event.isCancelled()) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutTabComplete(completions.toArray(new String[completions.size()])));
|
||||
}
|
||||
minecraftServer.postToMainThread(() -> {
|
||||
java.util.List<String> syncCompletions = this.minecraftServer.tabCompleteCommand(this.player, buffer, blockpos, isCommand);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutTabComplete(syncCompletions.toArray(new String[syncCompletions.size()])));
|
||||
});
|
||||
// Paper end
|
||||
}
|
||||
|
||||
@@ -2377,7 +2378,6 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
|
||||
itemstack1 = new ItemStack(Items.WRITABLE_BOOK); // CraftBukkit
|
||||
itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
|
||||
CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit
|
||||
}
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import com.destroystokyo.paper.PaperConfig; // Paper
|
||||
import java.util.LinkedHashMap; // Paper
|
||||
|
||||
/**
|
||||
* Akarin Changes Note
|
||||
* 1) Removes unneed synchronization (performance)
|
||||
*/
|
||||
public class RegionFileCache {
|
||||
|
||||
public static final Map<File, RegionFile> a = new LinkedHashMap(PaperConfig.regionFileCacheSize, 0.75f, true); // Spigot - private -> public, Paper - HashMap -> LinkedHashMap
|
||||
|
||||
public static synchronized RegionFile a(File file, int i, int j) {
|
||||
File file1 = new File(file, "region");
|
||||
File file2 = new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
|
||||
RegionFile regionfile = (RegionFile) RegionFileCache.a.get(file2);
|
||||
|
||||
if (regionfile != null) {
|
||||
return regionfile;
|
||||
} else {
|
||||
if (!file1.exists()) {
|
||||
file1.mkdirs();
|
||||
}
|
||||
|
||||
if (RegionFileCache.a.size() >= PaperConfig.regionFileCacheSize) { // Paper
|
||||
trimCache(); // Paper
|
||||
}
|
||||
|
||||
RegionFile regionfile1 = new RegionFile(file2);
|
||||
|
||||
RegionFileCache.a.put(file2, regionfile1);
|
||||
return regionfile1;
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized RegionFile b(File file, int i, int j) {
|
||||
File file1 = new File(file, "region");
|
||||
File file2 = new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
|
||||
RegionFile regionfile = (RegionFile) RegionFileCache.a.get(file2);
|
||||
|
||||
if (regionfile != null) {
|
||||
return regionfile;
|
||||
} else if (file1.exists() && file2.exists()) {
|
||||
if (RegionFileCache.a.size() >= 256) {
|
||||
a();
|
||||
}
|
||||
|
||||
RegionFile regionfile1 = new RegionFile(file2);
|
||||
|
||||
RegionFileCache.a.put(file2, regionfile1);
|
||||
return regionfile1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Paper Start
|
||||
private static synchronized void trimCache() {
|
||||
Iterator<Map.Entry<File, RegionFile>> itr = RegionFileCache.a.entrySet().iterator();
|
||||
int count = RegionFileCache.a.size() - PaperConfig.regionFileCacheSize;
|
||||
while (count-- >= 0 && itr.hasNext()) {
|
||||
try {
|
||||
itr.next().getValue().c();
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
ServerInternalException.reportInternalException(ioexception);
|
||||
}
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
// Paper End
|
||||
|
||||
public static synchronized void a() {
|
||||
Iterator iterator = RegionFileCache.a.values().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
RegionFile regionfile = (RegionFile) iterator.next();
|
||||
|
||||
try {
|
||||
if (regionfile != null) {
|
||||
regionfile.c();
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
ServerInternalException.reportInternalException(ioexception); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
RegionFileCache.a.clear();
|
||||
}
|
||||
|
||||
// CraftBukkit start - call sites hoisted for synchronization
|
||||
public static /*synchronized*/ NBTTagCompound d(File file, int i, int j) throws IOException { // Akarin - 1.13 backport - remove synchronization // OBFHELPER: read
|
||||
RegionFile regionfile = a(file, i, j);
|
||||
|
||||
DataInputStream datainputstream = regionfile.a(i & 31, j & 31);
|
||||
|
||||
if (datainputstream == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return NBTCompressedStreamTools.a(datainputstream);
|
||||
}
|
||||
|
||||
public static /*synchronized*/ void e(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException { // Akarin - 1.13 backport - remove synchronization // OBFHELPER: write
|
||||
RegionFile regionfile = a(file, i, j);
|
||||
|
||||
DataOutputStream dataoutputstream = regionfile.b(i & 31, j & 31);
|
||||
NBTCompressedStreamTools.a(nbttagcompound, (java.io.DataOutput) dataoutputstream);
|
||||
dataoutputstream.close();
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
public static /*synchronized*/ boolean chunkExists(File file, int i, int j) { // Akarin - 1.13 backport - remove synchronization
|
||||
RegionFile regionfile = b(file, i, j);
|
||||
|
||||
return regionfile != null ? regionfile.c(i & 31, j & 31) : false;
|
||||
}
|
||||
}
|
||||
@@ -1184,7 +1184,7 @@ public abstract class World implements IBlockAccess {
|
||||
|
||||
int i = MathHelper.floor(entity.locX / 16.0D);
|
||||
int j = MathHelper.floor(entity.locZ / 16.0D);
|
||||
boolean flag = entity.attachedToPlayer;
|
||||
boolean flag = true; // Paper - always load chunks
|
||||
|
||||
// Paper start - Set origin location when the entity is being added to the world
|
||||
if (entity.origin == null) {
|
||||
@@ -1831,7 +1831,7 @@ public abstract class World implements IBlockAccess {
|
||||
this.getChunkAt(entity.ab, entity.ad).a(entity, entity.ac);
|
||||
}
|
||||
|
||||
if (false && !entity.bD() && !this.isChunkLoaded(i, k, true)) { // Paper - Always send entities into a new chunk, never lose them
|
||||
if (!entity.valid && !entity.bD() && !this.isChunkLoaded(i, k, true)) { // Paper - always load to new chunk if valid
|
||||
entity.aa = false;
|
||||
} else {
|
||||
this.getChunkAt(i, k).a(entity);
|
||||
|
||||
Reference in New Issue
Block a user