Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaljaz committed Jan 2, 2024
1 parent 48f6a7f commit 8b45ffa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BukkitShopMCPlugin extends JavaPlugin {

@Override
public void onEnable() {
// init config file if not exist
// init config file
if (!new File(getDataFolder(), "config.yml").exists()) {
saveDefaultConfig();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.scheduler.ScheduledTask;
import net.md_5.bungee.config.YamlConfiguration;
import org.java_websocket.handshake.ServerHandshake;

import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;

import static net.md_5.bungee.config.ConfigurationProvider.getProvider;

@SuppressWarnings("ResultOfMethodCallIgnored")
public class BungeeShopMCPlugin extends Plugin {
private Socket socket;
Expand All @@ -24,9 +27,9 @@ public class BungeeShopMCPlugin extends Plugin {

@Override
public void onEnable() {
// init config file
File dataFolder = getDataFolder();
dataFolder.mkdirs();

File configFile = new File(dataFolder, "config.yml");
if (!configFile.exists()) {
try {
Expand All @@ -36,10 +39,11 @@ public void onEnable() {
}
}

// check if config is correct
try {
config = new Config(new BungeeConfigLoader(net.md_5.bungee.config.ConfigurationProvider.getProvider(net.md_5.bungee.config.YamlConfiguration.class).load(configFile)));
config = new Config(new BungeeConfigLoader(getProvider(YamlConfiguration.class).load(configFile)));
} catch (EmptyConfigFieldException | IOException exception) {
getLogger().log(Level.SEVERE, String.format("[%s] %s", pluginName, exception.getMessage()));
getLogger().log(Level.SEVERE, exception.getMessage());
proxyServer.getPluginManager().unregisterCommands(pluginInstance);
return;
}
Expand Down

0 comments on commit 8b45ffa

Please sign in to comment.