Add CommandProtect capabilities
Add Region.getProtectYLevel
Dieser Commit ist enthalten in:
Ursprung
010bac9741
Commit
4098d70a23
@ -23,18 +23,26 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
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.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
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.util.logging.Level;
|
||||
|
||||
public class CommandProtect extends SWCommand {
|
||||
public class CommandProtect extends SWCommand implements Listener {
|
||||
|
||||
public CommandProtect() {
|
||||
super("protect");
|
||||
if (Region.buildAreaEnabled()) {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
@ -105,4 +113,18 @@ public class CommandProtect extends SWCommand {
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
public int getProtectYLevel() {
|
||||
return getMinPoint(RegionType.TESTBLOCK, RegionExtensionType.NORMAL).getY();
|
||||
}
|
||||
|
||||
public boolean hasExtensionArea(RegionType regionType) {
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren