Merge pull request 'ColorCustomization' (#238) from ColorCustomization into master
Reviewed-on: #238 Reviewed-by: Zeanon <thezeanon@gmail.com>
Dieser Commit ist enthalten in:
Commit
47c965619c
@ -21,15 +21,17 @@ package de.steamwar.bausystem.world;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -42,7 +44,7 @@ class Region_15 {
|
|||||||
private 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;
|
Clipboard clipboard;
|
||||||
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
|
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
|
||||||
clipboard = reader.read();
|
clipboard = reader.read();
|
||||||
@ -50,11 +52,13 @@ class Region_15 {
|
|||||||
throw new SecurityException("Bausystem schematic not found", e);
|
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)) {
|
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||||
|
changeColor(clipboard, color);
|
||||||
|
|
||||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||||
BlockVector3 dimensions = clipboard.getDimensions();
|
BlockVector3 dimensions = clipboard.getDimensions();
|
||||||
BlockVector3 v = BlockVector3.at(x, y, z);
|
BlockVector3 v = BlockVector3.at(x, y, z);
|
||||||
@ -68,6 +72,121 @@ class Region_15 {
|
|||||||
|
|
||||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(ignoreAir).build());
|
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(ignoreAir).build());
|
||||||
return e;
|
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().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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlockType mapColor(BlockType original, Color color) {
|
||||||
|
if (original != BlockTypes.YELLOW_CONCRETE && original != BlockTypes.YELLOW_STAINED_GLASS) {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (color) {
|
||||||
|
case WHITE:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.WHITE_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.WHITE_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case ORANGE:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.ORANGE_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.ORANGE_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case MAGENTA:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.MAGENTA_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.MAGENTA_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case LIGHT_BLUE:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.LIGHT_BLUE_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.LIGHT_BLUE_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case LIME:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.LIME_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.LIME_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case PINK:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.PINK_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.PINK_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case GRAY:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.GRAY_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.GRAY_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case LIGHT_GRAY:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.LIGHT_GRAY_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.LIGHT_GRAY_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case CYAN:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.CYAN_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.CYAN_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case PURPLE:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.PURPLE_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.PURPLE_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case BLUE:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.BLUE_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.BLUE_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case BROWN:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.BROWN_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.BROWN_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case GREEN:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.GREEN_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.GREEN_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case RED:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.RED_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.RED_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case BLACK:
|
||||||
|
if (original == BlockTypes.YELLOW_CONCRETE) {
|
||||||
|
return BlockTypes.BLACK_CONCRETE;
|
||||||
|
} else {
|
||||||
|
return BlockTypes.BLACK_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
case YELLOW:
|
||||||
|
default:
|
||||||
|
return original;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
BauSystem_API/src/de/steamwar/bausystem/world/Color.java
Normale Datei
39
BauSystem_API/src/de/steamwar/bausystem/world/Color.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
public enum Color {
|
||||||
|
WHITE,
|
||||||
|
ORANGE,
|
||||||
|
MAGENTA,
|
||||||
|
LIGHT_BLUE,
|
||||||
|
YELLOW,
|
||||||
|
LIME,
|
||||||
|
PINK,
|
||||||
|
GRAY,
|
||||||
|
LIGHT_GRAY,
|
||||||
|
CYAN,
|
||||||
|
PURPLE,
|
||||||
|
BLUE,
|
||||||
|
BROWN,
|
||||||
|
GREEN,
|
||||||
|
RED,
|
||||||
|
BLACK;
|
||||||
|
}
|
@ -94,6 +94,12 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
new CommandWorldSpawn();
|
new CommandWorldSpawn();
|
||||||
new CommandRegion();
|
new CommandRegion();
|
||||||
|
|
||||||
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
|
if (Region.buildAreaEnabled()) {
|
||||||
|
new CommandColor();
|
||||||
|
}
|
||||||
|
}, 15));
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new ScriptListener(), this);
|
Bukkit.getPluginManager().registerEvents(new ScriptListener(), this);
|
||||||
@ -110,6 +116,11 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
TPSUtils.init();
|
TPSUtils.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
Region.save();
|
||||||
|
}
|
||||||
|
|
||||||
public static BauSystem getPlugin() {
|
public static BauSystem getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
56
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandColor.java
Normale Datei
56
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandColor.java
Normale Datei
@ -0,0 +1,56 @@
|
|||||||
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
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 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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
|
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
|
||||||
@ -32,6 +36,8 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -42,8 +48,18 @@ public class Region {
|
|||||||
private static final List<Region> regions = new ArrayList<>();
|
private static final List<Region> regions = new ArrayList<>();
|
||||||
private static boolean buildArea = false;
|
private static boolean buildArea = false;
|
||||||
private static boolean extensionArea = false;
|
private static boolean extensionArea = false;
|
||||||
|
private static JsonObject regionsObject = new JsonObject();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
File regionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json");
|
||||||
|
if (regionsFile.exists()) {
|
||||||
|
try {
|
||||||
|
regionsObject = new JsonParser().parse(new FileReader(regionsFile)).getAsJsonObject();
|
||||||
|
} catch (JsonSyntaxException | IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Item JSON error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml"));
|
config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml"));
|
||||||
@ -79,6 +95,30 @@ public class Region {
|
|||||||
return GlobalRegion.getInstance();
|
return GlobalRegion.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setGlobalColor(Color color) {
|
||||||
|
for (Region region : regions) {
|
||||||
|
region.setColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save() {
|
||||||
|
File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json");
|
||||||
|
if (!colorsFile.exists()) {
|
||||||
|
try {
|
||||||
|
colorsFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try (FileOutputStream fileOutputStream = new FileOutputStream(colorsFile)) {
|
||||||
|
fileOutputStream.write(regionsObject.toString().getBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int minX;
|
private final int minX;
|
||||||
private final int minY;
|
private final int minY;
|
||||||
@ -89,12 +129,47 @@ public class Region {
|
|||||||
private SizedStack<EditSession> undosessions;
|
private SizedStack<EditSession> undosessions;
|
||||||
private SizedStack<EditSession> redosessions;
|
private SizedStack<EditSession> redosessions;
|
||||||
|
|
||||||
|
private JsonObject regionOptions = new JsonObject();
|
||||||
|
|
||||||
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
|
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
|
||||||
private boolean freeze = false;
|
private boolean freeze = false;
|
||||||
private boolean fire = false;
|
private boolean fire = false;
|
||||||
|
|
||||||
|
private Color color = Color.YELLOW;
|
||||||
|
|
||||||
private Region(ConfigurationSection config) {
|
private Region(ConfigurationSection config) {
|
||||||
name = config.getName();
|
name = config.getName();
|
||||||
|
if (regionsObject.has(name)) {
|
||||||
|
regionOptions = regionsObject.getAsJsonObject(name);
|
||||||
|
if (regionOptions.has("tnt")) {
|
||||||
|
String tntName = regionsObject.getAsJsonObject(name).getAsJsonPrimitive("tnt").getAsString();
|
||||||
|
try {
|
||||||
|
tntMode = TNTMode.valueOf(tntName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regionOptions.has("fire")) {
|
||||||
|
fire = regionOptions.getAsJsonPrimitive("fire").getAsBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regionOptions.has("freeze")) {
|
||||||
|
freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regionOptions.has("color")) {
|
||||||
|
String colorName = regionOptions.getAsJsonPrimitive("color").getAsString();
|
||||||
|
try {
|
||||||
|
color = Color.valueOf(colorName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
regionsObject.add(name, regionOptions);
|
||||||
|
}
|
||||||
|
|
||||||
minX = config.getInt("minX");
|
minX = config.getInt("minX");
|
||||||
minY = config.getInt("minY");
|
minY = config.getInt("minY");
|
||||||
minZ = config.getInt("minZ");
|
minZ = config.getInt("minZ");
|
||||||
@ -114,6 +189,15 @@ public class Region {
|
|||||||
tntMode = TNTMode.OFF;
|
tntMode = TNTMode.OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
regionOptions.add("color", new JsonPrimitive(color.name()));
|
||||||
|
}
|
||||||
|
|
||||||
private void setLinkedRegion(Consumer<Region> regionConsumer) {
|
private void setLinkedRegion(Consumer<Region> regionConsumer) {
|
||||||
if (optionsLinkedWith == null) {
|
if (optionsLinkedWith == null) {
|
||||||
return;
|
return;
|
||||||
@ -138,6 +222,7 @@ public class Region {
|
|||||||
public void setTntMode(TNTMode tntMode) {
|
public void setTntMode(TNTMode tntMode) {
|
||||||
this.tntMode = tntMode;
|
this.tntMode = tntMode;
|
||||||
setLinkedRegion(region -> region.tntMode = tntMode);
|
setLinkedRegion(region -> region.tntMode = tntMode);
|
||||||
|
regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFreeze() {
|
public boolean isFreeze() {
|
||||||
@ -147,6 +232,7 @@ public class Region {
|
|||||||
public void setFreeze(boolean freeze) {
|
public void setFreeze(boolean freeze) {
|
||||||
this.freeze = freeze;
|
this.freeze = freeze;
|
||||||
setLinkedRegion(region -> region.freeze = freeze);
|
setLinkedRegion(region -> region.freeze = freeze);
|
||||||
|
regionOptions.add("freeze", new JsonPrimitive(freeze));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFire() {
|
public boolean isFire() {
|
||||||
@ -156,6 +242,7 @@ public class Region {
|
|||||||
public void setFire(boolean fire) {
|
public void setFire(boolean fire) {
|
||||||
this.fire = fire;
|
this.fire = fire;
|
||||||
setLinkedRegion(region -> region.fire = fire);
|
setLinkedRegion(region -> region.fire = fire);
|
||||||
|
regionOptions.add("fire", new JsonPrimitive(fire));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inRegion(Location l) {
|
public boolean inRegion(Location l) {
|
||||||
@ -180,7 +267,7 @@ public class Region {
|
|||||||
|
|
||||||
public void reset(Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException {
|
public void reset(Schematic schem, boolean ignoreAir) throws IOException, NoClipboardException {
|
||||||
initSessions();
|
initSessions();
|
||||||
undosessions.push(prototype.reset(this, schem, ignoreAir));
|
undosessions.push(prototype.reset(this, schem, ignoreAir, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTestblock() {
|
public boolean hasTestblock() {
|
||||||
@ -189,7 +276,7 @@ public class Region {
|
|||||||
|
|
||||||
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException {
|
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException {
|
||||||
initSessions();
|
initSessions();
|
||||||
undosessions.push(prototype.resetTestblock(this, schem));
|
undosessions.push(prototype.resetTestblock(this, schem, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProtection() {
|
public boolean hasProtection() {
|
||||||
@ -367,14 +454,14 @@ public class Region {
|
|||||||
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
|
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 x = region.minX + offsetX + sizeX / 2;
|
||||||
int y = region.minY + offsetY;
|
int y = region.minY + offsetY;
|
||||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||||
if (schem == null)
|
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
|
else
|
||||||
return paste(schem.load(), x, y, z, rotate, ignoreAir);
|
return paste(schem.load(), x, y, z, rotate, ignoreAir, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasProtection() {
|
public boolean hasProtection() {
|
||||||
@ -386,31 +473,31 @@ public class Region {
|
|||||||
int y = region.minY + testblock.offsetY - 1;
|
int y = region.minY + testblock.offsetY - 1;
|
||||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||||
if (schem == null)
|
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
|
else
|
||||||
return paste(schem.load(), x, y, z, rotate, false);
|
return paste(schem.load(), x, y, z, rotate, false, Color.YELLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTestblock() {
|
public boolean hasTestblock() {
|
||||||
return testblock != null;
|
return testblock != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditSession resetTestblock(Region region, Schematic schem) throws IOException, NoClipboardException {
|
public EditSession resetTestblock(Region region, Schematic schem, Color color) throws IOException, NoClipboardException {
|
||||||
return testblock.reset(region, schem, false);
|
return testblock.reset(region, schem, false, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean inRange(double l, int min, int size) {
|
private static boolean inRange(double l, int min, int size) {
|
||||||
return min <= l && l < min + 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),
|
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),
|
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