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

Fixes #2454 (Added mcMMO support)

This commit is contained in:
TheBusyBiscuit 2020-10-14 00:24:01 +02:00
parent 5c0b7e2ee2
commit 19de4c8476
8 changed files with 84 additions and 22 deletions

View File

@ -42,6 +42,7 @@
* Added Energy Connector
* Blackstone can now be turned into lava using a Crucible
* Basalt can now be turned into lava using a Crucible
* Added mcMMO support/integration
#### Changes
* Improved Auto-Updater (Multi-Threading and more)
@ -84,6 +85,7 @@
* Fixed Steel Thrusters being used to milk cows
* Fixed #2424
* Fixed #2468
* Fixed #2454
## Release Candidate 16 (07 Sep 2020)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16

30
pom.xml
View File

@ -64,6 +64,10 @@
<id>worldedit-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<id>placeholderapi-repo</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
@ -368,6 +372,32 @@
<groupId>de.schlichtherle</groupId>
<artifactId>truezip</artifactId>
</exclusion>
<exclusion>
<groupId>net.java.truevfs</groupId>
<artifactId>truevfs-profile-default_2.13</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.149</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<!-- We use javax.annotation instead. Excluding this -->
<!-- prevents us from using inconsistent annotations -->
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@ -13,9 +13,9 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.minebuilders.clearlag.events.EntityRemoveEvent;
class ClearLagHook implements Listener {
class ClearLagIntegration implements Listener {
ClearLagHook(@Nonnull SlimefunPlugin plugin) {
ClearLagIntegration(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

View File

@ -0,0 +1,26 @@
package io.github.thebusybiscuit.slimefun4.core.services.plugins;
import javax.annotation.Nonnull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.gmail.nossr50.mcMMO;
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
class McMMOIntegration implements Listener {
McMMOIntegration(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlacerPlace(BlockPlacerPlaceEvent e) {
// This registers blocks placed by the BlockPlacer as "player-placed"
mcMMO.getPlaceStore().setTrue(e.getBlock());
}
}

View File

@ -15,12 +15,12 @@ import io.github.thebusybiscuit.slimefun4.core.researching.Research;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
class PlaceholderAPIHook extends PlaceholderExpansion {
class PlaceholderAPIIntegration extends PlaceholderExpansion {
private final String version;
private final String author;
public PlaceholderAPIHook(@Nonnull SlimefunPlugin plugin) {
public PlaceholderAPIIntegration(@Nonnull SlimefunPlugin plugin) {
this.version = plugin.getDescription().getVersion();
this.author = plugin.getDescription().getAuthors().toString();
}

View File

@ -5,6 +5,7 @@ import java.util.function.Function;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
@ -34,12 +35,18 @@ public class ThirdPartyPluginService {
private boolean isExoticGardenInstalled = false;
private boolean isChestTerminalInstalled = false;
private boolean isEmeraldEnchantsInstalled = false;
private boolean isCoreProtectInstalled = false;
private boolean isPlaceholderAPIInstalled = false;
// Overridden if ExoticGarden is loaded
/**
* This gets overridden if ExoticGarden is loaded
*/
private Function<Block, Optional<ItemStack>> exoticGardenIntegration = b -> Optional.empty();
/**
* This initializes the {@link ThirdPartyPluginService}
*
* @param plugin
* Our instance of {@link SlimefunPlugin}
*/
public ThirdPartyPluginService(@Nonnull SlimefunPlugin plugin) {
this.plugin = plugin;
}
@ -47,9 +54,8 @@ public class ThirdPartyPluginService {
public void start() {
if (isPluginInstalled("PlaceholderAPI")) {
try {
PlaceholderAPIHook hook = new PlaceholderAPIHook(plugin);
PlaceholderAPIIntegration hook = new PlaceholderAPIIntegration(plugin);
hook.register();
isPlaceholderAPIInstalled = true;
} catch (Exception | LinkageError x) {
String version = plugin.getServer().getPluginManager().getPlugin("PlaceholderAPI").getDescription().getVersion();
@ -69,7 +75,7 @@ public class ThirdPartyPluginService {
if (isPluginInstalled("WorldEdit")) {
try {
Class.forName("com.sk89q.worldedit.extent.Extent");
new WorldEditHook();
new WorldEditIntegration();
} catch (Exception | LinkageError x) {
String version = plugin.getServer().getPluginManager().getPlugin("WorldEdit").getDescription().getVersion();
@ -78,6 +84,11 @@ public class ThirdPartyPluginService {
}
}
// mcMMO Block Placer Integration
if (isPluginInstalled("mcMMO")) {
new McMMOIntegration(plugin);
}
/*
* These Items are not marked as soft-dependencies and
* therefore need to be loaded after the Server has finished
@ -85,7 +96,7 @@ public class ThirdPartyPluginService {
*/
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (isPluginInstalled("ClearLag")) {
new ClearLagHook(plugin);
new ClearLagIntegration(plugin);
}
isChestTerminalInstalled = isPluginInstalled("ChestTerminal");
@ -101,6 +112,7 @@ public class ThirdPartyPluginService {
}
}
@ParametersAreNonnullByDefault
public void loadExoticGarden(Plugin plugin, Function<Block, Optional<ItemStack>> method) {
if (plugin.getName().equals("ExoticGarden")) {
isExoticGardenInstalled = true;
@ -120,14 +132,6 @@ public class ThirdPartyPluginService {
return isEmeraldEnchantsInstalled;
}
public boolean isCoreProtectInstalled() {
return isCoreProtectInstalled;
}
public boolean isPlaceholderAPIInstalled() {
return isPlaceholderAPIInstalled;
}
public Optional<ItemStack> harvestExoticGardenPlant(Block block) {
return exoticGardenIntegration.apply(block);
}

View File

@ -14,9 +14,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
class WorldEditHook {
class WorldEditIntegration {
WorldEditHook() {
WorldEditIntegration() {
WorldEdit.getInstance().getEventBus().register(this);
}

View File

@ -5,7 +5,7 @@ description: Slimefun basically turns your entire Server into a FTB modpack with
website: https://github.com/Slimefun
main: io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin
softdepend: [CS-CoreLib, PlaceholderAPI, WorldEdit, EmeraldEnchants]
softdepend: [CS-CoreLib, PlaceholderAPI, WorldEdit, EmeraldEnchants, mcMMO]
api-version: '1.13'