mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Refactored some things
This commit is contained in:
parent
e0860fd2f1
commit
3e90349551
@ -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%
|
||||
|
10
README.md
10
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.<br>
|
||||
(See also: [How to install Slimefun](https://github.com/TheBusyBiscuit/Slimefun4/wiki/Installing-Slimefun))<br>
|
||||
Slimefun 4 can be downloaded **for free** on our builds page.<br>
|
||||
We currently provide two versions of Slimefun, development builds and "stable" builds.<br>
|
||||
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.**<br>
|
||||
But we can understand the use of "stable" builds if your server's livelihood heavily depends on Slimefun.<br>
|
||||
@ -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).<br>
|
||||
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.<br>
|
||||
Please consider helping us maintain this project too, your engagement keeps the project alive <3.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/TheBusyBiscuit/Slimefun4/graphs/contributors">
|
||||
|
Binary file not shown.
58
pom.xml
58
pom.xml
@ -4,12 +4,20 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>me.mrCookieSlime</groupId>
|
||||
<artifactId>Slimefun</artifactId>
|
||||
|
||||
<!-- Our default version will be UNOFFICIAL, this will prevent the auto updater -->
|
||||
<!-- from overriding our local test file -->
|
||||
<version>UNOFFICIAL</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<!-- Default settings for sonarcloud.io -->
|
||||
<sonar.projectKey>TheBusyBiscuit_Slimefun4</sonar.projectKey>
|
||||
<sonar.organization>thebusybiscuit-github</sonar.organization>
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@ -30,7 +38,7 @@
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<id>bStats-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
@ -50,6 +58,8 @@
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<!-- package info files are only important to the Javadocs -->
|
||||
<!-- We can exclude them from the final jar -->
|
||||
<exclude>**/package-info.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
@ -75,6 +85,8 @@
|
||||
<version>3.2.2</version>
|
||||
|
||||
<configuration>
|
||||
|
||||
<!-- Shade bStats and CS-CoreLib2 into the output jar -->
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
@ -85,6 +97,16 @@
|
||||
<shadedPattern>me.mrCookieSlime.Slimefun.cscorelib2</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
|
||||
<!-- Exclude unneeded metadata from shaded dependencies -->
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
@ -101,16 +123,22 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
|
||||
<configuration>
|
||||
<reportOutputDirectory>${project.basedir}</reportOutputDirectory>
|
||||
<destDir>docs</destDir>
|
||||
|
||||
<doctitle>Slimefun4 - Javadocs</doctitle>
|
||||
<windowtitle>Slimefun4 - Javadocs</windowtitle>
|
||||
<detectOfflineLinks>false</detectOfflineLinks>
|
||||
<additionalJOption>-html5</additionalJOption>
|
||||
|
||||
<!-- We can reference Bukkit's API in our Javadocs -->
|
||||
<links>
|
||||
<link>https://hub.spigotmc.org/javadocs/bukkit/</link>
|
||||
</links>
|
||||
|
||||
<!-- We can group pakages together in our Javadocs -->
|
||||
<groups>
|
||||
<group>
|
||||
<title>Slimefun4 - API</title>
|
||||
@ -138,6 +166,8 @@
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Resources we want to include, such as configs or language files -->
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
@ -147,10 +177,20 @@
|
||||
<include>languages/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
|
||||
<!-- We also want to include our LICENSE file -->
|
||||
<resource>
|
||||
<directory>${basedir}</directory>
|
||||
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- Hard dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
@ -163,6 +203,8 @@
|
||||
<version>8081bb4fe4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Shaded packages -->
|
||||
<dependency>
|
||||
<groupId>com.github.thebusybiscuit</groupId>
|
||||
<artifactId>CS-CoreLib2</artifactId>
|
||||
@ -175,6 +217,8 @@
|
||||
<version>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Third party plugin integrations -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
@ -184,9 +228,12 @@
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>2.10.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- System dependencies, these projects have no repository -->
|
||||
<!-- In EmeraldEnchant's case it would create a dependency loop otherwise -->
|
||||
<dependency>
|
||||
<groupId>me.minebuilders</groupId>
|
||||
<artifactId>clearlag-core</artifactId>
|
||||
@ -201,12 +248,5 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/EmeraldEnchants v2.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.mrCookieSlime</groupId>
|
||||
<artifactId>ExoticGarden</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/ExoticGarden v1.2.0.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -159,7 +159,7 @@ public class ErrorReport {
|
||||
});
|
||||
}
|
||||
|
||||
private void scanPlugins(List<String> plugins, List<String> addons) {
|
||||
private static void scanPlugins(List<String> plugins, List<String> 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");
|
||||
|
||||
|
@ -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") + '_';
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public enum MachineTier {
|
||||
|
||||
private final String prefix;
|
||||
|
||||
private MachineTier(String prefix) {
|
||||
MachineTier(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ public enum MachineType {
|
||||
|
||||
private final String suffix;
|
||||
|
||||
private MachineType(String suffix) {
|
||||
MachineType(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public enum Radioactivity {
|
||||
|
||||
private final ChatColor color;
|
||||
|
||||
private Radioactivity(ChatColor color) {
|
||||
Radioactivity(ChatColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -29,6 +33,8 @@ public class ThirdPartyPluginService {
|
||||
private boolean isCoreProtectInstalled = false;
|
||||
private boolean isPlaceholderAPIInstalled = false;
|
||||
|
||||
private Function<Block, Optional<ItemStack>> exoticGardenIntegration;
|
||||
|
||||
public ThirdPartyPluginService(SlimefunPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -49,7 +55,6 @@ public class ThirdPartyPluginService {
|
||||
new ClearLagHook(plugin);
|
||||
}
|
||||
|
||||
isExoticGardenInstalled = isPluginInstalled("ExoticGarden");
|
||||
isChestTerminalInstalled = isPluginInstalled("ChestTerminal");
|
||||
isEmeraldEnchantsInstalled = isPluginInstalled("EmeraldEnchants");
|
||||
|
||||
@ -79,6 +84,13 @@ public class ThirdPartyPluginService {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadExoticGarden(Plugin plugin, Function<Block, Optional<ItemStack>> 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<ItemStack> harvestExoticGardenPlant(Block block) {
|
||||
return exoticGardenIntegration.apply(block);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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,13 +39,17 @@ public abstract class AdvancedFarmerAndroid extends FarmerAndroid {
|
||||
farm(menu, block);
|
||||
|
||||
if (SlimefunPlugin.getThirdPartySupportService().isExoticGardenInstalled()) {
|
||||
ItemStack drop = ExoticGarden.harvestPlant(block);
|
||||
Optional<ItemStack> result = SlimefunPlugin.getThirdPartySupportService().harvestExoticGardenPlant(block);
|
||||
|
||||
if (drop != null && menu.fits(drop, getOutputSlots())) {
|
||||
if (result.isPresent()) {
|
||||
ItemStack drop = result.get();
|
||||
menu.pushItem(drop, getOutputSlots());
|
||||
|
||||
if (menu.fits(drop, getOutputSlots())) {
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<BlockTicker> {
|
||||
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<BlockTicker> {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,8 @@ public class StormStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
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);
|
||||
|
@ -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;
|
||||
@ -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);
|
||||
|
@ -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<ItemStack> 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();
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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,13 +16,17 @@ 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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValid() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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}.
|
||||
*
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user