Skip to content

Commit

Permalink
Make minecraft integrations more stable and consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
rFranzr committed Jul 13, 2023
1 parent 0c0e691 commit 1df7abd
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bukkit/src/main/java/net/vyhub/VyHubPlugin.java
Expand Up @@ -124,7 +124,7 @@ public void onReady() {
scheduler.runTaskTimerAsynchronously(plugin, tGroups::syncGroupsForAll, 20L * 60L * 10L, 20L * 60L * 8L);
}

if (!VyHubConfiguration.getIsProxyServer()) {
if (!VyHubConfiguration.getIsBackendServer()) {
scheduler.runTaskTimerAsynchronously(plugin, tServer::patchServer, 20L * 1L, 20L * 60L);
}
}
Expand Down Expand Up @@ -207,9 +207,9 @@ public void sendStartupMessage() {
}

public void checkOfflineMode() {
if (!plugin.getServer().getOnlineMode() && !VyHubConfiguration.getIsProxyServer()) {
if (!plugin.getServer().getOnlineMode() && !VyHubConfiguration.getIsBackendServer()) {
this.platform.log(WARNING, "You are running in offline mode. Unless you are using a proxy (such as BungeeCord/Velocity) that corrects UUIDs, then you may experience issues with packages not applying");
this.platform.log(WARNING, "You can suppress this warning by setting is_proxy_server to true in your VyHub config.json");
this.platform.log(WARNING, "You can suppress this warning by setting is_backend_server to true in your VyHub config.json");
}
}
}
5 changes: 5 additions & 0 deletions bungeeCord/src/main/java/net/vyhub/command/Config.java
Expand Up @@ -3,6 +3,7 @@
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.vyhub.VyHubPlugin;
import net.vyhub.config.VyHubConfiguration;
Expand All @@ -17,6 +18,10 @@ public Config(final VyHubPlugin plugin) {

@Override
public void execute(CommandSender sender, String[] args) {
// Config /vh_config <key> <value>
if (sender instanceof ProxiedPlayer && !sender.hasPermission("vyhub.config")) {
return;
}
if (args.length != 2) {
return;
}
Expand Down
9 changes: 7 additions & 2 deletions bungeeCord/src/main/java/net/vyhub/command/Setup.java
Expand Up @@ -3,6 +3,7 @@
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.vyhub.VyHubPlugin;
import net.vyhub.config.VyHubConfiguration;
Expand All @@ -16,8 +17,12 @@ public Setup(final VyHubPlugin plugin) {
}

@Override
public void execute(CommandSender commandSender, String[] args) {
public void execute(CommandSender sender, String[] args) {
// Fast setup /vh_setup <api_key> <api_url> <server_id>
if (sender instanceof ProxiedPlayer && !sender.hasPermission("vyhub.config")) {
return;
}

if (args.length != 3) {
return;
}
Expand All @@ -34,6 +39,6 @@ public void execute(CommandSender commandSender, String[] args) {
VyHubConfiguration.setConfigValue("api_url", api_url);
VyHubConfiguration.setConfigValue("server_id", server_id);

commandSender.sendMessage(new TextComponent(ChatColor.GREEN + plugin.getI18n().get("Config Saved")));
sender.sendMessage(new TextComponent(ChatColor.GREEN + plugin.getI18n().get("Config Saved")));
}
}
4 changes: 2 additions & 2 deletions common/src/main/java/net/vyhub/config/VyHubConfiguration.java
Expand Up @@ -32,7 +32,7 @@ public static Map<String, String> loadConfig() {
config.put("api_url", "");
config.put("api_key", "");
config.put("server_id", "");
config.put("is_proxy_server", "false");
config.put("is_backend_server", "false");
config.put("advert_prefix", "[★] ");
config.put("advert_interval", "180");
config.put("locale", "en");
Expand Down Expand Up @@ -75,7 +75,7 @@ public static String getAdvertPrefix() {
return config.get("advert_prefix");
}

public static Boolean getIsProxyServer() { return Boolean.valueOf(config.get("is_proxy_server")); }
public static Boolean getIsBackendServer() { return Boolean.valueOf(config.get("is_backend_server")); }

public static void updateCache() {
configCache.save(config);
Expand Down
4 changes: 2 additions & 2 deletions velocity/src/main/java/net/vyhub/VyHubPlugin.java
Expand Up @@ -31,7 +31,7 @@
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;

@Plugin(id = "vyhub", name = "VyHub", version = "1.5.1",
@Plugin(id = "vyhub", name = "vyhub", version = "1.5.1",
url = "https://vyhub.net", description = "VyHub plugin to manage and monetize your Minecraft server. You can create your webstore for free with VyHub!", authors = {"VyHub, Matbyte"})
public class VyHubPlugin {
public static VyHubPlugin plugin;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
VyHubConfiguration.setPlatform(platform);
VyHubConfiguration.loadConfig();
i18n = new I18n(VyHubConfiguration.getLocale());
httpClient = Utility.okhttp(new File(dataDirectory.toFile(), "cache"));
httpClient = Utility.okhttp(new File("plugins/VyHub/", "cache"));

sendStartupMessage();

Expand Down
Expand Up @@ -37,7 +37,7 @@ public void execute(final Invocation invocation) {

@Override
public boolean hasPermission(final Invocation invocation) {
return invocation.source().hasPermission("vyhub.admin");
return invocation.source().hasPermission("vyhub.config");
}

}
2 changes: 1 addition & 1 deletion velocity/src/main/java/net/vyhub/command/SetupCommand.java
Expand Up @@ -41,7 +41,7 @@ public void execute(final SimpleCommand.Invocation invocation) {

@Override
public boolean hasPermission(final SimpleCommand.Invocation invocation) {
return invocation.source().hasPermission("vyhub.admin");
return invocation.source().hasPermission("vyhub.config");
}

}

0 comments on commit 1df7abd

Please sign in to comment.