mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-02-19 01:41:22 +01:00
Fix Slimefun item eat at cauldron
This commit is contained in:
parent
f08e3caac2
commit
db428892e9
@ -1,7 +1,7 @@
|
|||||||
name: Brewery
|
name: Brewery
|
||||||
version: 3.1
|
version: 3.1
|
||||||
main: com.dre.brewery.P
|
main: com.dre.brewery.P
|
||||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker]
|
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker, Slimefun]
|
||||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
|
@ -32,6 +32,7 @@ import com.dre.brewery.filedata.UpdateChecker;
|
|||||||
import com.dre.brewery.integration.ChestShopListener;
|
import com.dre.brewery.integration.ChestShopListener;
|
||||||
import com.dre.brewery.integration.IntegrationListener;
|
import com.dre.brewery.integration.IntegrationListener;
|
||||||
import com.dre.brewery.integration.ShopKeepersListener;
|
import com.dre.brewery.integration.ShopKeepersListener;
|
||||||
|
import com.dre.brewery.integration.SlimefunListener;
|
||||||
import com.dre.brewery.integration.barrel.BlocklockerBarrel;
|
import com.dre.brewery.integration.barrel.BlocklockerBarrel;
|
||||||
import com.dre.brewery.integration.barrel.LogBlockBarrel;
|
import com.dre.brewery.integration.barrel.LogBlockBarrel;
|
||||||
import com.dre.brewery.listeners.*;
|
import com.dre.brewery.listeners.*;
|
||||||
@ -161,6 +162,9 @@ public class P extends JavaPlugin {
|
|||||||
if (BConfig.hasShopKeepers) {
|
if (BConfig.hasShopKeepers) {
|
||||||
p.getServer().getPluginManager().registerEvents(new ShopKeepersListener(), p);
|
p.getServer().getPluginManager().registerEvents(new ShopKeepersListener(), p);
|
||||||
}
|
}
|
||||||
|
if (BConfig.hasSlimefun && use1_14) {
|
||||||
|
p.getServer().getPluginManager().registerEvents(new SlimefunListener(), p);
|
||||||
|
}
|
||||||
|
|
||||||
// Heartbeat
|
// Heartbeat
|
||||||
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
||||||
@ -267,7 +271,6 @@ public class P extends JavaPlugin {
|
|||||||
BCauldronRecipe.getConfigRecipes().clear();
|
BCauldronRecipe.getConfigRecipes().clear();
|
||||||
BCauldronRecipe.numConfigRecipes = 0;
|
BCauldronRecipe.numConfigRecipes = 0;
|
||||||
BConfig.customItems.clear();
|
BConfig.customItems.clear();
|
||||||
BConfig.hasSlimefun = null;
|
|
||||||
BConfig.hasMMOItems = null;
|
BConfig.hasMMOItems = null;
|
||||||
DistortChat.commands = null;
|
DistortChat.commands = null;
|
||||||
BConfig.drainItems.clear();
|
BConfig.drainItems.clear();
|
||||||
|
@ -55,7 +55,7 @@ public class BConfig {
|
|||||||
public static boolean hasVault; // Vault
|
public static boolean hasVault; // Vault
|
||||||
public static boolean useCitadel; // CivCraft/DevotedMC Citadel
|
public static boolean useCitadel; // CivCraft/DevotedMC Citadel
|
||||||
public static boolean useGMInventories; // GamemodeInventories
|
public static boolean useGMInventories; // GamemodeInventories
|
||||||
public static Boolean hasSlimefun = null; // Slimefun ; Null if not checked
|
public static boolean hasSlimefun; // Slimefun
|
||||||
public static Boolean hasMMOItems = null; // MMOItems ; Null if not checked
|
public static Boolean hasMMOItems = null; // MMOItems ; Null if not checked
|
||||||
public static boolean hasChestShop;
|
public static boolean hasChestShop;
|
||||||
public static boolean hasShopKeepers;
|
public static boolean hasShopKeepers;
|
||||||
@ -216,6 +216,7 @@ public class BConfig {
|
|||||||
&& Integer.parseInt(plMan.getPlugin("Vault").getDescription().getVersion().split("\\.")[1]) <= 6;
|
&& Integer.parseInt(plMan.getPlugin("Vault").getDescription().getVersion().split("\\.")[1]) <= 6;
|
||||||
hasChestShop = plMan.isPluginEnabled("ChestShop");
|
hasChestShop = plMan.isPluginEnabled("ChestShop");
|
||||||
hasShopKeepers = plMan.isPluginEnabled("Shopkeepers");
|
hasShopKeepers = plMan.isPluginEnabled("Shopkeepers");
|
||||||
|
hasSlimefun = plMan.isPluginEnabled("Slimefun");
|
||||||
|
|
||||||
// various Settings
|
// various Settings
|
||||||
DataSave.autosave = config.getInt("autosave", 3);
|
DataSave.autosave = config.getInt("autosave", 3);
|
||||||
|
56
src/com/dre/brewery/integration/SlimefunListener.java
Normal file
56
src/com/dre/brewery/integration/SlimefunListener.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package com.dre.brewery.integration;
|
||||||
|
|
||||||
|
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
|
||||||
|
import com.dre.brewery.Brew;
|
||||||
|
import com.dre.brewery.P;
|
||||||
|
import com.dre.brewery.filedata.BConfig;
|
||||||
|
import com.dre.brewery.integration.item.SlimefunPluginItem;
|
||||||
|
import com.dre.brewery.recipe.BCauldronRecipe;
|
||||||
|
import com.dre.brewery.recipe.RecipeItem;
|
||||||
|
import com.dre.brewery.utility.LegacyUtil;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Container;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class SlimefunListener implements Listener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Catch the Slimefun Right Click event, to cancel it if the right click was on a Cauldron.
|
||||||
|
* This prevents item consumption while adding to the cauldron
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onCauldronClickSlimefun(PlayerRightClickEvent event) {
|
||||||
|
try {
|
||||||
|
if (event.getClickedBlock().isPresent() && event.getHand() == EquipmentSlot.HAND) {
|
||||||
|
if (LegacyUtil.isWaterCauldron(event.getClickedBlock().get().getType())) {
|
||||||
|
Optional<SlimefunItem> slimefunItem = event.getSlimefunItem();
|
||||||
|
if (slimefunItem.isPresent()) {
|
||||||
|
for (RecipeItem rItem : BCauldronRecipe.acceptedCustom) {
|
||||||
|
if (rItem instanceof SlimefunPluginItem) {
|
||||||
|
if (slimefunItem.get().getId().equalsIgnoreCase(((SlimefunPluginItem) rItem).getItemId())) {
|
||||||
|
event.cancel();
|
||||||
|
P.p.playerListener.onPlayerInteract(event.getInteractEvent());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
P.p.errorLog("Slimefun check failed");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,9 +15,6 @@ public class SlimefunPluginItem extends PluginItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(ItemStack item) {
|
public boolean matches(ItemStack item) {
|
||||||
if (BConfig.hasSlimefun == null) {
|
|
||||||
BConfig.hasSlimefun = P.p.getServer().getPluginManager().isPluginEnabled("Slimefun");
|
|
||||||
}
|
|
||||||
if (!BConfig.hasSlimefun) return false;
|
if (!BConfig.hasSlimefun) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user