Add CommandColor
Fix Region_15 region size
Dieser Commit ist enthalten in:
Ursprung
3e9a103018
Commit
cdacf05871
@ -44,7 +44,7 @@ class Region_15 {
|
||||
private Region_15() {
|
||||
}
|
||||
|
||||
static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir) {
|
||||
static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) {
|
||||
Clipboard clipboard;
|
||||
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
|
||||
clipboard = reader.read();
|
||||
@ -52,11 +52,13 @@ class Region_15 {
|
||||
throw new SecurityException("Bausystem schematic not found", e);
|
||||
}
|
||||
|
||||
return paste(clipboard, x, y, z, rotate, ignoreAir);
|
||||
return paste(clipboard, x, y, z, rotate, ignoreAir, color);
|
||||
}
|
||||
|
||||
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir) {
|
||||
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) {
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||
changeColor(clipboard, color);
|
||||
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||
BlockVector3 dimensions = clipboard.getDimensions();
|
||||
BlockVector3 v = BlockVector3.at(x, y, z);
|
||||
@ -70,13 +72,15 @@ class Region_15 {
|
||||
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(ignoreAir).build());
|
||||
return e;
|
||||
} catch (WorldEditException e) {
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
static void changeColor(Clipboard clipboard, Color color) throws WorldEditException {
|
||||
for (int x = 0; x < clipboard.getDimensions().getX(); x++) {
|
||||
for (int y = 0; y < clipboard.getDimensions().getX(); y++) {
|
||||
for (int z = 0; z < clipboard.getDimensions().getX(); z++) {
|
||||
for (int y = 0; y < clipboard.getDimensions().getY(); y++) {
|
||||
for (int z = 0; z < clipboard.getDimensions().getZ(); z++) {
|
||||
BlockVector3 blockPointer = clipboard.getMinimumPoint().add(x, y, z);
|
||||
clipboard.setBlock(blockPointer, mapColor(clipboard.getFullBlock(blockPointer).getBlockType(), color).getDefaultState().toBaseBlock());
|
||||
}
|
||||
|
@ -94,6 +94,12 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
new CommandWorldSpawn();
|
||||
new CommandRegion();
|
||||
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||
if (Region.buildAreaEnabled()) {
|
||||
new CommandColor();
|
||||
}
|
||||
}, 15));
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new ScriptListener(), this);
|
||||
@ -159,7 +165,6 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
autoShutdown.cancel();
|
||||
}
|
||||
CommandTPSLimiter.setTPS(20.0);
|
||||
System.out.println("SAVING colors");
|
||||
Region.saveColors();
|
||||
autoShutdown = Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
|
||||
int count = 0;
|
||||
|
@ -1,10 +1,56 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.world.Color;
|
||||
import de.steamwar.bausystem.world.Region;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class CommandColor {
|
||||
public class CommandColor extends SWCommand {
|
||||
|
||||
public CommandColor() {
|
||||
super("color");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region");
|
||||
p.sendMessage("§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericColor(Player p, Color color) {
|
||||
genericColorSet(p, color, ColorizationType.LOCAL);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericColorSet(Player p, Color color, ColorizationType colorizationType) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
if (colorizationType == ColorizationType.GLOBAL) {
|
||||
Region.setGlobalColor(color);
|
||||
p.sendMessage(BauSystem.PREFIX + "Alle Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt");
|
||||
return;
|
||||
}
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
region.setColor(color);
|
||||
p.sendMessage(BauSystem.PREFIX + "Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt");
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player p) {
|
||||
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ColorizationType {
|
||||
LOCAL,
|
||||
GLOBAL
|
||||
}
|
||||
|
||||
}
|
@ -31,6 +31,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@ -88,6 +89,12 @@ public class Region {
|
||||
}
|
||||
return GlobalRegion.getInstance();
|
||||
}
|
||||
|
||||
public static void setGlobalColor(Color color) {
|
||||
for (Region region : regions) {
|
||||
region.setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveColors() {
|
||||
File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "colors.json");
|
||||
@ -231,7 +238,7 @@ public class Region {
|
||||
|
||||
public void reset(Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException {
|
||||
initSessions();
|
||||
undosessions.push(prototype.reset(this, schem, ignoreAir));
|
||||
undosessions.push(prototype.reset(this, schem, ignoreAir, color));
|
||||
}
|
||||
|
||||
public boolean hasTestblock() {
|
||||
@ -240,7 +247,7 @@ public class Region {
|
||||
|
||||
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException {
|
||||
initSessions();
|
||||
undosessions.push(prototype.resetTestblock(this, schem));
|
||||
undosessions.push(prototype.resetTestblock(this, schem, color));
|
||||
}
|
||||
|
||||
public boolean hasProtection() {
|
||||
@ -418,14 +425,14 @@ public class Region {
|
||||
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
|
||||
}
|
||||
|
||||
public EditSession reset(Region region, Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException {
|
||||
public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException {
|
||||
int x = region.minX + offsetX + sizeX / 2;
|
||||
int y = region.minY + offsetY;
|
||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||
if (schem == null)
|
||||
return paste(new File(schematic), x, y, z, rotate, ignoreAir);
|
||||
return paste(new File(schematic), x, y, z, rotate, ignoreAir, color);
|
||||
else
|
||||
return paste(schem.load(), x, y, z, rotate, ignoreAir);
|
||||
return paste(schem.load(), x, y, z, rotate, ignoreAir, color);
|
||||
}
|
||||
|
||||
public boolean hasProtection() {
|
||||
@ -437,31 +444,31 @@ public class Region {
|
||||
int y = region.minY + testblock.offsetY - 1;
|
||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||
if (schem == null)
|
||||
return paste(new File(protectSchematic), x, y, z, rotate, false);
|
||||
return paste(new File(protectSchematic), x, y, z, rotate, false, Color.YELLOW);
|
||||
else
|
||||
return paste(schem.load(), x, y, z, rotate, false);
|
||||
return paste(schem.load(), x, y, z, rotate, false, Color.YELLOW);
|
||||
}
|
||||
|
||||
public boolean hasTestblock() {
|
||||
return testblock != null;
|
||||
}
|
||||
|
||||
public EditSession resetTestblock(Region region, Schematic schem) throws IOException, NoClipboardException {
|
||||
return testblock.reset(region, schem, false);
|
||||
public EditSession resetTestblock(Region region, Schematic schem, Color color) throws IOException, NoClipboardException {
|
||||
return testblock.reset(region, schem, false, color);
|
||||
}
|
||||
|
||||
private static boolean inRange(double l, int min, int size) {
|
||||
return min <= l && l < min + size;
|
||||
}
|
||||
|
||||
private static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir) { //Type of protect
|
||||
private static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) { //Type of protect
|
||||
return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, rotate, ignoreAir), 8),
|
||||
new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate, ignoreAir), 15));
|
||||
new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate, ignoreAir, color), 15));
|
||||
}
|
||||
|
||||
private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir) {
|
||||
private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) {
|
||||
return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, rotate, ignoreAir), 8),
|
||||
new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate, ignoreAir), 15));
|
||||
new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate, ignoreAir, color), 15));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren