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

Small refactoring

This commit is contained in:
TheBusyBiscuit 2020-05-09 18:00:10 +02:00
parent dd159184a4
commit c93c6cfa68
6 changed files with 306 additions and 307 deletions

17
pom.xml
View File

@ -28,10 +28,18 @@
</properties>
<issueManagement>
<system>GitHub</system>
<system>GitHub Issues</system>
<url>https://github.com/TheBusyBiscuit/Slimefun4/issues</url>
</issueManagement>
<licenses>
<license>
<name>GNU General Public License v3.0</name>
<url>https://github.com/TheBusyBiscuit/Slimefun4/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<repositories>
<repository>
<id>paper-repo</id>
@ -73,8 +81,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 -->
<!-- package info files are only important for Javadocs -->
<!-- We can safely exclude them from the final jar -->
<exclude>**/package-info.java</exclude>
</excludes>
</configuration>
@ -174,6 +182,7 @@
</executions>
</plugin>
<!-- Javadocs Settings -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
@ -226,7 +235,7 @@
<resources>
<!-- Resources we want to include, such as configs or language files -->
<!-- Resources we want to include, e.g. configs or language files -->
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>

View File

@ -130,10 +130,6 @@ public class SlimefunRegistry {
return enabledItems;
}
public int countNonAddonItems() {
return (int) getEnabledSlimefunItems().stream().filter(item -> !item.isAddonItem()).count();
}
public List<Research> getResearches() {
return researches;
}

View File

@ -87,13 +87,13 @@ public final class PostSetup {
CommandSender sender = Bukkit.getConsoleSender();
int total = SlimefunPlugin.getRegistry().getEnabledSlimefunItems().size();
int vanilla = SlimefunPlugin.getRegistry().countNonAddonItems();
int slimefunOnly = countNonAddonItems();
sender.sendMessage("");
sender.sendMessage(ChatColor.GREEN + "######################### - Slimefun v" + SlimefunPlugin.getVersion() + " - #########################");
sender.sendMessage("");
sender.sendMessage(ChatColor.GREEN + "Successfully loaded " + total + " Items and " + SlimefunPlugin.getRegistry().getResearches().size() + " Researches");
sender.sendMessage(ChatColor.GREEN + "( " + vanilla + " Items from Slimefun, " + (total - vanilla) + " Items from " + SlimefunPlugin.getInstalledAddons().size() + " Addons )");
sender.sendMessage(ChatColor.GREEN + "( " + slimefunOnly + " Items from Slimefun, " + (total - slimefunOnly) + " Items from " + SlimefunPlugin.getInstalledAddons().size() + " Addons )");
sender.sendMessage("");
sender.sendMessage(ChatColor.GREEN + "Slimefun is an Open-Source project that is kept alive by a large community.");
sender.sendMessage(ChatColor.GREEN + "Consider helping us maintain this project by contributing on GitHub!");
@ -117,6 +117,10 @@ public final class PostSetup {
SlimefunPlugin.getRegistry().setAutoLoadingMode(true);
}
private static int countNonAddonItems() {
return (int) SlimefunPlugin.getRegistry().getEnabledSlimefunItems().stream().filter(item -> item.getAddon() instanceof SlimefunPlugin).count();
}
private static void loadAutomaticCraftingChamber() {
AutomatedCraftingChamber crafter = (AutomatedCraftingChamber) SlimefunItems.AUTOMATED_CRAFTING_CHAMBER.getItem();

View File

@ -275,15 +275,6 @@ public class SlimefunItem implements Placeable {
}
}
/**
* This method returns whether this {@link SlimefunItem} was added by an addon.
*
* @return Whether this {@link SlimefunItem} was added by an addon.
*/
public final boolean isAddonItem() {
return !(addon instanceof SlimefunPlugin);
}
/**
* This method returns whether this {@link SlimefunItem} is disabled.
*

View File

@ -103,7 +103,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
* @author TheBusyBiscuit
*
*/
public class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
public static SlimefunPlugin instance;

View File

@ -48,7 +48,6 @@ public class TestSlimefunItemRegistration {
Assertions.assertEquals(ItemState.ENABLED, item.getState());
Assertions.assertFalse(item.isDisabled());
Assertions.assertEquals(id, item.getID());
Assertions.assertFalse(item.isAddonItem());
Assertions.assertEquals(item, SlimefunItem.getByID(id));
}