13
0

Small cleanup refactoring #87

Manuell gemergt
Lixfel hat 2 Commits von cleanup nach master 2021-02-13 08:22:25 +01:00 zusammengeführt
3 geänderte Dateien mit 10 neuen und 64 gelöschten Zeilen
Nur Änderungen aus Commit c916063734 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<PosixFilePermission> 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<PosixFilePermission> 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/";
}

Datei anzeigen

@ -64,6 +64,12 @@ public class CheckSchemType implements ICheckSchemType {
types.put(SchematicType.fromDB("c" + name), this); 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){ public static CheckSchemType get(SchematicType type){
return types.get(type); return types.get(type);
} }

Datei anzeigen

@ -19,36 +19,24 @@
package de.steamwar.schematicsystem; package de.steamwar.schematicsystem;
import de.steamwar.core.CommandRemover;
import de.steamwar.schematicsystem.commands.SchematicCommand; import de.steamwar.schematicsystem.commands.SchematicCommand;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File; import java.io.File;
import java.util.logging.Level;
public class SchematicSystem extends JavaPlugin { public class SchematicSystem extends JavaPlugin {
public static final String PREFIX = "§eSchematic§8» §7"; public static final String PREFIX = "§eSchematic§8» §7";
public static SchematicSystem INSTANCE;
@Override @Override
public void onEnable() { public void onEnable() {
if (!new File("plugins/" + getName() + "/config.yml").exists()) { if (!new File(getDataFolder(), "config.yml").exists()) {
saveDefaultConfig(); saveDefaultConfig();
Bukkit.getLogger().info(SchematicSystem.PREFIX + "config.yml erstellt und geladen!"); Bukkit.getLogger().log(Level.SEVERE, "config.yml erstellt und geladen!");
Bukkit.shutdown();
} }
FileConfiguration config = getConfig(); CheckSchemType.init(getConfig());
ConfigurationSection types = config.getConfigurationSection("Schematics");
for(String sectionName : types.getKeys(false))
new CheckSchemType(types.getConfigurationSection(sectionName));
CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem");
getCommand("schem").setExecutor(new SchematicCommand()); getCommand("schem").setExecutor(new SchematicCommand());
INSTANCE = this;
} }
} }