CavePVP-Stuff/cSpigot-master/spigot-server-Patches/0219-Changes.patch

778 lines
37 KiB
Diff
Raw Permalink Normal View History

2023-05-01 20:59:40 +02:00
From c700625dc432345b8d8b97f0830bd7a118409c68 Mon Sep 17 00:00:00 2001
From: Alfie Cleveland <alfeh@me.com>
Date: Sat, 28 Apr 2018 18:29:08 +0100
Subject: [PATCH] Changes
diff --git a/src/main/java/net/minecraft/server/BlockTripwire.java b/src/main/java/net/minecraft/server/BlockTripwire.java
index cf84d794c..d34536137 100644
--- a/src/main/java/net/minecraft/server/BlockTripwire.java
+++ b/src/main/java/net/minecraft/server/BlockTripwire.java
@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Random;
import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+import org.spigotmc.SpigotConfig;
public class BlockTripwire extends Block {
@@ -22,6 +23,15 @@ public class BlockTripwire extends Block {
return null;
}
+ @Override
+ public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
+ if (SpigotConfig.pearlThroughGatesAndTripwire) {
+ return null;
+ }
+
+ return super.a(world, i, j, k, vec3d, vec3d1);
+ }
+
public boolean c() {
return false;
}
diff --git a/src/main/java/net/minecraft/server/BlockTripwireHook.java b/src/main/java/net/minecraft/server/BlockTripwireHook.java
index c23426583..e8e6ce567 100644
--- a/src/main/java/net/minecraft/server/BlockTripwireHook.java
+++ b/src/main/java/net/minecraft/server/BlockTripwireHook.java
@@ -3,6 +3,7 @@ package net.minecraft.server;
import java.util.Random;
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+import org.spigotmc.SpigotConfig;
public class BlockTripwireHook extends Block {
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 97fbde16f..f93b00778 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -70,12 +70,12 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true));
// CraftBukkit end
- i.info("Starting minecraft server version 1.7.10");
+ aF().info("Starting minecraft server version 1.7.10");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
- i.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
+ aF().warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
}
- i.info("Loading properties");
+ aF().info("Loading properties");
this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support
// MineHQ - screw the EULA
if (true) {
@@ -104,7 +104,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
int gamemode = this.propertyManager.getInt("gamemode", EnumGamemode.SURVIVAL.getId()); // CraftBukkit - Unique name to avoid stomping on logger
this.p = WorldSettings.a(gamemode); // CraftBukkit - Use new name
- i.info("Default game type: " + this.p);
+ aF().info("Default game type: " + this.p);
InetAddress inetaddress = null;
if (this.getServerIp().length() > 0) {
@@ -124,17 +124,17 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
org.github.paperspigot.PaperSpigotConfig.registerCommands();
// PaperSpigot stop
- i.info("Generating keypair");
+ aF().info("Generating keypair");
this.a(MinecraftEncryption.b());
- i.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.L());
+ aF().info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.L());
if (!org.spigotmc.SpigotConfig.lateBind) {
try {
this.ai().a(inetaddress, this.L());
} catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable
- i.warn("**** FAILED TO BIND TO PORT!");
- i.warn("The exception was: {}", new Object[] { ioexception.toString()});
- i.warn("Perhaps a server is already running on that port?");
+ aF().warn("**** FAILED TO BIND TO PORT!");
+ aF().warn("The exception was: {}", new Object[] { ioexception.toString()});
+ aF().warn("Perhaps a server is already running on that port?");
return false;
}
}
@@ -146,10 +146,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
// Spigot End
if (!this.getOnlineMode()) {
- i.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
- i.warn("The server will make no attempt to authenticate usernames. Beware.");
- i.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
- i.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
+ aF().warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
+ aF().warn("The server will make no attempt to authenticate usernames. Beware.");
+ aF().warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
+ aF().warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
}
if (this.aE()) {
@@ -198,20 +198,20 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
this.c((this.getMaxBuildHeight() + 8) / 16 * 16);
this.c(MathHelper.a(this.getMaxBuildHeight(), 64, 256));
this.propertyManager.setProperty("max-build-height", Integer.valueOf(this.getMaxBuildHeight()));
- i.info("Preparing level \"" + this.O() + "\"");
+ aF().info("Preparing level \"" + this.O() + "\"");
this.a(this.O(), this.O(), k, worldtype, s2);
long i1 = System.nanoTime() - j;
String s3 = String.format("%.3fs", new Object[] { Double.valueOf((double) i1 / 1.0E9D)});
- i.info("Done (" + s3 + ")! For help, type \"help\" or \"?\"");
+ aF().info("Done (" + s3 + ")! For help, type \"help\" or \"?\"");
if (this.propertyManager.getBoolean("enable-query", false)) {
- i.info("Starting GS4 status listener");
+ aF().info("Starting GS4 status listener");
this.k = new RemoteStatusListener(this);
this.k.a();
}
if (this.propertyManager.getBoolean("enable-rcon", false)) {
- i.info("Starting remote control listener");
+ aF().info("Starting remote control listener");
this.l = new RemoteControlListener(this);
this.l.a();
this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit
@@ -219,7 +219,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
// CraftBukkit start
if (this.server.getBukkitSpawnRadius() > -1) {
- i.info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you.");
+ aF().info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you.");
this.propertyManager.properties.remove("spawn-protection");
this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius());
this.server.removeBukkitSpawnRadius();
@@ -231,9 +231,9 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
try {
this.ai().a(inetaddress, this.L());
} catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable
- i.warn("**** FAILED TO BIND TO PORT!");
- i.warn("The exception was: {}", new Object[] { ioexception.toString()});
- i.warn("Perhaps a server is already running on that port?");
+ aF().warn("**** FAILED TO BIND TO PORT!");
+ aF().warn("The exception was: {}", new Object[] { ioexception.toString()});
+ aF().warn("Perhaps a server is already running on that port?");
return false;
}
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 6bc793a8e..102e9d2c9 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1381,7 +1381,16 @@ public abstract class Entity {
return !this.dead;
}
+ private int lastInBlockTick = -1;
+ private boolean lastInBlockResult = false;
+
public boolean inBlock() {
+ int currentTick = MinecraftServer.currentTick;
+
+ if (lastInBlockTick == currentTick) {
+ return lastInBlockResult;
+ }
+
for (int i = 0; i < 8; ++i) {
float f = ((float) ((i >> 0) % 2) - 0.5F) * this.width * 0.8F;
float f1 = ((float) ((i >> 1) % 2) - 0.5F) * 0.1F;
@@ -1391,10 +1400,14 @@ public abstract class Entity {
int l = MathHelper.floor(this.locZ + (double) f2);
if (this.world.getType(j, k, l).r()) {
+ lastInBlockTick = currentTick;
+ lastInBlockResult = true;
return true;
}
}
+ lastInBlockTick = currentTick;
+ lastInBlockResult = false;
return false;
}
diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java
index b17dde605..8da37d332 100644
--- a/src/main/java/net/minecraft/server/EntityEnderPearl.java
+++ b/src/main/java/net/minecraft/server/EntityEnderPearl.java
@@ -1,15 +1,24 @@
package net.minecraft.server;
+import java.util.Set;
+
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.player.PlayerPearlRefundEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
-// CraftBukkit end
+
+import com.google.common.collect.Sets;
public class EntityEnderPearl extends EntityProjectile {
private Location lastValidTeleport = null;
+ private Item toRefundPearl = null;
+
+ private static Set<Block> PROHIBITED_PEARL_BLOCKS = Sets.newHashSet(Block.getById(85),
+ Block.getById(107)
+ );
public EntityEnderPearl(World world) {
super(world);
@@ -23,7 +32,9 @@ public class EntityEnderPearl extends EntityProjectile {
// MineHQ start
public void h() {
- if (this.world.getCubes(this, this.boundingBox.grow(0.25D, 0D, 0.25D)).isEmpty()) {
+ AxisAlignedBB newBoundingBox = AxisAlignedBB.a(this.locX - 0.3D, this.locY - 0.05D, this.locZ - 0.3D, this.locX + 0.3D, this.locY + 0.5D, this.locZ + 0.3D);
+
+ if (!this.world.boundingBoxContainsMaterials(this.boundingBox.grow(0.25D, 0D, 0.25D), PROHIBITED_PEARL_BLOCKS) && this.world.getCubes(this, newBoundingBox).isEmpty()) {
this.lastValidTeleport = getBukkitEntity().getLocation();
}
@@ -50,32 +61,44 @@ public class EntityEnderPearl extends EntityProjectile {
if (this.getShooter() != null && this.getShooter() instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) this.getShooter();
- if (entityplayer.playerConnection.b().isConnected() && entityplayer.world == this.world && this.lastValidTeleport != null) { // MineHQ
- // CraftBukkit start - Fire PlayerTeleportEvent
- org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
- org.bukkit.Location location = this.lastValidTeleport.clone(); // MineHQ
- location.setPitch(player.getLocation().getPitch());
- location.setYaw(player.getLocation().getYaw());
-
- PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
- Bukkit.getPluginManager().callEvent(teleEvent);
-
- if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) {
- if (this.getShooter().am()) {
- this.getShooter().mount((Entity) null);
+ if (entityplayer.playerConnection.b().isConnected() && entityplayer.world == this.world) { // MineHQ
+ if (this.lastValidTeleport != null) {
+ // CraftBukkit start - Fire PlayerTeleportEvent
+ org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
+ org.bukkit.Location location = this.lastValidTeleport.clone(); // MineHQ
+ location.setPitch(player.getLocation().getPitch());
+ location.setYaw(player.getLocation().getYaw());
+
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
+ Bukkit.getPluginManager().callEvent(teleEvent);
+
+ if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) {
+ if (this.getShooter().am()) {
+ this.getShooter().mount((Entity) null);
+ }
+
+ entityplayer.playerConnection.teleport(teleEvent.getTo());
+ this.getShooter().fallDistance = 0.0F;
+ CraftEventFactory.entityDamage = this;
+ this.getShooter().damageEntity(DamageSource.FALL, 5.0F);
+ CraftEventFactory.entityDamage = null;
}
-
- entityplayer.playerConnection.teleport(teleEvent.getTo());
- this.getShooter().fallDistance = 0.0F;
- CraftEventFactory.entityDamage = this;
- this.getShooter().damageEntity(DamageSource.FALL, 5.0F);
- CraftEventFactory.entityDamage = null;
+ // CraftBukkit end
+ } else {
+ Bukkit.getPluginManager().callEvent(new PlayerPearlRefundEvent(entityplayer.getBukkitEntity()));
}
- // CraftBukkit end
}
}
this.die();
}
}
+
+ public Item getToRefundPearl() {
+ return this.toRefundPearl;
+ }
+
+ public void setToRefundPearl(Item pearl) {
+ this.toRefundPearl = pearl;
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index e783c28cc..4430227b9 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -174,8 +174,8 @@ public abstract class EntityLiving extends Entity {
boolean flag = this instanceof EntityHuman && ((EntityHuman) this).abilities.isInvulnerable;
- if (this.isAlive() && this.a(Material.WATER)) {
- if (!this.aE() && !this.hasEffect(MobEffectList.WATER_BREATHING.id) && !flag) {
+ if (this.isAlive() && this.inWater) {
+ if (!this.aE() && !flag && !this.hasEffect(MobEffectList.WATER_BREATHING.id)) {
this.setAirTicks(this.j(this.getAirTicks()));
if (this.getAirTicks() == -20) {
this.setAirTicks(0);
@@ -203,7 +203,7 @@ public abstract class EntityLiving extends Entity {
// CraftBukkit end
}
- if (this.isAlive() && this.L()) {
+ if (this.isAlive() && 0 < this.fireTicks && this.L()) {
this.extinguish();
}
@@ -495,11 +495,11 @@ public abstract class EntityLiving extends Entity {
flag1 = this.random.nextInt(15) == 0;
}
- if (flag) {
+ if (flag && !flag1) {
flag1 &= this.random.nextInt(5) == 0;
}
- if (flag1 && i > 0) {
+ if (flag1) {
double d0 = (double) (i >> 16 & 255) / 255.0D;
double d1 = (double) (i >> 8 & 255) / 255.0D;
double d2 = (double) (i >> 0 & 255) / 255.0D;
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
index 5e32faec6..5287cdab6 100644
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
@@ -2,6 +2,7 @@ package net.minecraft.server;
import java.util.List;
+import org.bukkit.Bukkit;
import org.spigotmc.SpigotConfig;
public abstract class EntityProjectile extends Entity implements IProjectile {
@@ -115,17 +116,33 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
// Riot start - pearling through open fence gates & string
- if (SpigotConfig.pearlThroughGatesAndTripwire && movingobjectposition != null && movingobjectposition.type == EnumMovingObjectType.BLOCK && this instanceof EntityEnderPearl) {
- int x = movingobjectposition.b;
- int y = movingobjectposition.c;
- int z = movingobjectposition.d;
- Block block = this.world.getType(x, y, z);
- if (block == Blocks.FENCE_GATE) {
- if ((this.world.getData(x, y, z) & 0x4) != 0x0) { // if the fence gate is open
- movingobjectposition = null;
- }
- } else if (block == Blocks.TRIPWIRE) {
+ if (SpigotConfig.pearlThroughGatesAndTripwire && this instanceof EntityEnderPearl && movingobjectposition != null && movingobjectposition.type == EnumMovingObjectType.BLOCK) {
+
+ int fromX = MathHelper.floor(this.locX);
+ int fromY = MathHelper.floor(this.locY);
+ int fromZ = MathHelper.floor(this.locZ);
+
+ int toX = MathHelper.floor(this.locX + this.motX);
+ int toY = MathHelper.floor(this.locY + this.motY);
+ int toZ = MathHelper.floor(this.locZ + this.motZ);
+
+ int collisionX = movingobjectposition.b;
+ int collisionY = movingobjectposition.c;
+ int collisionZ = movingobjectposition.d;
+
+ boolean isFromClear = isClear(fromX, fromY, fromZ);
+ boolean isToClear = isClear(toX, toY, toZ);
+ boolean isCollisionClear = isClear(collisionX, collisionY, collisionZ);
+
+ if (isFromClear && isCollisionClear && isToClear) {
movingobjectposition = null;
+ } else {
+ Bukkit.getLogger().info("isFromClear:" + isFromClear);
+ Bukkit.getLogger().info("isCollisionClear:" + isCollisionClear);
+ Bukkit.getLogger().info("isToClear:" + isToClear);
+ Bukkit.getLogger().info(String.format("from: %d,%d,%d", fromX, fromY, fromZ));
+ Bukkit.getLogger().info(String.format("collision: %d,%d,%d", collisionX, collisionY, collisionZ));
+ Bukkit.getLogger().info(String.format("to: %d,%d,%d", toX, toY, toZ));
}
}
// Riot end
@@ -272,4 +289,10 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
return this.shooter;
}
+
+ private boolean isClear(int x, int y, int z) {
+ Block block = this.world.getType(x, y, z);
+
+ return block == null || block == Blocks.AIR || (block == Blocks.FENCE_GATE && (this.world.getData(x, y, z) & 0x4) != 0x0);
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 74ee10cf4..a4ffea018 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -51,7 +51,6 @@ import net.frozenorb.autosave.AutoSave;
public abstract class MinecraftServer implements ICommandListener, Runnable, IMojangStatistics {
- private static final Logger i = LogManager.getLogger();
private static final File a = new File( "config/misc", "usercache.json"); // MineHQ - Dedicated config directory
private static MinecraftServer j;
public Convertable convertable; // CraftBukkit - private final -> public
@@ -167,7 +166,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.reader = new ConsoleReader(System.in, System.out);
this.reader.setExpandEvents(false);
} catch (IOException ex) {
- i.warn((String) null, ex);
+ getLogger().warn((String) null, ex);
}
}
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
@@ -182,7 +181,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
protected void a(String s) {
if (this.getConvertable().isConvertable(s)) {
- i.info("Converting map!");
+ getLogger().info("Converting map!");
this.b("menu.convertingLevel");
this.getConvertable().convert(s, new ConvertProgressUpdater(this));
}
@@ -324,7 +323,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
// CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory
for (int m = 0; m < this.worlds.size(); ++m) {
WorldServer worldserver = this.worlds.get(m);
- MinecraftServer.i.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
+ getLogger().info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
if (!worldserver.getWorld().getKeepSpawnInMemory()) {
continue;
}
@@ -409,7 +408,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
public void stop() throws ExceptionWorldConflict { // CraftBukkit - added throws
if (!this.M) {
- i.info("Stopping server");
+ getLogger().info("Stopping server");
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
@@ -421,13 +420,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
if (this.u != null) {
- i.info("Saving players");
+ getLogger().info("Saving players");
this.u.savePlayers();
this.u.u();
}
if (this.worldServer != null) {
- i.info("Saving worlds");
+ getLogger().info("Saving worlds");
this.saveChunks(false);
/* CraftBukkit start - Handled in saveChunks
@@ -445,7 +444,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
// Spigot start
if( org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly )
{
- i.info("Saving usercache.json");
+ getLogger().info("Saving usercache.json");
this.X.c();
}
//Spigot end
@@ -521,11 +520,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
} catch (Throwable throwable) {
this.abnormalTermination = true; // SportBukkit
- i.error("Encountered an unexpected exception", throwable);
+ getLogger().error("Encountered an unexpected exception", throwable);
// Spigot Start
if ( throwable.getCause() != null )
{
- i.error( "\tCause of unexpected exception was", throwable.getCause() );
+ getLogger().error( "\tCause of unexpected exception was", throwable.getCause() );
}
// Spigot End
CrashReport crashreport = null;
@@ -539,9 +538,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
File file1 = new File(new File(this.s(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
if (crashreport.a(file1)) {
- i.error("This crash report has been saved to: " + file1.getAbsolutePath());
+ getLogger().error("This crash report has been saved to: " + file1.getAbsolutePath());
} else {
- i.error("We were unable to save this crash report to disk.");
+ getLogger().error("We were unable to save this crash report to disk.");
}
this.a(crashreport);
@@ -551,7 +550,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.stop();
this.isStopped = true;
} catch (Throwable throwable1) {
- i.error("Exception stopping the server", throwable1);
+ getLogger().error("Exception stopping the server", throwable1);
} finally {
// CraftBukkit start - Restore terminal to original settings
try {
@@ -580,7 +579,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
} catch (Exception exception) {
- i.error("Couldn\'t load server icon", exception);
+ getLogger().error("Couldn\'t load server icon", exception);
} finally {
bytebuf.release();
}
@@ -921,7 +920,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
// Runtime.getRuntime().addShutdownHook(new ThreadShutdown("Server Shutdown Thread", dedicatedserver));
// CraftBukkit end
} catch (Exception exception) {
- i.fatal("Failed to start the minecraft server", exception);
+ getLogger().fatal("Failed to start the minecraft server", exception);
System.exit(1); // Sportbukkit
}
}
@@ -935,11 +934,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public void info(String s) {
- i.info(s);
+ getLogger().info(s);
}
public void warning(String s) {
- i.warn(s);
+ getLogger().warn(s);
}
public WorldServer getWorldServer(int i) {
@@ -1045,12 +1044,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
}
public void h(String s) {
- i.error(s);
+ getLogger().error(s);
}
public void i(String s) {
if (this.isDebugging()) {
- i.info(s);
+ getLogger().info(s);
}
}
@@ -1457,7 +1456,11 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
this.V = 0L;
}
+ private static Logger i;
public static Logger getLogger() {
+ if (i == null) {
+ i = LogManager.getLogger();
+ }
return i;
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 9a2443b58..5a36be196 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -15,6 +15,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.util.LazyPlayerSet;
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.entity.Player;
@@ -1222,7 +1223,7 @@ public class PlayerConnection implements PacketPlayInListener {
// Else we increment the drop count and check the amount.
this.dropCount++;
if (this.dropCount >= 20) {
- this.c.warn(this.player.getName() + " dropped their items too quickly!");
+ PlayerConnection.c.warn(this.player.getName() + " dropped their items too quickly!");
this.disconnect("You dropped your items too quickly (Hacking?)");
return;
}
@@ -1345,7 +1346,8 @@ public class PlayerConnection implements PacketPlayInListener {
int l = packetplayinblockplace.getFace();
this.player.v();
- if (packetplayinblockplace.getFace() == 255) {
+ boolean isEnderPearl = false;
+ if (packetplayinblockplace.getFace() == 255 || (isEnderPearl = (!isChest(i, j, k) && itemstack != null && itemstack.getItem() != null && CraftMagicNumbers.getMaterial(itemstack.getItem()) == org.bukkit.Material.ENDER_PEARL))) {
if (itemstack == null) {
return;
}
@@ -1357,6 +1359,10 @@ public class PlayerConnection implements PacketPlayInListener {
org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
if (event.useItemInHand() != Event.Result.DENY) {
this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
+
+ if (isEnderPearl) {
+ flag = true;
+ }
}
}
// Spigot end
@@ -1390,31 +1396,27 @@ public class PlayerConnection implements PacketPlayInListener {
if (flag) {
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver));
+
+ boolean sendSecondUpdate = true;
if (l == 0) {
--j;
- }
-
- if (l == 1) {
+ } else if (l == 1) {
++j;
- }
-
- if (l == 2) {
+ } else if (l == 2) {
--k;
- }
-
- if (l == 3) {
+ } else if (l == 3) {
++k;
- }
-
- if (l == 4) {
+ } else if (l == 4) {
--i;
- }
-
- if (l == 5) {
+ } else if (l == 5) {
++i;
+ } else {
+ sendSecondUpdate = false;
}
- this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver));
+ if (sendSecondUpdate) {
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver));
+ }
}
itemstack = this.player.inventory.getItemInHand();
@@ -1437,6 +1439,11 @@ public class PlayerConnection implements PacketPlayInListener {
}
}
+ private boolean isChest(int x, int y, int z) {
+ org.bukkit.Material bukkitMaterial = CraftMagicNumbers.getMaterial(this.player.world.getType(x, y, z));
+ return bukkitMaterial == org.bukkit.Material.CHEST || bukkitMaterial == org.bukkit.Material.TRAPPED_CHEST || bukkitMaterial == org.bukkit.Material.ENDER_CHEST;
+ }
+
public void a(IChatBaseComponent ichatbasecomponent) {
// CraftBukkit start - Rarely it would send a disconnect line twice
if (this.processedDisconnect) {
@@ -1780,7 +1787,7 @@ public class PlayerConnection implements PacketPlayInListener {
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
// CraftBukkit start - whole method
- if ( org.spigotmc.SpigotConfig.logCommands ) this.c.info(this.player.getName() + " issued server command: " + s);
+ if ( org.spigotmc.SpigotConfig.logCommands ) PlayerConnection.c.info(this.player.getName() + " issued server command: " + s);
CraftPlayer player = this.getPlayer();
@@ -1876,6 +1883,8 @@ public class PlayerConnection implements PacketPlayInListener {
this.player.setSneaking(false);
} else if (packetplayinentityaction.d() == 4) {
this.player.setSprinting(true);
+ this.player.setSneaking(false); // MineHQ
+
// Guardian start
if (this.player.isBlocking()) {
this.player.bA(); // stopUsingItem
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 6b76b4e77..6de5a6b6a 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -28,7 +28,6 @@ import org.spigotmc.SpigotConfig;
public class WorldServer extends World {
- private static final Logger a = LogManager.getLogger();
private final MinecraftServer server;
public EntityTracker tracker; // CraftBukkit - private final -> public
private final PlayerChunkMap manager;
@@ -657,9 +656,6 @@ public class WorldServer extends World {
iterator = this.N.iterator();
} else {
iterator = this.V.iterator();
- if (!this.V.isEmpty()) {
- a.debug("toBeTicked = " + this.V.size());
- }
}
while (iterator.hasNext()) {
@@ -793,7 +789,7 @@ public class WorldServer extends World {
i = chunkposition.x;
k = chunkposition.z;
} else {
- a.warn("Unable to find spawn biome");
+ LogManager.getLogger().warn("Unable to find spawn biome");
}
int l = 0;
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
deleted file mode 100644
index f5bcbdbe1..000000000
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.bukkit.craftbukkit.inventory;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.Matchers.*;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import net.minecraft.server.CommandAbstract;
-import net.minecraft.server.IAttribute;
-
-import org.bukkit.support.AbstractTestingBase;
-import org.junit.Test;
-
-public class ItemFactoryTest extends AbstractTestingBase {
-
- @Test
- public void testKnownAttributes() throws Throwable {
- final ZipInputStream nmsZipStream = new ZipInputStream(CommandAbstract.class/* Magic class that isn't imported! */.getProtectionDomain().getCodeSource().getLocation().openStream());
- final Collection<String> names = new HashSet<String>();
- for (ZipEntry clazzEntry; (clazzEntry = nmsZipStream.getNextEntry()) != null; ) {
- final String entryName = clazzEntry.getName();
- if (!(entryName.endsWith(".class") && entryName.startsWith("net/minecraft/server/"))) {
- continue;
- }
-
- final Class<?> clazz = Class.forName(entryName.substring(0, entryName.length() - ".class".length()).replace('/', '.'));
- assertThat(entryName, clazz, is(not(nullValue())));
- for (final Field field : clazz.getDeclaredFields()) {
- if (IAttribute.class.isAssignableFrom(field.getType()) && Modifier.isStatic(field.getModifiers())) {
- field.setAccessible(true);
- final String attributeName = ((IAttribute) field.get(null)).getName();
- assertThat("Logical error: duplicate name `" + attributeName + "' in " + clazz.getName(), names.add(attributeName), is(true));
- assertThat(clazz.getName(), CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES, hasItem(attributeName));
- }
- }
- }
-
- nmsZipStream.close();
-
- assertThat("Extra values detected", CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES, is(names));
- }
-}
--
2.15.2 (Apple Git-101.1)