Skip to content

Commit

Permalink
feat: Add player death cancelled support if version is Paper 1.13+ (#552
Browse files Browse the repository at this point in the history
)

👍
  • Loading branch information
BonesMgee authored Nov 1, 2024
1 parent 4e9269d commit 3a85e04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugin/src/main/java/org/screamingsandals/bedwars/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class Main extends JavaPlugin implements BedwarsAPI {
private static Main instance;
private String version;
private boolean isDisabling = false;
private boolean isSpigot, isLegacy;
private boolean isSpigot, isPaper, isLegacy;
private boolean isVault;
private int versionNumber = 0;
private Economy econ = null;
Expand Down Expand Up @@ -133,6 +133,10 @@ public static boolean isSpigot() {
return instance.isSpigot;
}

public static boolean isPaper() {
return instance.isPaper;
}

public static boolean isVault() {
return instance.isVault;
}
Expand Down Expand Up @@ -362,6 +366,7 @@ public void onEnable() {
version = this.getDescription().getVersion();
boolean snapshot = version.toLowerCase().contains("pre") || version.toLowerCase().contains("snapshot");
isSpigot = ClassStorage.IS_SPIGOT_SERVER;
isPaper = ClassStorage.IS_PAPER_SERVER;
colorChanger = new org.screamingsandals.bedwars.utils.ColorChanger();

if (!getServer().getPluginManager().isPluginEnabled("Vault")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
public class ClassStorage {

public static final boolean IS_SPIGOT_SERVER = safeGetClass("org.spigotmc.SpigotConfig") != null;
public static final boolean IS_PAPER_SERVER = safeGetClass("com.destroystokyo.paper.ParticleBuilder") != null;
public static final boolean HAS_CHUNK_TICKETS = getMethod(Chunk.class, "addPluginChunkTicket", Plugin.class).getReflectedMethod() != null;

public static Class<?> safeGetClass(String... clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public class PlayerListener implements Listener {
public void onPlayerDeath(PlayerDeathEvent event) {
final Player victim = event.getEntity();

if (!Main.isLegacy() && Main.isPaper()) {
if (event.isCancelled()) {
return;
}
}

if (Main.isPlayerInGame(victim)) {
GamePlayer gVictim = Main.getPlayerGameProfile(victim);
Game game = gVictim.getGame();
Expand Down

0 comments on commit 3a85e04

Please sign in to comment.