Actually made the this spigot load correctly

This commit is contained in:
ImHacking 2022-06-22 19:14:24 -04:00
parent 7f292dffca
commit c829d884d8
6 changed files with 112 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import com.elevatemc.spigot.knockback.KnockbackHandler; import com.elevatemc.spigot.knockback.KnockbackHandler;
import org.bukkit.craftbukkit.CraftServer;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@ -25,7 +26,7 @@ public class eSpigot {
public static final ScheduledExecutorService EXECUTOR_SERVICE = public static final ScheduledExecutorService EXECUTOR_SERVICE =
Executors.newSingleThreadScheduledExecutor(); Executors.newSingleThreadScheduledExecutor();
private static eSpigot instance = null; private static eSpigot instance;
public static eSpigot getInstance() { public static eSpigot getInstance() {
return instance; return instance;
@ -34,10 +35,9 @@ public class eSpigot {
private final YamlConfig config, knockbackConfig; private final YamlConfig config, knockbackConfig;
private final KnockbackHandler knockbackHandler; private final KnockbackHandler knockbackHandler;
public eSpigot() { public eSpigot(CraftServer server) {
// Set instance of the server // Set instance of the server
instance = this; instance = this;
config = new YamlConfig("espigot.yml"); config = new YamlConfig("espigot.yml");
knockbackConfig = new YamlConfig("knockback.yml"); knockbackConfig = new YamlConfig("knockback.yml");
@ -47,7 +47,7 @@ public class eSpigot {
eSpigotFeature.reload(config); eSpigotFeature.reload(config);
for (Command command : Arrays.asList(new KnockbackCommand(), new TicksPerSecondCommand())) for (Command command : Arrays.asList(new KnockbackCommand(), new TicksPerSecondCommand()))
MinecraftServer.getServer().server.getCommandMap() server.getCommandMap()
.register(command.getLabel(), "eSpigot", command); .register(command.getLabel(), "eSpigot", command);
EXECUTOR_SERVICE.scheduleAtFixedRate(() -> MinecraftServer.getServer().aq().processFastPackets(), 5L, 5L, TimeUnit.MILLISECONDS); EXECUTOR_SERVICE.scheduleAtFixedRate(() -> MinecraftServer.getServer().aq().processFastPackets(), 5L, 5L, TimeUnit.MILLISECONDS);

View File

@ -90,8 +90,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>(); public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod; public int autosavePeriod;
public double[] recentTps = new double[3]; // PaperSpigot - Fine have your darn compat with bad plugins 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 ServerConnection q; // Spigot
private String serverIp; private String serverIp;
private int u = -1; private int u = -1;
@ -662,7 +661,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
// eSpigot start - Thread affinity // eSpigot start - Thread affinity
MinecraftServer.LOGGER.info("[eSpigot] Locked main thread. CPU: " + lock.cpuId()); MinecraftServer.LOGGER.info("[eSpigot] Locked main thread. CPU: " + lock.cpuId());
affinityLock = lock; affinityLock = lock;
this.eSpigot = new eSpigot();
// eSpigot end // eSpigot end
this.ab = az(); this.ab = az();
@ -675,7 +674,6 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
// Spigot start // Spigot start
// PaperSpigot start - Further improve tick loop // PaperSpigot start - Further improve tick loop
Arrays.fill(recentTps, 20); 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; long start = System.nanoTime(), lastTick = start - TICK_TIME, nextTick = start + MinecraftServer.TICK_TIME, catchupTime = 0, curTime, wait, tickSection = start;
// PaperSpigot end // PaperSpigot end
while (this.isRunning) { while (this.isRunning) {

View File

@ -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;
}
}

View File

@ -948,7 +948,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
handler.handleSentPacket(this, packet); handler.handleSentPacket(this, packet);
} }
this.networkManager.a((EnumProtocol) packet); this.networkManager.handle(packet);
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Sending packet"); CrashReport crashreport = CrashReport.a(throwable, "Sending packet");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent");

View File

@ -23,6 +23,7 @@ import java.util.regex.Pattern;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import com.elevatemc.spigot.eSpigot;
import net.minecraft.server.*; import net.minecraft.server.*;
import org.bukkit.BanList; 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 UUID invalidUserUUID = UUID.nameUUIDFromBytes("InvalidUsername".getBytes(Charsets.UTF_8));
private final List<CraftPlayer> playerView; private final List<CraftPlayer> playerView;
public int reloadCount; public int reloadCount;
private final com.elevatemc.spigot.eSpigot eSpigot = new eSpigot(this);
private final class BooleanWrapper { private final class BooleanWrapper {
private boolean value = true; private boolean value = true;

View File

@ -1,5 +1,7 @@
package org.spigotmc; package org.spigotmc;
import com.elevatemc.spigot.command.KnockbackCommand;
import com.elevatemc.spigot.command.TicksPerSecondCommand;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;