-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../src/main/java/com/willfp/eco/spigot/integrations/mcmmo/plugins/McmmoIntegrationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ softdepend: | |
- AAC | ||
- Matrix | ||
- Spartan | ||
- PlaceholderAPI | ||
- PlaceholderAPI | ||
- mcMMO |
52 changes: 52 additions & 0 deletions
52
eco-util/src/main/java/com/willfp/eco/util/integrations/mcmmo/McmmoManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
eco-util/src/main/java/com/willfp/eco/util/integrations/mcmmo/McmmoWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |