1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Further Improvements on the backwards-compatibility toggle

This commit is contained in:
TheBusyBiscuit 2020-06-20 21:39:41 +02:00
parent 9563ca7377
commit 24cea8dade
5 changed files with 20 additions and 8 deletions

View File

@ -25,6 +25,7 @@
* Added a starting sound for the Ancient Altar
* Added config option to disable backwards compatibility and improve performance
* Added ReactorExplodeEvent to the API
* Compatibility mode status is now included in /sf versions
#### Changes
* Coolant Cells now last twice as long

View File

@ -347,6 +347,7 @@
<groupId>me.minebuilders</groupId>
<artifactId>clearlag-core</artifactId>
<version>3.1.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import java.util.Collection;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.Plugin;
@ -36,6 +37,11 @@ class VersionsCommand extends SubCommand {
sender.sendMessage("");
sender.sendMessage(ChatColors.color("&aCS-CoreLib &2v" + SlimefunPlugin.getCSCoreLibVersion()));
sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion()));
if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
sender.sendMessage(ChatColor.YELLOW + "Backwards compatiblity enabled!");
}
sender.sendMessage("");
Collection<Plugin> addons = SlimefunPlugin.getInstalledAddons();

View File

@ -22,7 +22,7 @@ public enum EnergyNetComponentType {
/**
* A Generator generates Energy and feeds it into the network.
* Also see: {@link AGenerator} or {@link AReactor}
* Also see: {@link AGenerator} or {@link Reactor}
*/
GENERATOR,

View File

@ -525,7 +525,9 @@ public class SlimefunItem implements Placeable {
* @return Whether the given {@link ItemStack} represents this {@link SlimefunItem}
*/
public boolean isItem(ItemStack item) {
if (item == null) return false;
if (item == null) {
return false;
}
if (item.hasItemMeta()) {
Optional<String> itemId = SlimefunPlugin.getItemDataService().getItemData(item);
@ -535,13 +537,13 @@ public class SlimefunItem implements Placeable {
}
}
// Support for legacy items
if (this instanceof ChargableItem && SlimefunUtils.isItemSimilar(item, this.item, false)) {
return true;
// Backwards compatibility
if (SlimefunPlugin.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_14) || SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
boolean loreInsensitive = this instanceof ChargableItem || this instanceof SlimefunBackpack || id.equals("BROKEN_SPAWNER") || id.equals("REINFORCED_SPAWNER");
return SlimefunUtils.isItemSimilar(item, this.item, !loreInsensitive);
}
else {
boolean loreInsensitive = this instanceof SlimefunBackpack || id.equals("BROKEN_SPAWNER") || id.equals("REINFORCED_SPAWNER");
return SlimefunUtils.isItemSimilar(item, this.item, !loreInsensitive);
return false;
}
}
@ -790,7 +792,9 @@ public class SlimefunItem implements Placeable {
}
public static SlimefunItem getByItem(ItemStack item) {
if (item == null || item.getType() == Material.AIR) return null;
if (item == null || item.getType() == Material.AIR) {
return null;
}
if (item instanceof SlimefunItemStack) {
return getByID(((SlimefunItemStack) item).getItemId());