mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
1.16 support
This commit is contained in:
parent
655fb44021
commit
81e16a6c47
14
pom.xml
14
pom.xml
@ -22,7 +22,7 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
||||
<!-- Bukkit properties -->
|
||||
<bukkit.version>1.15.2</bukkit.version>
|
||||
<bukkit.version>1.16.1</bukkit.version>
|
||||
<bukkit.javadocs>https://hub.spigotmc.org/javadocs/bukkit/</bukkit.javadocs>
|
||||
|
||||
<!-- Default settings for sonarcloud.io -->
|
||||
@ -270,15 +270,15 @@
|
||||
<dependencies>
|
||||
<!-- Hard dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${bukkit.version}-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TheBusyBiscuit</groupId>
|
||||
<groupId>com.github.WalshyDev</groupId>
|
||||
<artifactId>CS-CoreLib</artifactId>
|
||||
<version>4a7fce5202</version>
|
||||
<version>aa3bc64df3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -304,9 +304,9 @@
|
||||
|
||||
<!-- Shaded packages -->
|
||||
<dependency>
|
||||
<groupId>com.github.thebusybiscuit</groupId>
|
||||
<groupId>com.github.WalshyDev</groupId>
|
||||
<artifactId>CS-CoreLib2</artifactId>
|
||||
<version>0.21</version>
|
||||
<version>2ed2ddcfcd</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -32,6 +32,12 @@ public enum MinecraftVersion {
|
||||
*/
|
||||
MINECRAFT_1_15("1.15.x"),
|
||||
|
||||
/**
|
||||
* This constant represents Minecraft (Java Edition) Version 1.16
|
||||
* (The "Nether Update")
|
||||
*/
|
||||
MINECRAFT_1_16("1.16.x"),
|
||||
|
||||
/**
|
||||
* This constant represents an exceptional state in which we were unable
|
||||
* to identify the Minecraft Version we are using
|
||||
|
@ -17,6 +17,19 @@ import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.slimefun4.api.ErrorReport;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.chat.TextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
@ -26,18 +39,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ChatComponent;
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.json.HoverEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.ErrorReport;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
public class TickerTask implements Runnable {
|
||||
|
||||
private static final int VISIBILITY_THRESHOLD = 200_000;
|
||||
@ -251,7 +252,9 @@ public class TickerTask implements Runnable {
|
||||
List<Entry<String, Long>> timings = stream.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).collect(Collectors.toList());
|
||||
|
||||
if (sender instanceof Player) {
|
||||
ChatComponent component = new ChatComponent(ChatColors.color(" &7&oHover for more Info"));
|
||||
TextComponent component = new TextComponent(" Hover for more Info");
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.GRAY);
|
||||
component.setItalic(true);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int hidden = 0;
|
||||
|
||||
@ -265,9 +268,11 @@ public class TickerTask implements Runnable {
|
||||
}
|
||||
|
||||
builder.append("\n\n&c+ &4").append(hidden).append(" Hidden");
|
||||
component.setHoverEvent(new HoverEvent(ChatColors.color(builder.toString())));
|
||||
|
||||
component.sendMessage((Player) sender);
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.fromLegacyText(builder.toString())));
|
||||
|
||||
sender.spigot().sendMessage(component);
|
||||
}
|
||||
else {
|
||||
int hidden = 0;
|
||||
|
@ -9,16 +9,6 @@ import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
|
||||
@ -96,6 +86,15 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
|
||||
/**
|
||||
* This is the main class of Slimefun.
|
||||
@ -103,7 +102,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||
* Feel like home.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
*/
|
||||
public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
|
||||
@ -161,8 +159,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
local = new LocalizationService(this, "", null);
|
||||
gpsNetwork = new GPSNetwork();
|
||||
command.register();
|
||||
}
|
||||
else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
||||
} else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
||||
long timestamp = System.nanoTime();
|
||||
|
||||
// We wanna ensure that the Server uses a compatible version of Minecraft
|
||||
@ -200,8 +197,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
if (config.getBoolean("options.auto-update")) {
|
||||
getLogger().log(Level.INFO, "Starting Auto-Updater...");
|
||||
updaterService.start();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
updaterService.disable();
|
||||
}
|
||||
|
||||
@ -295,8 +291,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
|
||||
// Hooray!
|
||||
getLogger().log(Level.INFO, "Slimefun has finished loading in {0}", getStartupTime(timestamp));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
getLogger().log(Level.INFO, "#################### - INFO - ####################");
|
||||
getLogger().log(Level.INFO, " ");
|
||||
getLogger().log(Level.INFO, "Slimefun could not be loaded (yet).");
|
||||
@ -317,8 +312,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
|
||||
if (ms > 1000) {
|
||||
return DoubleHandler.fixDouble(ms / 1000.0) + "s";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return DoubleHandler.fixDouble(ms) + "ms";
|
||||
}
|
||||
}
|
||||
@ -397,12 +391,10 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
|
||||
if (storage != null) {
|
||||
storage.save(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"{0}\"", world.getName());
|
||||
}
|
||||
}
|
||||
catch (Exception x) {
|
||||
} catch (Exception x) {
|
||||
getLogger().log(Level.SEVERE, x, () -> "An Error occured while saving Slimefun-Blocks in World '" + world.getName() + "' for Slimefun " + getVersion());
|
||||
}
|
||||
}
|
||||
@ -435,8 +427,8 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
}
|
||||
|
||||
private void createDirectories() {
|
||||
String[] storageFolders = { "Players", "blocks", "stored-blocks", "stored-inventories", "stored-chunks", "universal-inventories", "waypoints", "block-backups" };
|
||||
String[] pluginFolders = { "scripts", "generators", "error-reports", "cache/github", "world-settings" };
|
||||
String[] storageFolders = {"Players", "blocks", "stored-blocks", "stored-inventories", "stored-chunks", "universal-inventories", "waypoints", "block-backups"};
|
||||
String[] pluginFolders = {"scripts", "generators", "error-reports", "cache/github", "world-settings"};
|
||||
|
||||
for (String folder : storageFolders) {
|
||||
File file = new File("data-storage/Slimefun", folder);
|
||||
@ -458,8 +450,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
private void loadItems() {
|
||||
try {
|
||||
SlimefunItemSetup.setup(this);
|
||||
}
|
||||
catch (Exception | LinkageError x) {
|
||||
} catch (Exception | LinkageError x) {
|
||||
getLogger().log(Level.SEVERE, x, () -> "An Error occured while initializing SlimefunItems for Slimefun " + getVersion());
|
||||
}
|
||||
}
|
||||
@ -467,8 +458,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
private void loadResearches() {
|
||||
try {
|
||||
ResearchSetup.setupResearches();
|
||||
}
|
||||
catch (Exception | LinkageError x) {
|
||||
} catch (Exception | LinkageError x) {
|
||||
getLogger().log(Level.SEVERE, x, () -> "An Error occured while initializing Slimefun Researches for Slimefun " + getVersion());
|
||||
}
|
||||
}
|
||||
@ -590,7 +580,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
||||
/**
|
||||
* This method returns a {@link Set} of every {@link Plugin} that lists Slimefun
|
||||
* as a required or optional dependency.
|
||||
*
|
||||
* <p>
|
||||
* We will just assume this to be a list of our addons.
|
||||
*
|
||||
* @return A {@link Set} of every {@link Plugin} that is dependent on Slimefun
|
||||
|
@ -40,13 +40,13 @@ public class TestResourceRegistration {
|
||||
@Test
|
||||
@Order(value = 1)
|
||||
public void testDefaultResources() {
|
||||
Assertions.assertDoesNotThrow(() -> GEOResourcesSetup.setup());
|
||||
Assertions.assertDoesNotThrow(GEOResourcesSetup::setup);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(value = 2)
|
||||
public void testDoubleRegistration() {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> GEOResourcesSetup.setup());
|
||||
Assertions.assertThrows(IllegalArgumentException.class, GEOResourcesSetup::setup);
|
||||
}
|
||||
|
||||
private GEOResource testResource(NamespacedKey key, String name, ItemStack item, boolean miner, int deviation) {
|
||||
@ -66,7 +66,7 @@ public class TestResourceRegistration {
|
||||
NamespacedKey key = new NamespacedKey(plugin, "oil");
|
||||
GEOResource resource = testResource(key, "Oil", SlimefunItems.OIL_BUCKET, false, 8);
|
||||
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER));
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
|
||||
|
||||
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.BEACH));
|
||||
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.DESERT) > 10);
|
||||
@ -83,7 +83,7 @@ public class TestResourceRegistration {
|
||||
NamespacedKey key = new NamespacedKey(plugin, "nether_ice");
|
||||
GEOResource resource = testResource(key, "Nether Ice", SlimefunItems.NETHER_ICE, true, 6);
|
||||
|
||||
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER));
|
||||
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.DESERT));
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class TestResourceRegistration {
|
||||
GEOResource resource = testResource(key, "Small Chunks of Uranium", SlimefunItems.SMALL_URANIUM, true, 2);
|
||||
|
||||
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS));
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER));
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.THE_END, Biome.THE_END));
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class TestResourceRegistration {
|
||||
NamespacedKey key = new NamespacedKey(plugin, "salt");
|
||||
GEOResource resource = testResource(key, "Salt", SlimefunItems.SALT, true, 18);
|
||||
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER));
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
|
||||
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.THE_END, Biome.THE_END));
|
||||
|
||||
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS));
|
||||
|
Loading…
Reference in New Issue
Block a user