Add Color
Add Region.colors Add World config colors.json
Dieser Commit ist enthalten in:
Ursprung
8e7352ee7e
Commit
e3880b3a30
@ -23,18 +23,18 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
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.ClipboardReader;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
class Region_15 {
|
||||
|
@ -159,6 +159,8 @@ 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;
|
||||
|
||||
|
39
BauSystem_Main/src/de/steamwar/bausystem/world/Color.java
Normale Datei
39
BauSystem_Main/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
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
|
||||
@ -31,8 +32,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
@ -42,8 +42,18 @@ public class Region {
|
||||
private static final List<Region> regions = new ArrayList<>();
|
||||
private static boolean buildArea = false;
|
||||
private static boolean extensionArea = false;
|
||||
private static JsonObject colors = new JsonObject();
|
||||
|
||||
static {
|
||||
File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "colors.json");
|
||||
if (colorsFile.exists()) {
|
||||
try {
|
||||
colors = new JsonParser().parse(new FileReader(colorsFile)).getAsJsonObject();
|
||||
} catch (JsonSyntaxException | IOException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Item JSON error");
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml"));
|
||||
@ -78,6 +88,24 @@ public class Region {
|
||||
}
|
||||
return GlobalRegion.getInstance();
|
||||
}
|
||||
|
||||
public static void saveColors() {
|
||||
File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "colors.json");
|
||||
if (!colorsFile.exists()) {
|
||||
try {
|
||||
colorsFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(colorsFile)) {
|
||||
fileOutputStream.write(colors.toString().getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final int minX;
|
||||
@ -93,8 +121,22 @@ public class Region {
|
||||
private boolean freeze = false;
|
||||
private boolean fire = false;
|
||||
|
||||
private Color color = Color.YELLOW;
|
||||
|
||||
private Region(ConfigurationSection config) {
|
||||
name = config.getName();
|
||||
if (colors.has(name)) {
|
||||
String colorName = colors.getAsJsonPrimitive(name).getAsString();
|
||||
try {
|
||||
color = Color.valueOf(colorName);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
if (color == null) {
|
||||
color = Color.YELLOW;
|
||||
}
|
||||
}
|
||||
|
||||
minX = config.getInt("minX");
|
||||
minY = config.getInt("minY");
|
||||
minZ = config.getInt("minZ");
|
||||
@ -114,6 +156,15 @@ public class Region {
|
||||
tntMode = TNTMode.OFF;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
colors.add(name, new JsonPrimitive(color.name()));
|
||||
}
|
||||
|
||||
private void setLinkedRegion(Consumer<Region> regionConsumer) {
|
||||
if (optionsLinkedWith == null) {
|
||||
return;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren