Support TrueOG teleportation and compat logger plugins

This commit is contained in:
NotAlexNoyle committed 2026-05-13 07:21:32 -04:00
1 parent a5e843618c
commit c422e555c7
4 files changed
+136 -2

No files matched your search

+6 -1
View File
@@ -16,12 +16,17 @@ For example configurations of these modes, see the [templates](./templates) fold
- **Server**: Purpur / Paper 1.19.4
- **Java**: 17+
- **Depends**: BattleArena 4.0.0-SNAPSHOT, WorldGuard
- **Soft-depends**: WorldEdit
- **Soft-depends**: HorseTp-OG, PetTeleport-OG, PlayerBounties-OG, WorldEdit
## Notes
- **Arena reset**: Layer pasting now hard-resets configured layer volumes each round instead of only filling air blocks.
- **Bow Spleef TNT**: TNT priming is now gated by WorldGuard. Set `worldguard-region: <region-id>` on the map used by a Bow Spleef arena, and make sure that region covers the TNT layer.
## Integrations
- **[PetTeleport-OG](https://github.com/true-og/PetTeleport-OG)**: pet teleports are suppressed while a player is in a Spleef match. No configuration required — PetTeleport-OG reads `SpleefAPI.isInSpleef`.
- **[HorseTp-OG](https://github.com/true-og/HorseTp-OG)**: horse teleports are suppressed while a player is in a Spleef match. No configuration required — HorseTp-OG reads `SpleefAPI.isInSpleef`.
- **[PlayerBounties-OG](https://github.com/true-og/PlayerBounties-OG)**: bounty claims and new bounty placements are cancelled whenever the claimant, victim, or target is in a Spleef match. Active automatically when PlayerBounties-OG is installed.
## Commands
| Command | Description |
|---------------------------------------|------------------------------------------------|
@@ -10,6 +10,7 @@ import org.battleplugins.arena.spleef.action.GiveShovelAction;
import org.battleplugins.arena.spleef.action.PasteLayersAction;
import org.battleplugins.arena.spleef.api.SpleefApiListener;
import org.battleplugins.arena.spleef.arena.SpleefArena;
import org.battleplugins.arena.spleef.hook.PlayerBountiesListener;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.Configuration;
@@ -71,6 +72,13 @@ public class ArenaSpleef extends JavaPlugin {
this.getServer().getPluginManager().registerEvents(new SpleefApiListener(), this);
if (PlayerBountiesListener.register(this)) {
this.getSLF4JLogger().info(
"Hooked into PlayerBounties-OG; bounty claims and placements for players in Spleef will be cancelled.");
}
}
@Override
@@ -0,0 +1,121 @@
package org.battleplugins.arena.spleef.hook;
import java.lang.reflect.Method;
import org.battleplugins.arena.spleef.api.SpleefAPI;
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;
import org.bukkit.plugin.Plugin;
public final class PlayerBountiesListener implements Listener {
public static final String PLUGIN_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 PlayerBountiesListener() {
}
public static boolean register(Plugin owner) {
Plugin bounties = Bukkit.getPluginManager().getPlugin(PLUGIN_NAME);
if (bounties == null) {
return false;
}
Class<? extends Event> claimEventClass;
Class<? extends Event> setEventClass;
Method getClaimant;
Method getVictim;
Method getTarget;
try {
claimEventClass = Class.forName(CLAIM_EVENT_CLASS).asSubclass(Event.class);
setEventClass = Class.forName(SET_EVENT_CLASS).asSubclass(Event.class);
getClaimant = claimEventClass.getMethod("getClaimant");
getVictim = claimEventClass.getMethod("getVictim");
getTarget = setEventClass.getMethod("getTarget");
} catch (ClassNotFoundException | NoSuchMethodException | ClassCastException ex) {
owner.getSLF4JLogger().warn(
"PlayerBounties-OG is present but the expected API is missing; skipping bounty protection.", ex);
return false;
}
if (!Cancellable.class.isAssignableFrom(claimEventClass)
|| !Cancellable.class.isAssignableFrom(setEventClass))
{
owner.getSLF4JLogger().warn("PlayerBounties-OG events are not Cancellable; skipping bounty protection.");
return false;
}
PlayerBountiesListener listener = new PlayerBountiesListener();
Bukkit.getPluginManager().registerEvent(claimEventClass, listener, EventPriority.NORMAL, new EventExecutor() {
@Override
public void execute(Listener listener, Event event) throws EventException {
cancelIfInSpleef(event, getClaimant, getVictim);
}
}, owner, true);
Bukkit.getPluginManager().registerEvent(setEventClass, listener, EventPriority.NORMAL, new EventExecutor() {
@Override
public void execute(Listener listener, Event event) throws EventException {
cancelIfInSpleef(event, getTarget);
}
}, owner, true);
return true;
}
private static void cancelIfInSpleef(Event event, Method... playerAccessors) throws EventException {
for (Method accessor : playerAccessors) {
Player player;
try {
player = (Player) accessor.invoke(event);
} catch (ReflectiveOperationException | ClassCastException ex) {
throw new EventException(ex);
}
if (SpleefAPI.isInSpleef(player)) {
((Cancellable) event).setCancelled(true);
return;
}
}
}
}
+1 -1
View File
@@ -6,4 +6,4 @@ author: BattlePlugins
website: https://battleplugins.org
api-version: ${apiVersion}
depend: [BattleArena, WorldGuard]
softdepend: [WorldEdit]
softdepend: [HorseTp-OG, PetTeleport-OG, PlayerBounties-OG, WorldEdit]