Skip to content

Commit d95b643

Browse files
committed
Attempt to temp. clear masks when in a WG region
1 parent 4d644c5 commit d95b643

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/main/java/io/github/thatsmusic99/headsplus/api/HPPlayer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,17 @@ public void clearMask() {
133133
} catch (NullPointerException ignored) { // When the mask messes up
134134

135135
}
136+
}
137+
138+
public void tempClearMasks() {
139+
try {
140+
if (!getPlayer().isOnline()) return;
141+
for (PotionEffect p : activeMask) {
142+
((Player) getPlayer()).removePotionEffect(p.getType());
143+
}
144+
} catch (NullPointerException e) {
136145

146+
}
137147
}
138148

139149
public void addMask(String s) {

src/main/java/io/github/thatsmusic99/headsplus/listeners/MaskEvent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.github.thatsmusic99.headsplus.nms.NMSIndex;
77
import io.github.thatsmusic99.headsplus.nms.NMSManager;
88
import io.github.thatsmusic99.headsplus.reflection.NBTManager;
9+
import io.github.thatsmusic99.headsplus.util.FlagHandler;
910
import org.bukkit.Bukkit;
1011
import org.bukkit.Material;
1112
import org.bukkit.configuration.ConfigurationSection;
@@ -70,6 +71,7 @@ public static void checkMask(Player player, ItemStack item) {
7071
}
7172
pl.addMask(s);
7273
final String type = s;
74+
boolean hasWG = Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
7375
maskMonitors.put(uuid, new BukkitRunnable() {
7476

7577
private int currentInterval = 0;
@@ -88,6 +90,8 @@ public void run() {
8890
} else if (!maskMonitors.containsKey(uuid)) {
8991
pl.clearMask();
9092
cancel();
93+
} else if (hasWG && !FlagHandler.canUseMasks(player)) {
94+
pl.tempClearMasks();
9195
} else if (currentInterval == reset) {
9296
pl.refreshMasks();
9397
currentInterval = 0;

0 commit comments

Comments
 (0)