2727
2828public class PluginConfig {
2929
30- private final static GameMode [] GAME_MODES = new GameMode []{GameMode .SURVIVAL , GameMode .CREATIVE , GameMode .ADVENTURE , GameMode .SPECTATOR };
30+ private final static GameMode [] GAME_MODES = new GameMode [] {GameMode .SURVIVAL , GameMode .CREATIVE , GameMode .ADVENTURE , GameMode .SPECTATOR };
3131 private static File FILE ;
3232
3333 private PluginConfig () {}
@@ -37,8 +37,8 @@ public static void checkConfig(File f) {
3737 if (FILE .exists ()) {
3838 YamlConfiguration cfg = getConfig ();
3939 if (!(cfg .isString ("worldfolder" ) && cfg .isInt ("unloadingtime" )
40- && cfg .isBoolean ("survival" ) && cfg .isString ("language" ) && cfg .isString ("prefix" )
41- && cfg .isInt ("request_expires" ) && cfg . isBoolean ( "need_confirm" )
40+ && cfg .isBoolean ("survival" ) && cfg .isString ("language" ) && cfg .isString ("prefix" ) && cfg . isString ( "cmd_prefix" )
41+ && cfg .isInt ("request_expires" )
4242 && cfg .isBoolean ("contact_authserver" ) && cfg .isBoolean ("spawn_teleportation" )
4343 && cfg .isInt ("delete_after" ) && cfg .isBoolean ("worldtemplates.multi_choose" )
4444 && cfg .isString ("worldtemplates.default" ) && cfg .isBoolean ("load_worlds_async" ) &&
@@ -73,7 +73,7 @@ public static void checkConfig(File f) {
7373 + new SimpleDateFormat ("dd-MM-yyyy-HH-mm-ss" ).format (new Date ()) + ".yml" ).toPath (),
7474 StandardCopyOption .REPLACE_EXISTING );
7575 Files .delete (FILE .toPath ());
76- WorldSystem .logger ().log (Level .SEVERE ,"[WorldSystem] Config is broken, creating a new one!" );
76+ WorldSystem .logger ().log (Level .SEVERE ,"Config is broken, creating a new one!" );
7777 checkConfig (f );
7878 } catch (IOException e ) {
7979 e .printStackTrace ();
@@ -87,18 +87,17 @@ public static void checkConfig(File f) {
8787 }
8888 // Try to get the config from resources
8989 InputStream in = JavaPlugin .getPlugin (WorldSystem .class ).getResource ("config.yml" );
90- if (in != null ) {
91- // Copy from resources
92- Files .copy (in , FILE .toPath ());
93- in .close ();
94- } else {
90+ // Copy from resources
91+ Files .copy (in , FILE .toPath ());
92+ in .close ();
93+ if (in == null ) {
9594 // Create a new config with default values if resource not found
9695 YamlConfiguration config = new YamlConfiguration ();
9796 config .set ("prefix" , "&8[&3WorldSystem&8] &6" );
98- config .set ("command_prefix " , "realms " );
97+ config .set ("cmd_prefix " , "ws " );
9998 config .set ("worldfolder" , "plugins/WorldSystem/Worlds" );
10099 config .set ("language" , "en" );
101- config .set ("need_confirm" , true );
100+ // config.set("need_confirm", true);
102101 config .set ("contact_authserver" , true );
103102 config .set ("spawn.gamemode" , 2 );
104103 config .set ("spawn.spawnpoint.use_last_location" , false );
@@ -146,14 +145,13 @@ public static void checkConfig(File f) {
146145
147146 // Should fix #2
148147 if (getSpawn (null ).getWorld () == null ) {
149- Bukkit . getConsoleSender ().sendMessage ( getPrefix () + "§cA lobby/hub spawn is missing. If this is not the first launch, add a spawn in config.yml" );
148+ WorldSystem . logger ().log ( Level . SEVERE , "A lobby/hub spawn is missing. If this is not the first launch, add a spawn in config.yml" );
150149 }
151150 }
152151
153152 public static YamlConfiguration getConfig () {
154153 try {
155- return YamlConfiguration
156- .loadConfiguration (new InputStreamReader (new FileInputStream (FILE ), StandardCharsets .UTF_8 ));
154+ return YamlConfiguration .loadConfiguration (new InputStreamReader (new FileInputStream (FILE ), StandardCharsets .UTF_8 ));
157155 } catch (FileNotFoundException e ) {
158156 e .printStackTrace ();
159157 }
0 commit comments