-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable piloting and repair in assaulted regions
- Loading branch information
1 parent
04a850d
commit 36e2f9a
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ava/net/countercraft/movecraft/warfare/features/assault/listener/CraftDetectListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.countercraft.movecraft.warfare.features.assault.listener; | ||
|
||
import net.countercraft.movecraft.craft.Craft; | ||
import net.countercraft.movecraft.events.CraftDetectEvent; | ||
import net.countercraft.movecraft.util.hitboxes.HitBox; | ||
import net.countercraft.movecraft.warfare.localisation.I18nSupport; | ||
import net.countercraft.movecraft.worldguard.MovecraftWorldGuard; | ||
import net.countercraft.movecraft.worldguard.utils.WorldGuardUtils; | ||
import org.bukkit.World; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class CraftDetectListener implements Listener { | ||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) | ||
public void onCraftDetect(@NotNull CraftDetectEvent e) { | ||
Craft craft = e.getCraft(); | ||
HitBox hitBox = craft.getHitBox(); | ||
if (hitBox.isEmpty()) | ||
return; | ||
|
||
WorldGuardUtils wgUtils = MovecraftWorldGuard.getInstance().getWGUtils(); | ||
World w = craft.getWorld(); | ||
for (String regionName : wgUtils.getRegions(hitBox, w)) { | ||
// Detect an assaulted region by one without owners and with TNT denied | ||
if (!wgUtils.isTNTDenied(regionName, w) || !wgUtils.getUUIDOwners(regionName, w).isEmpty()) | ||
continue; | ||
|
||
e.setCancelled(true); | ||
e.setFailMessage(I18nSupport.getInternationalisedString("Assault Detection - Not Permitted")); | ||
return; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ava/net/countercraft/movecraft/warfare/features/assault/listener/CraftRepairListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.countercraft.movecraft.warfare.features.assault.listener; | ||
|
||
import net.countercraft.movecraft.repair.events.ProtoRepairCreateEvent; | ||
import net.countercraft.movecraft.util.hitboxes.HitBox; | ||
import net.countercraft.movecraft.warfare.localisation.I18nSupport; | ||
import net.countercraft.movecraft.worldguard.MovecraftWorldGuard; | ||
import net.countercraft.movecraft.worldguard.utils.WorldGuardUtils; | ||
import org.bukkit.World; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Set; | ||
|
||
public class CraftRepairListener implements Listener { | ||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) | ||
public void onProtoRepairCreate(@NotNull ProtoRepairCreateEvent e) { | ||
HitBox hitBox = e.getProtoRepair().getHitBox(); | ||
if (hitBox.isEmpty()) | ||
return; | ||
|
||
WorldGuardUtils wgUtils = MovecraftWorldGuard.getInstance().getWGUtils(); | ||
World w = e.getProtoRepair().getWorld(); | ||
for (String regionName : wgUtils.getRegions(hitBox, w)) { | ||
// Detect an assaulted region by one without owners and with TNT denied | ||
if (!wgUtils.isTNTDenied(regionName, w) || !wgUtils.getUUIDOwners(regionName, w).isEmpty()) | ||
continue; | ||
|
||
e.setCancelled(true); | ||
e.setFailMessage(I18nSupport.getInternationalisedString("Assault Repair - Not Permitted")); | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters