Add PlayerBounties-OG support, remove BountyHunters support

This commit is contained in:
NotAlexNoyle committed 2026-05-13 07:21:55 -04:00
1 parent 84c545dc1a
commit b23801aab4
8 files changed
+118 -61

No files matched your search

+3
View File
@@ -13,6 +13,9 @@ Changes from Duels:
- Added an option to hide the bet winning title message by @NotAlexNoyle
- Prevent players from stealing Duels items from the inventory by @dwaslashe
- Prevent players from stealing Duels items from the ground by @SrBedrock
- Whitelist arenas/worlds and fix duel transportation, with [PetTeleport-OG](https://github.com/true-og/PetTeleport-OG) and [HorseTp-OG](https://github.com/true-og/HorseTp-OG) support by @NotAlexNoyle
- Add [EternalCombat](https://github.com/EternalCodeTeam/EternalCombat) support by @NotAlexNoyle
- Replace BountyHunters hook with [PlayerBounties-OG](https://github.com/true-og/PlayerBounties-OG) support by @NotAlexNoyle
---
-1
View File
@@ -121,7 +121,6 @@ project(":duels-plugin") {
compileOnly(localJar("Factions-1.6.9.5-U0.1.14"))
compileOnly(localJar("MassiveCore"))
compileOnly(localJar("Factions"))
compileOnly(localJar("BountyHunters-2.2.6"))
compileOnly(localJar("SimpleClans-2.14.4.1"))
compileOnly(localJar("LeaderHeadsAPI"))
@@ -280,7 +280,7 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
fNoPowerLoss = configuration.getBoolean("supported-plugins.Factions.no-power-loss-in-duel", true);
duelzoneEnabled = configuration.getBoolean("supported-plugins.WorldGuard.duelzone.enabled", false);
duelzones = configuration.getStringList("supported-plugins.WorldGuard.duelzone.regions");
preventBountyLoss = configuration.getBoolean("supported-plugins.BountyHunters.prevent-bounty-loss-in-duel", true);
preventBountyLoss = configuration.getBoolean("supported-plugins.PlayerBounties-OG.prevent-bounty-loss-in-duel", true);
preventKDRChange = configuration.getBoolean("supported-plugins.SimpleClans.prevent-kdr-change", true);
lhWinsCmd = configuration.getString("supported-plugins.LeaderHeads.wins.menu.command", "openwins");
lhWinsTitle = configuration.getString("supported-plugins.LeaderHeads.wins.menu.title", "Duel Wins");
@@ -1,7 +1,6 @@
package me.realized.duels.hook;
import me.realized.duels.DuelsPlugin;
import me.realized.duels.hook.hooks.BountyHuntersHook;
import me.realized.duels.hook.hooks.CombatLogXHook;
import me.realized.duels.hook.hooks.CombatTagPlusHook;
import me.realized.duels.hook.hooks.EssentialsHook;
@@ -11,6 +10,7 @@ import me.realized.duels.hook.hooks.LeaderHeadsHook;
import me.realized.duels.hook.hooks.MVdWPlaceholderHook;
import me.realized.duels.hook.hooks.McMMOHook;
import me.realized.duels.hook.hooks.PlaceholderHook;
import me.realized.duels.hook.hooks.PlayerBountiesOGHook;
import me.realized.duels.hook.hooks.PvPManagerHook;
import me.realized.duels.hook.hooks.SimpleClansHook;
import me.realized.duels.hook.hooks.VaultHook;
@@ -21,7 +21,6 @@ public class HookManager extends AbstractHookManager<DuelsPlugin> {
public HookManager(final DuelsPlugin plugin) {
super(plugin);
register(BountyHuntersHook.NAME, BountyHuntersHook.class);
register(CombatLogXHook.NAME, CombatLogXHook.class);
register(CombatTagPlusHook.NAME, CombatTagPlusHook.class);
register(EssentialsHook.NAME, EssentialsHook.class);
@@ -31,6 +30,7 @@ public class HookManager extends AbstractHookManager<DuelsPlugin> {
register(McMMOHook.NAME, McMMOHook.class);
register(MVdWPlaceholderHook.NAME, MVdWPlaceholderHook.class);
register(PlaceholderHook.NAME, PlaceholderHook.class);
register(PlayerBountiesOGHook.NAME, PlayerBountiesOGHook.class);
register(PvPManagerHook.NAME, PvPManagerHook.class);
register(SimpleClansHook.NAME, SimpleClansHook.class);
register(VaultHook.NAME, VaultHook.class);
@@ -1,55 +0,0 @@
package me.realized.duels.hook.hooks;
import me.realized.duels.DuelsPlugin;
import me.realized.duels.arena.ArenaManagerImpl;
import me.realized.duels.config.Config;
import me.realized.duels.util.hook.PluginHook;
import net.Indyuce.bountyhunters.api.event.BountyClaimEvent;
import net.Indyuce.bountyhunters.api.event.BountyCreateEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class BountyHuntersHook extends PluginHook<DuelsPlugin> implements Listener {
public static final String NAME = "BountyHunters";
private final Config config;
private final ArenaManagerImpl arenaManager;
public BountyHuntersHook(final DuelsPlugin plugin) {
super(plugin, NAME);
this.config = plugin.getConfiguration();
this.arenaManager = plugin.getArenaManager();
try {
Class.forName("net.Indyuce.bountyhunters.api.event.BountyClaimEvent");
Class.forName("net.Indyuce.bountyhunters.api.event.BountyCreateEvent");
} catch (ClassNotFoundException ex) {
throw new RuntimeException("This version of " + getName() + " is not supported. Please try upgrading to the latest version.");
}
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler(ignoreCancelled = true)
public void on(final BountyClaimEvent event) {
if (!config.isPreventBountyLoss() || !arenaManager.isInMatch(event.getClaimer())) {
return;
}
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void on(final BountyCreateEvent event) {
final Player target = event.getBounty().getTarget().getPlayer();
if (!config.isPreventBountyLoss() || target == null || !arenaManager.isInMatch(target)) {
return;
}
event.setCancelled(true);
}
}
@@ -0,0 +1,110 @@
package me.realized.duels.hook.hooks;
import java.lang.reflect.Method;
import me.realized.duels.DuelsPlugin;
import me.realized.duels.arena.ArenaManagerImpl;
import me.realized.duels.config.Config;
import me.realized.duels.util.hook.PluginHook;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.EventException;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.EventExecutor;
public class PlayerBountiesOGHook extends PluginHook<DuelsPlugin> {
public static final String NAME = "PlayerBounties-OG";
private static final String CLAIM_EVENT_CLASS = "com.tcoded.playerbountiesplus.event.BountyClaimEvent";
private static final String SET_EVENT_CLASS = "com.tcoded.playerbountiesplus.event.BountySetEvent";
private final Config config;
private final ArenaManagerImpl arenaManager;
private final Class<? extends Event> claimEventClass;
private final Class<? extends Event> setEventClass;
private final Method getClaimantMethod;
private final Method getVictimMethod;
private final Method getTargetMethod;
public PlayerBountiesOGHook(final DuelsPlugin plugin) {
super(plugin, NAME);
this.config = plugin.getConfiguration();
this.arenaManager = plugin.getArenaManager();
try {
this.claimEventClass = Class.forName(CLAIM_EVENT_CLASS).asSubclass(Event.class);
this.setEventClass = Class.forName(SET_EVENT_CLASS).asSubclass(Event.class);
this.getClaimantMethod = this.claimEventClass.getMethod("getClaimant");
this.getVictimMethod = this.claimEventClass.getMethod("getVictim");
this.getTargetMethod = this.setEventClass.getMethod("getTarget");
if (!Cancellable.class.isAssignableFrom(this.claimEventClass) || !Cancellable.class.isAssignableFrom(this.setEventClass)) {
throw new IllegalStateException("PlayerBounties-OG events are not cancellable");
}
} catch (ClassNotFoundException | NoSuchMethodException | ClassCastException ex) {
throw new RuntimeException("This version of " + getName() + " is not supported. Please try upgrading to the latest version.", ex);
}
final BountyListener listener = new BountyListener();
Bukkit.getPluginManager().registerEvent(this.claimEventClass, listener, EventPriority.NORMAL, new EventExecutor() {
@Override
public void execute(final Listener listener, final Event event) throws EventException {
onClaim(event);
}
}, plugin, true);
Bukkit.getPluginManager().registerEvent(this.setEventClass, listener, EventPriority.NORMAL, new EventExecutor() {
@Override
public void execute(final Listener listener, final Event event) throws EventException {
onSet(event);
}
}, plugin, true);
}
private void onClaim(final Event event) throws EventException {
if (!config.isPreventBountyLoss()) {
return;
}
final Player claimant;
final Player victim;
try {
claimant = (Player) getClaimantMethod.invoke(event);
victim = (Player) getVictimMethod.invoke(event);
} catch (ReflectiveOperationException | ClassCastException ex) {
throw new EventException(ex);
}
if ((claimant != null && arenaManager.isInMatch(claimant)) || (victim != null && arenaManager.isInMatch(victim))) {
((Cancellable) event).setCancelled(true);
}
}
private void onSet(final Event event) throws EventException {
if (!config.isPreventBountyLoss()) {
return;
}
final Player target;
try {
target = (Player) getTargetMethod.invoke(event);
} catch (ReflectiveOperationException | ClassCastException ex) {
throw new EventException(ex);
}
if (target != null && arenaManager.isInMatch(target)) {
((Cancellable) event).setCancelled(true);
}
}
public class BountyListener implements Listener {}
}
+2 -2
View File
@@ -66,8 +66,8 @@ supported-plugins:
# List of regions to allow dueling.
regions: [spawn, lobby]
BountyHunters:
# If set to 'true', player will not lose bounty even if they die in a duel.
PlayerBounties-OG:
# If set to 'true', bounty claims and new bounty placements involving a player in a duel will be cancelled.
# default: true
prevent-bounty-loss-in-duel: true
SimpleClans:
Binary file not shown.