diff --git a/TacoSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java b/TacoSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java index 8d799b7..5c2fb6c 100644 --- a/TacoSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java +++ b/TacoSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java @@ -9,6 +9,7 @@ import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.command.Command; import com.elevatemc.spigot.knockback.KnockbackHandler; +import org.bukkit.craftbukkit.CraftServer; import java.util.Arrays; import java.util.HashSet; @@ -25,7 +26,7 @@ public class eSpigot { public static final ScheduledExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadScheduledExecutor(); - private static eSpigot instance = null; + private static eSpigot instance; public static eSpigot getInstance() { return instance; @@ -34,10 +35,9 @@ public class eSpigot { private final YamlConfig config, knockbackConfig; private final KnockbackHandler knockbackHandler; - public eSpigot() { + public eSpigot(CraftServer server) { // Set instance of the server instance = this; - config = new YamlConfig("espigot.yml"); knockbackConfig = new YamlConfig("knockback.yml"); @@ -47,7 +47,7 @@ public class eSpigot { eSpigotFeature.reload(config); for (Command command : Arrays.asList(new KnockbackCommand(), new TicksPerSecondCommand())) - MinecraftServer.getServer().server.getCommandMap() + server.getCommandMap() .register(command.getLabel(), "eSpigot", command); EXECUTOR_SERVICE.scheduleAtFixedRate(() -> MinecraftServer.getServer().aq().processFastPackets(), 5L, 5L, TimeUnit.MILLISECONDS); diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java index b744605..60bff23 100644 --- a/TacoSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java @@ -90,8 +90,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs public java.util.Queue processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; public double[] recentTps = new double[3]; // PaperSpigot - Fine have your darn compat with bad plugins - // eSpigot start - private eSpigot eSpigot; + private ServerConnection q; // Spigot private String serverIp; private int u = -1; @@ -662,7 +661,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs // eSpigot start - Thread affinity MinecraftServer.LOGGER.info("[eSpigot] Locked main thread. CPU: " + lock.cpuId()); affinityLock = lock; - this.eSpigot = new eSpigot(); + // eSpigot end this.ab = az(); @@ -675,7 +674,6 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs // Spigot start // PaperSpigot start - Further improve tick loop Arrays.fill(recentTps, 20); - //long lastTick = System.nanoTime(), catchupTime = 0, curTime, wait, tickSection = lastTick; long start = System.nanoTime(), lastTick = start - TICK_TIME, nextTick = start + MinecraftServer.TICK_TIME, catchupTime = 0, curTime, wait, tickSection = start; // PaperSpigot end while (this.isRunning) { diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalTempt.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalTempt.java new file mode 100644 index 0000000..b846c6a --- /dev/null +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalTempt.java @@ -0,0 +1,101 @@ +package net.minecraft.server; + +public class PathfinderGoalTempt extends PathfinderGoal { + private EntityCreature a; + private double b; + private double c; + private double d; + private double e; + private double f; + private double g; + private EntityHuman h; + private int i; + private boolean j; + private Item k; + private boolean l; + private boolean m; + + public PathfinderGoalTempt(EntityCreature var1, double var2, Item var4, boolean var5) { + this.a = var1; + this.b = var2; + this.k = var4; + this.l = var5; + this.a(3); + if (!(var1.getNavigation() instanceof Navigation)) { + throw new IllegalArgumentException("Unsupported mob type for TemptGoal"); + } + } + + public boolean a() { + if (this.i > 0) { + --this.i; + return false; + } else { + this.h = this.a.world.findNearbyPlayer(this.a, 10.0); + if (this.h == null) { + return false; + } else { + ItemStack var1 = this.h.bZ(); + if (var1 == null) { + return false; + } else { + return var1.getItem() == this.k; + } + } + } + } + + public boolean b() { + if (this.l) { + if (this.a.h(this.h) < 36.0) { + if (this.h.e(this.c, this.d, this.e) > 0.010000000000000002) { + return false; + } + + if (Math.abs((double)this.h.pitch - this.f) > 5.0 || Math.abs((double)this.h.yaw - this.g) > 5.0) { + return false; + } + } else { + this.c = this.h.locX; + this.d = this.h.locY; + this.e = this.h.locZ; + } + + this.f = (double)this.h.pitch; + this.g = (double)this.h.yaw; + } + + return this.a(); + } + + public void c() { + this.c = this.h.locX; + this.d = this.h.locY; + this.e = this.h.locZ; + this.j = true; + this.m = ((Navigation)this.a.getNavigation()).e(); + ((Navigation)this.a.getNavigation()).a(false); + } + + public void d() { + this.h = null; + this.a.getNavigation().n(); + this.i = 100; + this.j = false; + ((Navigation)this.a.getNavigation()).a(this.m); + } + + public void e() { + this.a.getControllerLook().a(this.h, 30.0F, (float)this.a.bQ()); + if (this.a.h(this.h) < 6.25) { + this.a.getNavigation().n(); + } else { + this.a.getNavigation().a(this.h, this.b); + } + + } + + public boolean f() { + return this.j; + } +} diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java index 9cf80da..ac5b2fe 100644 --- a/TacoSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java @@ -948,7 +948,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList handler.handleSentPacket(this, packet); } - this.networkManager.a((EnumProtocol) packet); + this.networkManager.handle(packet); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Sending packet"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent"); diff --git a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 6190e22..9cea326 100644 --- a/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/TacoSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -23,6 +23,7 @@ import java.util.regex.Pattern; import javax.imageio.ImageIO; +import com.elevatemc.spigot.eSpigot; import net.minecraft.server.*; import org.bukkit.BanList; @@ -165,6 +166,7 @@ public final class CraftServer implements Server { private final UUID invalidUserUUID = UUID.nameUUIDFromBytes("InvalidUsername".getBytes(Charsets.UTF_8)); private final List playerView; public int reloadCount; + private final com.elevatemc.spigot.eSpigot eSpigot = new eSpigot(this); private final class BooleanWrapper { private boolean value = true; diff --git a/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java b/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java index 7eac37c..9aeeb6e 100644 --- a/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java +++ b/TacoSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java @@ -1,5 +1,7 @@ package org.spigotmc; +import com.elevatemc.spigot.command.KnockbackCommand; +import com.elevatemc.spigot.command.TicksPerSecondCommand; import com.google.common.base.Throwables; import java.io.File; import java.io.IOException;