Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.13.1 #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.justeli.coins</groupId>
<artifactId>Coins</artifactId>
<version>1.13</version>
<version>1.13.1</version>
<name>Coins</name>
<description>Coins is a plugin that allows players to collect coins for killing mobs and mining precious blocks. It also comes with the ability to withdraw balance into physical coins.</description>
<url>https://www.spigotmc.org/resources/coins.33382/</url>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/me/justeli/coins/Coins.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import me.justeli.coins.handler.PickupHandler;
import me.justeli.coins.handler.DropHandler;
import me.justeli.coins.handler.listener.PaperEventListener;
import me.justeli.coins.hook.levelledmobs.LevelledMobsHandler;
import me.justeli.coins.hook.mythicmobs.MMHook;
import me.justeli.coins.hook.bstats.Metrics;
import me.justeli.coins.config.Config;
Expand Down Expand Up @@ -109,6 +110,8 @@ else if (mm.isPresent())
}
}

this.levelledMobsHandler = new LevelledMobsHandler();

if (this.disabledReasons.size() == 0)
{
this.settings = new Settings(this);
Expand Down Expand Up @@ -298,6 +301,10 @@ public boolean toggleDisabled ()

private MMHook mmHook;

private LevelledMobsHandler levelledMobsHandler;

public LevelledMobsHandler getLevelledMobsHandler(){ return this.levelledMobsHandler; }

public Optional<MMHook> mmHook ()
{
return Optional.ofNullable(this.mmHook);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/justeli/coins/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Config
@ConfigEntry ("drop-with-any-death") public static Boolean DROP_WITH_ANY_DEATH = false;
@ConfigEntry ("enchanted-coin") public static Boolean ENCHANTED_COIN = false;
@ConfigEntry ("disable-mythic-mob-handling") public static Boolean DISABLE_MYTHIC_MOB_HANDLING = false;

@ConfigEntry("levelledmobs-level-multiplier") public static Double LEVELLEDMOBS_LEVEL_MULTIPLIER = 0.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets place it at all the other Doubles in the class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I can move this double since it is a config value.

@ConfigEntry (value = "detect-legacy-coins", motivation = "It is recommended that you add this option to the Coins config as soon as you can, " +
"AND SET IT TO FALSE. Please note: Keep this option to true if you have withdrawn coins laying around in the server from before Coins " +
"version 1.11. Also leave the keys 'name-of-coin' and 'multi-suffix' untouched, if you set 'detect-legacy-coins' to true! Legacy withdrawn " +
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/justeli/coins/handler/DropHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void onEntityDeath (EntityDeathEvent event)
if (Util.isDisabledHere(dead.getWorld()))
return;

coins.getLevelledMobsHandler().lastKilledMob = dead;

if (this.coins.mmHook().isPresent() && Config.DISABLE_MYTHIC_MOB_HANDLING && this.coins.mmHook().get().isMythicMob(dead))
return;

Expand Down Expand Up @@ -274,6 +276,10 @@ private void drop (int amount, @Nullable Player player, @NotNull Location locati
amount *= Util.getMultiplier(player);
}

double lmMultiplier = coins.getLevelledMobsHandler().getLevelledMobsMultipliedAmount(increment);
if (lmMultiplier > 0.0)
increment = lmMultiplier;

for (int i = 0; i < amount; i++)
{
location.getWorld().dropItem(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package me.justeli.coins.hook.levelledmobs;

import me.justeli.coins.config.Config;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.LivingEntity;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;

public class LevelledMobsHandler {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would appreciate using the project's code style

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I think.

public LevelledMobsHandler(){
Plugin lmPlugin = Bukkit.getPluginManager().getPlugin("LevelledMobs");
this.isInstalled = lmPlugin != null && Bukkit.getPluginManager().isPluginEnabled("LevelledMobs");
if (this.isInstalled)
this.levelKey = new NamespacedKey(lmPlugin, "level");
}

private final boolean isInstalled;
private NamespacedKey levelKey;
public LivingEntity lastKilledMob;

public boolean getIsInstalled(){
return this.isInstalled;
}

public int getMobLevel(LivingEntity livingEntity){
if (!this.isInstalled || this.levelKey == null ||
!livingEntity.getPersistentDataContainer().has(this.levelKey, PersistentDataType.INTEGER))
return 0;

Integer mobLevel = livingEntity.getPersistentDataContainer().get(this.levelKey, PersistentDataType.INTEGER);

return mobLevel != null ?
mobLevel : 0;
}

public double getLevelledMobsMultipliedAmount(double increment){
if (lastKilledMob == null || !getIsInstalled())
return 0.0;

if (Config.LEVELLEDMOBS_LEVEL_MULTIPLIER == 0.0) return 0.0;

int mobLevel = getMobLevel(lastKilledMob);
if (mobLevel <= 1) return 0.0;

return increment + Config.LEVELLEDMOBS_LEVEL_MULTIPLIER * (double) mobLevel;
}
}
5 changes: 5 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ detect-legacy-coins: false
# drops for Mythic Mobs handled by this plugin, under here.
disable-mythic-mob-handling: false


# LevelledMobs :: If the LevelledMobs plugin is installed you can utilize the following
# multiplier so higher level mobs give higher rewards
levelledmobs-level-multiplier: 0.0

# # # # # # #
# Player Death #
# # # # # # #
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ website: '${project.url}'
description: '${project.description}'
api-version: '1.14'
authors: [JustEli]
softdepend: [Vault, Treasury, WorldGuard, mcMMO, MythicMobs]
softdepend: [Vault, Treasury, WorldGuard, mcMMO, MythicMobs, LevelledMobs]
commands:
coins:
description: 'Command for showing all available commands from Coins. Also used for various admin tools.'
Expand Down