13
0

Merge pull request 'Small cleanup refactoring' (#87) from cleanup into master

Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2021-02-13 08:22:25 +01:00
Commit 923fc5c062
3 geänderte Dateien mit 11 neuen und 65 gelöschten Zeilen

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

@ -46,7 +46,7 @@ public class CheckSchemType implements ICheckSchemType {
private final int maxDispenser; private final int maxDispenser;
private final int maxBlocks; private final int maxBlocks;
CheckSchemType(ConfigurationSection section) { private CheckSchemType(ConfigurationSection section) {
name = section.getName(); name = section.getName();
width = section.getInt("width"); width = section.getInt("width");
height = section.getInt("height"); height = section.getInt("height");
@ -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;
} }
} }