mcMMO disable repair stat registers when using another RPG core plugin

This commit is contained in:
Indyuce 2020-12-23 14:45:53 +01:00
parent fc208567de
commit 397372c31f
2 changed files with 12 additions and 5 deletions

View File

@ -56,6 +56,7 @@ import net.Indyuce.mmoitems.comp.parse.placeholders.DefaultPlaceholderParser;
import net.Indyuce.mmoitems.comp.parse.placeholders.PlaceholderAPIParser;
import net.Indyuce.mmoitems.comp.parse.placeholders.PlaceholderParser;
import net.Indyuce.mmoitems.comp.rpg.DefaultHook;
import net.Indyuce.mmoitems.comp.rpg.McMMOHook;
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
import net.Indyuce.mmoitems.gui.PluginInventory;
import net.Indyuce.mmoitems.gui.listener.GuiListener;
@ -234,6 +235,9 @@ public class MMOItems extends JavaPlugin {
PlayerData.get(player).checkForInventoryUpdate();
}, 100, getConfig().getInt("inventory-update-delay"));
if (Bukkit.getPluginManager().getPlugin("mcMMO") != null)
statManager.register(McMMOHook.disableMcMMORepair);
if (Bukkit.getPluginManager().getPlugin("Residence") != null) {
flagPlugin = new ResidenceFlags();
getLogger().log(Level.INFO, "Hooked onto Residence");

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.stat.type.DisableStat;
@ -19,10 +18,14 @@ import net.mmogroup.mmolib.api.item.NBTItem;
public class McMMOHook implements RPGHandler, Listener {
public McMMOHook() {
ItemStat disableMcMMORepair = new DisableStat("MCMMO_REPAIR", Material.IRON_BLOCK, "Disable McMMO Repair", "Players can't repair this with McMMO.");
MMOItems.plugin.getStats().register(disableMcMMORepair);
}
/**
* McMMO is a special plugin, it can be used along with other RPG plugins
* like MMOCore. That stat must be registered even if McMMO is not the main
* RPG core plugin, therefore the register() method is on the onEnable() and
* not in the constructor of that class
*/
public static final ItemStat disableMcMMORepair = new DisableStat("MCMMO_REPAIR", Material.IRON_BLOCK, "Disable McMMO Repair",
"Players can't repair this with McMMO.");
@EventHandler(ignoreCancelled = true)
public void a(McMMOPlayerLevelUpEvent event) {