Skip to content

Commit

Permalink
Added direct mcMMO support
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jan 24, 2021
1 parent d5679dd commit 128d473
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ allprojects {
// NMS (for jitpack compilation)
maven { url 'https://repo.codemc.org/repository/nms/' }

// bStats
// bStats, mcMMO
maven { url 'https://repo.codemc.org/repository/maven-public' }

// Spigot API
Expand Down
1 change: 1 addition & 0 deletions eco-core/core-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
compileOnly 'com.github.angeschossen:LandsAPI:4.7.3'
compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT'
compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd'
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.157'
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.willfp.eco.spigot.integrations.antigrief.plugins.AntigriefLands;
import com.willfp.eco.spigot.integrations.antigrief.plugins.AntigriefTowny;
import com.willfp.eco.spigot.integrations.antigrief.plugins.AntigriefWorldGuard;
import com.willfp.eco.spigot.integrations.mcmmo.plugins.McmmoIntegrationImpl;
import com.willfp.eco.util.command.AbstractCommand;
import com.willfp.eco.util.drops.internal.FastCollatedDropQueue;
import com.willfp.eco.util.events.armorequip.ArmorListener;
Expand All @@ -24,6 +25,7 @@
import com.willfp.eco.util.integrations.IntegrationLoader;
import com.willfp.eco.util.integrations.anticheat.AnticheatManager;
import com.willfp.eco.util.integrations.antigrief.AntigriefManager;
import com.willfp.eco.util.integrations.mcmmo.McmmoManager;
import com.willfp.eco.util.plugin.AbstractEcoPlugin;
import com.willfp.eco.util.protocollib.AbstractPacketAdapter;
import lombok.Getter;
Expand Down Expand Up @@ -55,7 +57,6 @@ public void enable() {
this.getEventManager().registerListener(new ArmorListener());
this.getEventManager().registerListener(new DispenserArmorListener());
this.getEventManager().registerListener(new EntityDeathByEntityListeners(this));
//ProtocolLibrary.getProtocolManager().addPacketListener(new PacketPlayOutRecipeUpdateFix(this));
}

@Override
Expand Down Expand Up @@ -92,7 +93,10 @@ public List<IntegrationLoader> getIntegrationLoaders() {
// Anticheat
new IntegrationLoader("AAC5", () -> AnticheatManager.register(this, new AnticheatAAC())),
new IntegrationLoader("Matrix", () -> AnticheatManager.register(this, new AnticheatMatrix())),
new IntegrationLoader("NoCheatPlus", () -> AnticheatManager.register(this, new AnticheatNCP()))
new IntegrationLoader("NoCheatPlus", () -> AnticheatManager.register(this, new AnticheatNCP())),

// Misc
new IntegrationLoader("mcMMO", () -> McmmoManager.register(new McmmoIntegrationImpl()))
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.willfp.eco.spigot.integrations.mcmmo.plugins;

import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
import com.gmail.nossr50.events.fake.FakeEvent;
import com.gmail.nossr50.mcMMO;
import com.willfp.eco.util.integrations.mcmmo.McmmoWrapper;
import org.bukkit.block.Block;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;

public class McmmoIntegrationImpl implements McmmoWrapper {
@Override
public int getBonusDropCount(@NotNull final Block block) {
if (block.getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0) {
BonusDropMeta bonusDropMeta = (BonusDropMeta) block.getMetadata(mcMMO.BONUS_DROPS_METAKEY).get(0);
return bonusDropMeta.asInt();
}

return 0;
}

@Override
public boolean isFake(@NotNull final Event event) {
return event instanceof FakeEvent;
}
}
3 changes: 2 additions & 1 deletion eco-core/core-plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ softdepend:
- AAC
- Matrix
- Spartan
- PlaceholderAPI
- PlaceholderAPI
- mcMMO
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.willfp.eco.util.integrations.mcmmo;

import lombok.experimental.UtilityClass;
import org.bukkit.block.Block;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;

import java.util.HashSet;
import java.util.Set;

@UtilityClass
public class McmmoManager {
/**
* A set of all registered integrations.
*/
private final Set<McmmoWrapper> regsistered = new HashSet<>();

/**
* Register a new integration.
*
* @param integration The integration to register.
*/
public void register(@NotNull final McmmoWrapper integration) {
regsistered.add(integration);
}

/**
* Get bonus drop count from block.
*
* @param block The block.
* @return The bonus drop count.
*/
public int getBonusDropCount(@NotNull final Block block) {
for (McmmoWrapper mcmmoWrapper : regsistered) {
return mcmmoWrapper.getBonusDropCount(block);
}
return 0;
}

/**
* Get if event is fake.
*
* @param event The event to check.
* @return If the event is fake.
*/
public boolean isFake(@NotNull final Event event) {
for (McmmoWrapper mcmmoWrapper : regsistered) {
return mcmmoWrapper.isFake(event);
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.willfp.eco.util.integrations.mcmmo;

import org.bukkit.block.Block;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;

public interface McmmoWrapper {
/**
* Get bonus drop count of block.
*
* @param block The block.
* @return The drop multiplier.
*/
int getBonusDropCount(@NotNull Block block);

/**
* Get if event is fake.
*
* @param event The event.
* @return If is fake.
*/
boolean isFake(@NotNull Event event);
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 3.2.2
version = 3.3.0
plugin-name = eco

0 comments on commit 128d473

Please sign in to comment.