ProtectUpgrade #244
@ -23,18 +23,26 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import de.steamwar.bausystem.world.regions.Region;
|
import de.steamwar.bausystem.world.regions.Region;
|
||||||
|
import de.steamwar.bausystem.world.regions.RegionExtensionType;
|
||||||
|
import de.steamwar.bausystem.world.regions.RegionType;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CommandProtect extends SWCommand {
|
public class CommandProtect extends SWCommand implements Listener {
|
||||||
|
|
||||||
public CommandProtect() {
|
public CommandProtect() {
|
||||||
super("protect");
|
super("protect");
|
||||||
|
if (Region.buildAreaEnabled()) {
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(help = true)
|
@Register(help = true)
|
||||||
@ -105,4 +113,18 @@ public class CommandProtect extends SWCommand {
|
|||||||
}
|
}
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onExplode(EntityExplodeEvent event) {
|
||||||
|
|||||||
|
event.blockList().removeIf(block -> {
|
||||||
|
Region region = Region.getRegion(block.getLocation());
|
||||||
|
if (!region.isProtect()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!region.hasProtection()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return block.getY() < region.getProtectYLevel();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,10 @@ public class Region {
|
|||||||
undosessions.push(prototype.protect(this, schem));
|
undosessions.push(prototype.protect(this, schem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProtectYLevel() {
|
||||||
|
return getMinPoint(RegionType.TESTBLOCK, RegionExtensionType.NORMAL).getY();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasExtensionArea(RegionType regionType) {
|
public boolean hasExtensionArea(RegionType regionType) {
|
||||||
switch (regionType) {
|
switch (regionType) {
|
||||||
case BUILD:
|
case BUILD:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Idee: Das über den Tnt Block zu machen, damit würde man nicht die Array zugriffe spammen