Skip to content

Commit 919c88f

Browse files
committed
Add integration to nerf experience and currency gain from Jobs
1 parent f74bfa0 commit 919c88f

File tree

9 files changed

+103
-0
lines changed

9 files changed

+103
-0
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ anticheat-negativity = "2.7.1"
1818
anticheat-themis = "0.0.1-SNAPSHOT"
1919
anticheat-vulcan = "2.9.1"
2020
bstats = "3.0.2"
21+
jobs = "v5.2.6.2"
2122
mcmmo = "2.1.228"
2223
placeholder-api = "2.11.5"
2324
spigot-api = "1.17.1-R0.1-SNAPSHOT"
@@ -58,6 +59,7 @@ bstats-base = { module = "org.bstats:bstats-base", version.ref = "bstats" }
5859
bstats-bukkit = { module = "org.bstats:bstats-bukkit", version.ref = "bstats" }
5960
choco-networking-bukkit = { module = "wtf.choco:networking-bukkit", version.ref = "choco-networking" }
6061
mcmmo = { module = "com.gmail.nossr50.mcMMO:mcMMO", version.ref = "mcmmo" }
62+
jobs = { module = "com.github.Zrips:Jobs", version.ref = "jobs" }
6163
placeholder-api = { module = "me.clip:placeholderapi", version.ref = "placeholder-api" }
6264
spigot-api = { module = "org.spigotmc:spigot-api", version.ref = "spigot-api" }
6365
vault-api = { module = "net.milkbowl.vault:VaultAPI", version.ref = "vault-api" }

veinminer-bukkit/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies {
3131
compileOnly(libs.vault.api)
3232
compileOnly(libs.worldguard)
3333
compileOnly(libs.mcmmo)
34+
compileOnly(libs.jobs)
3435

3536
// Anti-cheats
3637
compileOnly(libs.anticheat.aac)

veinminer-bukkit/src/main/java/wtf/choco/veinminer/VeinMinerPlugin.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import wtf.choco.veinminer.listener.BlockDropCollectionListener;
5757
import wtf.choco.veinminer.listener.BreakBlockListener;
5858
import wtf.choco.veinminer.listener.ItemDamageListener;
59+
import wtf.choco.veinminer.listener.JobsIntegrationListener;
5960
import wtf.choco.veinminer.listener.McMMOIntegrationListener;
6061
import wtf.choco.veinminer.listener.PlayerDataListener;
6162
import wtf.choco.veinminer.manager.VeinMinerManager;
@@ -207,6 +208,11 @@ public void onEnable() {
207208
}
208209
}
209210

211+
Plugin jobsPlugin = manager.getPlugin("Jobs");
212+
if (jobsPlugin != null && manager.isPluginEnabled("Jobs")) {
213+
manager.registerEvents(new JobsIntegrationListener(this), this);
214+
}
215+
210216
Plugin placeholderAPIPlugin = manager.getPlugin("PlaceholderAPI");
211217
if (placeholderAPIPlugin != null && manager.isPluginEnabled("PlaceholderAPI")) {
212218
new PlaceholderExpansionVeinMiner(this).register();

veinminer-bukkit/src/main/java/wtf/choco/veinminer/config/VeinMinerConfiguration.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ public interface VeinMinerConfiguration extends VeinMiningConfiguration {
112112
*/
113113
public boolean isNerfMcMMO();
114114

115+
/**
116+
* Get whether or not Jobs' experience system should be nerfed while vein mining.
117+
* <p>
118+
* If this value returns true, job experience will only be yielded for the initial block
119+
* break. If false, every block broken in the vein mine will yield job experience.
120+
*
121+
* @return true to nerf Jobs' experience yield, false to behave as normal
122+
*/
123+
public boolean isNerfJobsExperienceGain();
124+
125+
/**
126+
* Get whether or not Jobs' currency gain should be nerfed while vein mining.
127+
* <p>
128+
* If this value returns true, job currency will only be yielded for the initial block
129+
* break. If false, every block broken in the vein mine will yield job currency.
130+
*
131+
* @return true to nerf Jobs' currency gain, false to behave as normal
132+
*/
133+
public boolean isNerfJobsCurrencyGain();
134+
115135
/**
116136
* Check whether or not vein mining is disabled when the player activates it while in the
117137
* specified {@link GameMode}.

veinminer-bukkit/src/main/java/wtf/choco/veinminer/config/impl/ConfigKeys.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ final class ConfigKeys {
1414
static final String KEY_COLLECT_EXPERIENCE_AT_SOURCE = "CollectExperienceAtSource";
1515
static final String KEY_ONLY_DAMAGE_ON_FIRST_BLOCK = "OnlyDamageOnFirstBlock";
1616
static final String KEY_NERF_MCMMO = "NerfMcMMO";
17+
static final String KEY_JOBS_NERF_EXPERIENCE_GAIN = "Jobs.NerfExperienceGain";
18+
static final String KEY_JOBS_NERF_CURRENCY_GAIN = "Jobs.NerfCurrencyGain";
1719
static final String KEY_DISABLED_GAME_MODES = "DisabledGameModes";
1820
static final String KEY_HUNGER_HUNGER_MODIFIER = "Hunger.HungerModifier";
1921
static final String KEY_HUNGER_MINIMUM_FOOD_LEVEL = "Hunger.MinimumFoodLevel";

veinminer-bukkit/src/main/java/wtf/choco/veinminer/config/impl/StandardVeinMinerConfiguration.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ public boolean isNerfMcMMO() {
101101
return plugin.getConfig().getBoolean(KEY_NERF_MCMMO, false);
102102
}
103103

104+
@Override
105+
public boolean isNerfJobsExperienceGain() {
106+
return plugin.getConfig().getBoolean(KEY_JOBS_NERF_EXPERIENCE_GAIN, false);
107+
}
108+
109+
@Override
110+
public boolean isNerfJobsCurrencyGain() {
111+
return plugin.getConfig().getBoolean(KEY_JOBS_NERF_CURRENCY_GAIN, false);
112+
}
113+
104114
@Override
105115
public boolean isRepairFriendly() {
106116
return plugin.getConfig().getBoolean(KEY_REPAIR_FRIENDLY, false);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package wtf.choco.veinminer.listener;
2+
3+
import com.gamingmesh.jobs.api.JobsExpGainEvent;
4+
import com.gamingmesh.jobs.api.JobsPrePaymentEvent;
5+
import com.gamingmesh.jobs.container.ActionType;
6+
7+
import org.bukkit.entity.Player;
8+
import org.bukkit.event.EventHandler;
9+
import org.bukkit.event.Listener;
10+
import org.jetbrains.annotations.Nullable;
11+
12+
import wtf.choco.veinminer.VeinMinerPlugin;
13+
import wtf.choco.veinminer.player.VeinMinerPlayer;
14+
15+
public final class JobsIntegrationListener implements Listener {
16+
17+
private final VeinMinerPlugin plugin;
18+
19+
public JobsIntegrationListener(VeinMinerPlugin plugin) {
20+
this.plugin = plugin;
21+
}
22+
23+
@EventHandler(ignoreCancelled = true)
24+
private void onGainVeinMinerXP(JobsExpGainEvent event) {
25+
if (event.getActionInfo().getType() != ActionType.BREAK) {
26+
return;
27+
}
28+
29+
if (!plugin.getConfiguration().isNerfJobsExperienceGain() || !isVeinMining(event.getPlayer().getPlayer())) {
30+
return;
31+
}
32+
33+
event.setCancelled(true);
34+
}
35+
36+
@EventHandler(ignoreCancelled = true)
37+
private void onGainVeinMinerCurrency(JobsPrePaymentEvent event) {
38+
if (event.getActionInfo().getType() != ActionType.BREAK) {
39+
return;
40+
}
41+
42+
if (!plugin.getConfiguration().isNerfJobsCurrencyGain() || !isVeinMining(event.getPlayer().getPlayer())) {
43+
return;
44+
}
45+
46+
event.setCancelled(true);
47+
}
48+
49+
private boolean isVeinMining(@Nullable Player player) {
50+
if (player == null) {
51+
return false;
52+
}
53+
54+
VeinMinerPlayer veinMinerPlayer = plugin.getPlayerManager().get(player);
55+
return veinMinerPlayer != null && veinMinerPlayer.isVeinMining();
56+
}
57+
58+
}

veinminer-bukkit/src/main/resources/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ CollectItemsAtSource: true
99
CollectExperienceAtSource: true
1010
OnlyDamageOnFirstBlock: false
1111
NerfMcMMO: false
12+
Jobs:
13+
NerfExpGain: false
14+
NerfCurrencyGain: false
1215

1316
# "RepairFriendly", "MaxVeinSize", "Cost", and "DisabledWorlds" may be
1417
# defined per-category in the categories.yml file

veinminer-bukkit/src/main/resources/plugin.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ softdepend:
2020
- Themis
2121
- Vulcan
2222
# others
23+
- Jobs
2324
- mcMMO
2425
- PlaceholderAPI
2526
- Vault

0 commit comments

Comments
 (0)