mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2025-04-21 22:19:04 +00:00
Merge branch 'master' into enums-to-registers
# Conflicts: # nms-patches/net/minecraft/world/level/gameevent/GameEventDispatcher.patch # nms-patches/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.patch # src/main/java/org/bukkit/craftbukkit/CraftGameEvent.java # src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java # src/main/java/org/bukkit/craftbukkit/CraftRegistry.java # src/main/java/org/bukkit/craftbukkit/CraftServer.java # src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
This commit is contained in:
nms-patches/net/minecraft
src
main
java
test
java
org
bukkit
support
@ -34,7 +34,7 @@
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
|
||||
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -249,6 +276,20 @@
|
||||
@@ -249,6 +276,19 @@
|
||||
protected SaveData worldData;
|
||||
private volatile boolean isSaving;
|
||||
|
||||
@ -43,7 +43,6 @@
|
||||
+ public org.bukkit.craftbukkit.CraftServer server;
|
||||
+ public OptionSet options;
|
||||
+ public org.bukkit.command.ConsoleCommandSender console;
|
||||
+ public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
|
||||
+ public ConsoleReader reader;
|
||||
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
|
||||
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
@ -55,7 +54,7 @@
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -262,14 +303,14 @@
|
||||
@@ -262,14 +302,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@ -72,7 +71,7 @@
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.profiler = this.metricsRecorder.getProfiler();
|
||||
@@ -289,7 +330,7 @@
|
||||
@@ -289,7 +329,7 @@
|
||||
this.frameTimer = new CircularTimer();
|
||||
this.registries = worldstem.registries();
|
||||
this.worldData = worldstem.worldData();
|
||||
@ -81,7 +80,7 @@
|
||||
throw new IllegalStateException("Missing Overworld dimension data");
|
||||
} else {
|
||||
this.proxy = proxy;
|
||||
@@ -312,13 +353,40 @@
|
||||
@@ -312,13 +352,40 @@
|
||||
this.serverThread = thread;
|
||||
this.executor = SystemUtils.backgroundExecutor();
|
||||
}
|
||||
@ -123,7 +122,7 @@
|
||||
ScoreboardServer scoreboardserver1 = this.getScoreboard();
|
||||
|
||||
Objects.requireNonNull(scoreboardserver1);
|
||||
@@ -327,7 +395,7 @@
|
||||
@@ -327,7 +394,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@ -132,7 +131,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -335,12 +403,8 @@
|
||||
@@ -335,12 +402,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@ -146,7 +145,7 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
}
|
||||
@@ -355,25 +419,183 @@
|
||||
@@ -355,25 +418,183 @@
|
||||
|
||||
}
|
||||
|
||||
@ -345,7 +344,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -397,30 +619,8 @@
|
||||
@@ -397,30 +618,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@ -377,7 +376,7 @@
|
||||
|
||||
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
if (flag1) {
|
||||
@@ -428,6 +628,21 @@
|
||||
@@ -428,6 +627,21 @@
|
||||
} else {
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@ -399,7 +398,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
|
||||
|
||||
if (i < worldserver.getMinBuildHeight()) {
|
||||
@@ -487,8 +702,11 @@
|
||||
@@ -487,8 +701,11 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
@ -413,7 +412,7 @@
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@@ -497,19 +715,23 @@
|
||||
@@ -497,19 +714,23 @@
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
|
||||
this.nextTickTime = SystemUtils.getMillis();
|
||||
@ -446,7 +445,7 @@
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -524,10 +746,17 @@
|
||||
@@ -524,10 +745,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,7 +466,7 @@
|
||||
}
|
||||
|
||||
public EnumGamemode getDefaultGameType() {
|
||||
@@ -557,12 +786,16 @@
|
||||
@@ -557,12 +785,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
|
||||
}
|
||||
|
||||
@ -484,7 +483,7 @@
|
||||
if (flag1) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -597,12 +830,33 @@
|
||||
@@ -597,12 +829,33 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@ -518,7 +517,7 @@
|
||||
if (this.getConnection() != null) {
|
||||
this.getConnection().stop();
|
||||
}
|
||||
@@ -612,6 +866,7 @@
|
||||
@@ -612,6 +865,7 @@
|
||||
MinecraftServer.LOGGER.info("Saving players");
|
||||
this.playerList.saveAll();
|
||||
this.playerList.removeAll();
|
||||
@ -526,7 +525,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -699,15 +954,16 @@
|
||||
@@ -699,15 +953,16 @@
|
||||
}
|
||||
|
||||
this.nextTickTime = SystemUtils.getMillis();
|
||||
@ -545,7 +544,7 @@
|
||||
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
|
||||
this.nextTickTime += j * 50L;
|
||||
this.lastOverloadWarning = this.nextTickTime;
|
||||
@@ -718,6 +974,7 @@
|
||||
@@ -718,6 +973,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@ -553,7 +552,7 @@
|
||||
this.nextTickTime += 50L;
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
@@ -756,6 +1013,12 @@
|
||||
@@ -756,6 +1012,12 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@ -566,7 +565,7 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -789,9 +1052,16 @@
|
||||
@@ -789,9 +1051,16 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@ -584,7 +583,7 @@
|
||||
protected void waitUntilNextTick() {
|
||||
this.runAllTasks();
|
||||
this.managedBlock(() -> {
|
||||
@@ -836,7 +1106,7 @@
|
||||
@@ -836,7 +1105,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,7 +592,7 @@
|
||||
this.getProfiler().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -889,7 +1159,7 @@
|
||||
@@ -889,7 +1158,7 @@
|
||||
this.status = this.buildServerStatus();
|
||||
}
|
||||
|
||||
@ -602,7 +601,7 @@
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.profiler.push("save");
|
||||
this.saveEverything(true, false, false);
|
||||
@@ -936,22 +1206,39 @@
|
||||
@@ -936,22 +1205,39 @@
|
||||
}
|
||||
|
||||
public void tickChildren(BooleanSupplier booleansupplier) {
|
||||
@ -642,7 +641,7 @@
|
||||
|
||||
this.profiler.push("tick");
|
||||
|
||||
@@ -1031,6 +1318,22 @@
|
||||
@@ -1031,6 +1317,22 @@
|
||||
return (WorldServer) this.levels.get(resourcekey);
|
||||
}
|
||||
|
||||
@ -665,7 +664,7 @@
|
||||
public Set<ResourceKey<World>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1057,7 +1360,7 @@
|
||||
@@ -1057,7 +1359,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@ -674,7 +673,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
@@ -1398,11 +1701,11 @@
|
||||
@@ -1398,11 +1700,11 @@
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@ -688,7 +687,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
|
||||
|
||||
@@ -1417,6 +1720,7 @@
|
||||
@@ -1417,6 +1719,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@ -696,7 +695,7 @@
|
||||
this.packRepository.setSelected(collection);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1777,7 +2081,7 @@
|
||||
@@ -1777,7 +2080,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@ -705,7 +704,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -1827,6 +2131,22 @@
|
||||
@@ -1827,6 +2130,22 @@
|
||||
|
||||
}
|
||||
|
||||
@ -728,7 +727,7 @@
|
||||
private void startMetricsRecordingTick() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
@@ -1953,8 +2273,30 @@
|
||||
@@ -1953,8 +2272,30 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,16 @@
|
||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -70,8 +80,10 @@
|
||||
@@ -61,7 +71,7 @@
|
||||
private final List<ServerCommand> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@Nullable
|
||||
private RemoteStatusListener queryThreadGs4;
|
||||
- public final RemoteControlCommandListener rconConsoleSource;
|
||||
+ // public final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
|
||||
@Nullable
|
||||
private RemoteControlListener rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -70,10 +80,12 @@
|
||||
@Nullable
|
||||
private final TextFilter textFilterClient;
|
||||
|
||||
@ -28,8 +37,11 @@
|
||||
+ super(options, worldLoader, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
|
||||
+ // CraftBukkit end
|
||||
this.settings = dedicatedserversettings;
|
||||
this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
- this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
+ // this.rconConsoleSource = new RemoteControlCommandListener(this); // CraftBukkit - remove field
|
||||
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
|
||||
}
|
||||
|
||||
@@ -81,13 +93,44 @@
|
||||
public boolean initServer() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
@ -144,15 +156,7 @@
|
||||
long j = SystemUtils.getNanos() - i;
|
||||
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
|
||||
|
||||
@@ -181,6 +251,7 @@
|
||||
if (dedicatedserverproperties.enableRcon) {
|
||||
DedicatedServer.LOGGER.info("Starting remote control listener");
|
||||
this.rconThread = RemoteControlListener.create(this);
|
||||
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.getMaxTickLength() > 0L) {
|
||||
@@ -296,6 +367,7 @@
|
||||
@@ -296,6 +366,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@ -160,7 +164,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -317,7 +389,15 @@
|
||||
@@ -317,7 +388,15 @@
|
||||
while (!this.consoleInput.isEmpty()) {
|
||||
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
|
||||
|
||||
@ -177,7 +181,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -539,14 +619,45 @@
|
||||
@@ -539,16 +618,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@ -210,22 +214,31 @@
|
||||
|
||||
@Override
|
||||
public String runCommand(String s) {
|
||||
this.rconConsoleSource.prepareForCommand();
|
||||
- this.rconConsoleSource.prepareForCommand();
|
||||
+ // CraftBukkit start - fire RemoteServerCommandEvent
|
||||
+ throw new UnsupportedOperationException("Not supported - remote source required.");
|
||||
+ }
|
||||
+
|
||||
+ public String runCommand(RemoteControlCommandListener rconConsoleSource, String s) {
|
||||
+ rconConsoleSource.prepareForCommand();
|
||||
this.executeBlocking(() -> {
|
||||
- this.getCommands().performPrefixedCommand(this.rconConsoleSource.createCommandSourceStack(), s);
|
||||
+ // CraftBukkit start - fire RemoteServerCommandEvent
|
||||
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
|
||||
+ CommandListenerWrapper wrapper = rconConsoleSource.createCommandSourceStack();
|
||||
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(rconConsoleSource.getBukkitSender(wrapper), s);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.createCommandSourceStack());
|
||||
+ server.dispatchServerCommand(remoteConsole, serverCommand);
|
||||
+ // CraftBukkit end
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), wrapper);
|
||||
+ server.dispatchServerCommand(event.getSender(), serverCommand);
|
||||
});
|
||||
return this.rconConsoleSource.getCommandResponse();
|
||||
- return this.rconConsoleSource.getCommandResponse();
|
||||
+ return rconConsoleSource.getCommandResponse();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -599,4 +710,15 @@
|
||||
|
||||
public void storeUsingWhiteList(boolean flag) {
|
||||
@@ -599,4 +714,15 @@
|
||||
public Optional<MinecraftServer.ServerResourcePackInfo> getServerResourcePack() {
|
||||
return this.settings.getProperties().serverResourcePackInfo;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/dedicated/PropertyManager.java
|
||||
+++ b/net/minecraft/server/dedicated/PropertyManager.java
|
||||
@@ -23,13 +23,28 @@
|
||||
@@ -23,17 +23,37 @@
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -30,7 +30,16 @@
|
||||
}
|
||||
|
||||
public static Properties loadFromFile(Path path) {
|
||||
@@ -97,6 +112,11 @@
|
||||
try {
|
||||
+ // CraftBukkit start - SPIGOT-7465, MC-264979: Don't load if file doesn't exist
|
||||
+ if (!path.toFile().exists()) {
|
||||
+ return new Properties();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Properties properties;
|
||||
Properties properties1;
|
||||
|
||||
@@ -97,6 +117,11 @@
|
||||
|
||||
public void store(Path path) {
|
||||
try {
|
||||
@ -42,7 +51,7 @@
|
||||
BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
|
||||
|
||||
try {
|
||||
@@ -125,7 +145,7 @@
|
||||
@@ -125,7 +150,7 @@
|
||||
private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> function) {
|
||||
return (s) -> {
|
||||
try {
|
||||
@ -51,7 +60,7 @@
|
||||
} catch (NumberFormatException numberformatexception) {
|
||||
return null;
|
||||
}
|
||||
@@ -144,7 +164,7 @@
|
||||
@@ -144,7 +169,7 @@
|
||||
|
||||
@Nullable
|
||||
private String getStringRaw(String s) {
|
||||
@ -60,7 +69,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -160,6 +180,16 @@
|
||||
@@ -160,6 +185,16 @@
|
||||
}
|
||||
|
||||
protected <V> V get(String s, Function<String, V> function, Function<V, String> function1, V v0) {
|
||||
@ -77,7 +86,7 @@
|
||||
String s1 = this.getStringRaw(s);
|
||||
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
|
||||
|
||||
@@ -172,7 +202,7 @@
|
||||
@@ -172,7 +207,7 @@
|
||||
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
|
||||
|
||||
this.properties.put(s, function1.apply(v1));
|
||||
@ -86,7 +95,7 @@
|
||||
}
|
||||
|
||||
protected <V> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
|
||||
@@ -236,7 +266,7 @@
|
||||
@@ -236,7 +271,7 @@
|
||||
return properties;
|
||||
}
|
||||
|
||||
@ -95,7 +104,7 @@
|
||||
|
||||
public class EditableProperty<V> implements Supplier<V> {
|
||||
|
||||
@@ -244,7 +274,7 @@
|
||||
@@ -244,7 +279,7 @@
|
||||
private final V value;
|
||||
private final Function<V, String> serializer;
|
||||
|
||||
@ -104,7 +113,7 @@
|
||||
this.key = s;
|
||||
this.value = object;
|
||||
this.serializer = function;
|
||||
@@ -258,7 +288,7 @@
|
||||
@@ -258,7 +293,7 @@
|
||||
Properties properties = PropertyManager.this.cloneProperties();
|
||||
|
||||
properties.put(this.key, this.serializer.apply(v0));
|
||||
|
@ -1,6 +1,32 @@
|
||||
--- a/net/minecraft/server/rcon/RemoteControlCommandListener.java
|
||||
+++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java
|
||||
@@ -34,6 +34,17 @@
|
||||
@@ -9,14 +9,23 @@
|
||||
import net.minecraft.world.phys.Vec2F;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.net.SocketAddress;
|
||||
+import org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender;
|
||||
+// CraftBukkit end
|
||||
public class RemoteControlCommandListener implements ICommandListener {
|
||||
|
||||
private static final String RCON = "Rcon";
|
||||
private static final IChatBaseComponent RCON_COMPONENT = IChatBaseComponent.literal("Rcon");
|
||||
private final StringBuffer buffer = new StringBuffer();
|
||||
private final MinecraftServer server;
|
||||
-
|
||||
- public RemoteControlCommandListener(MinecraftServer minecraftserver) {
|
||||
+ // CraftBukkit start
|
||||
+ public final SocketAddress socketAddress;
|
||||
+ private final CraftRemoteConsoleCommandSender remoteConsole = new CraftRemoteConsoleCommandSender(this);
|
||||
+
|
||||
+ public RemoteControlCommandListener(MinecraftServer minecraftserver, SocketAddress socketAddress) {
|
||||
+ this.socketAddress = socketAddress;
|
||||
+ // CraftBukkit end
|
||||
this.server = minecraftserver;
|
||||
}
|
||||
|
||||
@@ -34,6 +43,17 @@
|
||||
return new CommandListenerWrapper(this, Vec3D.atLowerCornerOf(worldserver.getSharedSpawnPos()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null);
|
||||
}
|
||||
|
||||
@ -11,7 +37,7 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return server.remoteConsole;
|
||||
+ return this.remoteConsole;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
@ -0,0 +1,77 @@
|
||||
--- a/net/minecraft/server/rcon/thread/RemoteControlSession.java
|
||||
+++ b/net/minecraft/server/rcon/thread/RemoteControlSession.java
|
||||
@@ -11,6 +11,10 @@
|
||||
import net.minecraft.server.IMinecraftServer;
|
||||
import net.minecraft.server.rcon.StatusChallengeUtils;
|
||||
import org.slf4j.Logger;
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||
+import net.minecraft.server.rcon.RemoteControlCommandListener;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class RemoteControlSession extends RemoteConnectionThread {
|
||||
|
||||
@@ -24,11 +28,14 @@
|
||||
private final Socket client;
|
||||
private final byte[] buf = new byte[1460];
|
||||
private final String rconPassword;
|
||||
- private final IMinecraftServer serverInterface;
|
||||
+ // CraftBukkit start
|
||||
+ private final DedicatedServer serverInterface;
|
||||
+ private final RemoteControlCommandListener rconConsoleSource;
|
||||
+ // CraftBukkit end
|
||||
|
||||
RemoteControlSession(IMinecraftServer iminecraftserver, String s, Socket socket) {
|
||||
super("RCON Client " + socket.getInetAddress());
|
||||
- this.serverInterface = iminecraftserver;
|
||||
+ this.serverInterface = (DedicatedServer) iminecraftserver; // CraftBukkit
|
||||
this.client = socket;
|
||||
|
||||
try {
|
||||
@@ -38,11 +45,14 @@
|
||||
}
|
||||
|
||||
this.rconPassword = s;
|
||||
+ this.rconConsoleSource = new net.minecraft.server.rcon.RemoteControlCommandListener(this.serverInterface, socket.getRemoteSocketAddress()); // CraftBukkit
|
||||
}
|
||||
|
||||
public void run() {
|
||||
- while (true) {
|
||||
- try {
|
||||
+ // CraftBukkit start - decompile error: switch try / while statement
|
||||
+ try {
|
||||
+ while (true) {
|
||||
+ // CraftBukkit end
|
||||
if (!this.running) {
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +81,7 @@
|
||||
String s = StatusChallengeUtils.stringFromByteArray(this.buf, k, i);
|
||||
|
||||
try {
|
||||
- this.sendCmdResponse(l, this.serverInterface.runCommand(s));
|
||||
+ this.sendCmdResponse(l, this.serverInterface.runCommand(this.rconConsoleSource, s)); // CraftBukkit
|
||||
} catch (Exception exception) {
|
||||
this.sendCmdResponse(l, "Error executing: " + s + " (" + exception.getMessage() + ")");
|
||||
}
|
||||
@@ -98,6 +108,7 @@
|
||||
continue;
|
||||
}
|
||||
}
|
||||
+ } // CraftBukkit - decompile error: switch try / while statement
|
||||
} catch (IOException ioexception) {
|
||||
return;
|
||||
} catch (Exception exception1) {
|
||||
@@ -109,8 +120,10 @@
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
- return;
|
||||
- }
|
||||
+ // CraftBukkit start - decompile error: switch try / while statement
|
||||
+ // return;
|
||||
+ // }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private void send(int i, int j, String s) throws IOException {
|
@ -9,7 +9,7 @@
|
||||
public class BlockVine extends Block {
|
||||
|
||||
public static final BlockStateBoolean UP = BlockSprawling.UP;
|
||||
@@ -196,20 +198,24 @@
|
||||
@@ -196,30 +198,34 @@
|
||||
BlockPosition blockposition3 = blockposition2.relative(enumdirection1);
|
||||
BlockPosition blockposition4 = blockposition2.relative(enumdirection2);
|
||||
|
||||
@ -38,7 +38,19 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else if (isAcceptableNeighbour(worldserver, blockposition2, enumdirection)) {
|
||||
worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(getPropertyForFace(enumdirection), true), 2);
|
||||
- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(getPropertyForFace(enumdirection), true), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(getPropertyForFace(enumdirection), true), 2); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (enumdirection == EnumDirection.UP && blockposition.getY() < worldserver.getMaxBuildHeight() - 1) {
|
||||
if (this.canSupportAtFace(worldserver, blockposition, enumdirection)) {
|
||||
- worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockVine.UP, true), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.setValue(BlockVine.UP, true), 2); // CraftBukkit
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,7 +245,7 @@
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
--- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
+++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
@@ -11,6 +11,12 @@
|
||||
@@ -11,6 +11,13 @@
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.CraftGameEvent;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.event.world.GenericGameEvent;
|
||||
+// CraftBukkit end
|
||||
@ -13,12 +14,12 @@
|
||||
public class GameEventDispatcher {
|
||||
|
||||
private final WorldServer level;
|
||||
@@ -22,6 +28,14 @@
|
||||
@@ -22,6 +29,14 @@
|
||||
public void post(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
|
||||
int i = gameevent.getNotificationRadius();
|
||||
BlockPosition blockposition = BlockPosition.containing(vec3d);
|
||||
+ // CraftBukkit start
|
||||
+ GenericGameEvent event = new GenericGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameevent), CraftLocation.toBukkit(blockposition, level.getWorld()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
|
||||
+ GenericGameEvent event = new GenericGameEvent(CraftGameEvent.minecraftToBukkit(gameevent), CraftLocation.toBukkit(blockposition, level.getWorld()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
|
||||
+ level.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
|
@ -1,10 +1,11 @@
|
||||
--- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java
|
||||
+++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java
|
||||
@@ -29,6 +29,11 @@
|
||||
@@ -29,6 +29,12 @@
|
||||
import net.minecraft.world.phys.MovingObjectPosition;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.CraftGameEvent;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.event.block.BlockReceiveGameEvent;
|
||||
+// CraftBukkit end
|
||||
@ -12,7 +13,7 @@
|
||||
public interface VibrationSystem {
|
||||
|
||||
GameEvent[] RESONANCE_EVENTS = new GameEvent[]{GameEvent.RESONATE_1, GameEvent.RESONATE_2, GameEvent.RESONATE_3, GameEvent.RESONATE_4, GameEvent.RESONATE_5, GameEvent.RESONATE_6, GameEvent.RESONATE_7, GameEvent.RESONATE_8, GameEvent.RESONATE_9, GameEvent.RESONATE_10, GameEvent.RESONATE_11, GameEvent.RESONATE_12, GameEvent.RESONATE_13, GameEvent.RESONATE_14, GameEvent.RESONATE_15};
|
||||
@@ -228,7 +233,8 @@
|
||||
@@ -228,7 +234,8 @@
|
||||
if (vibrationsystem_d.requiresAdjacentChunksToBeTicking() && !areAdjacentChunksTicking(worldserver, blockposition1)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -22,7 +23,7 @@
|
||||
vibrationsystem_a.setCurrentVibration((VibrationInfo) null);
|
||||
return true;
|
||||
}
|
||||
@@ -285,8 +291,14 @@
|
||||
@@ -285,8 +292,14 @@
|
||||
return false;
|
||||
} else {
|
||||
Vec3D vec3d1 = (Vec3D) optional.get();
|
||||
@ -31,7 +32,7 @@
|
||||
+ // CraftBukkit start
|
||||
+ boolean defaultCancel = !vibrationsystem_d.canReceiveVibration(worldserver, BlockPosition.containing(vec3d), gameevent, gameevent_a);
|
||||
+ Entity entity = gameevent_a.sourceEntity();
|
||||
+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameevent), CraftBlock.at(worldserver, BlockPosition.containing(vec3d1)), (entity == null) ? null : entity.getBukkitEntity());
|
||||
+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(CraftGameEvent.minecraftToBukkit(gameevent), CraftBlock.at(worldserver, BlockPosition.containing(vec3d1)), (entity == null) ? null : entity.getBukkitEntity());
|
||||
+ event.setCancelled(defaultCancel);
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
@ -39,7 +40,7 @@
|
||||
return false;
|
||||
} else if (isOccluded(worldserver, vec3d, vec3d1)) {
|
||||
return false;
|
||||
@@ -339,7 +351,7 @@
|
||||
@@ -339,7 +352,7 @@
|
||||
return instance.group(VibrationInfo.CODEC.optionalFieldOf("event").forGetter((vibrationsystem_a) -> {
|
||||
return Optional.ofNullable(vibrationsystem_a.currentVibration);
|
||||
}), VibrationSelector.CODEC.fieldOf("selector").forGetter(VibrationSystem.a::getSelectionStrategy), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(VibrationSystem.a::getTravelTimeInTicks)).apply(instance, (optional, vibrationselector, integer) -> {
|
||||
|
@ -14,7 +14,7 @@ public class CraftGameEvent extends GameEvent {
|
||||
public static GameEvent minecraftToBukkit(net.minecraft.world.level.gameevent.GameEvent minecraft) {
|
||||
Preconditions.checkArgument(minecraft != null);
|
||||
|
||||
IRegistry<net.minecraft.world.level.gameevent.GameEvent> registry = CraftRegistry.getMinecraftRegistry().registryOrThrow(Registries.GAME_EVENT);
|
||||
IRegistry<net.minecraft.world.level.gameevent.GameEvent> registry = CraftRegistry.getMinecraftRegistry(Registries.GAME_EVENT);
|
||||
GameEvent bukkit = Registry.GAME_EVENT.get(CraftNamespacedKey.fromMinecraft(registry.getKey(minecraft)));
|
||||
|
||||
Preconditions.checkArgument(bukkit != null);
|
||||
@ -63,4 +63,9 @@ public class CraftGameEvent extends GameEvent {
|
||||
public int hashCode() {
|
||||
return getKey().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftGameEvent{key=" + key + "}";
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class CraftMusicInstrument extends MusicInstrument {
|
||||
public static MusicInstrument minecraftToBukkit(Instrument minecraft) {
|
||||
Preconditions.checkArgument(minecraft != null);
|
||||
|
||||
IRegistry<Instrument> registry = CraftRegistry.getMinecraftRegistry().registryOrThrow(Registries.INSTRUMENT);
|
||||
IRegistry<Instrument> registry = CraftRegistry.getMinecraftRegistry(Registries.INSTRUMENT);
|
||||
MusicInstrument bukkit = Registry.INSTRUMENT.get(CraftNamespacedKey.fromMinecraft(registry.getKey(minecraft)));
|
||||
|
||||
Preconditions.checkArgument(bukkit != null);
|
||||
@ -64,4 +64,9 @@ public class CraftMusicInstrument extends MusicInstrument {
|
||||
public int hashCode() {
|
||||
return getKey().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftMusicInstrument{key=" + key + "}";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@ -8,6 +9,7 @@ import java.util.stream.Stream;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Fluid;
|
||||
@ -55,11 +57,28 @@ import org.bukkit.potion.PotionType;
|
||||
|
||||
public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
|
||||
public static IRegistryCustom getMinecraftRegistry() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().registryAccess();
|
||||
private static IRegistryCustom registry;
|
||||
|
||||
public static void setMinecraftRegistry(IRegistryCustom registry) {
|
||||
Preconditions.checkState(CraftRegistry.registry == null, "Registry already set");
|
||||
CraftRegistry.registry = registry;
|
||||
}
|
||||
|
||||
public static <B extends Keyed> Registry<?> createRegistry(Class<? super B> bukkitClass, IRegistryCustom registryHolder) {
|
||||
public static IRegistryCustom getMinecraftRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
public static <E> IRegistry<E> getMinecraftRegistry(ResourceKey<IRegistry<E>> key) {
|
||||
return getMinecraftRegistry().registryOrThrow(key);
|
||||
}
|
||||
|
||||
public static <B extends Keyed> Registry<?> createRegistry(Class<B> bukkitClass, IRegistryCustom registryHolder) {
|
||||
if (bukkitClass == GameEvent.class) {
|
||||
return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.GAME_EVENT), CraftGameEvent::new);
|
||||
}
|
||||
if (bukkitClass == MusicInstrument.class) {
|
||||
return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.INSTRUMENT), CraftMusicInstrument::new);
|
||||
}
|
||||
if (bukkitClass == Structure.class) {
|
||||
return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.STRUCTURE), CraftStructure::new);
|
||||
}
|
||||
@ -126,12 +145,6 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
if (bukkitClass == PotionType.class) {
|
||||
return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.POTION), CraftPotionType::new);
|
||||
}
|
||||
if (bukkitClass == GameEvent.class) {
|
||||
return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.GAME_EVENT), CraftGameEvent::new);
|
||||
}
|
||||
if (bukkitClass == MusicInstrument.class) {
|
||||
return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.INSTRUMENT), CraftMusicInstrument::new);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -322,6 +322,8 @@ public final class CraftServer implements Server {
|
||||
|
||||
Bukkit.setServer(this);
|
||||
|
||||
CraftRegistry.setMinecraftRegistry(console.registryAccess());
|
||||
|
||||
Potion.setPotionBrewer(new CraftPotionBrewer());
|
||||
// Ugly hack :(
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.server.rcon.RemoteControlCommandListener;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
@ -12,6 +13,15 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public RemoteControlCommandListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getAddress() {
|
||||
return listener.socketAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
listener.sendSystemMessage(IChatBaseComponent.literal(message + "\n")); // Send a newline after each message, to preserve formatting.
|
||||
|
@ -75,7 +75,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
|
||||
return ((CraftBlockCommandSender) sender).getWrapper();
|
||||
}
|
||||
if (sender instanceof RemoteConsoleCommandSender) {
|
||||
return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.createCommandSourceStack();
|
||||
return ((CraftRemoteConsoleCommandSender) sender).getListener().createCommandSourceStack();
|
||||
}
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
return ((CraftServer) sender.getServer()).getServer().createCommandSourceStack();
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.dimension.DimensionManager;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockEntityState;
|
||||
@ -141,4 +142,15 @@ public class BlockStateListPopulator extends DummyGeneratorAccess {
|
||||
public IRegistryCustom registryAccess() {
|
||||
return world.registryAccess();
|
||||
}
|
||||
|
||||
// Needed when a tree generates in water
|
||||
@Override
|
||||
public WorldData getLevelData() {
|
||||
return world.getLevelData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextSubTickCount() {
|
||||
return world.nextSubTickCount();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.junit.Assert;
|
||||
|
||||
@ -62,6 +63,8 @@ public abstract class AbstractTestingBase {
|
||||
|
||||
DummyServer.setup();
|
||||
|
||||
CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM);
|
||||
|
||||
ImmutableList.Builder<Material> builder = ImmutableList.builder();
|
||||
for (Material m : Material.values()) {
|
||||
if (m.isLegacy() || CraftMagicNumbers.getItem(m) == null) {
|
||||
|
Reference in New Issue
Block a user