diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7e2d31448..c0e57560f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -65,6 +65,8 @@
* Salt now only requires 2 blocks of Sand
* Fireworks from researching no longer damages entities
* Very slight performance improvements for Cargo networks
+* 4K-carat gold ingots can now be used in a workbench by default (overridden by Items.yml)
+* The project license is now included in every build
#### Fixes
* Fixed some languages showing numbers larger than 100%
diff --git a/README.md b/README.md
index 69453ee24..5e41b65dc 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,8 @@ Check out our [Addons](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Addons),
* **[Wiki](https://github.com/TheBusyBiscuit/Slimefun4/wiki)**
## Download Slimefun 4
-Slimefun 4 can be downloaded for free on our builds page.
+(See also: [How to install Slimefun](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Installing-Slimefun))
+Slimefun 4 can be downloaded **for free** on our builds page.
We currently provide two versions of Slimefun, development builds and "stable" builds.
Here is a full summary of the differences between these two versions of Slimefun.
@@ -30,7 +31,7 @@ Here is a full summary of the differences between these two versions of Slimefun
| **Bug Reports** | :heavy_check_mark: | :x: |
| **frequent updates & fast patches** | :heavy_check_mark: | :x: |
| **change logs** | :x: | :memo: **[change log](https://github.com/TheBusyBiscuit/Slimefun4/blob/master/CHANGELOG.md)** |
-| **Download** | :package: **[download development build](https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/master/)** | :package: **[download "stable" build](https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/)** |
+| **Download link** | :package: **[download development build](https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/master/)** | :package: **[download "stable" build](https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/)** |
**We wholeheartedly recommend you to use development builds.**
But we can understand the use of "stable" builds if your server's livelihood heavily depends on Slimefun.
@@ -80,9 +81,10 @@ https://github.com/TheBusyBiscuit/Slimefun4/wiki
* [Common issues](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Common-Issues)
## Contributing to this project
-Slimefun 4 is licensed under
+Slimefun 4 is an Open-Source project and licensed under
[GNU GPLv3](https://github.com/TheBusyBiscuit/Slimefun4/blob/master/LICENSE).
-Over 100 people have already contributed to this amazing project. You guys are awesome.
+Over 100 people have already contributed to this amazing project. You guys are awesome.
+Please consider helping us maintain this project too, your engagement keeps the project alive <3.
diff --git a/lib/ExoticGarden v1.2.0.jar b/lib/ExoticGarden v1.2.0.jar
deleted file mode 100644
index 67acb61f6..000000000
Binary files a/lib/ExoticGarden v1.2.0.jar and /dev/null differ
diff --git a/pom.xml b/pom.xml
index e9a21a165..11eb5f36f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,12 +4,20 @@
4.0.0
me.mrCookieSlime
Slimefun
+
+
+
UNOFFICIAL
1.8
1.8
UTF-8
+
+
+ TheBusyBiscuit_Slimefun4
+ thebusybiscuit-github
+ https://sonarcloud.io
@@ -30,7 +38,7 @@
https://maven.sk89q.com/repo/
- CodeMC
+ bStats-repo
https://repo.codemc.org/repository/maven-public
@@ -50,6 +58,8 @@
3.8.1
+
+
**/package-info.java
@@ -75,6 +85,8 @@
3.2.2
+
+
org.bstats
@@ -85,6 +97,16 @@
me.mrCookieSlime.Slimefun.cscorelib2
+
+
+
+
+ *:*
+
+ META-INF/*
+
+
+
@@ -101,16 +123,22 @@
org.apache.maven.plugins
maven-javadoc-plugin
3.2.0
+
${project.basedir}
docs
+
Slimefun4 - Javadocs
Slimefun4 - Javadocs
false
-html5
+
+
https://hub.spigotmc.org/javadocs/bukkit/
+
+
Slimefun4 - API
@@ -138,6 +166,8 @@
+
+
${basedir}/src/main/resources
true
@@ -147,10 +177,20 @@
languages/*
+
+
+
+ ${basedir}
+
+
+ LICENSE
+
+
+
org.bukkit
bukkit
@@ -163,6 +203,8 @@
8081bb4fe4
provided
+
+
com.github.thebusybiscuit
CS-CoreLib2
@@ -175,6 +217,8 @@
1.7
compile
+
+
com.sk89q.worldedit
worldedit-bukkit
@@ -184,9 +228,12 @@
me.clip
placeholderapi
- 2.10.4
+ 2.10.5
provided
+
+
+
me.minebuilders
clearlag-core
@@ -201,12 +248,5 @@
system
${project.basedir}/lib/EmeraldEnchants v2.0.jar
-
- me.mrCookieSlime
- ExoticGarden
- 1.2.0
- system
- ${project.basedir}/lib/ExoticGarden v1.2.0.jar
-
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java
index 3f7e27d73..e22efd4db 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java
@@ -159,7 +159,7 @@ public class ErrorReport {
});
}
- private void scanPlugins(List plugins, List addons) {
+ private static void scanPlugins(List plugins, List addons) {
String dependency = "Slimefun";
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
@@ -180,7 +180,7 @@ public class ErrorReport {
}
}
- private File getNewFile() {
+ private static File getNewFile() {
String path = "plugins/Slimefun/error-reports/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
File newFile = new File(path + ".err");
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java
index 8aba6164a..b9d67d5d2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java
@@ -33,7 +33,7 @@ public enum MinecraftVersion {
private final String name;
private final String prefix;
- private MinecraftVersion(String name) {
+ MinecraftVersion(String name) {
this.name = name;
this.prefix = name().replace("MINECRAFT_", "v") + '_';
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
index 05c1d6ea1..36112f677 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java
@@ -33,7 +33,7 @@ public enum SlimefunBranch {
private final String name;
private final boolean official;
- private SlimefunBranch(String name, boolean official) {
+ SlimefunBranch(String name, boolean official) {
this.name = name;
this.official = official;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java
index 485e113d6..5d1cd6aba 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java
@@ -11,7 +11,7 @@ public enum MachineTier {
private final String prefix;
- private MachineTier(String prefix) {
+ MachineTier(String prefix) {
this.prefix = prefix;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java
index 9e83eec6c..6eaa22301 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java
@@ -8,7 +8,7 @@ public enum MachineType {
private final String suffix;
- private MachineType(String suffix) {
+ MachineType(String suffix) {
this.suffix = suffix;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java
index 73f7a41c1..4c25a67f8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java
@@ -47,7 +47,7 @@ public enum Radioactivity {
private final ChatColor color;
- private Radioactivity(ChatColor color) {
+ Radioactivity(ChatColor color) {
this.color = color;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideSettings.java
index bd941bf5e..b1f9047e4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideSettings.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideSettings.java
@@ -184,7 +184,7 @@ public final class SlimefunGuideSettings {
Language language = SlimefunPlugin.getLocal().getLanguage(p);
String languageName = language.isDefault() ? (SlimefunPlugin.getLocal().getMessage(p, "languages.default") + ChatColor.DARK_GRAY + " (" + language.getName(p) + ")") : SlimefunPlugin.getLocal().getMessage(p, "languages." + language.getID());
- menu.addItem(i, new CustomItem(language.getItem(), "&7" + SlimefunPlugin.getLocal().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, "", "&7You now have the option to change", "&7the language in which Slimefun", "&7will send you messages.", "&7Note that this only translates", "&7messages, not items.", "", "&7\u21E8 &eClick to change your language"), (pl, slot, item, action) -> {
+ menu.addItem(i, new CustomItem(language.getItem(), "&7" + SlimefunPlugin.getLocal().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, "", "&7You now have the option to change", "&7the language in which Slimefun", "&7will send you messages.", "&7Note that this only translates", "&7some messages, not items.", "&7&oThis feature is still being worked on", "", "&7\u21E8 &eClick to change your language"), (pl, slot, item, action) -> {
openLanguages(pl);
return false;
});
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/EmbeddedLanguage.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/EmbeddedLanguage.java
index d438eddfc..b8723f3da 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/EmbeddedLanguage.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/EmbeddedLanguage.java
@@ -53,7 +53,7 @@ enum EmbeddedLanguage {
private final String id;
private final String textureHash;
- private EmbeddedLanguage(String id, String textureHash) {
+ EmbeddedLanguage(String id, String textureHash) {
this.id = id;
this.textureHash = textureHash;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagHook.java
index 607b12934..74a5c4128 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagHook.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagHook.java
@@ -7,6 +7,7 @@ import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.minebuilders.clearlag.events.EntityRemoveEvent;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
@@ -23,7 +24,7 @@ class ClearLagHook implements Listener {
while (iterator.hasNext()) {
Entity n = iterator.next();
- if (n instanceof Item && n.hasMetadata("no_pickup")) {
+ if (n instanceof Item && SlimefunUtils.hasNoPickupFlag((Item) n)) {
iterator.remove();
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java
index 54ec314fc..b621daabf 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java
@@ -1,7 +1,11 @@
package io.github.thebusybiscuit.slimefun4.core.services.plugins;
+import java.util.Optional;
+import java.util.function.Function;
import java.util.logging.Level;
+import org.bukkit.block.Block;
+import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
@@ -28,6 +32,8 @@ public class ThirdPartyPluginService {
private boolean isEmeraldEnchantsInstalled = false;
private boolean isCoreProtectInstalled = false;
private boolean isPlaceholderAPIInstalled = false;
+
+ private Function> exoticGardenIntegration;
public ThirdPartyPluginService(SlimefunPlugin plugin) {
this.plugin = plugin;
@@ -48,8 +54,7 @@ public class ThirdPartyPluginService {
if (isPluginInstalled("ClearLag")) {
new ClearLagHook(plugin);
}
-
- isExoticGardenInstalled = isPluginInstalled("ExoticGarden");
+
isChestTerminalInstalled = isPluginInstalled("ChestTerminal");
isEmeraldEnchantsInstalled = isPluginInstalled("EmeraldEnchants");
@@ -78,6 +83,13 @@ public class ThirdPartyPluginService {
return false;
}
}
+
+ public void loadExoticGarden(Plugin plugin, Function> method) {
+ if (plugin.getName().equals("ExoticGarden")) {
+ isExoticGardenInstalled = true;
+ exoticGardenIntegration = method;
+ }
+ }
public boolean isExoticGardenInstalled() {
return isExoticGardenInstalled;
@@ -99,4 +111,8 @@ public class ThirdPartyPluginService {
return isPlaceholderAPIInstalled;
}
+ public Optional harvestExoticGardenPlant(Block block) {
+ return exoticGardenIntegration.apply(block);
+ }
+
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
index 7e87f4964..cbf47f73e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
@@ -451,7 +451,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
ChestMenu menu = create(p);
Optional wiki = item.getWikipage();
-
+
if (wiki.isPresent()) {
menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK, ChatColor.RESET + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.open-category")));
menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> {
@@ -614,7 +614,17 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
int outputs = 45;
for (int i = 0; i < 18; i++) {
- int slot = i % 2 == 0 ? inputs++ : outputs++;
+ int slot;
+
+ if (i % 2 == 0) {
+ slot = inputs;
+ inputs++;
+ }
+ else {
+ slot = outputs;
+ outputs++;
+ }
+
addDisplayRecipe(menu, profile, recipes, slot, i, page);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java
index d64cff810..1c94c55e2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java
@@ -1,11 +1,12 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
+import java.util.Optional;
+
import org.bukkit.Effect;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import me.mrCookieSlime.ExoticGarden.ExoticGarden;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
@@ -38,11 +39,15 @@ public abstract class AdvancedFarmerAndroid extends FarmerAndroid {
farm(menu, block);
if (SlimefunPlugin.getThirdPartySupportService().isExoticGardenInstalled()) {
- ItemStack drop = ExoticGarden.harvestPlant(block);
+ Optional result = SlimefunPlugin.getThirdPartySupportService().harvestExoticGardenPlant(block);
- if (drop != null && menu.fits(drop, getOutputSlots())) {
+ if (result.isPresent()) {
+ ItemStack drop = result.get();
menu.pushItem(drop, getOutputSlots());
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+
+ if (menu.fits(drop, getOutputSlots())) {
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
+ }
}
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ScriptAction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ScriptAction.java
index 1759fd11c..45138b81b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ScriptAction.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ScriptAction.java
@@ -56,7 +56,7 @@ enum ScriptAction {
private final ItemStack item;
private final AndroidType type;
- private ScriptAction(AndroidType type, String texture) {
+ ScriptAction(AndroidType type, String texture) {
this.type = type;
this.item = SkullItem.fromHash(texture);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java
index 99a1ec638..a3c2b680b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java
@@ -9,6 +9,7 @@ import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
@@ -41,7 +42,7 @@ public class InfusedHopper extends SimpleSlimefunItem {
Location l = b.getLocation().add(0.5, 1.2, 0.5);
boolean sound = false;
- for (Entity item : b.getWorld().getNearbyEntities(l, 3.5D, 3.5D, 3.5D, n -> n instanceof Item && n.isValid() && !n.hasMetadata("no_pickup") && n.getLocation().distanceSquared(l) > 0.25)) {
+ for (Entity item : b.getWorld().getNearbyEntities(l, 3.5D, 3.5D, 3.5D, n -> isValidItem(l, n))) {
item.setVelocity(new Vector(0, 0.1, 0));
item.teleport(l);
sound = true;
@@ -58,4 +59,13 @@ public class InfusedHopper extends SimpleSlimefunItem {
}
};
}
+
+ private boolean isValidItem(Location l, Entity entity) {
+ if (entity instanceof Item && entity.isValid()) {
+ Item item = (Item) entity;
+ return !SlimefunUtils.hasNoPickupFlag(item) && item.getLocation().distanceSquared(l) > 0.25;
+ }
+
+ return false;
+ }
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java
index ff12e2ea2..a6d03718c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java
@@ -94,7 +94,8 @@ public class StormStaff extends SimpleSlimefunItem {
item.setAmount(0);
}
else {
- itemMeta.getPersistentDataContainer().set(usageKey, PersistentDataType.INTEGER, --currentUses);
+ currentUses--;
+ itemMeta.getPersistentDataContainer().set(usageKey, PersistentDataType.INTEGER, currentUses);
itemLore.set(4, ChatColor.translateAlternateColorCodes('&', "&e" + currentUses + ' ' + (currentUses > 1 ? "Uses" : "Use") + " &7left"));
itemMeta.setLore(itemLore);
item.setItemMeta(itemMeta);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java
index c5521e2a2..4235ea6ac 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java
@@ -25,7 +25,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
@@ -135,7 +134,7 @@ public class AncientAltarListener implements Listener {
p.playSound(pedestal.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 1F);
}
}
-
+
private void useAltar(Block b, Player p) {
ItemStack catalyst = new CustomItem(p.getInventory().getItemInMainHand(), 1);
List pedestals = getPedestals(b);
@@ -258,7 +257,7 @@ public class AncientAltarListener implements Listener {
String nametag = ItemUtils.getItemName(stack);
Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(stack, "&5&dALTAR &3Probe - &e" + System.nanoTime()));
entity.setVelocity(new Vector(0, 0.1, 0));
- entity.setMetadata("no_pickup", new FixedMetadataValue(SlimefunPlugin.instance, "altar_item"));
+ SlimefunUtils.markAsNoPickup(entity, "altar_item");
entity.setCustomNameVisible(true);
entity.setCustomName(nametag);
p.playSound(b.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.3F, 0.3F);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java
index cb482b79e..d5feaaccd 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java
@@ -18,6 +18,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.api.Slimefun;
@@ -43,7 +44,7 @@ public class ButcherAndroidListener implements Listener {
List items = new ArrayList<>();
for (Entity n : e.getEntity().getNearbyEntities(0.5D, 0.5D, 0.5D)) {
- if (n instanceof Item && !n.hasMetadata("no_pickup")) {
+ if (n instanceof Item && n.isValid() && !SlimefunUtils.hasNoPickupFlag((Item) n)) {
items.add(((Item) n).getItemStack());
n.remove();
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java
index aab28e4de..1a3abb542 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java
@@ -6,6 +6,7 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
/**
@@ -15,7 +16,6 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
*/
public class ItemPickupListener implements Listener {
- private static final String METADATA_JEY = "no_pickup";
private static final String ITEM_PREFIX = ChatColors.color("&5&dALTAR &3Probe - &e");
public ItemPickupListener(SlimefunPlugin plugin) {
@@ -24,7 +24,7 @@ public class ItemPickupListener implements Listener {
@EventHandler
public void onEntityPickup(EntityPickupItemEvent e) {
- if (e.getItem().hasMetadata(METADATA_JEY)) {
+ if (SlimefunUtils.hasNoPickupFlag(e.getItem())) {
e.setCancelled(true);
}
else if (e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ITEM_PREFIX)) {
@@ -35,7 +35,7 @@ public class ItemPickupListener implements Listener {
@EventHandler
public void onHopperPickup(InventoryPickupItemEvent e) {
- if (e.getItem().hasMetadata(METADATA_JEY)) {
+ if (SlimefunUtils.hasNoPickupFlag(e.getItem())) {
e.setCancelled(true);
}
else if (e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ITEM_PREFIX)) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java
index 9ec59e8e5..185715ab7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java
@@ -6,6 +6,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
+import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
+
public class MagnetTask extends SlimefunTask {
public MagnetTask(Player p) {
@@ -14,10 +16,14 @@ public class MagnetTask extends SlimefunTask {
@Override
public void executeTask() {
- for (Entity item : p.getNearbyEntities(6D, 6D, 6D)) {
- if (item instanceof Item && !item.hasMetadata("no_pickup") && ((Item) item).getPickupDelay() <= 0) {
- item.teleport(p.getEyeLocation());
- p.getWorld().playSound(p.getEyeLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F);
+ for (Entity n : p.getNearbyEntities(6D, 6D, 6D)) {
+ if (n instanceof Item) {
+ Item item = (Item) n;
+
+ if (!SlimefunUtils.hasNoPickupFlag(item) && item.getPickupDelay() <= 0) {
+ item.teleport(p.getEyeLocation());
+ p.getWorld().playSound(p.getEyeLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F);
+ }
}
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java
new file mode 100644
index 000000000..b83690daa
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java
@@ -0,0 +1,101 @@
+package io.github.thebusybiscuit.slimefun4.implementation.tasks;
+
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.ButcherAndroidListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.TeleporterListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener;
+import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
+import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+import me.mrCookieSlime.Slimefun.api.BlockStorage;
+
+/**
+ * This Task initializes all items, some listeners and various other stuff.
+ * This has been moved to its own class to make timings log easier to read, so
+ * they say "SlimefunStartupTask" instead of "Slimefun:lambda:123456789".
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+public class SlimefunStartupTask implements Runnable {
+
+ private final SlimefunPlugin plugin;
+ private final Runnable runnable;
+
+ /**
+ * This initializes our {@link SlimefunStartupTask} for the given {@link SlimefunPlugin}.
+ *
+ * @param plugin
+ * The main instance of our {@link SlimefunPlugin}
+ * @param runnable
+ * A {@link Runnable} containing additional operations that need to be run
+ */
+ public SlimefunStartupTask(SlimefunPlugin plugin, Runnable runnable) {
+ this.plugin = plugin;
+ this.runnable = runnable;
+ }
+
+ @Override
+ public void run() {
+ runnable.run();
+
+ // Load all items
+ PostSetup.loadItems();
+
+ // Load all worlds
+ for (World world : Bukkit.getWorlds()) {
+ new BlockStorage(world);
+ }
+
+ // Load all listeners that depend on items to be enabled
+
+ if (isEnabled("ANCIENT_ALTAR")) {
+ SlimefunPlugin.getAncientAltarListener().load(plugin);
+ }
+
+ if (isEnabled("GRAPPLING_HOOK")) {
+ SlimefunPlugin.getGrapplingHookListener().load(plugin);
+ }
+
+ if (isEnabled("BLADE_OF_VAMPIRES")) {
+ new VampireBladeListener(plugin);
+ }
+
+ if (isEnabled("COOLER")) {
+ new CoolerListener(plugin);
+ }
+
+ if (isEnabled("SEISMIC_AXE")) {
+ new SeismicAxeListener(plugin);
+ }
+
+ if (isEnabled("ELEVATOR_PLATE", "GPS_ACTIVATION_DEVICE_SHARED", "GPS_ACTIVATION_DEVICE_PERSONAL")) {
+ new TeleporterListener(plugin);
+ }
+
+ if (isEnabled("PROGRAMMABLE_ANDROID_BUTCHER", "PROGRAMMABLE_ANDROID_2_BUTCHER", "PROGRAMMABLE_ANDROID_3_BUTCHER")) {
+ new ButcherAndroidListener(plugin);
+ }
+
+ if (isEnabled("ENERGY_REGULATOR", "CARGO_MANAGER")) {
+ new NetworkListener(plugin);
+ }
+ }
+
+ private boolean isEnabled(String... itemIds) {
+ for (String id : itemIds) {
+ SlimefunItem item = SlimefunItem.getByID(id);
+
+ if (item != null && !item.isDisabled()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java
index b627810d4..73c4dc266 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java
@@ -333,4 +333,16 @@ public class TickerTask implements Runnable {
delete.put(l, destroy);
}
+ public void start(SlimefunPlugin plugin) {
+ plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
+ try {
+ run();
+ }
+ catch (Throwable x) {
+ plugin.getLogger().log(Level.SEVERE, x, () -> "An Exception was caught while ticking the Block Tickers Task for Slimefun v" + SlimefunPlugin.getVersion());
+ abortTick();
+ }
+ }, 100L, SlimefunPlugin.getCfg().getInt("URID.custom-ticker-delay"));
+ }
+
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
index 3f5502105..d0f976872 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java
@@ -5,12 +5,15 @@ import java.util.Optional;
import org.bukkit.ChatColor;
import org.bukkit.Material;
+import org.bukkit.entity.Item;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.metadata.FixedMetadataValue;
import io.github.thebusybiscuit.cscorelib2.item.ImmutableItemMeta;
import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound;
+import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
import me.mrCookieSlime.EmeraldEnchants.EmeraldEnchants;
import me.mrCookieSlime.EmeraldEnchants.ItemEnchantment;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
@@ -31,9 +34,35 @@ public final class SlimefunUtils {
private static final String EMERALDENCHANTS_LORE = ChatColor.YELLOW.toString() + ChatColor.YELLOW.toString() + ChatColor.GRAY.toString();
private static final String SOULBOUND_LORE = ChatColor.GRAY + "Soulbound";
+ private static final String NO_PICKUP_METADATA = "no_pickup";
private SlimefunUtils() {}
+ /**
+ * This method quickly returns whether an {@link Item} was marked as "no_pickup" by
+ * a Slimefun device.
+ *
+ * @param item
+ * The {@link Item} to query
+ * @return Whether the {@link Item} is excluded from being picked up
+ */
+ public static boolean hasNoPickupFlag(Item item) {
+ return !item.hasMetadata(NO_PICKUP_METADATA);
+ }
+
+ /**
+ * This will prevent the given {@link Item} from being picked up.
+ * This is useful for display items which the {@link AncientPedestal} uses.
+ *
+ * @param item
+ * The {@link Item} to prevent from being picked up
+ * @param context
+ * The context in which this {@link Item} was flagged
+ */
+ public static void markAsNoPickup(Item item, String context) {
+ item.setMetadata(NO_PICKUP_METADATA, new FixedMetadataValue(SlimefunPlugin.instance, context));
+ }
+
/**
* This method checks whether the given {@link ItemStack} is considered {@link Soulbound}.
*
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java
index 95c79bbac..ecc0d0427 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java
@@ -16,6 +16,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import io.github.thebusybiscuit.cscorelib2.config.Config;
+import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
@@ -41,8 +42,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarL
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.ButcherAndroidListener;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener;
@@ -55,9 +54,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHook
import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener;
@@ -65,8 +62,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemC
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.TeleporterListener;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener;
@@ -75,9 +70,9 @@ import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
+import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
@@ -135,6 +130,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
@Override
public void onEnable() {
if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
+ long timestamp = System.nanoTime();
// We wanna ensure that the Server uses a compatible version of Minecraft
if (isVersionUnsupported()) {
@@ -256,52 +252,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
new PlayerProfileListener(this);
// Initiating various Stuff and all Items with a slightly delay (0ms after the Server finished loading)
- Slimefun.runSync(() -> {
- textureService.register(registry.getAllSlimefunItems());
- permissionsService.register(registry.getAllSlimefunItems());
- recipeService.load();
-
+ Slimefun.runSync(new SlimefunStartupTask(this, () -> {
protections = new ProtectionManager(getServer());
-
- PostSetup.loadItems();
-
- for (World world : Bukkit.getWorlds()) {
- new BlockStorage(world);
- }
-
- if (isEnabled("ANCIENT_ALTAR")) {
- ancientAltarListener.load(this);
- }
-
- if (isEnabled("GRAPPLING_HOOK")) {
- grapplingHookListener.load(this);
- }
-
- if (isEnabled("BLADE_OF_VAMPIRES")) {
- new VampireBladeListener(this);
- }
-
- if (isEnabled("COOLER")) {
- new CoolerListener(this);
- }
-
- if (isEnabled("SEISMIC_AXE")) {
- new SeismicAxeListener(this);
- }
-
- if (isEnabled("ELEVATOR_PLATE", "GPS_ACTIVATION_DEVICE_SHARED", "GPS_ACTIVATION_DEVICE_PERSONAL")) {
- new TeleporterListener(this);
- }
-
- if (isEnabled("PROGRAMMABLE_ANDROID_BUTCHER", "PROGRAMMABLE_ANDROID_2_BUTCHER", "PROGRAMMABLE_ANDROID_3_BUTCHER")) {
- new ButcherAndroidListener(this);
- }
-
- if (isEnabled("ENERGY_REGULATOR", "CARGO_MANAGER")) {
- new NetworkListener(this);
- }
-
- }, 0);
+ }), 0);
// Setting up the command /sf and all subcommands
command.register();
@@ -312,26 +265,15 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
}
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
-
- // Starting all ASYNC Tasks
- getServer().getScheduler().runTaskTimerAsynchronously(this, () -> {
- try {
- ticker.run();
- }
- catch (Throwable x) {
- getLogger().log(Level.SEVERE, x, () -> "An Exception was caught while ticking the Block Tickers Task for Slimefun v" + getVersion());
- ticker.abortTick();
- }
- }, 100L, config.getInt("URID.custom-ticker-delay"));
-
+ ticker.start(this);
+ thirdPartySupportService.start();
gitHubService.start(this);
- // Hooray!
- getLogger().log(Level.INFO, "Finished!");
- thirdPartySupportService.start();
-
- // Do not show /sf elevator command in our Log, it could get quite spammy
+ // Exclude the command /sf elevator from our server log, it could get quite spammy
CSCoreLib.getLib().filterLog("([A-Za-z0-9_]{3,16}) issued server command: /sf elevator (.{0,})");
+
+ // Hooray!
+ getLogger().log(Level.INFO, "Slimefun has finished loading in {0}ms", DoubleHandler.fixDouble((System.nanoTime() - timestamp) / 1000000.0));
}
else {
getLogger().log(Level.INFO, "#################### - INFO - ####################");
@@ -349,17 +291,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
}
}
- private boolean isEnabled(String... itemIds) {
- for (String id : itemIds) {
- SlimefunItem item = SlimefunItem.getByID(id);
-
- if (item != null && !item.isDisabled()) {
- return true;
- }
- }
- return false;
- }
-
private boolean isVersionUnsupported() {
String currentVersion = ReflectionUtils.getVersion();