Skip to content

Commit

Permalink
Attempt to temp. clear masks when in a WG region
Browse files Browse the repository at this point in the history
  • Loading branch information
Thatsmusic99 committed Jul 22, 2020
1 parent 4d644c5 commit d95b643
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/io/github/thatsmusic99/headsplus/api/HPPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,17 @@ public void clearMask() {
} catch (NullPointerException ignored) { // When the mask messes up

}
}

public void tempClearMasks() {
try {
if (!getPlayer().isOnline()) return;
for (PotionEffect p : activeMask) {
((Player) getPlayer()).removePotionEffect(p.getType());
}
} catch (NullPointerException e) {

}
}

public void addMask(String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.github.thatsmusic99.headsplus.nms.NMSIndex;
import io.github.thatsmusic99.headsplus.nms.NMSManager;
import io.github.thatsmusic99.headsplus.reflection.NBTManager;
import io.github.thatsmusic99.headsplus.util.FlagHandler;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
Expand Down Expand Up @@ -70,6 +71,7 @@ public static void checkMask(Player player, ItemStack item) {
}
pl.addMask(s);
final String type = s;
boolean hasWG = Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
maskMonitors.put(uuid, new BukkitRunnable() {

private int currentInterval = 0;
Expand All @@ -88,6 +90,8 @@ public void run() {
} else if (!maskMonitors.containsKey(uuid)) {
pl.clearMask();
cancel();
} else if (hasWG && !FlagHandler.canUseMasks(player)) {
pl.tempClearMasks();
} else if (currentInterval == reset) {
pl.refreshMasks();
currentInterval = 0;
Expand Down

0 comments on commit d95b643

Please sign in to comment.