Skip to content

Commit

Permalink
use only one config field
Browse files Browse the repository at this point in the history
  • Loading branch information
michaljaz committed Dec 30, 2023
1 parent 0d88026 commit 63f1c26
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void onEnable() {
Bukkit.getPluginManager().disablePlugin(this);
}

String serverURI = "wss://router.shopmc.app/" + config.customer + "/" + config.server;
String serverURI = "wss://router.shopmc.app/" + config.key;
BukkitShopMCPlugin _this = this;
socket = new WebSocketClient(URI.create(serverURI)) {
@Override
Expand Down
14 changes: 4 additions & 10 deletions common/src/main/java/app/shopmc/plugin/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package app.shopmc.plugin.config;

public class Config {
public final String customer;
public final String server;
public final String key;

public Config(final ConfigLoader loader) throws EmptyConfigFieldException {
this.customer = loader.getString("customer");
this.server = loader.getString("server");
this.key = loader.getString("key");
this.checkValues();
}

private void checkValues() throws EmptyConfigFieldException {
if (this.customer == null || this.customer.isEmpty()) {
throw new EmptyConfigFieldException("customer");
}

if (this.server == null || this.server.isEmpty()) {
throw new EmptyConfigFieldException("server");
if (this.key == null || this.key.isEmpty()) {
throw new EmptyConfigFieldException("key");
}
}
}
8 changes: 2 additions & 6 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Customer ID
# You can find it https://shopmc.app/shop/[ID]
customer: ""

# Server ID
# Plugin Key
# You can find it in shopmc dashboard (edit server modal)
server: ""
key: ""

0 comments on commit 63f1c26

Please sign in to comment.