Skip to content

Commit 147765f

Browse files
committed
Add pearl stasis prevention feature
Took 27 minutes
1 parent 1d0d182 commit 147765f

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

eternalcombat-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ bukkit {
162162

163163
tasks {
164164
runServer {
165-
minecraftVersion("1.21.10")
165+
minecraftVersion("1.21.11")
166166
downloadPlugins.modrinth("WorldEdit", Versions.WORLDEDIT)
167167
downloadPlugins.modrinth("PacketEvents", "${Versions.PACKETEVENTS}+spigot")
168168
downloadPlugins.modrinth("WorldGuard", Versions.WORLDGUARD)

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.bukkit.event.entity.EntityDamageByEntityEvent;
1515
import org.bukkit.event.entity.EntityDamageEvent;
1616
import org.bukkit.event.entity.ProjectileLaunchEvent;
17+
import org.bukkit.event.player.PlayerTeleportEvent;
1718
import org.bukkit.inventory.ItemStack;
1819

1920
public class FightPearlController implements Listener {
@@ -80,6 +81,23 @@ public void onPearlDamage(EntityDamageByEntityEvent event) {
8081
event.setDamage(0.0);
8182
}
8283

84+
@EventHandler(priority = EventPriority.HIGHEST)
85+
public void onPearlStasisTeleport(PlayerTeleportEvent event) {
86+
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
87+
return;
88+
}
89+
90+
if (!this.settings.preventPearlStasis) {
91+
return;
92+
}
93+
94+
if (!this.fightManager.isInCombat(event.getPlayer().getUniqueId())) {
95+
return;
96+
}
97+
98+
event.setCancelled(true);
99+
}
100+
83101
private void handlePearlCooldown(ProjectileLaunchEvent event, Player player, UUID playerId) {
84102
if (this.settings.pearlThrowDelay.isZero()) {
85103
return;

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public class FightPearlSettings extends OkaeriConfig {
2121
@Comment("# Set true, If you want add cooldown to pearls")
2222
public boolean pearlCooldownEnabled = false;
2323

24+
@Comment({
25+
"# Prevent players from using ender pearl stasis to avoid combat.",
26+
"# This setting prevents the player from teleporting with a statis pearl during combat."
27+
})
28+
public boolean preventPearlStasis = false;
29+
2430
@Comment({
2531
"# Block throwing pearls with delay?",
2632
"# If you set this to for example 3s, player will have to wait 3 seconds before throwing another pearl"

0 commit comments

Comments
 (0)