diff --git a/.gradle/7.1/executionHistory/executionHistory.bin b/.gradle/7.1/executionHistory/executionHistory.bin index b372564..e495d42 100644 Binary files a/.gradle/7.1/executionHistory/executionHistory.bin and b/.gradle/7.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.1/executionHistory/executionHistory.lock b/.gradle/7.1/executionHistory/executionHistory.lock index 35c04fa..65d9c53 100644 Binary files a/.gradle/7.1/executionHistory/executionHistory.lock and b/.gradle/7.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.1/fileHashes/fileHashes.bin b/.gradle/7.1/fileHashes/fileHashes.bin index 0ce0fb8..941f363 100644 Binary files a/.gradle/7.1/fileHashes/fileHashes.bin and b/.gradle/7.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.1/fileHashes/fileHashes.lock b/.gradle/7.1/fileHashes/fileHashes.lock index eb57ca1..bfae6db 100644 Binary files a/.gradle/7.1/fileHashes/fileHashes.lock and b/.gradle/7.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.1/fileHashes/resourceHashesCache.bin b/.gradle/7.1/fileHashes/resourceHashesCache.bin index 7e94d0a..a1d81cd 100644 Binary files a/.gradle/7.1/fileHashes/resourceHashesCache.bin and b/.gradle/7.1/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 841a09a..ec2c304 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 89bf868..e4b4c62 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock index 057e535..0bb4c49 100644 Binary files a/.gradle/checksums/checksums.lock and b/.gradle/checksums/checksums.lock differ diff --git a/.gradle/checksums/md5-checksums.bin b/.gradle/checksums/md5-checksums.bin index 66cba72..03fc8b5 100644 Binary files a/.gradle/checksums/md5-checksums.bin and b/.gradle/checksums/md5-checksums.bin differ diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin index 89a276e..e96e373 100644 Binary files a/.gradle/checksums/sha1-checksums.bin and b/.gradle/checksums/sha1-checksums.bin differ diff --git a/eSpigot-API/src/main/java/co/aikar/timings/TimingHandler.java b/eSpigot-API/src/main/java/co/aikar/timings/TimingHandler.java index 3ffe7e5..13e592d 100644 --- a/eSpigot-API/src/main/java/co/aikar/timings/TimingHandler.java +++ b/eSpigot-API/src/main/java/co/aikar/timings/TimingHandler.java @@ -112,7 +112,14 @@ class TimingHandler implements Timing { start = 0; return; } - addDiff(System.nanoTime() - start); + try + { + addDiff(System.nanoTime() - start); + } + catch (ArrayIndexOutOfBoundsException ex) + { + ex.printStackTrace(); + } start = 0; } } diff --git a/eSpigot-API/src/main/java/org/bukkit/Bukkit.java b/eSpigot-API/src/main/java/org/bukkit/Bukkit.java index 933607e..cd3b4de 100644 --- a/eSpigot-API/src/main/java/org/bukkit/Bukkit.java +++ b/eSpigot-API/src/main/java/org/bukkit/Bukkit.java @@ -550,13 +550,6 @@ public final class Bukkit { return server.createMap(world); } - /** - * Reloads the server, refreshing settings and plugin information. - */ - public static void reload() { - server.reload(); - } - /** * Returns the primary logger associated with this server instance. * diff --git a/eSpigot-API/src/main/java/org/bukkit/Server.java b/eSpigot-API/src/main/java/org/bukkit/Server.java index bb2e2d1..3632413 100644 --- a/eSpigot-API/src/main/java/org/bukkit/Server.java +++ b/eSpigot-API/src/main/java/org/bukkit/Server.java @@ -452,11 +452,6 @@ public interface Server extends PluginMessageRecipient { */ MapView createMap(World world); - /** - * Reloads the server, refreshing settings and plugin information. - */ - void reload(); - /** * Returns the primary logger associated with this server instance. * diff --git a/eSpigot-API/src/main/java/org/bukkit/command/SimpleCommandMap.java b/eSpigot-API/src/main/java/org/bukkit/command/SimpleCommandMap.java index 29e2d0a..4c3fc92 100644 --- a/eSpigot-API/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/eSpigot-API/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -30,7 +30,6 @@ public class SimpleCommandMap implements CommandMap { private void setDefaultCommands() { register("bukkit", new VersionCommand("version")); - register("bukkit", new ReloadCommand("reload")); register("bukkit", new PluginsCommand("plugins")); register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Spigot } diff --git a/eSpigot-API/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/eSpigot-API/src/main/java/org/bukkit/command/defaults/ReloadCommand.java deleted file mode 100644 index 22f81af..0000000 --- a/eSpigot-API/src/main/java/org/bukkit/command/defaults/ReloadCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.Arrays; -import java.util.Collections; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; - -public class ReloadCommand extends BukkitCommand { - public ReloadCommand(String name) { - super(name); - this.description = "Reloads the server configuration and plugins"; - this.usageMessage = "/reload"; - this.setPermission("bukkit.command.reload"); - this.setAliases(Collections.singletonList("rl")); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins."); - Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server."); - Bukkit.reload(); - Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete."); - - return true; - } - - // Spigot Start - @Override - public java.util.List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException - { - return java.util.Collections.emptyList(); - } - // Spigot End -} diff --git a/eSpigot-Server/build.gradle.kts b/eSpigot-Server/build.gradle.kts index 5a92e5a..7896664 100644 --- a/eSpigot-Server/build.gradle.kts +++ b/eSpigot-Server/build.gradle.kts @@ -49,6 +49,7 @@ dependencies { implementation("com.github.luben:zstd-jni:1.5.2-3") implementation("net.openhft:affinity:3.20.0") implementation("net.jafama:jafama:2.3.2") + implementation("com.eatthepath:fast-uuid:0.2.0") testImplementation("junit:junit:4.11") diff --git a/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/BukkitConfig.java b/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/BukkitConfig.java new file mode 100644 index 0000000..adb8021 --- /dev/null +++ b/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/BukkitConfig.java @@ -0,0 +1,128 @@ +package com.elevatemc.spigot.config; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.util.List; +import java.util.Map; + +public class BukkitConfig { + + public static YamlConfiguration config; + static Map commands; + + public static void init() + { + config = SharedConfig.config; + commands = SharedConfig.commands; + SharedConfig.readConfig( BukkitConfig.class, null ); + } + + private static boolean getBoolean(String path, boolean def) + { + path = "bukkit." + path; + config.addDefault( path, def ); + return config.getBoolean( path, config.getBoolean( path ) ); + } + + private static double getDouble(String path, double def) + { + path = "bukkit." + path; + config.addDefault( path, def ); + return config.getDouble( path, config.getDouble( path ) ); + } + + private static int getInt(String path, int def) + { + path = "bukkit." + path; + config.addDefault( path, def ); + return config.getInt( path, config.getInt( path ) ); + } + + private static List getList(String path, T def) + { + path = "bukkit." + path; + config.addDefault( path, def ); + return config.getList( path, config.getList( path ) ); + } + + private static String getString(String path, String def) + { + path = "bukkit." + path; + config.addDefault( path, def ); + return config.getString( path, config.getString( path ) ); + } + + public static ConfigurationSection getConfigurationSection(String path) { + return config.getConfigurationSection("bukkit." + path); + } + + public static boolean allowEnd = true; + public static boolean warnOnOverlaod = true; + public static String permissionsFile = "permissions.yml"; + public static String updateFolder = "update"; + public static boolean pluginProfiling = false; + public static int connectionThrottle = 4000; + public static boolean queryPlugins = true; + public static String deprecatedVerbose = "default"; + public static String shutdownMessage = "Server closed"; + public static String permissionMessage = ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."; + public static boolean useExactLoginLocation = false; + public static String worldContainer = "."; + private static void settings() { + allowEnd = getBoolean("settings.allow-end", allowEnd); + warnOnOverlaod = getBoolean("settings.warn-on-overload", warnOnOverlaod); + permissionsFile = getString("settings.update-folder", updateFolder); + pluginProfiling = getBoolean("settings.plugin-profilling", pluginProfiling); + connectionThrottle = getInt("settings.connection-throttle", connectionThrottle); + queryPlugins = getBoolean("settings.query-plugins", queryPlugins); + deprecatedVerbose = getString("settings.deprecated-verbose", deprecatedVerbose); + shutdownMessage = getString("settings.shutdown-message", shutdownMessage); + permissionMessage = getString("settings.permission-message", permissionMessage); + useExactLoginLocation = getBoolean("settings.use-exact-login-location", useExactLoginLocation); + worldContainer = getString("settings.world-container", worldContainer); + } + + public static int monsterSpawnLimit = 70; + public static int animalSpawnLimit = 15; + public static int waterAnimalSpawnLimit = 5; + public static int ambientSpawnLimit = 15; + private static void spawnLimits() { + monsterSpawnLimit = getInt("spawn-limits.monsters", monsterSpawnLimit); + animalSpawnLimit = getInt("spawn-limits.animals", animalSpawnLimit); + waterAnimalSpawnLimit = getInt("spawn-limits.water-animals", waterAnimalSpawnLimit); + ambientSpawnLimit = getInt("spawn-limits.ambient", ambientSpawnLimit); + } + + public static int chunkGCPeriodInTicks = 600; + public static int chunkGCLoadThreshold = 0; + private static void chunkGC() { + chunkGCPeriodInTicks = getInt("chunk-gc.period-in-ticks", chunkGCPeriodInTicks); + chunkGCLoadThreshold = getInt("chunk-gc.load-threshold", chunkGCLoadThreshold); + } + + public static int ticksPerAnimalSpawn = 400; + public static int ticksPerMonsterSpawn = 1; + public static int ticksPerAutosave = 6000; + private static void ticksPer() { + ticksPerAnimalSpawn = getInt("ticks-per.animal-spawns", ticksPerAnimalSpawn); + ticksPerMonsterSpawn = getInt("ticks-per.monster-spawns", ticksPerMonsterSpawn); + ticksPerAutosave = getInt("ticks-per.autosave", ticksPerAutosave); + } + + public static String databaseUsername = "bukkit"; + public static String databaseIsolation = "SERIALIZABLE"; + public static String databaseDriver = "org.sqlite.JDBC"; + public static String databasePassword = "walrus"; + public static String databaseUrl = "jdbc:sqlite:{DIR}{NAME}.db"; + private static void database() { + databaseUsername = getString("database.username", databaseUsername); + databaseIsolation = getString("database.isolation", databaseIsolation); + databaseDriver = getString("database.driver", databaseDriver); + databasePassword = getString("database.password", databasePassword); + databaseUrl = getString("database.url", databaseUrl); + } + +} diff --git a/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/SharedConfig.java b/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/SharedConfig.java new file mode 100644 index 0000000..f5ba9b0 --- /dev/null +++ b/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/SharedConfig.java @@ -0,0 +1,90 @@ +package com.elevatemc.spigot.config; + +import com.google.common.base.Throwables; +import net.minecraft.server.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; +import org.github.paperspigot.PaperSpigotConfig; +import org.github.paperspigot.PaperSpigotWorldConfig; +import org.spigotmc.SpigotConfig; +import org.spigotmc.SpigotWorldConfig; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; + +public class SharedConfig { + + private static File CONFIG_FILE; + private static final String HEADER = "This is the main configuration file for eSpigot.\n" + + "Command aliases also go in this file, just put what you would normally put in commands.yml under a commands: tag"; + + /*========================================================================*/ + public static YamlConfiguration config; + public static Map commands; + /*========================================================================*/ + + public static void init(File configFile) { + CONFIG_FILE = configFile; + config = new YamlConfiguration(); + try { + config.load (CONFIG_FILE); + } catch (IOException ex) { + } catch (InvalidConfigurationException ex) { + Bukkit.getLogger().log(Level.SEVERE, "Could not load sportpaper.yml, please correct your syntax errors", ex); + throw Throwables.propagate(ex); + } + config.options().header(HEADER); + config.options().copyDefaults(true); + + commands = new HashMap(); + + eSpigotConfig.init(); + BukkitConfig.init(); + SpigotConfig.init(); + PaperSpigotConfig.init(); + SpigotWorldConfig.init(); + PaperSpigotWorldConfig.init(); + } + + public static void registerCommands() { + for (Map.Entry entry : commands.entrySet()) { + MinecraftServer. + getServer(). + server. + getCommandMap(). + register(entry.getKey(), "eSpigot", entry.getValue()); + } + } + + public static void readConfig(Class clazz, Object instance) { + for (Method method : clazz.getDeclaredMethods()) { + if (Modifier.isPrivate(method.getModifiers())) { + if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) { + try { + method.setAccessible(true); + method.invoke(instance); + } catch (InvocationTargetException ex) { + throw Throwables.propagate(ex.getCause()); + } catch (Exception ex) { + Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex); + } + } + } + } + + try { + config.save(CONFIG_FILE); + } catch (IOException ex) { + Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex); + } + } + +} diff --git a/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/eSpigotConfig.java b/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/eSpigotConfig.java new file mode 100644 index 0000000..ce5c04f --- /dev/null +++ b/eSpigot-Server/src/main/java/com/elevatemc/spigot/config/eSpigotConfig.java @@ -0,0 +1,109 @@ +package com.elevatemc.spigot.config; + +import java.util.*; + +import org.bukkit.command.Command; +import org.bukkit.configuration.file.YamlConfiguration; + +public class eSpigotConfig +{ + + public static YamlConfiguration config; + static Map commands; + + public static void init() + { + config = SharedConfig.config; + commands = SharedConfig.commands; + SharedConfig.readConfig( eSpigotConfig.class, null ); + } + + private static boolean getBoolean(String path, boolean def) + { + path = "espigot." + path; + config.addDefault( path, def ); + return config.getBoolean( path, config.getBoolean( path ) ); + } + + private static double getDouble(String path, double def) + { + path = "espigot." + path; + config.addDefault( path, def ); + return config.getDouble( path, config.getDouble( path ) ); + } + + private static int getInt(String path, int def) + { + path = "espigot." + path; + config.addDefault( path, def ); + return config.getInt( path, config.getInt( path ) ); + } + + private static List getList(String path, T def) + { + path = "espigot." + path; + config.addDefault( path, def ); + return config.getList( path, config.getList( path ) ); + } + + private static String getString(String path, String def) + { + path = "espigot." + path; + config.addDefault( path, def ); + return config.getString( path, config.getString( path ) ); + } + + public static boolean entityCollisions; + private static void entityCollisions() + { + entityCollisions = getBoolean( "settings.entity-collisions", false ); + } + + public static boolean villageTicking; + private static void villageTicking() + { + villageTicking = getBoolean( "settings.village-ticking", false ); + } + + public static boolean enchantmentTableTicking; + private static void enchantmentTableTicking() + { + enchantmentTableTicking = getBoolean( "settings.enchantment-table-ticking", false ); + } + + public static boolean dayLightCycle; + private static void dayLightCycle() + { + dayLightCycle = getBoolean( "settings.day-light-cycle", false ); + } + + public static boolean naturalMobSpawning; + private static void naterualMobSpawning() + { + naturalMobSpawning = getBoolean( "settings.natural-mob-spawning", false ); + } + + public static boolean showHiddenPlayersInTab; + private static void showHiddenPlayersInTab() + { + showHiddenPlayersInTab = getBoolean( "settings.show-hidden-players-in-tab", true ); + } + + public static boolean mobAI; + private static void mobAI() + { + mobAI = getBoolean( "settings.mob-ai", false ); + } + + public static boolean fixSprintEatExploit; + private static void fixSprintEatExploit() + { + fixSprintEatExploit = getBoolean( "settings.fix-sprint-eat-exploit", true ); + } + + public static boolean obfuscatePlayerHealth; + private static void obfuscatePlayerHealth() + { + obfuscatePlayerHealth = getBoolean( "settings.obfuscate-player-health", true ); + } +} diff --git a/eSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java b/eSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java index 6b05c49..5027946 100644 --- a/eSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java +++ b/eSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigot.java @@ -28,20 +28,16 @@ public class eSpigot { return instance; } - private final YamlConfig config, knockbackConfig; + private final YamlConfig knockbackConfig; private final KnockbackHandler knockbackHandler; public eSpigot(CraftServer server) { // Set instance of the server instance = this; - config = new YamlConfig("espigot.yml"); knockbackConfig = new YamlConfig("knockback.yml"); knockbackHandler = new KnockbackHandler(); - for (eSpigotFeature eSpigotFeature : eSpigotFeature.values()) - eSpigotFeature.reload(config); - for (Command command : Arrays.asList(new KnockbackCommand(), new TicksPerSecondCommand())) server.getCommandMap() .register(command.getLabel(), "eSpigot", command); @@ -67,11 +63,6 @@ public class eSpigot { return this.packetHandlers; } - - public YamlConfig getConfig() { - return config; - } - public YamlConfig getKnockbackConfig() { return knockbackConfig; } diff --git a/eSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigotFeature.java b/eSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigotFeature.java deleted file mode 100644 index 6e4dd0f..0000000 --- a/eSpigot-Server/src/main/java/com/elevatemc/spigot/eSpigotFeature.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.elevatemc.spigot; - -import org.bukkit.configuration.file.YamlConfiguration; -import com.elevatemc.spigot.util.YamlConfig; - -public enum eSpigotFeature { - - ENTITY_COLLISION(false), - VILLAGE_TICKING(false), - DAY_LIGHT_CYCLE(false), - NATURAL_MOB_SPAWNING(false), - SHOW_HIDDEN_PLAYERS_IN_TAB(true), - MOB_AI(false), - FIX_SPRINT_EAT_EXPLOIT(true), - OBFUSCATE_HEALTH(true); - - private boolean enabled; - - eSpigotFeature(boolean enabled) { - this.enabled = enabled; - } - - public void reload(YamlConfig yamlConfig) { - yamlConfig.reload(); - YamlConfiguration config = yamlConfig.getConfig(); - - if (config != null) { - enabled = config.getBoolean("features." + name().toLowerCase(), enabled); - config.set("features." + name().toLowerCase(), enabled); - yamlConfig.saveAsync(); - } - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } -} diff --git a/eSpigot-Server/src/main/java/com/elevatemc/spigot/network/VarIntUtil.java b/eSpigot-Server/src/main/java/com/elevatemc/spigot/network/VarIntUtil.java index 4013383..4005259 100644 --- a/eSpigot-Server/src/main/java/com/elevatemc/spigot/network/VarIntUtil.java +++ b/eSpigot-Server/src/main/java/com/elevatemc/spigot/network/VarIntUtil.java @@ -1,3 +1,4 @@ +// Original source: velocity package com.elevatemc.spigot.network; import io.netty.buffer.ByteBuf; diff --git a/eSpigot-Server/src/main/java/com/elevatemc/spigot/util/Constants.java b/eSpigot-Server/src/main/java/com/elevatemc/spigot/util/Constants.java new file mode 100644 index 0000000..246eb08 --- /dev/null +++ b/eSpigot-Server/src/main/java/com/elevatemc/spigot/util/Constants.java @@ -0,0 +1,6 @@ +package com.elevatemc.spigot.util; + +public class Constants +{ + public static final int[] EMPTY_ARRAY = new int[0]; +} \ No newline at end of file diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockDragonEgg.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockDragonEgg.java index 4b81020..47351ef 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockDragonEgg.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockDragonEgg.java @@ -2,6 +2,7 @@ package net.minecraft.server; import java.util.Random; +import com.elevatemc.spigot.util.Constants; import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit public class BlockDragonEgg extends Block { @@ -87,7 +88,7 @@ public class BlockDragonEgg extends Block { double d2 = (double) blockposition1.getY() + (double) (blockposition.getY() - blockposition1.getY()) * d0 + world.random.nextDouble() * 1.0D - 0.5D; double d3 = (double) blockposition1.getZ() + (double) (blockposition.getZ() - blockposition1.getZ()) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D; - world.addParticle(EnumParticle.PORTAL, d1, d2, d3, f, f1, f2, new int[0]); + world.addParticle(EnumParticle.PORTAL, d1, d2, d3, f, f1, f2, Constants.EMPTY_ARRAY); } } else { world.setTypeAndData(blockposition1, iblockdata, 2); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockFluids.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockFluids.java index 29b1cc8..a7df73f 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockFluids.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockFluids.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + import java.util.Iterator; import java.util.Random; @@ -171,7 +173,7 @@ public abstract class BlockFluids extends Block { world.makeSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); for (int i = 0; i < 8; ++i) { - world.addParticle(EnumParticle.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockGrass.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockGrass.java index 0d0f241..6eec173 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockGrass.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockGrass.java @@ -44,7 +44,7 @@ public class BlockGrass extends Block implements IBlockFragilePlantElement { } // CraftBukkit end } else { - if (world.tacoSpigotConfig.grassIgnoresLight || world.getLightLevel(blockposition.up()) >= 9) { // TacoSpigot - add an option to ignore light + if (world.paperSpigotConfig.grassIgnoresLight || world.getLightLevel(blockposition.up()) >= 9) { // TacoSpigot - add an option to ignore light for (int i = 0; i < Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); ++i) { // Spigot BlockPosition blockposition1 = blockposition.a(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); Block block = world.getType(blockposition1.up()).getBlock(); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockNote.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockNote.java index e6b7546..c7e419a 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockNote.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockNote.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.collect.Lists; import java.util.List; @@ -76,7 +77,7 @@ public class BlockNote extends BlockContainer { float f = (float) Math.pow(2.0D, (double) (j - 12) / 12.0D); world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "note." + this.b(i), 3.0F, f); - world.addParticle(EnumParticle.NOTE, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 1.2D, (double) blockposition.getZ() + 0.5D, (double) j / 24.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.NOTE, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 1.2D, (double) blockposition.getZ() + 0.5D, (double) j / 24.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); return true; } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockPumpkin.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockPumpkin.java index 21b3cc2..b876273 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockPumpkin.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockPumpkin.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.base.Predicate; // CraftBukkit start @@ -65,7 +66,7 @@ public class BlockPumpkin extends BlockDirectional { blockList.updateList(); for (j = 0; j < 120; ++j) { - world.addParticle(EnumParticle.SNOW_SHOVEL, (double) blockposition1.getX() + world.random.nextDouble(), (double) blockposition1.getY() + world.random.nextDouble() * 2.5D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.SNOW_SHOVEL, (double) blockposition1.getX() + world.random.nextDouble(), (double) blockposition1.getY() + world.random.nextDouble() * 2.5D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } for (j = 0; j < this.getDetectorSnowGolem().b(); ++j) { @@ -97,7 +98,7 @@ public class BlockPumpkin extends BlockDirectional { blockList.updateList(); for (j = 0; j < 120; ++j) { - world.addParticle(EnumParticle.SNOWBALL, (double) blockposition2.getX() + world.random.nextDouble(), (double) blockposition2.getY() + world.random.nextDouble() * 3.9D, (double) blockposition2.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.SNOWBALL, (double) blockposition2.getX() + world.random.nextDouble(), (double) blockposition2.getY() + world.random.nextDouble() * 3.9D, (double) blockposition2.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } for (j = 0; j < this.getDetectorIronGolem().c(); ++j) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneOre.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneOre.java index 881de93..3252015 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneOre.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneOre.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.Random; // CraftBukkit start +import com.elevatemc.spigot.util.Constants; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit end @@ -147,7 +148,7 @@ public class BlockRedstoneOre extends Block { } if (d1 < (double) blockposition.getX() || d1 > (double) (blockposition.getX() + 1) || d2 < 0.0D || d2 > (double) (blockposition.getY() + 1) || d3 < (double) blockposition.getZ() || d3 > (double) (blockposition.getZ() + 1)) { - world.addParticle(EnumParticle.REDSTONE, d1, d2, d3, 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.REDSTONE, d1, d2, d3, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneTorch.java index 2627344..6fe68c2 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneTorch.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockRedstoneTorch.java @@ -2,6 +2,7 @@ package net.minecraft.server; import java.util.Random; +import com.elevatemc.spigot.util.Constants; import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit public class BlockRedstoneTorch extends BlockTorch { @@ -152,7 +153,7 @@ public class BlockRedstoneTorch extends BlockTorch { double d1 = blockposition.getY() + random.nextDouble() * 0.6D + 0.2D; double d2 = blockposition.getZ() + random.nextDouble() * 0.6D + 0.2D; - world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } world.a(blockposition, world.getType(blockposition).getBlock(), 160); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockSkull.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockSkull.java index 74673e4..5bdad2d 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockSkull.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockSkull.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.base.Predicate; import java.util.Iterator; import java.util.Random; @@ -208,7 +209,7 @@ public class BlockSkull extends BlockContainer { int k; for (k = 0; k < 120; ++k) { - world.addParticle(EnumParticle.SNOWBALL, (double) blockposition1.getX() + world.random.nextDouble(), (double) (blockposition1.getY() - 2) + world.random.nextDouble() * 3.9D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.SNOWBALL, (double) blockposition1.getX() + world.random.nextDouble(), (double) (blockposition1.getY() - 2) + world.random.nextDouble() * 3.9D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } for (k = 0; k < shapedetector.c(); ++k) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/BlockStateList.java b/eSpigot-Server/src/main/java/net/minecraft/server/BlockStateList.java index 031d41b..16b2eeb 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/BlockStateList.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/BlockStateList.java @@ -26,7 +26,7 @@ import com.google.common.collect.Table; import net.techcable.tacospigot.ImmutableArrayMap; import net.techcable.tacospigot.ImmutableArrayTable; -import net.techcable.tacospigot.TacoSpigotConfig; +import org.github.paperspigot.PaperSpigotConfig; // TacoSpigot end public class BlockStateList { @@ -126,7 +126,7 @@ public class BlockStateList { this.a = block; // TacoSpigot start this.bAsImmutableMap = immutablemap; - if (TacoSpigotConfig.useArraysForBlockStates) { + if (PaperSpigotConfig.useArraysForBlockStates) { b = new ImmutableArrayMap<>(IBlockState.INDEXER, immutablemap); } else { b = immutablemap; @@ -195,7 +195,7 @@ public class BlockStateList { } // TacoSpigot start - if (TacoSpigotConfig.useArraysForBlockStates) { + if (PaperSpigotConfig.useArraysForBlockStates) { this.c = new ImmutableArrayTable ( IBlockState.INDEXER, (IBlockState state, Comparable value) -> state.getValueId(value), diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/Chunk.java b/eSpigot-Server/src/main/java/net/minecraft/server/Chunk.java index 0f79fef..5bf4ec2 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/Chunk.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/Chunk.java @@ -687,6 +687,44 @@ public class Chunk { return chunksection == null ? (this.d(blockposition) ? enumskyblock.c : 0) : (enumskyblock == EnumSkyBlock.SKY ? (this.world.worldProvider.o() ? 0 : chunksection.d(i, j & 15, k)) : (enumskyblock == EnumSkyBlock.BLOCK ? chunksection.e(i, j & 15, k) : enumskyblock.c)); } + public int getBrightness(EnumSkyBlock enumskyblock, int blockposition_x, int blockposition_y, int blockposition_z) { + int i = blockposition_x & 15; + int j = blockposition_y; + int k = blockposition_z & 15; + ChunkSection chunksection = this.sections[j >> 4]; + + if(chunksection == null) + { + if(j >= this.heightMap[(k) << 4 | (i)]) + { + return enumskyblock.c; + } + } + else + { + if(enumskyblock == EnumSkyBlock.SKY) + { + if(!this.world.worldProvider.o()) + { + return chunksection.d(i, j & 15, k); + } + } + else + { + if(enumskyblock == EnumSkyBlock.BLOCK) + { + return chunksection.e(i, j & 15, k); + } + else + { + return enumskyblock.c; + } + } + } + + return 0; + } + public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) { int j = blockposition.getX() & 15; int k = blockposition.getY(); @@ -838,9 +876,10 @@ public class Chunk { public boolean isBelowHeightMap(int blockposition_x, int blockposition_y, int blockposition_z) { int i = blockposition_x & 15; + int j = blockposition_y; int k = blockposition_z & 15; - return blockposition_y >= this.heightMap[k << 4 | i]; + return j >= this.heightMap[k << 4 | i]; } public TileEntity i(BlockPosition blockposition) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/CommandAbstract.java b/eSpigot-Server/src/main/java/net/minecraft/server/CommandAbstract.java index 1121880..d38e0d8 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/CommandAbstract.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/CommandAbstract.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.common.base.Functions; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -139,7 +140,7 @@ public abstract class CommandAbstract implements ICommand { if (entityplayer == null) { try { - entityplayer = MinecraftServer.getServer().getPlayerList().a(UUID.fromString(s)); + entityplayer = MinecraftServer.getServer().getPlayerList().a(FastUUID.parseUUID(s)); } catch (IllegalArgumentException illegalargumentexception) { ; } @@ -170,7 +171,7 @@ public abstract class CommandAbstract implements ICommand { if (object == null) { try { - UUID uuid = UUID.fromString(s); + UUID uuid = FastUUID.parseUUID(s); object = minecraftserver.a(uuid); if (object == null) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/CommandScoreboard.java b/eSpigot-Server/src/main/java/net/minecraft/server/CommandScoreboard.java index 5e4ed54..c992da1 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/CommandScoreboard.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/CommandScoreboard.java @@ -475,7 +475,7 @@ public class CommandScoreboard extends CommandAbstract { for (Object o : list) { Entity entity = (Entity) o; - if (!entity.world.tacoSpigotConfig.nonPlayerEntitiesOnScoreboards && !(entity instanceof EntityHuman)) + if (!entity.world.paperSpigotConfig.nonPlayerEntitiesOnScoreboards && !(entity instanceof EntityHuman)) continue; // TacoSpigot String s2 = e(icommandlistener, entity.getUniqueID().toString()); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/DedicatedServer.java b/eSpigot-Server/src/main/java/net/minecraft/server/DedicatedServer.java index 594e1f8..90a71bd 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/DedicatedServer.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.config.SharedConfig; import com.elevatemc.spigot.console.PandaConsole; import java.io.File; @@ -159,9 +160,9 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer // PandaSpigot - Move SpigotConfig to load earlier, so that we can check IP forwarding status here. // Spigot start this.a(new DedicatedPlayerList(this)); - org.spigotmc.SpigotConfig.init((File) options.valueOf("spigot-settings")); - org.spigotmc.SpigotConfig.registerCommands(); // Spigot end + SharedConfig.registerCommands(); + java.net.SocketAddress bindAddress; if (this.getServerIp().startsWith("unix:")) { if (!io.netty.channel.epoll.Epoll.isAvailable()) { @@ -189,12 +190,6 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer bindAddress = new java.net.InetSocketAddress(inetaddress, this.R()); } - // PandaSpigot end - // PaperSpigot start - org.github.paperspigot.PaperSpigotConfig.init((File) options.valueOf("paper-settings")); - org.github.paperspigot.PaperSpigotConfig.registerCommands(); - // PaperSpigot end - DedicatedServer.LOGGER.info("Generating keypair"); this.a(MinecraftEncryption.b()); DedicatedServer.LOGGER.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.R()); @@ -295,16 +290,6 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit } - // CraftBukkit start - if (this.server.getBukkitSpawnRadius() > -1) { - DedicatedServer.LOGGER.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(); - this.propertyManager.savePropertiesFile(); - } - // CraftBukkit end - if (org.spigotmc.SpigotConfig.lateBind) { try { this.aq().bind(bindAddress); // PandaSpigot - Unix domain socket support diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/Entity.java b/eSpigot-Server/src/main/java/net/minecraft/server/Entity.java index 5a82d03..f9de1d9 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/Entity.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/Entity.java @@ -4,6 +4,8 @@ import java.util.*; import java.util.concurrent.Callable; // CraftBukkit start +import com.eatthepath.uuid.FastUUID; +import com.elevatemc.spigot.util.Constants; import com.elevatemc.spigot.util.FastRandom; import org.apache.logging.log4j.LogManager; import org.bukkit.Bukkit; @@ -557,7 +559,7 @@ public abstract class Entity implements ICommandListener { double xLength = totalArea.d - totalArea.a; double yLength = totalArea.e - totalArea.b; double zLength = totalArea.f - totalArea.c; - boolean axisScan = this.world.tacoSpigotConfig.optimizeTntMovement && xLength * yLength * zLength > 10; + boolean axisScan = this.world.paperSpigotConfig.optimizeTntMovement && xLength * yLength * zLength > 10; List list = this.world.getCubes(this, axisScan ? this.getBoundingBox().a(0, d1, 0) : totalArea); // TacoSpigot end @@ -577,7 +579,7 @@ public abstract class Entity implements ICommandListener { Iterator iterator1; // eSpigot start - getCubesNoEntities - if(this.world.tacoSpigotConfig.fixEastWest && Math.abs(d0) > Math.abs(d2)) { //TacoSpigot - fix east/west cannoning by calculating the z movement before x if the x velocity is greater + if(this.world.paperSpigotConfig.fixEastWest && Math.abs(d0) > Math.abs(d2)) { //TacoSpigot - fix east/west cannoning by calculating the z movement before x if the x velocity is greater if(axisScan) list = this.world.getCubesNoEntities(this, this.getBoundingBox().a(0, 0, d2)); // TacoSpigot - get z axis blocks for (iterator1 = list.iterator(); iterator1.hasNext(); d2 = axisalignedbb2.c(this.getBoundingBox(), d2)) { @@ -1053,13 +1055,13 @@ public abstract class Entity implements ICommandListener { for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + (double) f2, f1 + 1.0F, this.locZ + (double) f3, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + (double) f2, f1 + 1.0F, this.locZ + (double) f3, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ, Constants.EMPTY_ARRAY); } for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.addParticle(EnumParticle.WATER_SPLASH, this.locX + (double) f2, f1 + 1.0F, this.locZ + (double) f3, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_SPLASH, this.locX + (double) f2, f1 + 1.0F, this.locZ + (double) f3, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } } @@ -1440,7 +1442,7 @@ public abstract class Entity implements ICommandListener { if (nbttagcompound.hasKeyOfType("UUIDMost", 4) && nbttagcompound.hasKeyOfType("UUIDLeast", 4)) { this.uniqueID = new UUID(nbttagcompound.getLong("UUIDMost"), nbttagcompound.getLong("UUIDLeast")); } else if (nbttagcompound.hasKeyOfType("UUID", 8)) { - this.uniqueID = UUID.fromString(nbttagcompound.getString("UUID")); + this.uniqueID = FastUUID.parseUUID(nbttagcompound.getString("UUID")); } this.setPosition(this.locX, this.locY, this.locZ); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityAgeable.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityAgeable.java index e6f32ea..37c7ef0 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityAgeable.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityAgeable.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public abstract class EntityAgeable extends EntityCreature { protected int a; @@ -140,7 +142,7 @@ public abstract class EntityAgeable extends EntityCreature { if (this.world.isClientSide || ageLocked) { // CraftBukkit if (this.c > 0) { if (this.c % 4 == 0) { - this.world.addParticle(EnumParticle.VILLAGER_HAPPY, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.VILLAGER_HAPPY, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } --this.c; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityAnimal.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityAnimal.java index c725368..535cbb8 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityAnimal.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityAnimal.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public abstract class EntityAnimal extends EntityAgeable implements IAnimal { protected Block bn; @@ -32,7 +34,7 @@ public abstract class EntityAnimal extends EntityAgeable implements IAnimal { double d1 = this.random.nextGaussian() * 0.02D; double d2 = this.random.nextGaussian() * 0.02D; - this.world.addParticle(EnumParticle.HEART, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2, new int[0]); + this.world.addParticle(EnumParticle.HEART, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityArmorStand.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityArmorStand.java index ed4b3bd..2774043 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityArmorStand.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityArmorStand.java @@ -714,7 +714,7 @@ public class EntityArmorStand extends EntityLiving { // TacoSpigot start - add an option to make armor stands not move @Override public void move(double motX, double motY, double motZ) { - if (getWorld().tacoSpigotConfig.optimizeArmorStandMovement) return; + if (getWorld().paperSpigotConfig.optimizeArmorStandMovement) return; super.move(motX, motY, motZ); } // TacoSpigot end diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityArrow.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityArrow.java index 1c3aa31..cc1050a 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityArrow.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityArrow.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.List; // CraftBukkit start +import com.elevatemc.spigot.util.Constants; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -342,7 +343,7 @@ public class EntityArrow extends Entity implements IProjectile { if (this.isCritical()) { for (j = 0; j < 4; ++j) { - this.world.addParticle(EnumParticle.CRIT, this.locX + this.motX * (double) j / 4.0D, this.locY + this.motY * (double) j / 4.0D, this.locZ + this.motZ * (double) j / 4.0D, -this.motX, -this.motY + 0.2D, -this.motZ, new int[0]); + this.world.addParticle(EnumParticle.CRIT, this.locX + this.motX * (double) j / 4.0D, this.locY + this.motY * (double) j / 4.0D, this.locZ + this.motZ * (double) j / 4.0D, -this.motX, -this.motY + 0.2D, -this.motZ, Constants.EMPTY_ARRAY); } } @@ -375,7 +376,7 @@ public class EntityArrow extends Entity implements IProjectile { if (this.V()) { for (int l = 0; l < 4; ++l) { f3 = 0.25F; - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } f4 = 0.6F; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityBlaze.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityBlaze.java index c6b7113..e9c0a66 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityBlaze.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityBlaze.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class EntityBlaze extends EntityMonster { private float a = 0.5F; @@ -57,7 +59,7 @@ public class EntityBlaze extends EntityMonster { } for (int i = 0; i < 2; ++i) { - this.world.addParticle(EnumParticle.SMOKE_LARGE, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.SMOKE_LARGE, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityBoat.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityBoat.java index 7b78b7c..45cca9b 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityBoat.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityBoat.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.List; // CraftBukkit start +import com.elevatemc.spigot.util.Constants; import org.bukkit.Location; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.entity.Vehicle; @@ -200,11 +201,11 @@ public class EntityBoat extends Entity { if (this.random.nextBoolean()) { d8 = this.locX - d4 * d6 * 0.8D + d5 * d7; d9 = this.locZ - d5 * d6 * 0.8D - d4 * d7; - this.world.addParticle(EnumParticle.WATER_SPLASH, d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_SPLASH, d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } else { d8 = this.locX + d4 + d5 * d6 * 0.7D; d9 = this.locZ + d5 - d4 * d6 * 0.7D; - this.world.addParticle(EnumParticle.WATER_SPLASH, d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_SPLASH, d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityCreature.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityCreature.java index 3daf7c4..e205513 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityCreature.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityCreature.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.UUID; // CraftBukkit start +import com.eatthepath.uuid.FastUUID; import com.elevatemc.spigot.pathsearch.jobs.PathSearchJob; import com.elevatemc.spigot.pathsearch.jobs.PathSearchJobEntity; import com.elevatemc.spigot.pathsearch.jobs.PathSearchJobPosition; @@ -12,7 +13,7 @@ import org.bukkit.event.entity.EntityUnleashEvent; public abstract class EntityCreature extends EntityInsentient { - public static final UUID bk = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); + public static final UUID bk = FastUUID.parseUUID("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); public static final AttributeModifier bl = (new AttributeModifier(EntityCreature.bk, "Fleeing speed bonus", 2.0D, 2)).a(false); private BlockPosition a; private float b; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderDragon.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderDragon.java index 44f7cc3..b681beb 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderDragon.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.collect.Lists; import java.util.ArrayList; import java.util.Iterator; @@ -99,7 +100,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo f = (this.random.nextFloat() - 0.5F) * 8.0F; f1 = (this.random.nextFloat() - 0.5F) * 4.0F; f2 = (this.random.nextFloat() - 0.5F) * 8.0F; - this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } else { this.n(); f = 0.2F / (MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 10.0F + 1.0F); @@ -498,7 +499,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo double d1 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) this.random.nextFloat(); double d2 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) this.random.nextFloat(); - this.world.addParticle(EnumParticle.EXPLOSION_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } return flag; @@ -548,7 +549,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo float f1 = (this.random.nextFloat() - 0.5F) * 4.0F; float f2 = (this.random.nextFloat() - 0.5F) * 8.0F; - this.world.addParticle(EnumParticle.EXPLOSION_HUGE, this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_HUGE, this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } boolean flag = this.world.getGameRules().getBoolean("doMobLoot"); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderSignal.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderSignal.java index 1e4188c..03318f5 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderSignal.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderSignal.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class EntityEnderSignal extends Entity { private double a; @@ -99,10 +101,10 @@ public class EntityEnderSignal extends Entity { if (this.V()) { for (int i = 0; i < 4; ++i) { - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } } else { - this.world.addParticle(EnumParticle.PORTAL, this.locX - this.motX * (double) f3 + this.random.nextDouble() * 0.6D - 0.3D, this.locY - this.motY * (double) f3 - 0.5D, this.locZ - this.motZ * (double) f3 + this.random.nextDouble() * 0.6D - 0.3D, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.PORTAL, this.locX - this.motX * (double) f3 + this.random.nextDouble() * 0.6D - 0.3D, this.locY - this.motY * (double) f3 - 0.5D, this.locZ - this.motZ * (double) f3 + this.random.nextDouble() * 0.6D - 0.3D, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } if (!this.world.isClientSide) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderman.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderman.java index 03a6906..cd0ac9c 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderman.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEnderman.java @@ -1,8 +1,9 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; +import com.elevatemc.spigot.util.Constants; import com.google.common.base.Predicate; import com.google.common.collect.Sets; -import java.util.Collections; import java.util.List; import java.util.Random; import java.util.Set; @@ -15,7 +16,7 @@ import org.bukkit.event.entity.EntityTeleportEvent; public class EntityEnderman extends EntityMonster { - private static final UUID a = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0"); + private static final UUID a = FastUUID.parseUUID("020E0DFB-87AE-4653-9556-831010E291A0"); private static final AttributeModifier b = (new AttributeModifier(EntityEnderman.a, "Attacking speed boost", 0.15000000596046448D, 0)).a(false); private static final Set c = Sets.newIdentityHashSet(); private boolean bm; @@ -104,7 +105,7 @@ public class EntityEnderman extends EntityMonster { public void m() { if (this.world.isClientSide) { for (int i = 0; i < 2; ++i) { - this.world.addParticle(EnumParticle.PORTAL, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - 0.25D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D, new int[0]); + this.world.addParticle(EnumParticle.PORTAL, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - 0.25D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D, Constants.EMPTY_ARRAY); } } @@ -214,7 +215,7 @@ public class EntityEnderman extends EntityMonster { double d8 = d4 + (this.locY - d4) * d6 + this.random.nextDouble() * (double) this.length; double d9 = d5 + (this.locZ - d5) * d6 + (this.random.nextDouble() - 0.5D) * (double) this.width * 2.0D; - this.world.addParticle(EnumParticle.PORTAL, d7, d8, d9, f, f1, f2, new int[0]); + this.world.addParticle(EnumParticle.PORTAL, d7, d8, d9, f, f1, f2, Constants.EMPTY_ARRAY); } this.world.makeSound(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEndermite.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEndermite.java index be2bf9c..3014b25 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityEndermite.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityEndermite.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class EntityEndermite extends EntityMonster { private int a = 0; @@ -82,7 +84,7 @@ public class EntityEndermite extends EntityMonster { super.m(); if (this.world.isClientSide) { for (int i = 0; i < 2; ++i) { - this.world.addParticle(EnumParticle.PORTAL, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D, new int[0]); + this.world.addParticle(EnumParticle.PORTAL, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D, Constants.EMPTY_ARRAY); } } else { if (!this.isPersistent()) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFallingBlock.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFallingBlock.java index 5789de6..a332c64 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFallingBlock.java @@ -113,7 +113,7 @@ public class EntityFallingBlock extends Entity { if (this.world.getType(blockposition).getBlock() != Blocks.PISTON_EXTENSION) { this.die(); if (!this.e) { - if (this.world.a(block, blockposition, true, EnumDirection.UP, null, null) && !BlockFalling.canFall(this.world, blockposition.down()) /* mimic the false conditions of setTypeIdAndData */ && blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000 && blockposition.getY() >= 0 && blockposition.getY() < (this.world.tacoSpigotConfig.disableFallingBlockStackingAt256 ? 255 : 256) && this.world.getType(blockposition) != this.block) { + if (this.world.a(block, blockposition, true, EnumDirection.UP, null, null) && !BlockFalling.canFall(this.world, blockposition.down()) /* mimic the false conditions of setTypeIdAndData */ && blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000 && blockposition.getY() >= 0 && blockposition.getY() < (this.world.paperSpigotConfig.disableFallingBlockStackingAt256 ? 255 : 256) && this.world.getType(blockposition) != this.block) { if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) { return; } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireball.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireball.java index 06b54ad..738ca30 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireball.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireball.java @@ -2,6 +2,7 @@ package net.minecraft.server; import java.util.List; +import com.elevatemc.spigot.util.Constants; import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit public abstract class EntityFireball extends Entity { @@ -166,7 +167,7 @@ public abstract class EntityFireball extends Entity { for (int j = 0; j < 4; ++j) { float f3 = 0.25F; - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } f2 = 0.8F; @@ -178,7 +179,7 @@ public abstract class EntityFireball extends Entity { this.motX *= f2; this.motY *= f2; this.motZ *= f2; - this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); this.setPosition(this.locX, this.locY, this.locZ); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireworks.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireworks.java index 2d101a4..50c6e61 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireworks.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFireworks.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class EntityFireworks extends Entity { private int ticksFlown; @@ -82,7 +84,7 @@ public class EntityFireworks extends Entity { ++this.ticksFlown; if (this.world.isClientSide && this.ticksFlown % 2 < 2) { - this.world.addParticle(EnumParticle.FIREWORKS_SPARK, this.locX, this.locY - 0.3D, this.locZ, this.random.nextGaussian() * 0.05D, -this.motY * 0.5D, this.random.nextGaussian() * 0.05D, new int[0]); + this.world.addParticle(EnumParticle.FIREWORKS_SPARK, this.locX, this.locY - 0.3D, this.locZ, this.random.nextGaussian() * 0.05D, -this.motY * 0.5D, this.random.nextGaussian() * 0.05D, Constants.EMPTY_ARRAY); } if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFishingHook.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFishingHook.java index e1f9ff7..4bb3f96 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityFishingHook.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityFishingHook.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; // CraftBukkit start +import com.elevatemc.spigot.util.Constants; import org.bukkit.entity.Player; import org.bukkit.entity.Fish; import org.bukkit.event.player.PlayerFishEvent; @@ -288,8 +289,8 @@ public class EntityFishingHook extends Entity { this.motY -= 0.20000000298023224D; this.makeSound("random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); f3 = (float) MathHelper.floor(this.getBoundingBox().b); - worldserver.a(EnumParticle.WATER_BUBBLE, this.locX, f3 + 1.0F, this.locZ, (int) (1.0F + this.width * 20.0F), this.width, 0.0D, this.width, 0.20000000298023224D, new int[0]); - worldserver.a(EnumParticle.WATER_WAKE, this.locX, f3 + 1.0F, this.locZ, (int) (1.0F + this.width * 20.0F), this.width, 0.0D, this.width, 0.20000000298023224D, new int[0]); + worldserver.a(EnumParticle.WATER_BUBBLE, this.locX, f3 + 1.0F, this.locZ, (int) (1.0F + this.width * 20.0F), this.width, 0.0D, this.width, 0.20000000298023224D, Constants.EMPTY_ARRAY); + worldserver.a(EnumParticle.WATER_WAKE, this.locX, f3 + 1.0F, this.locZ, (int) (1.0F + this.width * 20.0F), this.width, 0.0D, this.width, 0.20000000298023224D, Constants.EMPTY_ARRAY); this.av = MathHelper.nextInt(this.random, 10, 30); } else { this.ay = (float) ((double) this.ay + this.random.nextGaussian() * 4.0D); @@ -302,14 +303,14 @@ public class EntityFishingHook extends Entity { block = worldserver.getType(new BlockPosition((int) d8, (int) d12 - 1, (int) d11)).getBlock(); if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) { if (this.random.nextFloat() < 0.15F) { - worldserver.a(EnumParticle.WATER_BUBBLE, d8, d12 - 0.10000000149011612D, d11, 1, f5, 0.1D, f4, 0.0D, new int[0]); + worldserver.a(EnumParticle.WATER_BUBBLE, d8, d12 - 0.10000000149011612D, d11, 1, f5, 0.1D, f4, 0.0D, Constants.EMPTY_ARRAY); } float f6 = f5 * 0.04F; float f7 = f4 * 0.04F; - worldserver.a(EnumParticle.WATER_WAKE, d8, d12, d11, 0, f7, 0.01D, -f6, 1.0D, new int[0]); - worldserver.a(EnumParticle.WATER_WAKE, d8, d12, d11, 0, -f7, 0.01D, f6, 1.0D, new int[0]); + worldserver.a(EnumParticle.WATER_WAKE, d8, d12, d11, 0, f7, 0.01D, -f6, 1.0D, Constants.EMPTY_ARRAY); + worldserver.a(EnumParticle.WATER_WAKE, d8, d12, d11, 0, -f7, 0.01D, f6, 1.0D, Constants.EMPTY_ARRAY); } } } else if (this.aw > 0) { @@ -331,7 +332,7 @@ public class EntityFishingHook extends Entity { d11 = this.locZ + (double) (MathHelper.cos(f5) * f4 * 0.1F); block = worldserver.getType(new BlockPosition((int) d8, (int) d12 - 1, (int) d11)).getBlock(); if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) { - worldserver.a(EnumParticle.WATER_SPLASH, d8, d12, d11, 2 + this.random.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, new int[0]); + worldserver.a(EnumParticle.WATER_SPLASH, d8, d12, d11, 2 + this.random.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityGuardian.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityGuardian.java index 4dfe5a6..2616206 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityGuardian.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityGuardian.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.base.Predicate; import java.util.Iterator; import java.util.List; @@ -211,7 +212,7 @@ public class EntityGuardian extends EntityMonster { Vec3D vec3d = this.d(0.0F); for (int i = 0; i < 2; ++i) { - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width - vec3d.a * 1.5D, this.locY + this.random.nextDouble() * (double) this.length - vec3d.b * 1.5D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width - vec3d.c * 1.5D, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width - vec3d.a * 1.5D, this.locY + this.random.nextDouble() * (double) this.length - vec3d.b * 1.5D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width - vec3d.c * 1.5D, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } @@ -238,7 +239,7 @@ public class EntityGuardian extends EntityMonster { while (d5 < d4) { d5 += 1.8D - d0 + this.random.nextDouble() * (1.7D - d0); - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + d1 * d5, this.locY + d2 * d5 + (double) this.getHeadHeight(), this.locZ + d3 * d5, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + d1 * d5, this.locY + d2 * d5 + (double) this.getHeadHeight(), this.locZ + d3 * d5, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityInsentient.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityInsentient.java index f9e8cae..0788ef1 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityInsentient.java @@ -7,6 +7,7 @@ import java.util.UUID; // CraftBukkit start import com.elevatemc.spigot.pathsearch.AsyncNavigation; +import com.elevatemc.spigot.util.Constants; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.event.entity.EntityTargetLivingEntityEvent; @@ -184,7 +185,7 @@ public abstract class EntityInsentient extends EntityLiving { double d2 = this.random.nextGaussian() * 0.02D; double d3 = 10.0D; - this.world.addParticle(EnumParticle.EXPLOSION_NORMAL, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.length) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d2 * d3, d0, d1, d2, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_NORMAL, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.length) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d2 * d3, d0, d1, d2, Constants.EMPTY_ARRAY); } } else { this.world.broadcastEntityEffect(this, (byte) 20); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityLiving.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityLiving.java index 2d8e90b..fb9ff97 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityLiving.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityLiving.java @@ -1,5 +1,8 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; +import com.elevatemc.spigot.config.eSpigotConfig; +import com.elevatemc.spigot.util.Constants; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Maps; @@ -28,14 +31,13 @@ import org.bukkit.event.vehicle.VehicleExitEvent; // PaperSpigot start import org.bukkit.Bukkit; -import com.elevatemc.spigot.eSpigotFeature; import com.elevatemc.spigot.eSpigot; import org.spigotmc.event.entity.EntityDismountEvent; // PaperSpigot end public abstract class EntityLiving extends Entity { - private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); + private static final UUID a = FastUUID.parseUUID("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); private static final AttributeModifier b = (new AttributeModifier(EntityLiving.a, "Sprinting speed boost", 0.30000001192092896D, 2)).a(false); private AttributeMapBase c; public CombatTracker combatTracker = new CombatTracker(this); @@ -214,7 +216,7 @@ public abstract class EntityLiving extends Entity { float f1 = this.random.nextFloat() - this.random.nextFloat(); float f2 = this.random.nextFloat() - this.random.nextFloat(); - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } this.damageEntity(DamageSource.DROWN, 2.0F); @@ -315,7 +317,7 @@ public abstract class EntityLiving extends Entity { double d1 = this.random.nextGaussian() * 0.02D; double d2 = this.random.nextGaussian() * 0.02D; - this.world.addParticle(EnumParticle.EXPLOSION_NORMAL, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_NORMAL, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2, Constants.EMPTY_ARRAY); } } @@ -539,7 +541,7 @@ public abstract class EntityLiving extends Entity { double d1 = (double) (i >> 8 & 255) / 255.0D; double d2 = (double) (i & 255) / 255.0D; - this.world.addParticle(flag ? EnumParticle.SPELL_MOB_AMBIENT : EnumParticle.SPELL_MOB, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, d0, d1, d2, new int[0]); + this.world.addParticle(flag ? EnumParticle.SPELL_MOB_AMBIENT : EnumParticle.SPELL_MOB, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, d0, d1, d2, Constants.EMPTY_ARRAY); } } @@ -1664,7 +1666,7 @@ public abstract class EntityLiving extends Entity { this.ba = 0.0F; this.bb = 0.0F; } else if (this.bM()) { - if (eSpigotFeature.MOB_AI.isEnabled() || this instanceof EntityHuman) { + if (eSpigotConfig.mobAI || this instanceof EntityHuman) { this.world.methodProfiler.a("newAi"); this.doTick(); this.world.methodProfiler.b(); @@ -1704,7 +1706,7 @@ public abstract class EntityLiving extends Entity { protected void doTick() {} protected void bL() { - if (!eSpigotFeature.ENTITY_COLLISION.isEnabled()) + if (!eSpigotConfig.entityCollisions) return; List list = this.world.a(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), Predicates.and(IEntitySelector.d, new Predicate() { @@ -1871,7 +1873,7 @@ public abstract class EntityLiving extends Entity { } public ScoreboardTeamBase getScoreboardTeam() { - if (!this.world.tacoSpigotConfig.nonPlayerEntitiesOnScoreboards && !(this instanceof EntityHuman)) return null; // TacoSpigot + if (!this.world.paperSpigotConfig.nonPlayerEntitiesOnScoreboards && !(this instanceof EntityHuman)) return null; // TacoSpigot return this.world.getScoreboard().getPlayerTeam(this.getUniqueID().toString()); } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartFurnace.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartFurnace.java index ccc59d9..920fe25 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartFurnace.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartFurnace.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class EntityMinecartFurnace extends EntityMinecartAbstract { private int c; @@ -35,7 +37,7 @@ public class EntityMinecartFurnace extends EntityMinecartAbstract { this.i(this.c > 0); if (this.j() && this.random.nextInt(4) == 0) { - this.world.addParticle(EnumParticle.SMOKE_LARGE, this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.SMOKE_LARGE, this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartTNT.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartTNT.java index 98d3217..8d364e9 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartTNT.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityMinecartTNT.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class EntityMinecartTNT extends EntityMinecartAbstract { private int a = -1; @@ -24,7 +26,7 @@ public class EntityMinecartTNT extends EntityMinecartAbstract { super.t_(); if (this.a > 0) { --this.a; - this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } else if (this.a == 0) { this.b(this.motX * this.motX + this.motZ * this.motZ); } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityMushroomCow.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityMushroomCow.java index fef767c..1dbd645 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityMushroomCow.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityMushroomCow.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import org.bukkit.event.player.PlayerShearEntityEvent; // CraftBukkit public class EntityMushroomCow extends EntityCow { @@ -35,7 +36,7 @@ public class EntityMushroomCow extends EntityCow { } // CraftBukkit end this.die(); - this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); if (!this.world.isClientSide) { EntityCow entitycow = new EntityCow(this.world); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityPigZombie.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityPigZombie.java index 10f363a..c672aae 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -1,10 +1,12 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; + import java.util.UUID; public class EntityPigZombie extends EntityZombie { - private static final UUID b = UUID.fromString("49455A49-7EC5-45BA-B886-3B90B23A1718"); + private static final UUID b = FastUUID.parseUUID("49455A49-7EC5-45BA-B886-3B90B23A1718"); private static final AttributeModifier c = (new AttributeModifier(EntityPigZombie.b, "Attacking speed boost", 0.05D, 0)).a(false); public int angerLevel; private int soundDelay; @@ -92,7 +94,7 @@ public class EntityPigZombie extends EntityZombie { String s = nbttagcompound.getString("HurtBy"); if (s.length() > 0) { - this.hurtBy = UUID.fromString(s); + this.hurtBy = FastUUID.parseUUID(s); EntityHuman entityhuman = this.world.b(this.hurtBy); this.b((EntityLiving) entityhuman); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityPlayer.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityPlayer.java index 01f3ce4..0eab50f 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityPlayer.java @@ -8,6 +8,7 @@ import io.netty.buffer.Unpooled; import java.util.*; import com.elevatemc.spigot.eSpigot; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -192,6 +193,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.bs(), PacketPlayOutCombatEvent.EnumCombatEventType.END_COMBAT)); } + private long chunkToLong(int chunkX, int chunkZ) + { + return (chunkX << 32L) + chunkZ - -2147483648L; + } + public void t_() { // CraftBukkit start if (this.joining) { @@ -231,49 +237,71 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } if (!this.chunkCoordIntPairQueue.isEmpty()) { - ArrayList arraylist = Lists.newArrayList(); - Iterator iterator1 = this.chunkCoordIntPairQueue.iterator(); - ArrayList arraylist1 = Lists.newArrayList(); + ArrayList chunkList = Lists.newArrayList(); + Iterator chunksToLoad = this.chunkCoordIntPairQueue.iterator(); + ArrayList tileEntities = Lists.newArrayList(); - Chunk chunk; + Chunk chunk = null; - while (iterator1.hasNext() && arraylist.size() < this.world.spigotConfig.maxBulkChunk) { // Spigot - ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator1.next(); + while (chunksToLoad.hasNext() && chunkList.size() < this.world.spigotConfig.maxBulkChunk) { // Spigot + ChunkCoordIntPair chunkcoordintpair = chunksToLoad.next(); if (chunkcoordintpair != null) { - if (this.world.isLoaded(new BlockPosition(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4))) { + if (this.world.isLoaded(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4)) {// [Nacho-0024] Do not create new BlockPosition when loading chunk chunk = this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z); if (chunk.isReady()) { - arraylist.add(chunk); - arraylist1.addAll(chunk.tileEntities.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world - iterator1.remove(); + chunkList.add(chunk); + tileEntities.addAll(chunk.tileEntities.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world + chunksToLoad.remove(); } } } else { - iterator1.remove(); + chunksToLoad.remove(); } } - if (!arraylist.isEmpty()) { - if (arraylist.size() == 1) { - this.playerConnection.sendPacket(new PacketPlayOutMapChunk((Chunk) arraylist.get(0), true, '\uffff')); + if (!chunkList.isEmpty()) { + if (chunkList.size() == 1) { + this.playerConnection.sendPacket(new PacketPlayOutMapChunk(chunkList.get(0), true, '\uffff')); } else { - this.playerConnection.sendPacket(new PacketPlayOutMapChunkBulk(arraylist)); + this.playerConnection.sendPacket(new PacketPlayOutMapChunkBulk(chunkList)); } - Iterator iterator2 = arraylist1.iterator(); + Iterator tileEntitiesIterator = tileEntities.iterator(); - while (iterator2.hasNext()) { - TileEntity tileentity = (TileEntity) iterator2.next(); + while (tileEntitiesIterator.hasNext()) { + TileEntity tileentity = tileEntitiesIterator.next(); this.a(tileentity); } - iterator2 = arraylist.iterator(); + // //Nacho - if there are a lot of entities, we end up scanning the WHOLE list of entities multiple times +// // Which isn't the best if we have 100 players doing that + // So instead of updating all entities by chunk, we update all entities at once with a hashset of chunks + // This means we don't have to pass over the list x chunks + // o(chunk * entityList) => o(entitylist) - while (iterator2.hasNext()) { - chunk = (Chunk) iterator2.next(); - this.u().getTracker().a(this, chunk); +// Iterator chunkIterator = chunkList.iterator(); +// while (chunkIterator.hasNext()) +// { +// chunk = (Chunk) chunkIterator.next(); +// this.u().getTracker().a(this, chunk); +// } +// Nacho - end + + LongOpenHashSet chunkPosSet = new LongOpenHashSet(chunkList.size()); + for (Chunk newChunk : chunkList) + chunkPosSet.add(this.chunkToLong(newChunk.locX, newChunk.locZ)); + + Iterator trackerEntryIterator = this.u().getTracker().getEntityTrackerEntries(); + while (trackerEntryIterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = trackerEntryIterator.next(); + + if (entitytrackerentry.tracker != this && chunkPosSet.contains(this.chunkToLong(entitytrackerentry.tracker.ae, entitytrackerentry.tracker.ag))) + { + entitytrackerentry.updatePlayer(this); + } } } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityProjectile.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityProjectile.java index ce4a98c..b1636ab 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityProjectile.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityProjectile.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; +import com.elevatemc.spigot.util.Constants; import org.bukkit.craftbukkit.entity.CraftPlayer; import java.util.List; @@ -207,7 +209,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile { for (int j = 0; j < 4; ++j) { float f4 = 0.25F; - this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_BUBBLE, this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } f2 = 0.8F; @@ -268,7 +270,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile { this.shooter = this.world.a(this.shooterName); if (this.shooter == null && this.world instanceof WorldServer) { try { - Entity entity = ((WorldServer) this.world).getEntity(UUID.fromString(this.shooterName)); + Entity entity = ((WorldServer) this.world).getEntity(FastUUID.parseUUID(this.shooterName)); if (entity instanceof EntityLiving) { this.shooter = (EntityLiving) entity; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntitySlime.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntitySlime.java index aee272e..6e69c83 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntitySlime.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntitySlime.java @@ -1,6 +1,7 @@ package net.minecraft.server; // CraftBukkit start +import com.elevatemc.spigot.util.Constants; import org.bukkit.event.entity.SlimeSplitEvent; // CraftBukkit end @@ -88,7 +89,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { double d0 = this.locX + (double) f2; double d1 = this.locZ + (double) f3; - world.addParticle(enumparticle, d0, this.getBoundingBox().b, d1, 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(enumparticle, d0, this.getBoundingBox().b, d1, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } if (this.cl()) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntitySnowball.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntitySnowball.java index dade83b..5e6e81d 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntitySnowball.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class EntitySnowball extends EntityProjectile { public EntitySnowball(World world) { @@ -26,7 +28,7 @@ public class EntitySnowball extends EntityProjectile { } for (int i = 0; i < 8; ++i) { - this.world.addParticle(EnumParticle.SNOWBALL, this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.SNOWBALL, this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } if (!this.world.isClientSide) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTNTPrimed.java index 4874dbc..4b82987 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit public class EntityTNTPrimed extends Entity { @@ -90,7 +91,7 @@ public class EntityTNTPrimed extends Entity { // CraftBukkit end } else { this.W(); - this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTameableAnimal.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTameableAnimal.java index 1cc087d..15b4598 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTameableAnimal.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTameableAnimal.java @@ -1,5 +1,8 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; +import com.elevatemc.spigot.util.Constants; + import java.util.UUID; public abstract class EntityTameableAnimal extends EntityAnimal implements EntityOwnable { @@ -61,7 +64,7 @@ public abstract class EntityTameableAnimal extends EntityAnimal implements Entit double d1 = this.random.nextGaussian() * 0.02D; double d2 = this.random.nextGaussian() * 0.02D; - this.world.addParticle(enumparticle, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2, new int[0]); + this.world.addParticle(enumparticle, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2, Constants.EMPTY_ARRAY); } } @@ -109,7 +112,7 @@ public abstract class EntityTameableAnimal extends EntityAnimal implements Entit public EntityLiving getOwner() { try { - UUID uuid = UUID.fromString(this.getOwnerUUID()); + UUID uuid = FastUUID.parseUUID(this.getOwnerUUID()); return uuid == null ? null : this.world.b(uuid); } catch (IllegalArgumentException illegalargumentexception) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTracker.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTracker.java index ef704e7..95bb657 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTracker.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTracker.java @@ -3,6 +3,7 @@ package net.minecraft.server; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.concurrent.Callable; @@ -265,6 +266,11 @@ public class EntityTracker { else TASK_EXECUTOR.submit(task); } + public Iterator getEntityTrackerEntries() + { + return this.c.iterator(); + } + public void a(EntityPlayer entityplayer, Chunk chunk) { Task task = executor -> { for (EntityTrackerEntry entitytrackerentry : this.c) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTrackerEntry.java index 89d69de..1073364 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -3,7 +3,7 @@ package net.minecraft.server; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import com.elevatemc.spigot.eSpigotFeature; +import com.elevatemc.spigot.config.eSpigotConfig; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -273,7 +273,7 @@ public class EntityTrackerEntry { DataWatcher datawatcher = this.tracker.getDataWatcher(); if (datawatcher.a()) { - if (eSpigotFeature.OBFUSCATE_HEALTH.isEnabled() && this.tracker instanceof EntityHuman) { + if (eSpigotConfig.obfuscatePlayerHealth && this.tracker instanceof EntityHuman) { List changedMetadata = datawatcher.c(); Iterator iter = changedMetadata.iterator(); boolean found = false; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityWitch.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityWitch.java index d59d779..2824a1e 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityWitch.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityWitch.java @@ -1,12 +1,14 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; + import java.util.Iterator; import java.util.List; import java.util.UUID; public class EntityWitch extends EntityMonster implements IRangedEntity { - private static final UUID a = UUID.fromString("5CD17E52-A79A-43D3-A529-90FDE04B181E"); + private static final UUID a = FastUUID.parseUUID("5CD17E52-A79A-43D3-A529-90FDE04B181E"); private static final AttributeModifier b = (new AttributeModifier(EntityWitch.a, "Drinking speed penalty", -0.25D, 0)).a(false); private static final Item[] c = new Item[] { Items.GLOWSTONE_DUST, Items.SUGAR, Items.REDSTONE, Items.SPIDER_EYE, Items.GLASS_BOTTLE, Items.GUNPOWDER, Items.STICK, Items.STICK}; private int bm; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityWither.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityWither.java index d8e3b65..a5c9dea 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityWither.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityWither.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import java.util.Iterator; @@ -154,15 +155,15 @@ public class EntityWither extends EntityMonster implements IRangedEntity { double d9 = this.u(j); double d10 = this.v(j); - this.world.addParticle(EnumParticle.SMOKE_NORMAL, d8 + this.random.nextGaussian() * 0.30000001192092896D, d9 + this.random.nextGaussian() * 0.30000001192092896D, d10 + this.random.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.SMOKE_NORMAL, d8 + this.random.nextGaussian() * 0.30000001192092896D, d9 + this.random.nextGaussian() * 0.30000001192092896D, d10 + this.random.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); if (flag && this.world.random.nextInt(4) == 0) { - this.world.addParticle(EnumParticle.SPELL_MOB, d8 + this.random.nextGaussian() * 0.30000001192092896D, d9 + this.random.nextGaussian() * 0.30000001192092896D, d10 + this.random.nextGaussian() * 0.30000001192092896D, 0.699999988079071D, 0.699999988079071D, 0.5D, new int[0]); + this.world.addParticle(EnumParticle.SPELL_MOB, d8 + this.random.nextGaussian() * 0.30000001192092896D, d9 + this.random.nextGaussian() * 0.30000001192092896D, d10 + this.random.nextGaussian() * 0.30000001192092896D, 0.699999988079071D, 0.699999988079071D, 0.5D, Constants.EMPTY_ARRAY); } } if (this.cl() > 0) { for (j = 0; j < 3; ++j) { - this.world.addParticle(EnumParticle.SPELL_MOB, this.locX + this.random.nextGaussian() * 1.0D, this.locY + (double) (this.random.nextFloat() * 3.3F), this.locZ + this.random.nextGaussian() * 1.0D, 0.699999988079071D, 0.699999988079071D, 0.8999999761581421D, new int[0]); + this.world.addParticle(EnumParticle.SPELL_MOB, this.locX + this.random.nextGaussian() * 1.0D, this.locY + (double) (this.random.nextFloat() * 3.3F), this.locZ + this.random.nextGaussian() * 1.0D, 0.699999988079071D, 0.699999988079071D, 0.8999999761581421D, Constants.EMPTY_ARRAY); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityWolf.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityWolf.java index ae0a219..7fe0268 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityWolf.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityWolf.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.base.Predicate; // CraftBukkit start @@ -183,7 +184,7 @@ public class EntityWolf extends EntityTameableAnimal { float f1 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; float f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; - this.world.addParticle(EnumParticle.WATER_SPLASH, this.locX + (double) f1, f + 0.8F, this.locZ + (double) f2, this.motX, this.motY, this.motZ, new int[0]); + this.world.addParticle(EnumParticle.WATER_SPLASH, this.locX + (double) f1, f + 0.8F, this.locZ + (double) f2, this.motX, this.motY, this.motZ, Constants.EMPTY_ARRAY); } } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EntityZombie.java b/eSpigot-Server/src/main/java/net/minecraft/server/EntityZombie.java index a7daf95..a05bec1 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EntityZombie.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EntityZombie.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.UUID; //CraftBukkit start +import com.eatthepath.uuid.FastUUID; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustEvent; @@ -14,7 +15,7 @@ import org.bukkit.event.entity.EntityTargetEvent; public class EntityZombie extends EntityMonster { protected static final IAttribute a = (new AttributeRanged(null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); - private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); + private static final UUID b = FastUUID.parseUUID("B9766B59-9566-4402-BC1F-2EE2A276D836"); private static final AttributeModifier c = new AttributeModifier(EntityZombie.b, "Baby speed boost", org.github.paperspigot.PaperSpigotConfig.babyZombieMovementSpeed, 1); // PaperSpigot - Configurable baby zombie movement speed private final PathfinderGoalBreakDoor bm = new PathfinderGoalBreakDoor(this); private int bn; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/EnumDirection.java b/eSpigot-Server/src/main/java/net/minecraft/server/EnumDirection.java index 938769b..496b1aa 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/EnumDirection.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/EnumDirection.java @@ -20,9 +20,10 @@ public enum EnumDirection implements INamable { private final BaseBlockPosition m; private static final EnumDirection[] n = new EnumDirection[6]; private static final EnumDirection[] o = new EnumDirection[4]; + private static final EnumDirection[] ALL = EnumDirection.values(); private static final Map p = Maps.newHashMap(); - private EnumDirection(int i, int j, int k, String s, EnumDirection.EnumAxisDirection enumdirection_enumaxisdirection, EnumDirection.EnumAxis enumdirection_enumaxis, BaseBlockPosition baseblockposition) { + EnumDirection(int i, int j, int k, String s, EnumDirection.EnumAxisDirection enumdirection_enumaxisdirection, EnumDirection.EnumAxis enumdirection_enumaxis, BaseBlockPosition baseblockposition) { this.g = i; this.i = k; this.h = j; @@ -45,42 +46,34 @@ public enum EnumDirection implements INamable { } public EnumDirection opposite() { - return fromType1(this.h); + return ALL[this.h]; } public EnumDirection e() { - switch (EnumDirection.SyntheticClass_1.b[this.ordinal()]) { - case 1: - return EnumDirection.EAST; - - case 2: - return EnumDirection.SOUTH; - - case 3: - return EnumDirection.WEST; - - case 4: - return EnumDirection.NORTH; - + switch(this) { + case NORTH: + return EAST; + case EAST: + return SOUTH; + case SOUTH: + return WEST; + case WEST: + return NORTH; default: throw new IllegalStateException("Unable to get Y-rotated facing of " + this); } } public EnumDirection f() { - switch (EnumDirection.SyntheticClass_1.b[this.ordinal()]) { - case 1: - return EnumDirection.WEST; - - case 2: - return EnumDirection.NORTH; - - case 3: - return EnumDirection.EAST; - - case 4: - return EnumDirection.SOUTH; - + switch(this) { + case NORTH: + return WEST; + case EAST: + return NORTH; + case SOUTH: + return EAST; + case WEST: + return SOUTH; default: throw new IllegalStateException("Unable to get CCW facing of " + this); } @@ -119,7 +112,7 @@ public enum EnumDirection implements INamable { } public static EnumDirection a(Random random) { - return values()[random.nextInt(values().length)]; + return ALL[random.nextInt(ALL.length)]; } public String toString() { @@ -131,11 +124,10 @@ public enum EnumDirection implements INamable { } public static EnumDirection a(EnumDirection.EnumAxisDirection enumdirection_enumaxisdirection, EnumDirection.EnumAxis enumdirection_enumaxis) { - EnumDirection[] aenumdirection = values(); - int i = aenumdirection.length; + int i = ALL.length; for (int j = 0; j < i; ++j) { - EnumDirection enumdirection = aenumdirection[j]; + EnumDirection enumdirection = ALL[j]; if (enumdirection.c() == enumdirection_enumaxisdirection && enumdirection.k() == enumdirection_enumaxis) { return enumdirection; @@ -146,11 +138,10 @@ public enum EnumDirection implements INamable { } static { - EnumDirection[] aenumdirection = values(); - int i = aenumdirection.length; + int i = ALL.length; for (int j = 0; j < i; ++j) { - EnumDirection enumdirection = aenumdirection[j]; + EnumDirection enumdirection = ALL[j]; EnumDirection.n[enumdirection.g] = enumdirection; if (enumdirection.k().c()) { @@ -162,102 +153,20 @@ public enum EnumDirection implements INamable { } - static class SyntheticClass_1 { - - static final int[] a; - static final int[] b; - static final int[] c = new int[EnumDirection.EnumDirectionLimit.values().length]; - - static { - try { - EnumDirection.SyntheticClass_1.c[EnumDirection.EnumDirectionLimit.HORIZONTAL.ordinal()] = 1; - } catch (NoSuchFieldError nosuchfielderror) { - ; - } - - try { - EnumDirection.SyntheticClass_1.c[EnumDirection.EnumDirectionLimit.VERTICAL.ordinal()] = 2; - } catch (NoSuchFieldError nosuchfielderror1) { - ; - } - - b = new int[EnumDirection.values().length]; - - try { - EnumDirection.SyntheticClass_1.b[EnumDirection.NORTH.ordinal()] = 1; - } catch (NoSuchFieldError nosuchfielderror2) { - ; - } - - try { - EnumDirection.SyntheticClass_1.b[EnumDirection.EAST.ordinal()] = 2; - } catch (NoSuchFieldError nosuchfielderror3) { - ; - } - - try { - EnumDirection.SyntheticClass_1.b[EnumDirection.SOUTH.ordinal()] = 3; - } catch (NoSuchFieldError nosuchfielderror4) { - ; - } - - try { - EnumDirection.SyntheticClass_1.b[EnumDirection.WEST.ordinal()] = 4; - } catch (NoSuchFieldError nosuchfielderror5) { - ; - } - - try { - EnumDirection.SyntheticClass_1.b[EnumDirection.UP.ordinal()] = 5; - } catch (NoSuchFieldError nosuchfielderror6) { - ; - } - - try { - EnumDirection.SyntheticClass_1.b[EnumDirection.DOWN.ordinal()] = 6; - } catch (NoSuchFieldError nosuchfielderror7) { - ; - } - - a = new int[EnumDirection.EnumAxis.values().length]; - - try { - EnumDirection.SyntheticClass_1.a[EnumDirection.EnumAxis.X.ordinal()] = 1; - } catch (NoSuchFieldError nosuchfielderror8) { - ; - } - - try { - EnumDirection.SyntheticClass_1.a[EnumDirection.EnumAxis.Y.ordinal()] = 2; - } catch (NoSuchFieldError nosuchfielderror9) { - ; - } - - try { - EnumDirection.SyntheticClass_1.a[EnumDirection.EnumAxis.Z.ordinal()] = 3; - } catch (NoSuchFieldError nosuchfielderror10) { - ; - } - - } - } - - public static enum EnumDirectionLimit implements Predicate, Iterable { + public enum EnumDirectionLimit implements Predicate, Iterable { HORIZONTAL, VERTICAL; - private EnumDirectionLimit() {} + EnumDirectionLimit() {} public EnumDirection[] a() { - switch (EnumDirection.SyntheticClass_1.c[this.ordinal()]) { - case 1: - return new EnumDirection[] { EnumDirection.NORTH, EnumDirection.EAST, EnumDirection.SOUTH, EnumDirection.WEST}; - - case 2: - return new EnumDirection[] { EnumDirection.UP, EnumDirection.DOWN}; - + switch(this) { + case HORIZONTAL: + return new EnumDirection[]{EnumDirection.NORTH, EnumDirection.EAST, EnumDirection.SOUTH, EnumDirection.WEST}; + case VERTICAL: + return new EnumDirection[]{EnumDirection.UP, EnumDirection.DOWN}; default: - throw new Error("Someone\'s been tampering with the universe!"); + throw new Error("Someone's been tampering with the universe!"); } } @@ -280,7 +189,7 @@ public enum EnumDirection implements INamable { } } - public static enum EnumAxisDirection { + public enum EnumAxisDirection { POSITIVE(1, "Towards positive"), NEGATIVE(-1, "Towards negative"); @@ -301,7 +210,7 @@ public enum EnumDirection implements INamable { } } - public static enum EnumAxis implements Predicate, INamable { + public enum EnumAxis implements Predicate, INamable { X("x", EnumDirection.EnumDirectionLimit.HORIZONTAL), Y("y", EnumDirection.EnumDirectionLimit.VERTICAL), Z("z", EnumDirection.EnumDirectionLimit.HORIZONTAL); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/Explosion.java b/eSpigot-Server/src/main/java/net/minecraft/server/Explosion.java index 3c891d9..7608b5b 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/Explosion.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/Explosion.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.elevatemc.spigot.util.FastRandom; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -58,7 +59,7 @@ public class Explosion { Block b = world.getChunkAt((int)posX >> 4, (int)posZ >> 4).getBlockData(new BlockPosition(posX, posY, posZ)).getBlock(); // TacoSpigot - get block of the explosion - if (!this.world.tacoSpigotConfig.optimizeLiquidExplosions || !b.getMaterial().isLiquid()) { //TacoSpigot - skip calculating what blocks to blow up in water/lava + if (!this.world.paperSpigotConfig.optimizeLiquidExplosions || !b.getMaterial().isLiquid()) { //TacoSpigot - skip calculating what blocks to blow up in water/lava for (int k = 0; k < 16; ++k) { for (i = 0; i < 16; ++i) { for (j = 0; j < 16; ++j) { @@ -170,9 +171,9 @@ public class Explosion { this.world.makeSound(this.posX, this.posY, this.posZ, "random.explode", volume, (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F); // PaperSpigot end if (this.size >= 2.0F && this.b) { - this.world.addParticle(EnumParticle.EXPLOSION_HUGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_HUGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } else { - this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } Iterator iterator; @@ -248,8 +249,8 @@ public class Explosion { d3 *= d7; d4 *= d7; d5 *= d7; - this.world.addParticle(EnumParticle.EXPLOSION_NORMAL, (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D, (d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5, new int[0]); - this.world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]); + this.world.addParticle(EnumParticle.EXPLOSION_NORMAL, (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D, (d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5, Constants.EMPTY_ARRAY); + this.world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, Constants.EMPTY_ARRAY); } if (block.getMaterial() != Material.AIR) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileBanEntry.java b/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileBanEntry.java index daa1bc3..0ebab11 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileBanEntry.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileBanEntry.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import java.util.Date; @@ -36,7 +37,7 @@ public class GameProfileBanEntry extends ExpirableListEntry { String s = jsonobject.get("uuid").getAsString(); try { - uuid = UUID.fromString(s); + uuid = FastUUID.parseUUID(s); } catch (Throwable ignored) { } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileSerializer.java b/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileSerializer.java index 998cf70..d8d084f 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileSerializer.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/GameProfileSerializer.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import java.util.Iterator; @@ -25,7 +26,7 @@ public final class GameProfileSerializer { UUID uuid; try { - uuid = UUID.fromString(s1); + uuid = FastUUID.parseUUID(s1); } catch (Throwable throwable) { uuid = null; } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/Item.java b/eSpigot-Server/src/main/java/net/minecraft/server/Item.java index 87a2d7b..d5d93e9 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/Item.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/Item.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.common.base.Function; import com.google.common.collect.HashMultimap; import com.google.common.collect.Maps; @@ -12,7 +13,7 @@ public class Item { public static final RegistryMaterials REGISTRY = new RegistryMaterials(); private static final Map a = Maps.newHashMap(); - protected static final UUID f = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); + protected static final UUID f = FastUUID.parseUUID("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); private CreativeModeTab b; protected static Random g = new Random(); protected int maxStackSize = 64; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/ItemBucket.java b/eSpigot-Server/src/main/java/net/minecraft/server/ItemBucket.java index 080d79c..1f0f3fe 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/ItemBucket.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/ItemBucket.java @@ -1,6 +1,7 @@ package net.minecraft.server; // CraftBukkit start +import com.elevatemc.spigot.util.Constants; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.player.PlayerBucketEmptyEvent; @@ -154,7 +155,7 @@ public class ItemBucket extends Item { world.makeSound((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { - world.addParticle(EnumParticle.SMOKE_LARGE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]); + world.addParticle(EnumParticle.SMOKE_LARGE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); } } else { if (!world.isClientSide && flag && !material.isLiquid()) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/ItemEnderEye.java b/eSpigot-Server/src/main/java/net/minecraft/server/ItemEnderEye.java index 8c000a1..4c4571c 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/ItemEnderEye.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/ItemEnderEye.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + public class ItemEnderEye extends Item { public ItemEnderEye() { @@ -25,7 +27,7 @@ public class ItemEnderEye extends Item { double d4 = 0.0D; double d5 = 0.0D; - world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]); + world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, Constants.EMPTY_ARRAY); } EnumDirection enumdirection1 = (EnumDirection) iblockdata.get(BlockEnderPortalFrame.FACING); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java b/eSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java index 27bf1e1..088ab6c 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java @@ -16,6 +16,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; import io.netty.handler.codec.base64.Base64; +import io.netty.util.ResourceLeakDetector; import joptsimple.OptionSet; import com.elevatemc.spigot.eSpigot; import net.minecrell.terminalconsole.TerminalConsoleAppender; @@ -176,7 +177,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs private final ThreadingManager threadingManager; public MinecraftServer(OptionSet options, Proxy proxy, File file1) { - io.netty.util.ResourceLeakDetector.setEnabled(false); // Spigot - disable + io.netty.util.ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED); // [Nacho-0040] Change deprecated Netty parameter // Spigot - disable this.e = proxy; this.threadingManager = new ThreadingManager(); MinecraftServer.l = this; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/MobEffectList.java b/eSpigot-Server/src/main/java/net/minecraft/server/MobEffectList.java index 64ed4e3..7aa27b3 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/MobEffectList.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/MobEffectList.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.common.collect.Maps; import java.util.Iterator; import java.util.Map; @@ -194,7 +195,7 @@ public class MobEffectList { } public MobEffectList a(IAttribute iattribute, String s, double d0, int i) { - AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(s), this.a(), d0, i); + AttributeModifier attributemodifier = new AttributeModifier(FastUUID.parseUUID(s), this.a(), d0, i); this.J.put(iattribute, attributemodifier); return this; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/eSpigot-Server/src/main/java/net/minecraft/server/MobSpawnerAbstract.java index 3774b3a..90dd3b4 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/MobSpawnerAbstract.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/MobSpawnerAbstract.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.collect.Lists; import java.util.Iterator; import java.util.List; @@ -75,8 +76,8 @@ public abstract class MobSpawnerAbstract { double d2 = (float) blockposition.getY() + this.a().random.nextFloat(); d0 = (float) blockposition.getZ() + this.a().random.nextFloat(); - this.a().addParticle(EnumParticle.SMOKE_NORMAL, d1, d2, d0, 0.0D, 0.0D, 0.0D, new int[0]); - this.a().addParticle(EnumParticle.FLAME, d1, d2, d0, 0.0D, 0.0D, 0.0D, new int[0]); + this.a().addParticle(EnumParticle.SMOKE_NORMAL, d1, d2, d0, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); + this.a().addParticle(EnumParticle.FLAME, d1, d2, d0, 0.0D, 0.0D, 0.0D, Constants.EMPTY_ARRAY); if (this.spawnDelay > 0) { this.spawnDelay -= tickDelay; // PaperSpigot } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagCompound.java b/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagCompound.java index 7239bf2..0b59e4a 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagCompound.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagCompound.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -201,7 +203,7 @@ public class NBTTagCompound extends NBTBase { public int[] getIntArray(String s) { try { - return !this.hasKeyOfType(s, 11) ? new int[0] : ((NBTTagIntArray) this.map.get(s)).c(); + return !this.hasKeyOfType(s, 11) ? Constants.EMPTY_ARRAY : ((NBTTagIntArray) this.map.get(s)).c(); } catch (ClassCastException classcastexception) { throw new ReportedException(this.a(s, 11, classcastexception)); } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagList.java b/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagList.java index 45ea25d..9ae5401 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagList.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/NBTTagList.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; import com.google.common.collect.Lists; import java.io.DataInput; import java.io.DataOutput; @@ -131,9 +132,9 @@ public class NBTTagList extends NBTBase { if (i >= 0 && i < this.list.size()) { NBTBase nbtbase = this.list.get(i); - return nbtbase.getTypeId() == 11 ? ((NBTTagIntArray) nbtbase).c() : new int[0]; + return nbtbase.getTypeId() == 11 ? ((NBTTagIntArray) nbtbase).c() : Constants.EMPTY_ARRAY; } else { - return new int[0]; + return Constants.EMPTY_ARRAY; } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/NameReferencingFileConverter.java b/eSpigot-Server/src/main/java/net/minecraft/server/NameReferencingFileConverter.java index 959b895..cdd63db 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/NameReferencingFileConverter.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/NameReferencingFileConverter.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.common.base.Charsets; import com.google.common.base.Predicate; import com.google.common.collect.Iterators; @@ -330,7 +331,7 @@ public class NameReferencingFileConverter { if (uuid == null) { throw new NameReferencingFileConverter.FileConversionException("Missing UUID for user profile " + gameprofile.getName(), null); } else { - this.a(file, this.a(gameprofile), uuid.toString()); + this.a(file, this.a(gameprofile), FastUUID.toString(uuid)); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/NetworkManager.java b/eSpigot-Server/src/main/java/net/minecraft/server/NetworkManager.java index 468734c..478fbc6 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/NetworkManager.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/NetworkManager.java @@ -126,16 +126,6 @@ public class NetworkManager extends SimpleChannelInboundHandler { super.channelActive(channelhandlercontext); this.channel = channelhandlercontext.channel(); this.l = this.channel.remoteAddress(); - // eSpigot start - ChannelConfig config = this.channel.config(); - config.setOption(ChannelOption.SO_KEEPALIVE, true); - config.setOption(ChannelOption.TCP_NODELAY, true); - config.setOption(ChannelOption.TCP_FASTOPEN, 1); - config.setOption(ChannelOption.TCP_FASTOPEN_CONNECT, true); - config.setOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); - config.setOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024)); - config.setOption(ChannelOption.IP_TOS, 0x18); - // eSpigot end // Spigot Start this.preparing = false; diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/OpListEntry.java b/eSpigot-Server/src/main/java/net/minecraft/server/OpListEntry.java index 6fb9fef..e339110 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/OpListEntry.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/OpListEntry.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import java.util.UUID; @@ -46,7 +47,7 @@ public class OpListEntry extends JsonListEntry { UUID uuid; try { - uuid = UUID.fromString(s); + uuid = FastUUID.parseUUID(s); } catch (Throwable throwable) { return null; } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/PacketLoginOutSuccess.java b/eSpigot-Server/src/main/java/net/minecraft/server/PacketLoginOutSuccess.java index c811dd6..9dcc9aa 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/PacketLoginOutSuccess.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/PacketLoginOutSuccess.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.mojang.authlib.GameProfile; import java.io.IOException; import java.util.UUID; @@ -17,7 +18,7 @@ public class PacketLoginOutSuccess implements Packet { public void a(PacketDataSerializer packetdataserializer) throws IOException { String s = packetdataserializer.c(36); String s1 = packetdataserializer.c(16); - UUID uuid = UUID.fromString(s); + UUID uuid = FastUUID.parseUUID(s); this.a = new GameProfile(uuid, s1); } @@ -25,7 +26,7 @@ public class PacketLoginOutSuccess implements Packet { public void b(PacketDataSerializer packetdataserializer) throws IOException { UUID uuid = this.a.getId(); - packetdataserializer.a(uuid == null ? "" : uuid.toString()); + packetdataserializer.a(uuid == null ? "" : FastUUID.toString(uuid)); packetdataserializer.a(this.a.getName()); } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java b/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java index 4dfb6c0..993d853 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java @@ -14,6 +14,10 @@ public class PacketPlayInCloseWindow implements Packet { } // CraftBukkit end + public int getId() { + return id; + } + public void a(PacketListenerPlayIn packetlistenerplayin) { packetlistenerplayin.a(this); } @@ -26,3 +30,4 @@ public class PacketPlayInCloseWindow implements Packet { packetdataserializer.writeByte(this.id); } } + diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java index 4336f65..f5c97c1 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java @@ -19,7 +19,7 @@ public class PacketPlayOutMapChunk implements Packet { this.b = chunk.locZ; this.d = flag; this.c = chunk.getChunkMap(flag, i); // PaperSpigot - chunk.world.spigotConfig.antiXrayInstance.obfuscateSync(chunk.locX, chunk.locZ, c.b, c.a, chunk.world); + chunk.world.spigotConfig.antiXrayInstance.obfuscate(chunk.locX, chunk.locZ, c.b, c.a, chunk.world); } public void a(PacketDataSerializer packetdataserializer) throws IOException { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java b/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java index 8227519..e276fd6 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java @@ -23,11 +23,11 @@ public class PacketPlayOutMapChunkBulk implements Packet for (int j = 0; j < i; ++j) { Chunk chunk = list.get(j); - PacketPlayOutMapChunk.ChunkMap packetplayoutmapchunk_chunkmap = chunk.getChunkMap(true, '\uffff'); // PaperSpigot + PacketPlayOutMapChunk.ChunkMap map = chunk.getChunkMap(true, '\uffff'); // PaperSpigot this.a[j] = chunk.locX; this.b[j] = chunk.locZ; - this.c[j] = packetplayoutmapchunk_chunkmap; + this.c[j] = map; } world = list.get(0).getWorld(); // Spigot diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalBreed.java b/eSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalBreed.java index 897696f..4d7fa9e 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalBreed.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalBreed.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.util.Constants; + import java.util.Iterator; import java.util.List; import java.util.Random; @@ -104,7 +106,7 @@ public class PathfinderGoalBreed extends PathfinderGoal { double d4 = 0.5D + random.nextDouble() * (double) this.d.length; double d5 = random.nextDouble() * (double) this.d.width * 2.0D - (double) this.d.width; - this.a.addParticle(EnumParticle.HEART, this.d.locX + d3, this.d.locY + d4, this.d.locZ + d5, d0, d1, d2, new int[0]); + this.a.addParticle(EnumParticle.HEART, this.d.locX + d3, this.d.locY + d4, this.d.locZ + d5, d0, d1, d2, Constants.EMPTY_ARRAY); } if (this.a.getGameRules().getBoolean("doMobLoot")) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java b/eSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java index 703f6ed..fc2dfdc 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/PlayerConnection.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.config.eSpigotConfig; import com.elevatemc.spigot.eSpigot; import com.elevatemc.spigot.handler.MovementHandler; import com.elevatemc.spigot.handler.PacketHandler; @@ -67,7 +68,6 @@ import co.aikar.timings.SpigotTimings; // Spigot // CraftBukkit end import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot -import com.elevatemc.spigot.eSpigotFeature; public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerListBox { @@ -636,7 +636,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList return; case 3: // RELEASE_USE_ITEM - if (eSpigotFeature.FIX_SPRINT_EAT_EXPLOIT.isEnabled()) + if (eSpigotConfig.fixSprintEatExploit) this.player.bU(); // eSpigot - Patch eat while running glitch this.player.setSprinting(true); @@ -1541,9 +1541,11 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList if (this.player.dead) return; // CraftBukkit PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.u()); - CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit - - this.player.p(); + // Nacho: only fire InventoryCloseEvent if inventory is open + if (packetplayinclosewindow.getId() == player.activeContainer.windowId) { + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit + this.player.p(); + } } public void a(PacketPlayInWindowClick packetplayinwindowclick) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/PlayerList.java b/eSpigot-Server/src/main/java/net/minecraft/server/PlayerList.java index 39f90e3..dbfaee6 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/PlayerList.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/PlayerList.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; +import com.elevatemc.spigot.config.eSpigotConfig; import com.elevatemc.spigot.console.PandaConsoleCommandSender; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -9,14 +11,8 @@ import io.netty.buffer.Unpooled; import java.io.File; import java.net.SocketAddress; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; -import com.elevatemc.spigot.eSpigotFeature; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -57,6 +53,7 @@ public abstract class PlayerList { private final GameProfileBanList k; private final IpBanList l; private final OpList operators; + private Set fastOperator = new HashSet<>(); private final WhiteList whitelist; private final Map o; public IPlayerFileData playerFileData; @@ -79,6 +76,9 @@ public abstract class PlayerList { this.k = new GameProfileBanList(PlayerList.a); this.l = new IpBanList(PlayerList.b); this.operators = new OpList(PlayerList.c); + for (OpListEntry value : this.operators.getValues()) { + this.fastOperator.add(value.getKey().getId()); + } this.whitelist = new WhiteList(PlayerList.d); this.o = Maps.newHashMap(); this.server = minecraftserver; @@ -328,11 +328,11 @@ public abstract class PlayerList { for (EntityPlayer player : this.players) { EntityPlayer entityplayer1 = player; - if (eSpigotFeature.SHOW_HIDDEN_PLAYERS_IN_TAB.isEnabled() || entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { + if (eSpigotConfig.showHiddenPlayersInTab || entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { entityplayer1.playerConnection.sendPacket(packet); } - if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity()) && !eSpigotFeature.SHOW_HIDDEN_PLAYERS_IN_TAB.isEnabled()) { + if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity()) && !eSpigotConfig.showHiddenPlayersInTab) { continue; } @@ -1020,6 +1020,7 @@ public abstract class PlayerList { public void addOp(GameProfile gameprofile) { this.operators.add(new OpListEntry(gameprofile, this.server.p(), this.operators.b(gameprofile))); + this.fastOperator.add(gameprofile.getId()); // CraftBukkit start Player player = server.server.getPlayer(gameprofile.getId()); @@ -1031,6 +1032,7 @@ public abstract class PlayerList { public void removeOp(GameProfile gameprofile) { this.operators.remove(gameprofile); + this.fastOperator.remove(gameprofile.getId()); // CraftBukkit start Player player = server.server.getPlayer(gameprofile.getId()); @@ -1041,11 +1043,11 @@ public abstract class PlayerList { } public boolean isWhitelisted(GameProfile gameprofile) { - return !this.hasWhitelist || this.operators.d(gameprofile) || this.whitelist.d(gameprofile); + return !this.hasWhitelist || this.fastOperator.contains(gameprofile.getId()) || this.whitelist.d(gameprofile); } public boolean isOp(GameProfile gameprofile) { - return this.operators.d(gameprofile) || this.server.T() && this.server.worlds.get(0).getWorldData().v() && this.server.S().equalsIgnoreCase(gameprofile.getName()) || this.t; // CraftBukkit + return this.fastOperator.contains(gameprofile.getId()) || this.server.T() && this.server.worlds.get(0).getWorldData().v() && this.server.S().equalsIgnoreCase(gameprofile.getName()) || this.t; // CraftBukkit } public EntityPlayer getPlayer(String s) { @@ -1057,6 +1059,7 @@ public abstract class PlayerList { } public void sendPacketNearby(EntityHuman entityhuman, double d0, double d1, double d2, double d3, int i, Packet packet) { + double squared = d3 * d3; for (EntityPlayer player : this.players) { EntityPlayer entityplayer = player; @@ -1071,7 +1074,7 @@ public abstract class PlayerList { double d5 = d1 - entityplayer.locY; double d6 = d2 - entityplayer.locZ; - if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) { + if (d4 * d4 + d5 * d5 + d6 * d6 < squared) { entityplayer.playerConnection.sendPacket(packet); } } @@ -1249,7 +1252,7 @@ public abstract class PlayerList { if (serverstatisticmanager == null) { File file = new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "stats"); - File file1 = new File(file, uuid.toString() + ".json"); + File file1 = new File(file, FastUUID.toString(uuid) + ".json"); if (!file1.exists()) { File file2 = new File(file, entityhuman.getName() + ".json"); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/ServerConnection.java b/eSpigot-Server/src/main/java/net/minecraft/server/ServerConnection.java index c32f4e7..1065937 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/ServerConnection.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/ServerConnection.java @@ -4,12 +4,8 @@ import com.google.common.collect.Lists; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.velocitypowered.natives.util.Natives; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.Channel; -import io.netty.channel.ChannelException; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; +import io.netty.buffer.PooledByteBufAllocator; +import io.netty.channel.*; import io.netty.channel.epoll.Epoll; import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollServerSocketChannel; @@ -92,17 +88,24 @@ public class ServerConnection { Class oclass; LazyInitVar lazyinitvar; - if (Epoll.isAvailable() && this.f.ai()) { - // PandaSpigot start - Unix domain socket support - if (address instanceof io.netty.channel.unix.DomainSocketAddress) { - oclass = io.netty.channel.epoll.EpollServerDomainSocketChannel.class; + try { + if (Epoll.isAvailable() && this.f.ai()) { + // PandaSpigot start - Unix domain socket support + if (address instanceof io.netty.channel.unix.DomainSocketAddress) { + oclass = io.netty.channel.epoll.EpollServerDomainSocketChannel.class; + } else { + oclass = EpollServerSocketChannel.class; + } + // PandaSpigot end + lazyinitvar = ServerConnection.b; + ServerConnection.e.info("Using epoll channel type"); } else { - oclass = EpollServerSocketChannel.class; + oclass = NioServerSocketChannel.class; + lazyinitvar = ServerConnection.a; + ServerConnection.e.info("Using default channel type"); } - // PandaSpigot end - lazyinitvar = ServerConnection.b; - ServerConnection.e.info("Using epoll channel type"); - } else { + } catch (Exception e) { + ServerConnection.e.warn("An error occurred trying to check if Epoll is available, falling back to default channel type."); oclass = NioServerSocketChannel.class; lazyinitvar = ServerConnection.a; ServerConnection.e.info("Using default channel type"); @@ -115,11 +118,6 @@ public class ServerConnection { this.g.add((new ServerBootstrap()).channel(oclass).childHandler(new ChannelInitializer() { protected void initChannel(Channel channel) throws Exception { - try { - channel.config().setOption(ChannelOption.TCP_NODELAY, Boolean.TRUE); - } catch (ChannelException ignored) { - } - // KigPaper start if(PaperSpigotConfig.nettyReadTimeout) channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30)); // KigPaper end diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/ServerPing.java b/eSpigot-Server/src/main/java/net/minecraft/server/ServerPing.java index eeb8100..b0d0773 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/ServerPing.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/ServerPing.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; @@ -202,7 +203,7 @@ public class ServerPing { JsonObject jsonobject1 = ChatDeserializer.l(jsonarray.get(i), "player[" + i + "]"); String s = ChatDeserializer.h(jsonobject1, "id"); - agameprofile[i] = new GameProfile(UUID.fromString(s), ChatDeserializer.h(jsonobject1, "name")); + agameprofile[i] = new GameProfile(FastUUID.parseUUID(s), ChatDeserializer.h(jsonobject1, "name")); } serverping_serverpingplayersample.a(agameprofile); @@ -224,7 +225,7 @@ public class ServerPing { JsonObject jsonobject1 = new JsonObject(); UUID uuid = serverping_serverpingplayersample.c()[i].getId(); - jsonobject1.addProperty("id", uuid == null ? "" : uuid.toString()); + jsonobject1.addProperty("id", uuid == null ? "" : FastUUID.toString(uuid)); jsonobject1.addProperty("name", serverping_serverpingplayersample.c()[i].getName()); jsonarray.add(jsonobject1); } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/SpawnerCreature.java b/eSpigot-Server/src/main/java/net/minecraft/server/SpawnerCreature.java index 530a75c..1654c79 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Random; // CraftBukkit start +import it.unimi.dsi.fastutil.objects.ObjectIterator; import org.bukkit.craftbukkit.util.LongHash; import org.bukkit.craftbukkit.util.LongHashSet; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; @@ -20,28 +21,40 @@ public final class SpawnerCreature { // Spigot start - get entity count only from chunks being processed in b private int getEntityCount(WorldServer server, Class oClass) { + // NachoSpigot start - remove Steam + int sum = 0; + for (ObjectIterator objectIterator = (server.chunkProviderServer).chunks.values().iterator(); objectIterator.hasNext(); ) { + Chunk c = objectIterator.next(); + sum += c.entityCount.get(oClass); + } + return sum; + // NachoSpigot end + + // TacoSpigot start - use entire world, not just active chunks. Spigot broke vanilla expectations. - if (true) { - return server - .chunkProviderServer - .chunks.values() - .stream() - .collect(java.util.stream.Collectors.summingInt(c -> c.entityCount.get(oClass))); - } - // TacoSpigot end - int i = 0; - Iterator it = this.b.iterator(); - while ( it.hasNext() ) - { - Long coord = it.next(); - int x = LongHash.msw( coord ); - int z = LongHash.lsw( coord ); - if ( !server.chunkProviderServer.unloadQueue.contains( coord ) && server.isChunkLoaded( x, z, true ) ) - { - i += server.getChunkAt( x, z ).entityCount.get( oClass ); - } - } - return i; +// if (true) { +// +// server.chunkProviderServer.chunks.values().iterator() +// return server +// .chunkProviderServer +// .chunks.values() +// .stream() +// .collect(java.util.stream.Collectors.summingInt(c -> c.entityCount.get(oClass))); +// } +// // TacoSpigot end +// int i = 0; +// Iterator it = this.b.iterator(); +// while ( it.hasNext() ) +// { +// Long coord = it.next(); +// int x = LongHash.msw( coord ); +// int z = LongHash.lsw( coord ); +// if ( !server.chunkProviderServer.unloadQueue.contains( coord ) && server.isChunkLoaded( x, z, true ) ) +// { +// i += server.getChunkAt( x, z ).entityCount.get( oClass ); +// } +// } +// return i; } // Spigot end diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityEnchantTable.java b/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityEnchantTable.java index e054166..77feb1f 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityEnchantTable.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityEnchantTable.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import com.elevatemc.spigot.config.eSpigotConfig; + import java.util.Random; public class TileEntityEnchantTable extends TileEntity implements IUpdatePlayerListBox, ITileEntityContainer { @@ -36,6 +38,9 @@ public class TileEntityEnchantTable extends TileEntity implements IUpdatePlayerL } public void c() { + if (!eSpigotConfig.enchantmentTableTicking) { + return; + } this.k = this.j; this.m = this.l; EntityHuman entityhuman = this.world.findNearbyPlayer((double) ((float) this.position.getX() + 0.5F), (double) ((float) this.position.getY() + 0.5F), (double) ((float) this.position.getZ() + 0.5F), 3.0D); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityFurnace.java b/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityFurnace.java index f0a7014..dd10ddc 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -350,6 +350,8 @@ public class TileEntityFurnace extends TileEntityContainer implements IUpdatePla } } + if(item == Items.COAL) return 1600; + return item instanceof ItemTool && ((ItemTool) item).h().equals("WOOD") ? 200 : (item instanceof ItemSword && ((ItemSword) item).h().equals("WOOD") ? 200 : (item instanceof ItemHoe && ((ItemHoe) item).g().equals("WOOD") ? 200 : (item == Items.STICK ? 100 : (item == Items.COAL ? 1600 : (item == Items.LAVA_BUCKET ? 20000 : (item == Item.getItemOf(Blocks.SAPLING) ? 100 : (item == Items.BLAZE_ROD ? 2400 : 0))))))); } } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityHopper.java b/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityHopper.java index a66b5a0..bb51a6b 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityHopper.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/TileEntityHopper.java @@ -202,7 +202,7 @@ public class TileEntityHopper extends TileEntityContainer implements IHopper, IU } } // PaperSpigot start - if (world.paperSpigotConfig.useHopperCheck && !world.tacoSpigotConfig.isHopperPushBased && !this.n()) { // TacoSpigot - dont use hopper check in push mode + if (world.paperSpigotConfig.useHopperCheck && !world.paperSpigotConfig.isHopperPushBased && !this.n()) { // TacoSpigot - dont use hopper check in push mode this.d(world.spigotConfig.hopperCheck); } // PaperSpigot end @@ -367,7 +367,7 @@ public class TileEntityHopper extends TileEntityContainer implements IHopper, IU @Deprecated public static boolean a(IHopper ihopper) { IInventory iinventory; - if (ihopper.getWorld().tacoSpigotConfig.isHopperPushBased && ihopper instanceof TileEntityHopper) { + if (ihopper.getWorld().paperSpigotConfig.isHopperPushBased && ihopper instanceof TileEntityHopper) { BlockPosition pos = ((TileEntityHopper) ihopper).getPosition().up(); // Only pull from a above, because everything else comes to us iinventory = HopperHelper.getInventory(ihopper.getWorld(), pos); } else { @@ -403,7 +403,7 @@ public class TileEntityHopper extends TileEntityContainer implements IHopper, IU } } } - } else if (!ihopper.getWorld().tacoSpigotConfig.isHopperPushBased || !(ihopper instanceof TileEntityHopper)) { // TacoSpigot - only search for entities in 'pull mode' + } else if (!ihopper.getWorld().paperSpigotConfig.isHopperPushBased || !(ihopper instanceof TileEntityHopper)) { // TacoSpigot - only search for entities in 'pull mode' for (EntityItem entityitem : a(ihopper.getWorld(), ihopper.A(), ihopper.B() + 1.0D, ihopper.C())) { if (a(ihopper, entityitem)) { diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/UserCache.java b/eSpigot-Server/src/main/java/net/minecraft/server/UserCache.java index 1637404..0b9ee61 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/UserCache.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/UserCache.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.common.base.Charsets; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; @@ -287,7 +288,7 @@ public class UserCache { jsonobject.addProperty("name", usercache_usercacheentry.a().getName()); UUID uuid = usercache_usercacheentry.a().getId(); - jsonobject.addProperty("uuid", uuid == null ? "" : uuid.toString()); + jsonobject.addProperty("uuid", uuid == null ? "" : FastUUID.toString(uuid)); jsonobject.addProperty("expiresOn", UserCache.a.format(usercache_usercacheentry.b())); return jsonobject; } @@ -316,7 +317,7 @@ public class UserCache { UUID uuid; try { - uuid = UUID.fromString(s); + uuid = FastUUID.parseUUID(s); } catch (Throwable throwable) { return null; } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/Village.java b/eSpigot-Server/src/main/java/net/minecraft/server/Village.java index 87e7096..390f76b 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/Village.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/Village.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import java.util.Iterator; @@ -411,7 +412,7 @@ public class Village { if (nbttagcompound2.hasKey("UUID")) { UserCache usercache = MinecraftServer.getServer().getUserCache(); - GameProfile gameprofile = usercache.a(UUID.fromString(nbttagcompound2.getString("UUID"))); + GameProfile gameprofile = usercache.a(FastUUID.parseUUID(nbttagcompound2.getString("UUID"))); if (gameprofile != null) { this.j.put(gameprofile.getName(), nbttagcompound2.getInt("S")); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/WhiteListEntry.java b/eSpigot-Server/src/main/java/net/minecraft/server/WhiteListEntry.java index 06d29a4..da93bb5 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/WhiteListEntry.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/WhiteListEntry.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.eatthepath.uuid.FastUUID; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import java.util.UUID; @@ -29,7 +30,7 @@ public class WhiteListEntry extends JsonListEntry { UUID uuid; try { - uuid = UUID.fromString(s); + uuid = FastUUID.parseUUID(s); } catch (Throwable throwable) { return null; } diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/World.java b/eSpigot-Server/src/main/java/net/minecraft/server/World.java index 81ec6c0..46238c1 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/World.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/World.java @@ -166,7 +166,6 @@ public abstract class World implements IBlockAccess { public final org.github.paperspigot.PaperSpigotWorldConfig paperSpigotConfig; // PaperSpigot public final co.aikar.timings.WorldTimingsHandler timings; // Spigot - public final net.techcable.tacospigot.TacoSpigotWorldConfig tacoSpigotConfig; // Migot start private Chunk dummyChunk = new EmptyChunk(this, Integer.MIN_VALUE, Integer.MIN_VALUE); @@ -203,9 +202,8 @@ public abstract class World implements IBlockAccess { } protected World(IDataManager idatamanager, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag, ChunkGenerator gen, org.bukkit.World.Environment env) { - this.spigotConfig = new org.spigotmc.SpigotWorldConfig( worlddata.getName() ); // Spigot - this.paperSpigotConfig = new org.github.paperspigot.PaperSpigotWorldConfig( worlddata.getName() ); // PaperSpigot - this.tacoSpigotConfig = new net.techcable.tacospigot.TacoSpigotWorldConfig(worlddata.getName()); // TacoSpigot + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(); // Spigot + this.paperSpigotConfig = new org.github.paperspigot.PaperSpigotWorldConfig(); // PaperSpigot this.generator = gen; this.world = new CraftWorld((WorldServer) this, gen, env); this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit @@ -315,6 +313,10 @@ public abstract class World implements IBlockAccess { return blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000 && blockposition.getY() >= 0 && blockposition.getY() < 256; } + private boolean isValidLocation(int blockposition_x, int blockposition_y, int blockposition_z) { + return blockposition_x >= -30000000 && blockposition_z >= -30000000 && blockposition_x < 30000000 && blockposition_z < 30000000 && blockposition_z >= 0 && blockposition_y < 256; + } + public boolean isEmpty(BlockPosition blockposition) { return this.getType(blockposition).getBlock().getMaterial() == Material.AIR; } @@ -324,6 +326,11 @@ public abstract class World implements IBlockAccess { // return this.a(blockposition, true); } + public boolean isLoaded(int blockposition_x, int blockposition_y, int blockposition_z) { + return getChunkIfLoaded(blockposition_x >> 4, blockposition_z >> 4) != null; // Paper + //return this.a(blockposition, true); + } + public boolean a(BlockPosition blockposition, boolean flag) { return this.isValidLocation(blockposition) && this.isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4, flag); } @@ -381,6 +388,10 @@ public abstract class World implements IBlockAccess { return this.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4); } + public Chunk getChunkAtWorldCoords(int blockposition_x, int blockposition_y, int blockposition_z) { + return this.getChunkAt(blockposition_x >> 4, blockposition_z >> 4); + } + // Migot start private void cacheLastChunkAccess(Chunk foundChunk) { this.lastChunkAccessed = ((foundChunk == null || foundChunk.isEmpty() || foundChunk.wasUnloaded()) ? this.dummyChunk : foundChunk); @@ -614,13 +625,14 @@ public abstract class World implements IBlockAccess { public void d(BlockPosition blockposition, final Block block) { if (!this.isClientSide) { - IBlockData iblockdata = this.getType(blockposition); + IBlockData iblockdata = this.getTypeIfLoaded(blockposition); // Nacho-0012 :: Don't load chunks for physics + if (iblockdata == null) return; // Nacho-0012 :: Don't load chunks for physics try { // CraftBukkit start CraftWorld world = this.getWorld(); // TacoSpigot start - Add config to disable redstone firing BlockPhysicsEvent - if (world != null && (this.tacoSpigotConfig.isRedstoneFireBPE || !(block instanceof BlockRedstoneWire || block instanceof BlockRedstoneTorch || block instanceof BlockRepeater)) && ((WorldServer) this).hasPhysicsEvent) { + if (world != null && (this.paperSpigotConfig.isRedstoneFireBPE || !(block instanceof BlockRedstoneWire || block instanceof BlockRedstoneTorch || block instanceof BlockRepeater)) && ((WorldServer) this).hasPhysicsEvent) { // TacoSpigot end BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block)); this.getServer().getPluginManager().callEvent(event); @@ -786,8 +798,9 @@ public abstract class World implements IBlockAccess { int i; if (blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000) { - if (this.isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4, true)) { - i = this.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4).b(blockposition.getX() & 15, blockposition.getZ() & 15); + Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); + if (chunk != null) { + i = chunk.b(blockposition.getX() & 15, blockposition.getZ() & 15); } else { i = 0; } @@ -798,13 +811,15 @@ public abstract class World implements IBlockAccess { return new BlockPosition(blockposition.getX(), i, blockposition.getZ()); } - public int b(int i, int j) { - if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) { - if (!this.isChunkLoaded(i >> 4, j >> 4, true)) { + public int b(int i, int j) + { + if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) + { + Chunk chunk = this.getChunkIfLoaded(i >> 4, j >> 4); + if (chunk != null) + { return 0; } else { - Chunk chunk = this.getChunkAt(i >> 4, j >> 4); - return chunk.v(); } } else { @@ -812,6 +827,22 @@ public abstract class World implements IBlockAccess { } } + public int b(EnumSkyBlock enumskyblock, int blockposition_x, int blockposition_y, int blockposition_z) { + if (blockposition_y < 0) { + blockposition_y = 0; + } + + if (!this.isValidLocation(blockposition_x, blockposition_y, blockposition_z)) { + return enumskyblock.c; + } else if (!this.isLoaded(blockposition_x, blockposition_y, blockposition_z)) { + return enumskyblock.c; + } else { + Chunk chunk = this.getChunkAtWorldCoords(blockposition_x, blockposition_y, blockposition_z); + + return chunk.getBrightness(enumskyblock, blockposition_x, blockposition_y, blockposition_z); + } + } + public int b(EnumSkyBlock enumskyblock, BlockPosition blockposition) { if (blockposition.getY() < 0) { blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ()); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/WorldNBTStorage.java b/eSpigot-Server/src/main/java/net/minecraft/server/WorldNBTStorage.java index 1ae0f72..9d37f24 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/WorldNBTStorage.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/WorldNBTStorage.java @@ -199,7 +199,7 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData { File file = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat"); // Spigot Start boolean usingWrongFile = false; - boolean normalFile = file.exists() && file.isFile(); // KigPaper + boolean normalFile = file.isFile(); // KigPaper if ( org.bukkit.Bukkit.getOnlineMode() && !normalFile ) // PaperSpigot - Check online mode first { file = new File( this.playerDir, UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes(StandardCharsets.UTF_8) ) + ".dat"); diff --git a/eSpigot-Server/src/main/java/net/minecraft/server/WorldServer.java b/eSpigot-Server/src/main/java/net/minecraft/server/WorldServer.java index 360aa1c..43efd56 100644 --- a/eSpigot-Server/src/main/java/net/minecraft/server/WorldServer.java +++ b/eSpigot-Server/src/main/java/net/minecraft/server/WorldServer.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import com.elevatemc.spigot.config.eSpigotConfig; import com.google.common.base.Predicate; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -19,7 +20,6 @@ import org.bukkit.craftbukkit.util.HashTreeSet; import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.weather.LightningStrikeEvent; -import com.elevatemc.spigot.eSpigotFeature; // CraftBukkit end public class WorldServer extends World implements IAsyncTaskHandler { @@ -209,7 +209,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { } this.worldProvider.m().b(); - if (eSpigotFeature.DAY_LIGHT_CYCLE.isEnabled()) { + if (eSpigotConfig.dayLightCycle) { if (this.everyoneDeeplySleeping()) { if (this.getGameRules().getBoolean("doDaylightCycle")) { long i = this.worldData.getDayTime() + 24000L; @@ -221,7 +221,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { } } - if (eSpigotFeature.NATURAL_MOB_SPAWNING.isEnabled()) { + if (eSpigotConfig.naturalMobSpawning) { // CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals long time = this.worldData.getTime(); if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) { @@ -264,7 +264,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { this.manager.flush(); timings.doChunkMap.stopTiming(); // Spigot - if (eSpigotFeature.VILLAGE_TICKING.isEnabled()) { // eSpigot - Disable village ticking + if (eSpigotConfig.villageTicking) { // eSpigot - Disable village ticking this.methodProfiler.c("village"); timings.doVillages.startTiming(); // Spigot this.villages.tick(); @@ -1151,17 +1151,15 @@ public class WorldServer extends World implements IAsyncTaskHandler { // */ if (flag != this.S()) { // Only send weather packets to those affected - for (EntityHuman player : this.players) { - if (player.world == this) { + for (EntityHuman player : this.players) + { + if (player.world == this) + { ((EntityPlayer) player).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); + ((EntityPlayer) player).updateWeather(this.o, this.p, this.q, this.r); } } } - for (EntityHuman player : this.players) { - if (player.world == this) { - ((EntityPlayer) player).updateWeather(this.o, this.p, this.q, this.r); - } - } // CraftBukkit end } diff --git a/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperHelper.java b/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperHelper.java index 630a81b..becada5 100644 --- a/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperHelper.java +++ b/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperHelper.java @@ -36,6 +36,6 @@ public class HopperHelper { } public static boolean isFireInventoryMoveItemEvent(IHopper hopper) { - return hopper.getWorld().tacoSpigotConfig.isHopperFireIMIE && InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length > 0; + return hopper.getWorld().paperSpigotConfig.isHopperFireIMIE && InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length > 0; } } diff --git a/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperPusher.java b/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperPusher.java index 214ec08..f3a3e5d 100644 --- a/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperPusher.java +++ b/eSpigot-Server/src/main/java/net/techcable/tacospigot/HopperPusher.java @@ -39,7 +39,7 @@ public interface HopperPusher { boolean acceptItem(TileEntityHopper hopper); default boolean tryPutInHopper() { - if (!getWorld().tacoSpigotConfig.isHopperPushBased) return false; + if (!getWorld().paperSpigotConfig.isHopperPushBased) return false; TileEntityHopper hopper = findHopper(); return hopper != null && hopper.canAcceptItems() && acceptItem(hopper); } diff --git a/eSpigot-Server/src/main/java/net/techcable/tacospigot/TacoSpigotConfig.java b/eSpigot-Server/src/main/java/net/techcable/tacospigot/TacoSpigotConfig.java deleted file mode 100644 index 45ed786..0000000 --- a/eSpigot-Server/src/main/java/net/techcable/tacospigot/TacoSpigotConfig.java +++ /dev/null @@ -1,106 +0,0 @@ -package net.techcable.tacospigot; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.List; -import java.util.logging.Level; - -import org.bukkit.Bukkit; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; - -import com.google.common.base.Throwables; - -public class TacoSpigotConfig { - - private static File CONFIG_FILE; - private static final String HEADER = "This is the main configuration file for TacoSpigot.\n" + "As you can see, there's tons to configure. Some options may impact gameplay, so use\n" + "with caution, and make sure you know what each option does before configuring.\n" + "\n" + "If you need help with the configuration or have any questions related to TacoSpigot,\n" + "join us at the IRC.\n" + "\n" + "IRC: #taco @ irc.spi.gt ( http://irc.spi.gt/iris/?channels=taco )\n"; - /*========================================================================*/ - static YamlConfiguration config; - static int version; - /*========================================================================*/ - - public static void init(File configFile) { - CONFIG_FILE = configFile; - config = new YamlConfiguration(); - try { - System.out.println("Loading TacoSpigot config from " + configFile.getName()); - config.load(CONFIG_FILE); - } catch (IOException ignored) { - } catch (InvalidConfigurationException ex) { - Bukkit.getLogger().log(Level.SEVERE, "Could not load taco.yml, please correct your syntax errors", ex); - throw Throwables.propagate(ex); - } - config.options().header(HEADER); - config.options().copyDefaults(true); - - version = getInt("config-version", 1); - set("config-version", 1); - readConfig(TacoSpigotConfig.class, null); - } - - static void readConfig(Class clazz, Object instance) { - for (Method method : clazz.getDeclaredMethods()) { - if (Modifier.isPrivate(method.getModifiers())) { - if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) { - try { - method.setAccessible(true); - method.invoke(instance); - } catch (InvocationTargetException ex) { - throw Throwables.propagate(ex.getCause()); - } catch (Exception ex) { - Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex); - } - } - } - } - - try { - config.save(CONFIG_FILE); - } catch (IOException ex) { - Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex); - } - } - - private static void set(String path, Object val) { - config.set(path, val); - } - - private static boolean getBoolean(String path, boolean def) { - config.addDefault(path, def); - return config.getBoolean(path, config.getBoolean(path)); - } - - private static double getDouble(String path, double def) { - config.addDefault(path, def); - return config.getDouble(path, config.getDouble(path)); - } - - private static float getFloat(String path, float def) { - config.addDefault(path, def); - return config.getFloat(path, config.getFloat(path)); - } - - private static int getInt(String path, int def) { - config.addDefault(path, def); - return config.getInt(path, config.getInt(path)); - } - - private static List getList(String path, T def) { - config.addDefault(path, def); - return config.getList(path, config.getList(path)); - } - - private static String getString(String path, String def) { - config.addDefault(path, def); - return config.getString(path, config.getString(path)); - } - - public static boolean useArraysForBlockStates; - private static void useArraysForBlockStates() { - useArraysForBlockStates = getBoolean("useArraysForBlockStates", false); - } -} diff --git a/eSpigot-Server/src/main/java/net/techcable/tacospigot/TacoSpigotWorldConfig.java b/eSpigot-Server/src/main/java/net/techcable/tacospigot/TacoSpigotWorldConfig.java index f6975ff..e69de29 100644 --- a/eSpigot-Server/src/main/java/net/techcable/tacospigot/TacoSpigotWorldConfig.java +++ b/eSpigot-Server/src/main/java/net/techcable/tacospigot/TacoSpigotWorldConfig.java @@ -1,113 +0,0 @@ -package net.techcable.tacospigot; - -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; - -public class TacoSpigotWorldConfig { - - private final String worldName; - private final YamlConfiguration config; - private boolean verbose; - - public TacoSpigotWorldConfig(String worldName) { - this.worldName = worldName; - this.config = TacoSpigotConfig.config; - init(); - } - - public void init() { - this.verbose = getBoolean("verbose", true); - - log("-------- World Settings For [" + worldName + "] --------"); - TacoSpigotConfig.readConfig(TacoSpigotWorldConfig.class, this); - } - - private void log(String s) { - if (verbose) { - Bukkit.getLogger().info(s); - } - } - - private void set(String path, Object val) { - config.set("world-settings.default." + path, val); - } - - private boolean getBoolean(String path, boolean def) { - config.addDefault("world-settings.default." + path, def); - return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path)); - } - - private double getDouble(String path, double def) { - config.addDefault("world-settings.default." + path, def); - return config.getDouble("world-settings." + worldName + "." + path, config.getDouble("world-settings.default." + path)); - } - - private int getInt(String path, int def) { - config.addDefault("world-settings.default." + path, def); - return config.getInt("world-settings." + worldName + "." + path, config.getInt("world-settings.default." + path)); - } - - private float getFloat(String path, float def) { - config.addDefault("world-settings.default." + path, def); - return config.getFloat("world-settings." + worldName + "." + path, config.getFloat("world-settings.default." + path)); - } - - private List getList(String path, T def) { - config.addDefault("world-settings.default." + path, def); - return config.getList("world-settings." + worldName + "." + path, config.getList("world-settings.default." + path)); - } - - private String getString(String path, String def) { - config.addDefault("world-settings.default." + path, def); - return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path)); - } - - public boolean isRedstoneFireBPE; - private void isRedstoneFireBPE() { - isRedstoneFireBPE = getBoolean("redstone-fire-BlockPhysicsEvent", true); - } - - public boolean isHopperPushBased; - private void isHopperPushBased() { - isHopperPushBased = getBoolean("hopper.push-based", true); - } - - public boolean isHopperFireIMIE; - private void isHopperFireIMIE() { - isHopperFireIMIE = getBoolean("hopper.fire-InventoryMoveItemEvent", true); - } - - public boolean optimizeArmorStandMovement; - private void isArmorStandMoveWithoutGravity() { - optimizeArmorStandMovement = getBoolean("armor-stand.optimize-movement", false); // Doesn't fully emulate vanilla behavior, see issue #1 - } - - public boolean nonPlayerEntitiesOnScoreboards = false; - private void nonPlayerEntitiesOnScoreboards() { - nonPlayerEntitiesOnScoreboards = getBoolean("allow-non-player-entities-on-scoreboards", false); - } - - public boolean grassIgnoresLight = false; - private void isGrassIgnoresLight() { - grassIgnoresLight = getBoolean("grass-ignores-light", false); - } - - public boolean optimizeTntMovement = false; - private void isOptimizeTnt() { - optimizeTntMovement = getBoolean("tnt.optimize-movement", false); // May not fully emulate vanilla behavior - } - public boolean optimizeLiquidExplosions = true; - private void isOptimizeLiquidExplosions() { - optimizeLiquidExplosions = getBoolean("tnt.optimize-liquid-explosions", true); // This seems like a pretty sane default - } - - public boolean fixEastWest; - private void fixEastWest() { - fixEastWest = getBoolean("fix-east-west-cannoning", false); - } - - public boolean disableFallingBlockStackingAt256; - private void DisableFallingBlockStackingAt256() { disableFallingBlockStackingAt256 = getBoolean("disable-falling-block-stacking-at-256", false);} -} diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java index 8998372..e08afce 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java @@ -24,7 +24,6 @@ public class CraftCrashReport implements Callable { value.append(' ').append(description.getFullName()).append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(','); } value.append("}\n Warnings: ").append(Bukkit.getWarningState().name()); - value.append("\n Reload Count: ").append(String.valueOf(MinecraftServer.getServer().server.reloadCount)); value.append("\n Threads: {"); for (Map.Entry entry : Thread.getAllStackTraces().entrySet()) { value.append(' ').append(entry.getKey().getState().name()).append(' ').append(entry.getKey().getName()).append(": ").append(Arrays.toString(entry.getValue())).append(','); diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index a7ab893..eb360bb 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit; +import com.eatthepath.uuid.FastUUID; import com.mojang.authlib.GameProfile; import java.io.File; import java.util.LinkedHashMap; @@ -134,7 +135,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa return Bukkit.getServer().getOfflinePlayer((String) args.get("name")); } - return Bukkit.getServer().getOfflinePlayer(UUID.fromString((String) args.get("UUID"))); + return Bukkit.getServer().getOfflinePlayer(FastUUID.parseUUID((String) args.get("UUID"))); } @Override diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index e502320..d9e81ba 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -6,6 +6,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -21,8 +22,12 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; +import javax.annotation.Nullable; import javax.imageio.ImageIO; +import com.eatthepath.uuid.FastUUID; +import com.elevatemc.spigot.config.BukkitConfig; +import com.elevatemc.spigot.config.SharedConfig; import com.elevatemc.spigot.eSpigot; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -93,6 +98,7 @@ import org.bukkit.plugin.messaging.StandardMessenger; import org.bukkit.scheduler.BukkitWorker; import org.bukkit.util.StringUtil; import org.bukkit.util.permissions.DefaultPermissions; +import org.github.paperspigot.PaperSpigotConfig; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; @@ -131,8 +137,6 @@ public final class CraftServer implements Server { protected final MinecraftServer console; protected final DedicatedPlayerList playerList; private final Map worlds = new LinkedHashMap<>(); - private YamlConfiguration configuration; - private YamlConfiguration commandsConfiguration; // KigPaper start - CVE-2017-18640 private final LoaderOptions loaderOptions = new LoaderOptions(); private final Yaml yaml = new Yaml(new SafeConstructor(), new Representer(), new DumperOptions(), loaderOptions); @@ -158,7 +162,6 @@ public final class CraftServer implements Server { private final Pattern validUserPattern = Pattern.compile("^[a-zA-Z0-9_]{2,16}$"); 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 { @@ -193,52 +196,18 @@ public final class CraftServer implements Server { getLogger().info("PandaConsole input is disabled due to --noconsole command argument"); } - configuration = YamlConfiguration.loadConfiguration(getConfigFile()); - configuration.options().copyDefaults(true); - configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8))); - ConfigurationSection legacyAlias = null; - if (!configuration.isString("aliases")) { - legacyAlias = configuration.getConfigurationSection("aliases"); - configuration.set("aliases", "now-in-commands.yml"); - } - saveConfig(); - if (getCommandsConfigFile().isFile()) { - legacyAlias = null; - } - commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile()); - commandsConfiguration.options().copyDefaults(true); - commandsConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8))); - saveCommandsConfig(); + SharedConfig.init((File) console.options.valueOf("espigot-settings")); // eSpigot - // Migrate aliases from old file and add previously implicit $1- to pass all arguments - if (legacyAlias != null) { - ConfigurationSection aliases = commandsConfiguration.createSection("aliases"); - for (String key : legacyAlias.getKeys(false)) { - ArrayList commands = new ArrayList<>(); - - if (legacyAlias.isList(key)) { - for (String command : legacyAlias.getStringList(key)) { - commands.add(command + " $1-"); - } - } else { - commands.add(legacyAlias.getString(key) + " $1-"); - } - - aliases.set(key, commands); - } - } - - saveCommandsConfig(); - overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*"); - ((SimplePluginManager) pluginManager).useTimings(configuration.getBoolean("settings.plugin-profiling")); - monsterSpawn = configuration.getInt("spawn-limits.monsters"); - animalSpawn = configuration.getInt("spawn-limits.animals"); - waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); - ambientSpawn = configuration.getInt("spawn-limits.ambient"); - console.autosavePeriod = configuration.getInt("ticks-per.autosave"); - warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); - chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); - chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); + overrideAllCommandBlockCommands = SharedConfig.config.getStringList("commands.command-block-overrides").contains("*"); + ((SimplePluginManager) pluginManager).useTimings(BukkitConfig.pluginProfiling); + monsterSpawn = BukkitConfig.monsterSpawnLimit; + animalSpawn = BukkitConfig.animalSpawnLimit; + waterAnimalSpawn = BukkitConfig.waterAnimalSpawnLimit; + ambientSpawn = BukkitConfig.ambientSpawnLimit; + console.autosavePeriod = BukkitConfig.ticksPerAutosave; + warningState = WarningState.value(BukkitConfig.deprecatedVerbose); + chunkGCPeriod = BukkitConfig.chunkGCPeriodInTicks; + chunkGCLoadThresh = BukkitConfig.chunkGCLoadThreshold; loadIcon(); // Spigot Start - Moved to old location of new DedicatedPlayerList in DedicatedServer @@ -248,31 +217,7 @@ public final class CraftServer implements Server { } public boolean getCommandBlockOverride(String command) { - return overrideAllCommandBlockCommands || commandsConfiguration.getStringList("command-block-overrides").contains(command); - } - - private File getConfigFile() { - return (File) console.options.valueOf("bukkit-settings"); - } - - private File getCommandsConfigFile() { - return (File) console.options.valueOf("commands-settings"); - } - - private void saveConfig() { - try { - configuration.save(getConfigFile()); - } catch (IOException ex) { - Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + getConfigFile(), ex); - } - } - - private void saveCommandsConfig() { - try { - commandsConfiguration.save(getCommandsConfigFile()); - } catch (IOException ex) { - Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + getCommandsConfigFile(), ex); - } + return overrideAllCommandBlockCommands || SharedConfig.config.getStringList("commands.command-block-overrides").contains(command); } public void loadPlugins() { @@ -514,7 +459,7 @@ public final class CraftServer implements Server { @Override public boolean getAllowEnd() { - return this.configuration.getBoolean("settings.allow-end"); + return BukkitConfig.allowEnd; } @Override @@ -523,11 +468,11 @@ public final class CraftServer implements Server { } public boolean getWarnOnOverload() { - return this.configuration.getBoolean("settings.warn-on-overload"); + return BukkitConfig.warnOnOverlaod; } public boolean getQueryPlugins() { - return this.configuration.getBoolean("settings.query-plugins"); + return BukkitConfig.queryPlugins; } @Override @@ -552,12 +497,12 @@ public final class CraftServer implements Server { @Override public String getUpdateFolder() { - return this.configuration.getString("settings.update-folder", "update"); + return BukkitConfig.updateFolder; } @Override public File getUpdateFolderFile() { - return new File((File) console.options.valueOf("plugins"), this.configuration.getString("settings.update-folder", "update")); + return new File((File) console.options.valueOf("plugins"), getUpdateFolder()); } @Override @@ -566,19 +511,19 @@ public final class CraftServer implements Server { if (org.spigotmc.SpigotConfig.bungee) { return -1; } else { - return this.configuration.getInt("settings.connection-throttle"); + return BukkitConfig.connectionThrottle; } // Spigot End } @Override public int getTicksPerAnimalSpawns() { - return this.configuration.getInt("ticks-per.animal-spawns"); + return BukkitConfig.ticksPerAnimalSpawn; } @Override public int getTicksPerMonsterSpawns() { - return this.configuration.getInt("ticks-per.monster-spawns"); + return BukkitConfig.ticksPerMonsterSpawn; } @Override @@ -598,7 +543,7 @@ public final class CraftServer implements Server { @Override public List getWorlds() { - return new ArrayList<>(worlds.values()); + return new ArrayList(worlds.values()); } public DedicatedPlayerList getHandle() { @@ -663,115 +608,6 @@ public final class CraftServer implements Server { return false; } - @Override - public void reload() { - reloadCount++; - configuration = YamlConfiguration.loadConfiguration(getConfigFile()); - commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile()); - PropertyManager config = new PropertyManager(console.options); - - ((DedicatedServer) console).propertyManager = config; - - boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals()); - boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).getDifficulty() != EnumDifficulty.PEACEFUL); - EnumDifficulty difficulty = EnumDifficulty.getById(config.getInt("difficulty", console.worlds.get(0).getDifficulty().ordinal())); - - online.value = config.getBoolean("online-mode", console.getOnlineMode()); - console.setSpawnAnimals(config.getBoolean("spawn-animals", console.getSpawnAnimals())); - console.setPVP(config.getBoolean("pvp", console.getPVP())); - console.setAllowFlight(config.getBoolean("allow-flight", console.getAllowFlight())); - console.setMotd(config.getString("motd", console.getMotd())); - monsterSpawn = configuration.getInt("spawn-limits.monsters"); - animalSpawn = configuration.getInt("spawn-limits.animals"); - waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); - ambientSpawn = configuration.getInt("spawn-limits.ambient"); - warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); - printSaveWarning = false; - console.autosavePeriod = configuration.getInt("ticks-per.autosave"); - chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); - chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); - loadIcon(); - - try { - playerList.getIPBans().load(); - } catch (IOException ex) { - logger.log(Level.WARNING, "Failed to load banned-ips.json, " + ex.getMessage()); - } - try { - playerList.getProfileBans().load(); - } catch (IOException ex) { - logger.log(Level.WARNING, "Failed to load banned-players.json, " + ex.getMessage()); - } - - org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot - org.github.paperspigot.PaperSpigotConfig.init((File) console.options.valueOf("paper-settings")); // PaperSpigot - net.techcable.tacospigot.TacoSpigotConfig.init((File) console.options.valueOf("taco-settings")); // TacoSpigot - for (WorldServer world : console.worlds) { - world.worldData.setDifficulty(difficulty); - world.setSpawnFlags(monsters, animals); - if (this.getTicksPerAnimalSpawns() < 0) { - world.ticksPerAnimalSpawns = 400; - } else { - world.ticksPerAnimalSpawns = this.getTicksPerAnimalSpawns(); - } - - if (this.getTicksPerMonsterSpawns() < 0) { - world.ticksPerMonsterSpawns = 1; - } else { - world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns(); - } - world.spigotConfig.init(); // Spigot - world.paperSpigotConfig.init(); // PaperSpigot - world.tacoSpigotConfig.init(); // TacoSpigot - } - - Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper - pluginManager.clearPlugins(); - commandMap.clearCommands(); - - // Paper start - for (Plugin plugin : pluginClone) { - entityMetadata.removeAll(plugin); - worldMetadata.removeAll(plugin); - playerMetadata.removeAll(plugin); - } - // Paper end - - resetRecipes(); - org.spigotmc.SpigotConfig.registerCommands(); // Spigot - org.github.paperspigot.PaperSpigotConfig.registerCommands(); // PaperSpigot - - overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*"); - - int pollCount = 0; - - // Wait for at most 2.5 seconds for plugins to close their threads - while (pollCount < 50 && getScheduler().getActiveWorkers().size() > 0) { - try { - Thread.sleep(50); - } catch (InterruptedException ignored) {} - pollCount++; - } - - List overdueWorkers = getScheduler().getActiveWorkers(); - for (BukkitWorker worker : overdueWorkers) { - Plugin plugin = worker.getOwner(); - String author = ""; - if (plugin.getDescription().getAuthors().size() > 0) { - author = plugin.getDescription().getAuthors().get(0); - } - getLogger().log(Level.SEVERE, String.format( - "Nag author: '%s' of '%s' about the following: %s", - author, - plugin.getDescription().getName(), - "This plugin is not properly shutting down its async tasks when it is being reloaded. This may cause conflicts with the newly loaded version of the plugin" - )); - } - loadPlugins(); - enablePlugins(PluginLoadOrder.STARTUP); - enablePlugins(PluginLoadOrder.POSTWORLD); - } - private void loadIcon() { icon = new CraftIconCache(null); try { @@ -786,7 +622,7 @@ public final class CraftServer implements Server { @SuppressWarnings({ "unchecked", "finally" }) private void loadCustomPermissions() { - File file = new File(configuration.getString("settings.permissions-file")); + File file = new File(BukkitConfig.permissionsFile); FileInputStream stream; try { @@ -804,7 +640,7 @@ public final class CraftServer implements Server { try { perms = yaml.load(stream); } catch (MarkedYAMLException ex) { - getLogger().log(Level.WARNING, "Server permissions file " + file + " is not valid YAML: " + ex); + getLogger().log(Level.WARNING, "Server permissions file " + file + " is not valid YAML: " + ex.toString()); return; } catch (Throwable ex) { getLogger().log(Level.WARNING, "Server permissions file " + file + " is not valid YAML.", ex); @@ -812,7 +648,7 @@ public final class CraftServer implements Server { } finally { try { stream.close(); - } catch (IOException ignored) {} + } catch (IOException ex) {} } if (perms == null) { @@ -1118,11 +954,11 @@ public final class CraftServer implements Server { Validate.notNull(config, "Config cannot be null"); DataSourceConfig ds = new DataSourceConfig(); - ds.setDriver(configuration.getString("database.driver")); - ds.setUrl(configuration.getString("database.url")); - ds.setUsername(configuration.getString("database.username")); - ds.setPassword(configuration.getString("database.password")); - ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation"))); + ds.setDriver(BukkitConfig.databaseDriver); + ds.setUrl(BukkitConfig.databaseUrl); + ds.setUsername(BukkitConfig.databaseUsername); + ds.setPassword(BukkitConfig.databasePassword); + ds.setIsolationLevel(TransactionIsolation.getLevel(BukkitConfig.databaseIsolation)); if (ds.getDriver().contains("sqlite")) { config.setDatabasePlatform(new SQLitePlatform()); @@ -1193,8 +1029,8 @@ public final class CraftServer implements Server { @Override public Map getCommandAliases() { - ConfigurationSection section = commandsConfiguration.getConfigurationSection("aliases"); - Map result = new LinkedHashMap<>(); + ConfigurationSection section = SharedConfig.config.getConfigurationSection("commands.aliases"); + Map result = new LinkedHashMap(); if (section != null) { for (String key : section.getKeys(false)) { @@ -1206,25 +1042,20 @@ public final class CraftServer implements Server { commands = ImmutableList.of(section.getString(key)); } - result.put(key, commands.toArray(new String[0])); + result.put(key, commands.toArray(new String[commands.size()])); } } return result; } - public void removeBukkitSpawnRadius() { - configuration.set("settings.spawn-radius", null); - saveConfig(); - } - public int getBukkitSpawnRadius() { - return configuration.getInt("settings.spawn-radius", -1); + return -1; } @Override public String getShutdownMessage() { - return configuration.getString("settings.shutdown-message"); + return BukkitConfig.shutdownMessage; } @Override @@ -1234,8 +1065,9 @@ public final class CraftServer implements Server { @Override public void setSpawnRadius(int value) { - configuration.set("settings.spawn-radius", value); - saveConfig(); + PropertyManager propertyManager = ((DedicatedServer) console).propertyManager; + propertyManager.setProperty("spawn-protection", value); + propertyManager.savePropertiesFile(); } @Override @@ -1255,11 +1087,11 @@ public final class CraftServer implements Server { @Override public boolean useExactLoginLocation() { - return configuration.getBoolean("settings.use-exact-login-location"); + return BukkitConfig.useExactLoginLocation; } public ChunkGenerator getGenerator(String world) { - ConfigurationSection section = configuration.getConfigurationSection("worlds"); + ConfigurationSection section = BukkitConfig.getConfigurationSection("worlds"); ChunkGenerator result = null; if (section != null) { @@ -1520,7 +1352,7 @@ public final class CraftServer implements Server { } if (container == null) { - container = new File(configuration.getString("settings.world-container", ".")); + container = new File(BukkitConfig.worldContainer); } return container; @@ -1534,7 +1366,7 @@ public final class CraftServer implements Server { for (String file : files) { try { - players.add(getOfflinePlayer(UUID.fromString(file.substring(0, file.length() - 4)))); + players.add(getOfflinePlayer(FastUUID.parseUUID(file.substring(0, file.length() - 4)))); } catch (IllegalArgumentException ex) { // Who knows what is in this directory, just ignore invalid files } @@ -1855,7 +1687,7 @@ public final class CraftServer implements Server { @Override public YamlConfiguration getBukkitConfig() { - return configuration; + return BukkitConfig.config; } @Override @@ -1898,7 +1730,7 @@ public final class CraftServer implements Server { // KigPaper start @Override public String getPermissionMessage() { - return configuration.getString("settings.permission-message", ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."); + return BukkitConfig.permissionMessage; } // KigPaper end } diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 92c0681..5c1b0e2 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit; +import com.elevatemc.spigot.util.Constants; import com.elevatemc.spigot.util.Dictionary; import com.google.common.base.Preconditions; import java.io.File; @@ -1515,7 +1516,7 @@ public class CraftWorld implements World { } if ( extra == null ) { - extra = new int[0]; + extra = Constants.EMPTY_ARRAY; } packet = new PacketPlayOutWorldParticles( particle, true, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, particleCount, extra ); } diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/Main.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/Main.java index 5ab1c08..1d8511b 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -126,29 +126,13 @@ public class Main { acceptsAll(asList("demo"), "Demo mode"); - // Spigot Start - acceptsAll(asList("S", "spigot-settings"), "File for spigot settings") + // SportPaper start + acceptsAll(asList("SP", "espigot-settings"), "File for espigot settings") .withRequiredArg() .ofType(File.class) - .defaultsTo(new File("spigot.yml")) + .defaultsTo(new File("espigot.yml")) .describedAs("Yml file"); - // Spigot End - - // PaperSpigot Start - acceptsAll(asList("paper", "paper-settings"), "File for paperspigot settings") - .withRequiredArg() - .ofType(File.class) - .defaultsTo(new File("paper.yml")) - .describedAs("Yml file"); - // PaperSpigot End - - // TacoSpigot start - acceptsAll(asList("taco", "taco-settings"), "File for tacospigot settings") - .withRequiredArg() - .ofType(File.class) - .defaultsTo(new File("taco.yml")) - .describedAs("Yml file"); - // TacoSpigot end + // SportPaper end } }; @@ -229,8 +213,7 @@ public class Main { } // Spigot End System.setProperty("library.jansi.version", "eSpigot"); // PandaSpigot - set meaningless jansi version to prevent git builds from crashing on Windows - net.techcable.tacospigot.TacoSpigotConfig.init((File) options.valueOf("taco-settings")); // TacoSpigot - load config before we load libraries to allow access while loading - System.out.println("Loading libraries, please wait..."); + System.out.println("Starting the spigot, please wait..."); MinecraftServer.main(options); } catch (Throwable t) { t.printStackTrace(); diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index 230ae9e..7dfd3f9 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.entity; +import com.eatthepath.uuid.FastUUID; import net.minecraft.server.EntityHorse; import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; @@ -117,7 +118,7 @@ public class CraftHorse extends CraftAnimals implements Horse { public UUID getOwnerUUID() { try { - return UUID.fromString(getHandle().getOwnerUUID()); + return FastUUID.parseUUID(getHandle().getOwnerUUID()); } catch (IllegalArgumentException ex) { return null; } @@ -127,7 +128,7 @@ public class CraftHorse extends CraftAnimals implements Horse { if (uuid == null) { getHandle().setOwnerUUID(""); } else { - getHandle().setOwnerUUID(uuid.toString()); + getHandle().setOwnerUUID(FastUUID.toString(uuid)); } } diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0dff03b..6aa5a2d 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1,6 +1,8 @@ package org.bukkit.craftbukkit.entity; +import com.elevatemc.spigot.config.eSpigotConfig; import com.elevatemc.spigot.event.PlayerHealthChangeEvent; +import com.elevatemc.spigot.util.Constants; import com.elevatemc.spigot.util.Dictionary; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; @@ -24,7 +26,6 @@ import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; -import com.elevatemc.spigot.eSpigotFeature; import net.md_5.bungee.api.chat.BaseComponent; import net.minecraft.server.*; @@ -999,7 +1000,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } //remove the hidden player from this player user list - if (!eSpigotFeature.SHOW_HIDDEN_PLAYERS_IN_TAB.isEnabled()) + if (!eSpigotConfig.showHiddenPlayersInTab) getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other)); } @@ -1014,7 +1015,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { EntityTracker tracker = ((WorldServer) entity.world).tracker; EntityPlayer other = ((CraftPlayer) player).getHandle(); - if (!eSpigotFeature.SHOW_HIDDEN_PLAYERS_IN_TAB.isEnabled()) + if (!eSpigotConfig.showHiddenPlayersInTab) getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId()); @@ -1536,7 +1537,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } if ( extra == null ) { - extra = new int[0]; + extra = Constants.EMPTY_ARRAY; } packet = new PacketPlayOutWorldParticles( particle, true, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, particleCount, extra ); } diff --git a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java index ea1d10b..e6d3c9a 100644 --- a/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/eSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.entity; +import com.eatthepath.uuid.FastUUID; import net.minecraft.server.EntityTameableAnimal; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.AnimalTamer; @@ -20,7 +21,7 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat public UUID getOwnerUUID() { try { - return UUID.fromString(getHandle().getOwnerUUID()); + return FastUUID.parseUUID(getHandle().getOwnerUUID()); } catch (IllegalArgumentException ex) { return null; } @@ -30,7 +31,7 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat if (uuid == null) { getHandle().setOwnerUUID(""); } else { - getHandle().setOwnerUUID(uuid.toString()); + getHandle().setOwnerUUID(FastUUID.toString(uuid)); } } diff --git a/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java index 847a456..c721f8e 100644 --- a/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java +++ b/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotConfig.java @@ -1,144 +1,61 @@ package org.github.paperspigot; -import com.google.common.base.Throwables; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; +import com.elevatemc.spigot.config.SharedConfig; import java.util.*; import java.util.logging.Level; import net.minecraft.server.Items; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.RegionFile; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.Command; -import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; public class PaperSpigotConfig { - private static File CONFIG_FILE; - private static final String HEADER = "This is the main configuration file for PaperSpigot.\n" - + "As you can see, there's tons to configure. Some options may impact gameplay, so use\n" - + "with caution, and make sure you know what each option does before configuring.\n" - + "\n" - + "If you need help with the configuration or have any questions related to PaperSpigot,\n" - + "join us at the IRC.\n" - + "\n" - + "IRC: #paperspigot @ irc.spi.gt ( http://irc.spi.gt/iris/?channels=PaperSpigot )\n"; - /*========================================================================*/ public static YamlConfiguration config; - static int version; static Map commands; - /*========================================================================*/ - public static void init(File configFile) + public static void init() { - CONFIG_FILE = configFile; - config = new YamlConfiguration(); - try - { - config.load ( CONFIG_FILE ); - } catch ( IOException ignored) - { - } catch ( InvalidConfigurationException ex ) - { - Bukkit.getLogger().log( Level.SEVERE, "Could not load paper.yml, please correct your syntax errors", ex ); - throw Throwables.propagate( ex ); - } - config.options().header( HEADER ); - config.options().copyDefaults( true ); - - commands = new HashMap<>(); - - version = getInt( "config-version", 9 ); - set( "config-version", 9 ); - readConfig( PaperSpigotConfig.class, null ); - } - - public static void registerCommands() - { - for ( Map.Entry entry : commands.entrySet() ) - { - MinecraftServer.getServer().server.getCommandMap().register( entry.getKey(), "PaperSpigot", entry.getValue() ); - } - } - - static void readConfig(Class clazz, Object instance) - { - for ( Method method : clazz.getDeclaredMethods() ) - { - if ( Modifier.isPrivate( method.getModifiers() ) ) - { - if ( method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE ) - { - try - { - method.setAccessible( true ); - method.invoke( instance ); - } catch ( InvocationTargetException ex ) - { - throw Throwables.propagate( ex.getCause() ); - } catch ( Exception ex ) - { - Bukkit.getLogger().log( Level.SEVERE, "Error invoking " + method, ex ); - } - } - } - } - - try - { - config.save( CONFIG_FILE ); - } catch ( IOException ex ) - { - Bukkit.getLogger().log( Level.SEVERE, "Could not save " + CONFIG_FILE, ex ); - } - } - - private static void set(String path, Object val) - { - config.set( path, val ); + config = SharedConfig.config; + commands = SharedConfig.commands; + SharedConfig.readConfig( PaperSpigotConfig.class, null ); } private static boolean getBoolean(String path, boolean def) { + path = "paper." + path; config.addDefault( path, def ); return config.getBoolean( path, config.getBoolean( path ) ); } private static double getDouble(String path, double def) { + path = "paper." + path; config.addDefault( path, def ); return config.getDouble( path, config.getDouble( path ) ); } - private static float getFloat(String path, float def) - { - // TODO: Figure out why getFloat() always returns the default value. - return (float) getDouble( path, def); - } - private static int getInt(String path, int def) { + path = "paper." + path; config.addDefault( path, def ); return config.getInt( path, config.getInt( path ) ); } private static List getList(String path, T def) { + path = "paper." + path; config.addDefault( path, def ); - return config.getList( path, config.getList( path ) ); + return (List) config.getList( path, config.getList( path ) ); } private static String getString(String path, String def) { + path = "paper." + path; config.addDefault( path, def ); return config.getString( path, config.getString( path ) ); } @@ -269,4 +186,9 @@ public class PaperSpigotConfig private static void regionCompressionAlgorithm() { regionCompressionAlgorithm = RegionFile.CompressionAlgorithm.valueOf(getString("region-compression-algo", "ZLIB").toUpperCase(Locale.ROOT)); } + + public static boolean useArraysForBlockStates; + public static void useArraysForBlockStates() { + useArraysForBlockStates = getBoolean("useArraysForBlockStates", false); + } } diff --git a/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java b/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java index 7398a6d..a6be096 100644 --- a/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java +++ b/eSpigot-Server/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java @@ -1,32 +1,25 @@ package org.github.paperspigot; import java.util.List; + +import com.elevatemc.spigot.config.SharedConfig; +import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; public class PaperSpigotWorldConfig { + private static YamlConfiguration config; + private static boolean verbose; - private final String worldName; - private final YamlConfiguration config; - private boolean verbose; - - public PaperSpigotWorldConfig(String worldName) + public static void init() { - this.worldName = worldName; - this.config = PaperSpigotConfig.config; - init(); + config = SharedConfig.config; + verbose = getBoolean( "verbose", true ); + SharedConfig.readConfig( PaperSpigotWorldConfig.class, null ); } - public void init() - { - this.verbose = getBoolean( "verbose", true ); - - log( "-------- World Settings For [" + worldName + "] --------" ); - PaperSpigotConfig.readConfig( PaperSpigotWorldConfig.class, this ); - } - - private void log(String s) + private static void log(String s) { if ( verbose ) { @@ -34,98 +27,93 @@ public class PaperSpigotWorldConfig } } - private void set(String path, Object val) + private static boolean getBoolean(String path, boolean def) { - config.set( "world-settings.default." + path, val ); + config.addDefault( "paper.world-settings." + path, def ); + return config.getBoolean( "paper.world-settings." + path, config.getBoolean( "paper.world-settings." + path ) ); } - private boolean getBoolean(String path, boolean def) + private static double getDouble(String path, double def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getBoolean( "world-settings." + worldName + "." + path, config.getBoolean( "world-settings.default." + path ) ); + config.addDefault( "paper.world-settings." + path, def ); + return config.getDouble( "paper.world-settings." + path, config.getDouble( "paper.world-settings." + path ) ); } - private double getDouble(String path, double def) + private static int getInt(String path, int def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getDouble( "world-settings." + worldName + "." + path, config.getDouble( "world-settings.default." + path ) ); + config.addDefault( "paper.world-settings." + path, def ); + return config.getInt( "paper.world-settings." + path, config.getInt( "paper.world-settings." + path ) ); } - private int getInt(String path, int def) - { - config.addDefault( "world-settings.default." + path, def ); - return config.getInt( "world-settings." + worldName + "." + path, config.getInt( "world-settings.default." + path ) ); - } - - private float getFloat(String path, float def) + private static float getFloat(String path, float def) { // TODO: Figure out why getFloat() always returns the default value. - return (float) getDouble( path, def); + return (float) getDouble( path, (double) def ); } - private List getList(String path, T def) + private static List getList(String path, T def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getList( "world-settings." + worldName + "." + path, config.getList( "world-settings.default." + path ) ); + config.addDefault( "paper.world-settings." + path, def ); + return (List) config.getList( "paper.world-settings." + path, config.getList( "paper.world-settings." + path ) ); } - private String getString(String path, String def) + private static String getString(String path, String def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) ); + config.addDefault( "paper.world-settings." + path, def ); + return config.getString( "paper.world-settings." + path, config.getString( "paper.world-settings." + path ) ); } - public boolean allowUndeadHorseLeashing; - private void allowUndeadHorseLeashing() + public static boolean allowUndeadHorseLeashing; + private static void allowUndeadHorseLeashing() { allowUndeadHorseLeashing = getBoolean( "allow-undead-horse-leashing", false ); log( "Allow undead horse types to be leashed: " + allowUndeadHorseLeashing ); } - public double squidMinSpawnHeight; - public double squidMaxSpawnHeight; - private void squidSpawnHeight() + public static double squidMinSpawnHeight; + public static double squidMaxSpawnHeight; + private static void squidSpawnHeight() { squidMinSpawnHeight = getDouble( "squid-spawn-height.minimum", 45.0D ); squidMaxSpawnHeight = getDouble( "squid-spawn-height.maximum", 63.0D ); log( "Squids will spawn between Y: " + squidMinSpawnHeight + " and Y: " + squidMaxSpawnHeight ); } - public float playerBlockingDamageMultiplier; - private void playerBlockingDamageMultiplier() + public static float playerBlockingDamageMultiplier; + private static void playerBlockingDamageMultiplier() { playerBlockingDamageMultiplier = getFloat( "player-blocking-damage-multiplier", 0.5F ); log( "Player blocking damage multiplier set to " + playerBlockingDamageMultiplier ); } - public int cactusMaxHeight; - public int reedMaxHeight; - private void blockGrowthHeight() + public static int cactusMaxHeight; + public static int reedMaxHeight; + private static void blockGrowthHeight() { cactusMaxHeight = getInt( "max-growth-height.cactus", 3 ); reedMaxHeight = getInt( "max-growth-height.reeds", 3 ); log( "Max height for cactus growth " + cactusMaxHeight + ". Max height for reed growth " + reedMaxHeight ); } - public int fishingMinTicks; - public int fishingMaxTicks; - private void fishingTickRange() + public static int fishingMinTicks; + public static int fishingMaxTicks; + private static void fishingTickRange() { fishingMinTicks = getInt( "fishing-time-range.MinimumTicks", 100 ); fishingMaxTicks = getInt( "fishing-time-range.MaximumTicks", 900 ); } - public float blockBreakExhaustion; - public float playerSwimmingExhaustion; - private void exhaustionValues() + public static float blockBreakExhaustion; + public static float playerSwimmingExhaustion; + private static void exhaustionValues() { blockBreakExhaustion = getFloat( "player-exhaustion.block-break", 0.025F ); playerSwimmingExhaustion = getFloat( "player-exhaustion.swimming", 0.015F ); } - public int softDespawnDistance; - public int hardDespawnDistance; - private void despawnDistances() + public static int softDespawnDistance; + public static int hardDespawnDistance; + private static void despawnDistances() { softDespawnDistance = getInt( "despawn-ranges.soft", 32 ); // 32^2 = 1024, Minecraft Default hardDespawnDistance = getInt( "despawn-ranges.hard", 128 ); // 128^2 = 16384, Minecraft Default; @@ -140,15 +128,15 @@ public class PaperSpigotWorldConfig hardDespawnDistance = hardDespawnDistance*hardDespawnDistance; } - public boolean keepSpawnInMemory; - private void keepSpawnInMemory() + public static boolean keepSpawnInMemory; + private static void keepSpawnInMemory() { keepSpawnInMemory = getBoolean( "keep-spawn-loaded", true ); log( "Keep spawn chunk loaded: " + keepSpawnInMemory ); } - public int fallingBlockHeightNerf; - private void fallingBlockheightNerf() + public static int fallingBlockHeightNerf; + private static void fallingBlockheightNerf() { fallingBlockHeightNerf = getInt( "falling-block-height-nerf", 0 ); if ( fallingBlockHeightNerf != 0 ) @@ -157,8 +145,8 @@ public class PaperSpigotWorldConfig } } - public int tntEntityHeightNerf; - private void tntEntityHeightNerf() + public static int tntEntityHeightNerf; + private static void tntEntityHeightNerf() { tntEntityHeightNerf = getInt( "tnt-entity-height-nerf", 0 ); if ( tntEntityHeightNerf != 0 ) @@ -167,49 +155,49 @@ public class PaperSpigotWorldConfig } } - public int waterOverLavaFlowSpeed; - private void waterOverLavaFlowSpeed() + public static int waterOverLavaFlowSpeed; + private static void waterOverLavaFlowSpeed() { waterOverLavaFlowSpeed = getInt( "water-over-lava-flow-speed", 5 ); log( "Water over lava flow speed: " + waterOverLavaFlowSpeed ); } - public boolean removeInvalidMobSpawnerTEs; - private void removeInvalidMobSpawnerTEs() + public static boolean removeInvalidMobSpawnerTEs; + private static void removeInvalidMobSpawnerTEs() { removeInvalidMobSpawnerTEs = getBoolean( "remove-invalid-mob-spawner-tile-entities", true ); log( "Remove invalid mob spawner tile entities: " + removeInvalidMobSpawnerTEs ); } - public boolean removeUnloadedEnderPearls; - public boolean removeUnloadedTNTEntities; - public boolean removeUnloadedFallingBlocks; - private void removeUnloaded() + public static boolean removeUnloadedEnderPearls; + public static boolean removeUnloadedTNTEntities; + public static boolean removeUnloadedFallingBlocks; + private static void removeUnloaded() { removeUnloadedEnderPearls = getBoolean( "remove-unloaded.enderpearls", true ); removeUnloadedTNTEntities = getBoolean( "remove-unloaded.tnt-entities", true ); removeUnloadedFallingBlocks = getBoolean( "remove-unloaded.falling-blocks", true ); } - public boolean boatsDropBoats; - public boolean disablePlayerCrits; - public boolean disableChestCatDetection; - private void mechanicsChanges() + public static boolean boatsDropBoats; + public static boolean disablePlayerCrits; + public static boolean disableChestCatDetection; + private static void mechanicsChanges() { boatsDropBoats = getBoolean( "game-mechanics.boats-drop-boats", false ); disablePlayerCrits = getBoolean( "game-mechanics.disable-player-crits", false ); disableChestCatDetection = getBoolean( "game-mechanics.disable-chest-cat-detection", false ); } - public boolean netherVoidTopDamage; - private void nethervoidTopDamage() + public static boolean netherVoidTopDamage; + private static void nethervoidTopDamage() { netherVoidTopDamage = getBoolean( "nether-ceiling-void-damage", false ); } - public int tickNextTickCap; - public boolean tickNextTickListCapIgnoresRedstone; - private void tickNextTickCap() + public static int tickNextTickCap; + public static boolean tickNextTickListCapIgnoresRedstone; + private static void tickNextTickCap() { tickNextTickCap = getInt( "tick-next-tick-list-cap", 10000 ); // Higher values will be friendlier to vanilla style mechanics (to a point) but may hurt performance tickNextTickListCapIgnoresRedstone = getBoolean( "tick-next-tick-list-cap-ignores-redstone", false ); // Redstone TickNextTicks will always bypass the preceding cap. @@ -217,40 +205,40 @@ public class PaperSpigotWorldConfig log( "WorldServer TickNextTickList cap always processes redstone: " + tickNextTickListCapIgnoresRedstone ); } - public boolean useAsyncLighting; - private void useAsyncLighting() + public static boolean useAsyncLighting; + private static void useAsyncLighting() { useAsyncLighting = getBoolean( "use-async-lighting", false ); log( "World async lighting: " + useAsyncLighting ); } - public boolean disableEndCredits; - private void disableEndCredits() + public static boolean disableEndCredits; + private static void disableEndCredits() { disableEndCredits = getBoolean( "game-mechanics.disable-end-credits", false ); } - public boolean loadUnloadedEnderPearls; - public boolean loadUnloadedTNTEntities; - public boolean loadUnloadedFallingBlocks; - private void loadUnloaded() + public static boolean loadUnloadedEnderPearls; + public static boolean loadUnloadedTNTEntities; + public static boolean loadUnloadedFallingBlocks; + private static void loadUnloaded() { loadUnloadedEnderPearls = getBoolean( "load-chunks.enderpearls", false ); loadUnloadedTNTEntities = getBoolean( "load-chunks.tnt-entities", false ); loadUnloadedFallingBlocks = getBoolean( "load-chunks.falling-blocks", false ); } - public boolean generateCanyon; - public boolean generateCaves; - public boolean generateDungeon; - public boolean generateFortress; - public boolean generateMineshaft; - public boolean generateMonument; - public boolean generateStronghold; - public boolean generateTemple; - public boolean generateVillage; - public boolean generateFlatBedrock; - private void generatorSettings() + public static boolean generateCanyon; + public static boolean generateCaves; + public static boolean generateDungeon; + public static boolean generateFortress; + public static boolean generateMineshaft; + public static boolean generateMonument; + public static boolean generateStronghold; + public static boolean generateTemple; + public static boolean generateVillage; + public static boolean generateFlatBedrock; + private static void generatorSettings() { generateCanyon = getBoolean( "generator-settings.canyon", true ); generateCaves = getBoolean( "generator-settings.caves", true ); @@ -264,152 +252,198 @@ public class PaperSpigotWorldConfig generateFlatBedrock = getBoolean( "generator-settings.flat-bedrock", false ); } - public boolean fixCannons; - private void fixCannons() + public static boolean fixCannons; + private static void fixCannons() { - // TODO: Remove migrations after most users have upgraded. - if ( PaperSpigotConfig.version < 9 ) - { - // Migrate default value - - boolean value = config.getBoolean( "world-settings.default.fix-cannons", false ); - if ( !value ) value = config.getBoolean( "world-settings.default.tnt-gameplay.fix-directional-bias", false ); - if ( !value ) value = !config.getBoolean( "world-settings.default.tnt-gameplay.moves-in-water", true ); - if ( !value ) value = config.getBoolean( "world-settings.default.tnt-gameplay.legacy-explosion-height", false ); - if ( value ) config.set( "world-settings.default.fix-cannons", true ); - - if ( config.contains( "world-settings.default.tnt-gameplay" ) ) - { - config.getDefaults().set( "world-settings.default.tnt-gameplay", null); - config.set( "world-settings.default.tnt-gameplay", null ); - } - - // Migrate world setting - - value = config.getBoolean( "world-settings." + worldName + ".fix-cannons", false ); - if ( !value ) value = config.getBoolean( "world-settings." + worldName + ".tnt-gameplay.fix-directional-bias", false ); - if ( !value ) value = !config.getBoolean( "world-settings." + worldName + ".tnt-gameplay.moves-in-water", true ); - if ( !value ) value = config.getBoolean( "world-settings." + worldName + ".tnt-gameplay.legacy-explosion-height", false ); - if ( value ) config.set( "world-settings." + worldName + ".fix-cannons", true ); - - if ( config.contains( "world-settings." + worldName + ".tnt-gameplay" ) ) - { - config.getDefaults().set( "world-settings." + worldName + ".tnt-gameplay", null); - config.set( "world-settings." + worldName + ".tnt-gameplay", null ); - } - } - fixCannons = getBoolean( "fix-cannons", false ); - log( "Fix TNT cannons: " + fixCannons ); } - public boolean fallingBlocksCollideWithSigns; - private void fallingBlocksCollideWithSigns() + public static boolean fallingBlocksCollideWithSigns; + private static void fallingBlocksCollideWithSigns() { fallingBlocksCollideWithSigns = getBoolean( "falling-blocks-collide-with-signs", false ); } - public boolean optimizeExplosions; - private void optimizeExplosions() + public static boolean optimizeExplosions; + private static void optimizeExplosions() { optimizeExplosions = getBoolean( "optimize-explosions", false ); } - public boolean fastDrainLava; - public boolean fastDrainWater; - private void fastDraining() + public static boolean fastDrainLava; + public static boolean fastDrainWater; + private static void fastDraining() { fastDrainLava = getBoolean( "fast-drain.lava", false ); fastDrainWater = getBoolean( "fast-drain.water", false ); } - public int lavaFlowSpeedNormal; - public int lavaFlowSpeedNether; - private void lavaFlowSpeed() + public static int lavaFlowSpeedNormal; + public static int lavaFlowSpeedNether; + private static void lavaFlowSpeed() { lavaFlowSpeedNormal = getInt( "lava-flow-speed.normal", 30 ); lavaFlowSpeedNether = getInt( "lava-flow-speed.nether", 10 ); } - public boolean disableExplosionKnockback; - private void disableExplosionKnockback() + public static boolean disableExplosionKnockback; + private static void disableExplosionKnockback() { disableExplosionKnockback = getBoolean( "disable-explosion-knockback", false ); } - public boolean disableThunder; - private void disableThunder() + public static boolean disableThunder; + private static void disableThunder() { disableThunder = getBoolean( "disable-thunder", false ); } - public boolean disableIceAndSnow; - private void disableIceAndSnow() + public static boolean disableIceAndSnow; + private static void disableIceAndSnow() { disableIceAndSnow = getBoolean( "disable-ice-and-snow", false ); } - public boolean disableMoodSounds; - private void disableMoodSounds() + public static boolean disableMoodSounds; + private static void disableMoodSounds() { disableMoodSounds = getBoolean( "disable-mood-sounds", false ); } - public int mobSpawnerTickRate; - private void mobSpawnerTickRate() + public static int mobSpawnerTickRate; + private static void mobSpawnerTickRate() { mobSpawnerTickRate = getInt( "mob-spawner-tick-rate", 1 ); } - public boolean cacheChunkMaps; - private void cacheChunkMaps() + public static boolean cacheChunkMaps; + private static void cacheChunkMaps() { cacheChunkMaps = getBoolean( "cache-chunk-maps", false ); } - public int containerUpdateTickRate; - private void containerUpdateTickRate() + public static int containerUpdateTickRate; + private static void containerUpdateTickRate() { containerUpdateTickRate = getInt( "container-update-tick-rate", 1 ); } - public float tntExplosionVolume; - private void tntExplosionVolume() + public static float tntExplosionVolume; + private static void tntExplosionVolume() { tntExplosionVolume = getFloat( "tnt-explosion-volume", 4.0F ); } - public boolean useHopperCheck; - private void useHopperCheck() + public static boolean useHopperCheck; + private static void useHopperCheck() { useHopperCheck = getBoolean( "use-hopper-check", false ); } - public boolean allChunksAreSlimeChunks; - private void allChunksAreSlimeChunks() + public static boolean allChunksAreSlimeChunks; + private static void allChunksAreSlimeChunks() { allChunksAreSlimeChunks = getBoolean( "all-chunks-are-slime-chunks", false ); } - public boolean allowBlockLocationTabCompletion; - private void allowBlockLocationTabCompletion() + public static boolean allowBlockLocationTabCompletion; + private static void allowBlockLocationTabCompletion() { allowBlockLocationTabCompletion = getBoolean( "allow-block-location-tab-completion", true ); } - public int portalSearchRadius; - private void portalSearchRadius() + public static int portalSearchRadius; + private static void portalSearchRadius() { portalSearchRadius = getInt("portal-search-radius", 128); } - public boolean removeCorruptTEs; - private void removeCorruptTEs() { + public static boolean disableTeleportationSuffocationCheck; + private static void disableTeleportationSuffocationCheck() + { + disableTeleportationSuffocationCheck = getBoolean("disable-teleportation-suffocation-check", false); + } + + public static boolean useInhabitedTime = true; + private static void useInhabitedTime() { + useInhabitedTime = getBoolean("use-chunk-inhabited-timer", true); + } + + public static int grassUpdateRate = 1; + private static void grassUpdateRate() { + grassUpdateRate = Math.max(0, getInt("grass-spread-tick-rate", grassUpdateRate)); + log("Grass Spread Tick Rate: " + grassUpdateRate); + } + + public static int autoSavePeriod = -1; + private static void autoSavePeriod() { + autoSavePeriod = getInt("auto-save-interval", -1); + if (autoSavePeriod > 0) { + log("Auto Save Interval: " +autoSavePeriod + " (" + (autoSavePeriod / 20) + "s)"); + } else if (autoSavePeriod < 0) { + autoSavePeriod = MinecraftServer.getServer().autosavePeriod; + } + } + + public static int maxAutoSaveChunksPerTick = 24; + private static void maxAutoSaveChunksPerTick() { + maxAutoSaveChunksPerTick = getInt("max-auto-save-chunks-per-tick", 24); + } + + public static boolean removeCorruptTEs = false; + private static void removeCorruptTEs() { removeCorruptTEs = getBoolean("remove-corrupt-tile-entities", false); } - public boolean armorStandEntityLookups; - private void armorStandEntityLookups() { + public static boolean armorStandEntityLookups = true; + private static void armorStandEntityLookups() { armorStandEntityLookups = getBoolean("armor-stands-do-collision-entity-lookups", true); } + + public static boolean isRedstoneFireBPE; + private void isRedstoneFireBPE() { + isRedstoneFireBPE = getBoolean("redstone-fire-BlockPhysicsEvent", true); + } + + public static boolean isHopperPushBased; + private static void isHopperPushBased() { + isHopperPushBased = getBoolean("hopper.push-based", true); + } + + public static boolean isHopperFireIMIE; + private static void isHopperFireIMIE() { + isHopperFireIMIE = getBoolean("hopper.fire-InventoryMoveItemEvent", true); + } + + public static boolean optimizeArmorStandMovement; + private static void isArmorStandMoveWithoutGravity() { + optimizeArmorStandMovement = getBoolean("armor-stand.optimize-movement", false); // Doesn't fully emulate vanilla behavior, see issue #1 + } + + public static boolean nonPlayerEntitiesOnScoreboards = false; + private static void nonPlayerEntitiesOnScoreboards() { + nonPlayerEntitiesOnScoreboards = getBoolean("allow-non-player-entities-on-scoreboards", false); + } + + public static boolean grassIgnoresLight = false; + private static void isGrassIgnoresLight() { + grassIgnoresLight = getBoolean("grass-ignores-light", false); + } + + public static boolean optimizeTntMovement = false; + private static void isOptimizeTnt() { + optimizeTntMovement = getBoolean("tnt.optimize-movement", false); // May not fully emulate vanilla behavior + } + public static boolean optimizeLiquidExplosions = true; + private static void isOptimizeLiquidExplosions() { + optimizeLiquidExplosions = getBoolean("tnt.optimize-liquid-explosions", true); // This seems like a pretty sane default + } + + public static boolean fixEastWest; + private void fixEastWest() { + fixEastWest = getBoolean("fix-east-west-cannoning", false); + } + + public static boolean disableFallingBlockStackingAt256; + private void DisableFallingBlockStackingAt256() { disableFallingBlockStackingAt256 = getBoolean("disable-falling-block-stacking-at-256", false);} } diff --git a/eSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java b/eSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java index bcae756..da25c63 100644 --- a/eSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java +++ b/eSpigot-Server/src/main/java/org/spigotmc/SpigotConfig.java @@ -1,24 +1,14 @@ package org.spigotmc; -import com.google.common.base.Throwables; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.logging.Level; + +import com.elevatemc.spigot.config.SharedConfig; import gnu.trove.map.hash.TObjectIntHashMap; import com.google.common.collect.Lists; import net.minecraft.server.AttributeRanged; import net.minecraft.server.GenericAttributes; -import net.minecraft.server.MinecraftServer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.Configuration; @@ -26,141 +16,53 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import co.aikar.timings.Timings; import co.aikar.timings.TimingsManager; public class SpigotConfig { - - private static File CONFIG_FILE; - private static final String HEADER = "This is the main configuration file for Spigot.\n" - + "As you can see, there's tons to configure. Some options may impact gameplay, so use\n" - + "with caution, and make sure you know what each option does before configuring.\n" - + "For a reference for any variable inside this file, check out the Spigot wiki at\n" - + "http://www.spigotmc.org/wiki/spigot-configuration/\n" - + "\n" - + "If you need help with the configuration or have any questions related to Spigot,\n" - + "join us at the IRC or drop by our forums and leave a post.\n" - + "\n" - + "IRC: #spigot @ irc.spi.gt ( http://www.spigotmc.org/pages/irc/ )\n" - + "Forums: http://www.spigotmc.org/\n"; - /*========================================================================*/ public static YamlConfiguration config; - static int version; static Map commands; - /*========================================================================*/ - private static Metrics metrics; - public static void init(File configFile) + public static void init() { - CONFIG_FILE = configFile; - config = new YamlConfiguration(); - try - { - config.load( CONFIG_FILE ); - } catch ( IOException ignored) - { - } catch ( InvalidConfigurationException ex ) - { - Bukkit.getLogger().log( Level.SEVERE, "Could not load spigot.yml, please correct your syntax errors", ex ); - throw Throwables.propagate( ex ); - } - - config.options().header( HEADER ); - config.options().copyDefaults( true ); - - commands = new HashMap<>(); - - version = getInt( "config-version", 8 ); - set( "config-version", 8 ); - readConfig( SpigotConfig.class, null ); - } - - public static void registerCommands() - { - for ( Map.Entry entry : commands.entrySet() ) - { - MinecraftServer.getServer().server.getCommandMap().register( entry.getKey(), "Spigot", entry.getValue() ); - } - - if ( metrics == null ) - { - try - { - metrics = new Metrics(); - metrics.start(); - } catch ( IOException ex ) - { - Bukkit.getServer().getLogger().log( Level.SEVERE, "Could not start metrics service", ex ); - } - } - } - - static void readConfig(Class clazz, Object instance) - { - for ( Method method : clazz.getDeclaredMethods() ) - { - if ( Modifier.isPrivate( method.getModifiers() ) ) - { - if ( method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE ) - { - try - { - method.setAccessible( true ); - method.invoke( instance ); - } catch ( InvocationTargetException ex ) - { - throw Throwables.propagate( ex.getCause() ); - } catch ( Exception ex ) - { - Bukkit.getLogger().log( Level.SEVERE, "Error invoking " + method, ex ); - } - } - } - } - - try - { - config.save( CONFIG_FILE ); - } catch ( IOException ex ) - { - Bukkit.getLogger().log( Level.SEVERE, "Could not save " + CONFIG_FILE, ex ); - } - } - - private static void set(String path, Object val) - { - config.set( path, val ); + config = SharedConfig.config; + commands = SharedConfig.commands; + SharedConfig.readConfig( SpigotConfig.class, null ); } private static boolean getBoolean(String path, boolean def) { + path = "spigot." + path; config.addDefault( path, def ); return config.getBoolean( path, config.getBoolean( path ) ); } private static int getInt(String path, int def) { + path = "spigot." + path; config.addDefault( path, def ); return config.getInt( path, config.getInt( path ) ); } private static List getList(String path, T def) { + path = "spigot." + path; config.addDefault( path, def ); - return config.getList( path, config.getList( path ) ); + return (List) config.getList( path, config.getList( path ) ); } private static String getString(String path, String def) { + path = "spigot." + path; config.addDefault( path, def ); return config.getString( path, config.getString( path ) ); } private static double getDouble(String path, double def) { + path = "spigot." + path; config.addDefault( path, def ); return config.getDouble( path, config.getDouble( path ) ); } @@ -174,22 +76,12 @@ public class SpigotConfig public static int tabComplete; private static void tabComplete() { - if ( version < 6 ) - { - boolean oldValue = getBoolean( "commands.tab-complete", true ); - if ( oldValue ) - { - set( "commands.tab-complete", 0 ); - } else - { - set( "commands.tab-complete", -1 ); - } - } tabComplete = getInt( "commands.tab-complete", 0 ); } public static String whitelistMessage; public static String unknownCommandMessage; + public static String internalErrorMessage; public static String serverFullMessage; public static String outdatedClientMessage = "Outdated client! Please use {0}"; public static String outdatedServerMessage = "Outdated server! I\'m still on {0}"; @@ -199,14 +91,9 @@ public class SpigotConfig } private static void messages() { - if (version < 8) - { - set( "messages.outdated-client", outdatedClientMessage ); - set( "messages.outdated-server", outdatedServerMessage ); - } - whitelistMessage = transform( getString( "messages.whitelist", "You are not whitelisted on this server!" ) ); unknownCommandMessage = transform( getString( "messages.unknown-command", "Unknown command. Type \"/help\" for help." ) ); + internalErrorMessage = transform( getString( "messages.internal-error", "&cAn internal error occurred while attempting to perform this command" ) ); serverFullMessage = transform( getString( "messages.server-full", "The server is full!" ) ); outdatedClientMessage = transform( getString( "messages.outdated-client", outdatedClientMessage ) ); outdatedServerMessage = transform( getString( "messages.outdated-server", outdatedServerMessage ) ); @@ -226,13 +113,14 @@ public class SpigotConfig WatchdogThread.doStart( timeoutTime, restartOnCrash ); } + public static boolean fetchSkulls = true; + private static void fetchSkulls() + { + fetchSkulls = getBoolean("settings.fetch-skulls", fetchSkulls); + } + public static boolean bungee; private static void bungee() { - if ( version < 4 ) - { - set( "settings.bungeecord", false ); - System.out.println( "Oudated config, disabling BungeeCord support!" ); - } bungee = getBoolean( "settings.bungeecord", false ); } @@ -282,16 +170,16 @@ public class SpigotConfig } public static boolean disableStatSaving; - public static TObjectIntHashMap forcedStats = new TObjectIntHashMap<>(); + public static TObjectIntHashMap forcedStats = new TObjectIntHashMap(); private static void stats() { disableStatSaving = getBoolean( "stats.disable-saving", false ); - if ( !config.contains( "stats.forced-stats" ) ) { - config.createSection( "stats.forced-stats" ); + if ( !config.contains( "spigot.stats.forced-stats" ) ) { + config.createSection( "spigot.stats.forced-stats" ); } - ConfigurationSection section = config.getConfigurationSection( "stats.forced-stats" ); + ConfigurationSection section = config.getConfigurationSection( "spigot.stats.forced-stats" ); for ( String name : section.getKeys( true ) ) { if ( section.isInt( name ) ) @@ -324,10 +212,7 @@ public class SpigotConfig public static List spamExclusions; private static void spamExclusions() { - spamExclusions = getList( "commands.spam-exclusions", Arrays.asList( new String[] - { - "/skill" - } ) ); + spamExclusions = getList( "commands.spam-exclusions", Collections.singletonList("/skill")); } public static boolean silentCommandBlocks; @@ -345,21 +230,16 @@ public class SpigotConfig public static Set replaceCommands; private static void replaceCommands() { - if ( config.contains( "replace-commands" ) ) - { - set( "commands.replace-commands", config.getStringList( "replace-commands" ) ); - config.set( "replace-commands", null ); - } - replaceCommands = new HashSet<>((List) getList("commands.replace-commands", - Arrays.asList("setblock", "summon", "testforblock", "tellraw"))); + replaceCommands = new HashSet( (List) getList( "commands.replace-commands", + Arrays.asList( "setblock", "summon", "testforblock", "tellraw" ) ) ); } - + public static int userCacheCap; private static void userCacheCap() { userCacheCap = getInt( "settings.user-cache-size", 1000 ); } - + public static boolean saveUserCacheOnStopOnly; private static void saveUserCacheOnStopOnly() { diff --git a/eSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java b/eSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java index 76db455..880780b 100644 --- a/eSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/eSpigot-Server/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -2,32 +2,25 @@ package org.spigotmc; import java.util.Arrays; import java.util.List; + +import com.elevatemc.spigot.config.SharedConfig; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; public class SpigotWorldConfig { + private static YamlConfiguration config; + private static boolean verbose; - private final String worldName; - private final YamlConfiguration config; - private boolean verbose; - - public SpigotWorldConfig(String worldName) + public static void init() { - this.worldName = worldName; - this.config = SpigotConfig.config; - init(); + config = SharedConfig.config; + verbose = getBoolean( "verbose", true ); + + SharedConfig.readConfig( SpigotWorldConfig.class, null ); } - public void init() - { - this.verbose = getBoolean( "verbose", true ); - - log( "-------- World Settings For [" + worldName + "] --------" ); - SpigotConfig.readConfig( SpigotWorldConfig.class, this ); - } - - private void log(String s) + private static void log(String s) { if ( verbose ) { @@ -35,44 +28,39 @@ public class SpigotWorldConfig } } - private void set(String path, Object val) + private static boolean getBoolean(String path, boolean def) { - config.set( "world-settings.default." + path, val ); + config.addDefault( "spigot.world-settings." + path, def ); + return config.getBoolean( "spigot.world-settings." + path, config.getBoolean( "spigot.world-settings." + path ) ); } - private boolean getBoolean(String path, boolean def) + private static double getDouble(String path, double def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getBoolean( "world-settings." + worldName + "." + path, config.getBoolean( "world-settings.default." + path ) ); + config.addDefault( "spigot.world-settings." + path, def ); + return config.getDouble( "spigot.world-settings." + path, config.getDouble( "spigot.world-settings." + path ) ); } - private double getDouble(String path, double def) + private static int getInt(String path, int def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getDouble( "world-settings." + worldName + "." + path, config.getDouble( "world-settings.default." + path ) ); + config.addDefault( "spigot.world-settings." + path, def ); + return config.getInt( "spigot.world-settings." + path, config.getInt( "spigot.world-settings." + path ) ); } - private int getInt(String path, int def) + private static List getList(String path, T def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getInt( "world-settings." + worldName + "." + path, config.getInt( "world-settings.default." + path ) ); + config.addDefault( "spigot.world-settings." + path, def ); + return (List) config.getList( "spigot.world-settings." + path, config.getList( "spigot.world-settings." + path ) ); } - private List getList(String path, T def) + private static String getString(String path, String def) { - config.addDefault( "world-settings.default." + path, def ); - return config.getList( "world-settings." + worldName + "." + path, config.getList( "world-settings.default." + path ) ); + config.addDefault( "spigot.world-settings." + path, def ); + return config.getString( "spigot.world-settings." + path, config.getString( "spigot.world-settings." + path ) ); } - private String getString(String path, String def) - { - config.addDefault( "world-settings.default." + path, def ); - return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) ); - } - - public int chunksPerTick; - public boolean clearChunksOnTick; - private void chunksPerTick() + public static int chunksPerTick; + public static boolean clearChunksOnTick; + private static void chunksPerTick() { chunksPerTick = getInt( "chunks-per-tick", 650 ); log( "Chunks to Grow per Tick: " + chunksPerTick ); @@ -82,15 +70,15 @@ public class SpigotWorldConfig } // Crop growth rates - public int cactusModifier; - public int caneModifier; - public int melonModifier; - public int mushroomModifier; - public int pumpkinModifier; - public int saplingModifier; - public int wheatModifier; - public int wartModifier; - private int getAndValidateGrowth(String crop) + public static int cactusModifier; + public static int caneModifier; + public static int melonModifier; + public static int mushroomModifier; + public static int pumpkinModifier; + public static int saplingModifier; + public static int wheatModifier; + public static int wartModifier; + private static int getAndValidateGrowth(String crop) { int modifier = getInt( "growth." + crop.toLowerCase() + "-modifier", 100 ); if ( modifier == 0 ) @@ -102,7 +90,7 @@ public class SpigotWorldConfig return modifier; } - private void growthModifiers() + private static void growthModifiers() { cactusModifier = getAndValidateGrowth( "Cactus" ); caneModifier = getAndValidateGrowth( "Cane" ); @@ -114,38 +102,38 @@ public class SpigotWorldConfig wartModifier = getAndValidateGrowth( "NetherWart" ); } - public double itemMerge; - private void itemMerge() + public static double itemMerge; + private static void itemMerge() { itemMerge = getDouble("merge-radius.item", 2.5 ); log( "Item Merge Radius: " + itemMerge ); } - public double expMerge; - private void expMerge() + public static double expMerge; + private static void expMerge() { expMerge = getDouble("merge-radius.exp", 3.0 ); log( "Experience Merge Radius: " + expMerge ); } - public int viewDistance; - private void viewDistance() + public static int viewDistance; + private static void viewDistance() { viewDistance = getInt( "view-distance", Bukkit.getViewDistance() ); log( "View Distance: " + viewDistance ); } - public byte mobSpawnRange; - private void mobSpawnRange() + public static byte mobSpawnRange; + private static void mobSpawnRange() { mobSpawnRange = (byte) getInt( "mob-spawn-range", 4 ); log( "Mob Spawn Range: " + mobSpawnRange ); } - public int animalActivationRange = 32; - public int monsterActivationRange = 32; - public int miscActivationRange = 16; - private void activationRange() + public static int animalActivationRange = 32; + public static int monsterActivationRange = 32; + public static int miscActivationRange = 16; + private static void activationRange() { animalActivationRange = getInt( "entity-activation-range.animals", animalActivationRange ); monsterActivationRange = getInt( "entity-activation-range.monsters", monsterActivationRange ); @@ -153,12 +141,12 @@ public class SpigotWorldConfig log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Mi " + miscActivationRange ); } - public int playerTrackingRange = 48; - public int animalTrackingRange = 48; - public int monsterTrackingRange = 48; - public int miscTrackingRange = 32; - public int otherTrackingRange = 64; - private void trackingRange() + public static int playerTrackingRange = 48; + public static int animalTrackingRange = 48; + public static int monsterTrackingRange = 48; + public static int miscTrackingRange = 32; + public static int otherTrackingRange = 64; + private static void trackingRange() { playerTrackingRange = getInt( "entity-tracking-range.players", playerTrackingRange ); animalTrackingRange = getInt( "entity-tracking-range.animals", animalTrackingRange ); @@ -168,10 +156,10 @@ public class SpigotWorldConfig log( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Other " + otherTrackingRange ); } - public int hopperTransfer; - public int hopperCheck; - public int hopperAmount; - private void hoppers() + public static int hopperTransfer; + public static int hopperCheck; + public static int hopperAmount; + private static void hoppers() { // Set the tick delay between hopper item movements hopperTransfer = getInt( "ticks-per.hopper-transfer", 8 ); @@ -183,16 +171,16 @@ public class SpigotWorldConfig log( "Hopper Transfer: " + hopperTransfer + " Hopper Check: " + hopperCheck + " Hopper Amount: " + hopperAmount ); } - public boolean randomLightUpdates; - private void lightUpdates() + public static boolean randomLightUpdates; + private static void lightUpdates() { randomLightUpdates = getBoolean( "random-light-updates", false ); log( "Random Lighting Updates: " + randomLightUpdates ); } - public boolean saveStructureInfo; - public boolean saveMineshaftStructureInfo; // Migot - private void structureInfo() + public static boolean saveStructureInfo; + public static boolean saveMineshaftStructureInfo; // Migot + private static void structureInfo() { saveStructureInfo = getBoolean( "save-structure-info", true ); log( "Structure Info Saving: " + saveStructureInfo ); @@ -207,113 +195,103 @@ public class SpigotWorldConfig } } - public int itemDespawnRate; - private void itemDespawnRate() + public static int itemDespawnRate; + private static void itemDespawnRate() { itemDespawnRate = getInt( "item-despawn-rate", 6000 ); log( "Item Despawn Rate: " + itemDespawnRate ); } - public int arrowDespawnRate; - private void arrowDespawnRate() + public static int arrowDespawnRate; + private static void arrowDespawnRate() { arrowDespawnRate = getInt( "arrow-despawn-rate", 1200 ); log( "Arrow Despawn Rate: " + arrowDespawnRate ); } - - public boolean antiXray; - public int engineMode; - public List hiddenBlocks; - public List replaceBlocks; - public AntiXray antiXrayInstance; - private void antiXray() + + public static boolean antiXray; + public static int engineMode; + public static List hiddenBlocks; + public static List replaceBlocks; + public static AntiXray antiXrayInstance; + private static void antiXray() { - antiXray = getBoolean( "anti-xray.enabled", true ); + antiXray = getBoolean( "anti-xray.enabled", false ); log( "Anti X-Ray: " + antiXray ); engineMode = getInt( "anti-xray.engine-mode", 1 ); log( "\tEngine Mode: " + engineMode ); - if ( SpigotConfig.version < 5 ) - { - set( "anti-xray.blocks", null ); - } - hiddenBlocks = getList( "anti-xray.hide-blocks", Arrays.asList( new Integer[] - { - 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130 - } ) ); + hiddenBlocks = getList( "anti-xray.hide-blocks", Arrays.asList(14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130) ); log( "\tHidden Blocks: " + hiddenBlocks ); - replaceBlocks = getList( "anti-xray.replace-blocks", Arrays.asList( new Integer[] - { - 1, 5 - } ) ); + replaceBlocks = getList( "anti-xray.replace-blocks", Arrays.asList(1, 5) ); log( "\tReplace Blocks: " + replaceBlocks ); - antiXrayInstance = new AntiXray( this ); + antiXrayInstance = new AntiXray( new SpigotWorldConfig() ); } - public boolean zombieAggressiveTowardsVillager; - private void zombieAggressiveTowardsVillager() + public static boolean zombieAggressiveTowardsVillager; + private static void zombieAggressiveTowardsVillager() { zombieAggressiveTowardsVillager = getBoolean( "zombie-aggressive-towards-villager", true ); log( "Zombie Aggressive Towards Villager: " + zombieAggressiveTowardsVillager ); } - public boolean nerfSpawnerMobs; - private void nerfSpawnerMobs() + public static boolean nerfSpawnerMobs; + private static void nerfSpawnerMobs() { nerfSpawnerMobs = getBoolean( "nerf-spawner-mobs", false ); log( "Nerfing mobs spawned from spawners: " + nerfSpawnerMobs ); } - public boolean enableZombiePigmenPortalSpawns; - private void enableZombiePigmenPortalSpawns() + public static boolean enableZombiePigmenPortalSpawns; + private static void enableZombiePigmenPortalSpawns() { enableZombiePigmenPortalSpawns = getBoolean( "enable-zombie-pigmen-portal-spawns", true ); log( "Allow Zombie Pigmen to spawn from portal blocks: " + enableZombiePigmenPortalSpawns ); } - public int maxBulkChunk; - private void bulkChunkCount() + public static int maxBulkChunk; + private static void bulkChunkCount() { maxBulkChunk = getInt( "max-bulk-chunks", 10 ); log( "Sending up to " + maxBulkChunk + " chunks per packet" ); } - public int maxCollisionsPerEntity; - private void maxEntityCollision() + public static int maxCollisionsPerEntity; + private static void maxEntityCollision() { maxCollisionsPerEntity = getInt( "max-entity-collisions", 8 ); log( "Max Entity Collisions: " + maxCollisionsPerEntity ); } - public int dragonDeathSoundRadius; - private void keepDragonDeathPerWorld() + public static int dragonDeathSoundRadius; + private static void keepDragonDeathPerWorld() { dragonDeathSoundRadius = getInt( "dragon-death-sound-radius", 0 ); } - public int witherSpawnSoundRadius; - private void witherSpawnSoundRadius() + public static int witherSpawnSoundRadius; + private static void witherSpawnSoundRadius() { witherSpawnSoundRadius = getInt( "wither-spawn-sound-radius", 0 ); } - public int villageSeed; - public int largeFeatureSeed; - private void initWorldGenSeeds() + public static int villageSeed; + public static int largeFeatureSeed; + private static void initWorldGenSeeds() { villageSeed = getInt( "seed-village", 10387312 ); largeFeatureSeed = getInt( "seed-feature", 14357617 ); log( "Custom Map Seeds: Village: " + villageSeed + " Feature: " + largeFeatureSeed ); } - public float walkExhaustion; - public float sprintExhaustion; - public float combatExhaustion; - public float regenExhaustion; - private void initHunger() + public static float walkExhaustion; + public static float sprintExhaustion; + public static float combatExhaustion; + public static float regenExhaustion; + private static void initHunger() { walkExhaustion = (float) getDouble( "hunger.walk-exhaustion", 0.2 ); sprintExhaustion = (float) getDouble( "hunger.sprint-exhaustion", 0.8 ); @@ -321,26 +299,22 @@ public class SpigotWorldConfig regenExhaustion = (float) getDouble( "hunger.regen-exhaustion", 3 ); } - public int currentPrimedTnt = 0; - public int maxTntTicksPerTick; - private void maxTntPerTick() { - if ( SpigotConfig.version < 7 ) - { - set( "max-tnt-per-tick", 100 ); - } + public static int currentPrimedTnt = 0; + public static int maxTntTicksPerTick; + private static void maxTntPerTick() { maxTntTicksPerTick = getInt( "max-tnt-per-tick", 100 ); log( "Max TNT Explosions: " + maxTntTicksPerTick ); } - public int hangingTickFrequency; - private void hangingTickFrequency() + public static int hangingTickFrequency; + private static void hangingTickFrequency() { hangingTickFrequency = getInt( "hanging-tick-frequency", 100 ); } - public int tileMaxTickTime; - public int entityMaxTickTime; - private void maxTickTimes() + public static int tileMaxTickTime; + public static int entityMaxTickTime; + private static void maxTickTimes() { tileMaxTickTime = getInt("max-tick-time.tile", 50); entityMaxTickTime = getInt("max-tick-time.entity", 50);