From c916063734f54b6a24c4fb1bdafcc82378b5ff64 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 4 Feb 2021 10:31:31 +0100 Subject: [PATCH] Small cleanup refactoring Signed-off-by: Lixfel --- .../steamwar/schematicsystem/Constants.java | 48 ------------------- .../schematicsystem/CheckSchemType.java | 6 +++ .../schematicsystem/SchematicSystem.java | 20 ++------ 3 files changed, 10 insertions(+), 64 deletions(-) delete mode 100644 SchematicSystem_API/src/de/steamwar/schematicsystem/Constants.java diff --git a/SchematicSystem_API/src/de/steamwar/schematicsystem/Constants.java b/SchematicSystem_API/src/de/steamwar/schematicsystem/Constants.java deleted file mode 100644 index 31439aa..0000000 --- a/SchematicSystem_API/src/de/steamwar/schematicsystem/Constants.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - 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 . -*/ - -package de.steamwar.schematicsystem; - -import java.nio.file.attribute.PosixFilePermission; -import java.util.EnumSet; -import java.util.Set; - -public class Constants { - private Constants(){} - - public static final Set FILE_PERMS = EnumSet.of( - PosixFilePermission.OWNER_READ, - PosixFilePermission.OWNER_WRITE, - PosixFilePermission.GROUP_READ, - PosixFilePermission.GROUP_WRITE, - PosixFilePermission.OTHERS_READ, - PosixFilePermission.OTHERS_WRITE); - public static final Set FOLDER_PERMS = EnumSet.of( - PosixFilePermission.OWNER_READ, - PosixFilePermission.OWNER_WRITE, - PosixFilePermission.GROUP_READ, - PosixFilePermission.GROUP_WRITE, - PosixFilePermission.OTHERS_READ, - PosixFilePermission.OTHERS_WRITE, - PosixFilePermission.OWNER_EXECUTE, - PosixFilePermission.GROUP_EXECUTE, - PosixFilePermission.OTHERS_EXECUTE); - - public static final String SCHEM_DIR = "/home/minecraft/schematics/"; -} diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java index cd4a8ae..8c5fc1a 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java @@ -64,6 +64,12 @@ public class CheckSchemType implements ICheckSchemType { types.put(SchematicType.fromDB("c" + name), this); } + static void init(ConfigurationSection config){ + ConfigurationSection types = config.getConfigurationSection("Schematics"); + for(String sectionName : types.getKeys(false)) + new CheckSchemType(types.getConfigurationSection(sectionName)); + } + public static CheckSchemType get(SchematicType type){ return types.get(type); } diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java index 881cab5..ddb8d6c 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -19,36 +19,24 @@ package de.steamwar.schematicsystem; -import de.steamwar.core.CommandRemover; import de.steamwar.schematicsystem.commands.SchematicCommand; import org.bukkit.Bukkit; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; import java.io.File; +import java.util.logging.Level; public class SchematicSystem extends JavaPlugin { - public static final String PREFIX = "§eSchematic§8» §7"; - public static SchematicSystem INSTANCE; @Override public void onEnable() { - if (!new File("plugins/" + getName() + "/config.yml").exists()) { + if (!new File(getDataFolder(), "config.yml").exists()) { saveDefaultConfig(); - Bukkit.getLogger().info(SchematicSystem.PREFIX + "config.yml erstellt und geladen!"); - Bukkit.shutdown(); + Bukkit.getLogger().log(Level.SEVERE, "config.yml erstellt und geladen!"); } - FileConfiguration config = getConfig(); - ConfigurationSection types = config.getConfigurationSection("Schematics"); - for(String sectionName : types.getKeys(false)) - new CheckSchemType(types.getConfigurationSection(sectionName)); - - CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem"); - + CheckSchemType.init(getConfig()); getCommand("schem").setExecutor(new SchematicCommand()); - INSTANCE = this; } }