Add SelectCommand
Dieser Commit ist enthalten in:
Ursprung
da392a5d9c
Commit
ce0fb037d7
@ -0,0 +1,21 @@
|
||||
package de.steamwar.bausystem.features.util;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.RegionUtils_15;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SelectCommand_15 {
|
||||
|
||||
static final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||
static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
|
||||
static void setSelection(Player p, Point minPoint, Point maxPoint) {
|
||||
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, RegionUtils_15.toBlockVector3(minPoint), RegionUtils_15.toBlockVector3(maxPoint)));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package de.steamwar.bausystem.features.util;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.VersionedRunnable;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class SelectCommand extends SWCommand {
|
||||
|
||||
public SelectCommand() {
|
||||
super("select");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus");
|
||||
p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
if (region.isGlobal()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!region.hasType(regionType)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen " + regionType.getChatValue());
|
||||
return;
|
||||
}
|
||||
|
||||
setSelection(regionType, RegionExtensionType.NORMAL, region, p);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
if (region.isGlobal()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!region.hasType(regionType)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen " + regionType.getChatValue());
|
||||
return;
|
||||
}
|
||||
if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionType(regionType)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße");
|
||||
return;
|
||||
}
|
||||
|
||||
setSelection(regionType, regionExtensionType, region, p);
|
||||
}
|
||||
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Permission.hasPermission(player, Permission.WORLDEDIT)) {
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Select Befehl verwenden");
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) {
|
||||
Point minPoint = region.getMinPoint(regionType, regionExtensionType);
|
||||
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);
|
||||
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> SelectCommand_15.setSelection(p, minPoint, maxPoint), 15));
|
||||
p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " und " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt");
|
||||
}
|
||||
|
||||
}
|
@ -96,6 +96,8 @@ public class Prototype {
|
||||
private final int extensionNegativeZ;
|
||||
private final int extensionPositiveZ;
|
||||
|
||||
private boolean extensionRegistered;
|
||||
|
||||
private SubPrototype(YAPIONObject yapionObject) {
|
||||
offsetX = yapionObject.getPlainValueOrDefault("offsetX", 0);
|
||||
offsetY = yapionObject.getPlainValueOrDefault("offsetY", 0);
|
||||
@ -134,6 +136,8 @@ public class Prototype {
|
||||
extensionNegativeZ = yapionObject.getPlainValueOrDefault("extensionNegativeZ", 0);
|
||||
extensionPositiveZ = yapionObject.getPlainValueOrDefault("extensionPositiveZ", 0);
|
||||
}
|
||||
|
||||
extensionRegistered = extensionNegativeX != 0 || extensionPositiveX != 0 || extensionNegativeY != 0 || extensionPositiveY != 0 || extensionNegativeZ != 0 || extensionPositiveZ != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Getter
|
||||
@ -194,6 +193,18 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasExtensionType(RegionType regionType) {
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
return prototype != null && prototype.getBuild() != null && prototype.getBuild().isExtensionRegistered();
|
||||
case TESTBLOCK:
|
||||
return prototype != null && prototype.getTestblock() != null && prototype.getTestblock().isExtensionRegistered();
|
||||
default:
|
||||
case NORMAL:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return prototype != null ? prototype.getDisplayName() : "";
|
||||
}
|
||||
@ -257,6 +268,30 @@ public class Region {
|
||||
return (T) flagStorage.get(flagType).getValue();
|
||||
}
|
||||
|
||||
public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
switch (regionType) {
|
||||
case TESTBLOCK:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointTestblock : minPointTestblockExtension;
|
||||
case BUILD:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? minPointBuild : minPointBuildExtension;
|
||||
default:
|
||||
case NORMAL:
|
||||
return minPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
switch (regionType) {
|
||||
case TESTBLOCK:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointTestblock : maxPointTestblockExtension;
|
||||
case BUILD:
|
||||
return (regionExtensionType == null || regionExtensionType == RegionExtensionType.NORMAL) ? maxPointBuild : maxPointBuildExtension;
|
||||
default:
|
||||
case NORMAL:
|
||||
return maxPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public void reset(RegionType regionType) {
|
||||
if (!hasType(regionType)) {
|
||||
return;
|
||||
@ -270,4 +305,8 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isGlobal() {
|
||||
return this == GlobalRegion.getInstance();
|
||||
}
|
||||
|
||||
}
|
@ -19,8 +19,17 @@
|
||||
|
||||
package de.steamwar.bausystem.region.utils;
|
||||
|
||||
public enum RegionType {
|
||||
NORMAL,
|
||||
BUILD,
|
||||
TESTBLOCK
|
||||
import de.steamwar.bausystem.shared.EnumDisplay;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum RegionType implements EnumDisplay {
|
||||
NORMAL("Normal"),
|
||||
BUILD("Baubereich"),
|
||||
TESTBLOCK("Testblock");
|
||||
|
||||
|
||||
@Getter
|
||||
private String chatValue;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren