Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Fix build issue and bungeecord issue
Browse files Browse the repository at this point in the history
Closes #75
  • Loading branch information
DaniFoldi committed Jun 17, 2021
1 parent 0ba47b8 commit 4facf58
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/main/java/com/danifoldi/bungeegui/command/PluginCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String[]
if (args.length > 3) {
try {
category = SoundCategory.valueOf(args[3]);
} catch (final @NotNull IllegalArgumentException ignored) {
} catch (IllegalArgumentException ignored) {

}
}
Expand All @@ -213,7 +213,7 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String[]
if (args.length > 4) {
try {
volume = Float.parseFloat(args[4]);
} catch (final @NotNull IllegalArgumentException ignored) {
} catch (IllegalArgumentException ignored) {

}
}
Expand All @@ -222,7 +222,7 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String[]
if (args.length > 5) {
try {
pitch = Float.parseFloat(args[5]);
} catch (final @NotNull IllegalArgumentException ignored) {
} catch (IllegalArgumentException ignored) {

}
}
Expand All @@ -245,21 +245,21 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String[]
int fadeIn = 20;
try {
fadeIn = Integer.parseInt(args[3]);
} catch (final @NotNull NumberFormatException ignored) {
} catch (NumberFormatException ignored) {

}

int stay = 60;
try {
stay = Integer.parseInt(args[4]);
} catch (final @NotNull NumberFormatException ignored) {
} catch (NumberFormatException ignored) {

}

int fadeOut = 20;
try {
fadeOut = Integer.parseInt(args[5]);
} catch (final @NotNull NumberFormatException ignored) {
} catch (NumberFormatException ignored) {

}

Expand Down Expand Up @@ -289,7 +289,7 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String[]
case "p":
return List.of(ProxyServer.getInstance().getPlayer(target.getSecond()));
case "s":
return ProxyServer.getInstance().getServers().get(target.getSecond()).getPlayers();
return ProxyServer.getInstance().getServersCopy().get(target.getSecond()).getPlayers();
default:
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.api.scheduler.TaskScheduler;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;

import javax.inject.Singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void load() {
}

pluginManager.registerListener(plugin, listener);
} catch (final @NotNull IOException e) {
} catch (IOException e) {
StringUtil.blockPrint(logger::severe, "Could not enable plugin, please see the error below");
logger.severe(e.getMessage());
e.printStackTrace();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/danifoldi/bungeegui/main/GuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.danifoldi.bungeegui.util.StringUtil;
import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.core.EnumGetMethod;
import dagger.Module;
import de.exceptionflug.protocolize.inventory.Inventory;
import de.exceptionflug.protocolize.inventory.InventoryModule;
import de.exceptionflug.protocolize.items.ItemStack;
Expand Down Expand Up @@ -136,7 +137,7 @@ void load(@NotNull Config config) {
.build();

addGui(name, grid);
} catch (final @NotNull Exception e) {
} catch (Exception e) {
logger.warning("Could not load gui " + name);
logger.warning(e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void registerBuiltin(final @NotNull String name, final @NotNull Function<Proxied
text = text.replace("%" + placeholder + "%", value);
changed = true;
}
} catch (final @NotNull Exception e) {
} catch (Exception e) {
logger.warning("Placeholder " + placeholder + " couldn't be processed");
e.printStackTrace();
}
Expand All @@ -107,7 +107,7 @@ void unregisterAll() {
void registerBuiltins() {
final @NotNull ConcurrentMap<ServerInfo, Boolean> lastStatus = new ConcurrentHashMap<>();
refreshData = proxyServer.getScheduler().schedule(plugin, () -> {
for (ServerInfo server: Map.copyOf(proxyServer.getServers()).values()) {
for (ServerInfo server: proxyServer.getServersCopy().values()) {
server.ping((ping, error) -> {
if (lastStatus.containsKey(server) && lastStatus.get(server) != (error == null)) {
if (error != null) {
Expand Down Expand Up @@ -149,7 +149,7 @@ void registerBuiltins() {
return String.valueOf(count);
});
registerBuiltin("guicount", player -> String.valueOf(BungeeGuiAPI.getInstance().getAvailableGuis().size()));
registerBuiltin("servercount", player -> String.valueOf(proxyServer.getServers().size()));
registerBuiltin("servercount", player -> String.valueOf(proxyServer.getServersCopy().size()));
registerBuiltin("plugincount", player -> String.valueOf(pluginManager.getPlugins().size()));
registerBuiltin("placeholdercount", player -> String.valueOf(placeholders.size() + builtinPlaceholders.size()));
registerBuiltin("displayname", player -> {
Expand Down Expand Up @@ -268,7 +268,7 @@ void registerBuiltins() {
return "";
}
return user.getFriendlyName();
} catch (final @NotNull IllegalStateException | NullPointerException e) {
} catch (IllegalStateException | NullPointerException e) {
return "";
}
});
Expand All @@ -283,7 +283,7 @@ void registerBuiltins() {
}
final @Nullable String value = user.getCachedData().getMetaData().getPrefix();
return value == null ? "" : value;
} catch (final @NotNull IllegalStateException | NullPointerException e) {
} catch (IllegalStateException | NullPointerException e) {
return "";
}
});
Expand All @@ -298,7 +298,7 @@ void registerBuiltins() {
}
final @Nullable String value = user.getCachedData().getMetaData().getSuffix();
return value == null ? "" : value;
} catch (final @NotNull IllegalStateException | NullPointerException e) {
} catch (IllegalStateException | NullPointerException e) {
return "";
}
});
Expand All @@ -313,12 +313,12 @@ void registerBuiltins() {
}
final @Nullable String value = user.getCachedData().getMetaData().getPrimaryGroup();
return value == null ? "" : value;
} catch (final @NotNull IllegalStateException | NullPointerException e) {
} catch (IllegalStateException | NullPointerException e) {
return "";
}
});

for (Map.Entry<String, ServerInfo> server: Map.copyOf(proxyServer.getServers()).entrySet()) {
for (Map.Entry<String, ServerInfo> server: proxyServer.getServersCopy().entrySet()) {
registerBuiltin("status@" + server.getKey(), player -> {
final boolean online = lastStatus.get(server.getValue());
return online ? "Online" : "Offline";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/danifoldi/bungeegui/util/SoundUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static boolean isValidSound(final @NotNull String soundName) {
final @NotNull Pair<String, String> value = StringUtil.get(soundName);
try {
Sound.valueOf(value.getSecond());
} catch (final @NotNull IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
if (!value.getFirst().equals("custom")) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/danifoldi/bungeegui/util/UpdateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static CompletableFuture<String> getNewest() {
.thenApply(o -> o.get("tag_name").getAsString())
.join();

} catch (final @NotNull Exception e) {
} catch (Exception e) {
Logger.getAnonymousLogger().warning(e.getMessage());
final @NotNull HttpRequest sgRequest = HttpRequest
.newBuilder()
Expand All @@ -45,7 +45,7 @@ public static CompletableFuture<String> getNewest() {
.thenApply(b -> new Gson().fromJson(b, JsonElement.class).getAsJsonObject())
.thenApply(o -> o.get("name").getAsString())
.join();
} catch (final @NotNull Exception e2) {
} catch (Exception e2) {
Logger.getAnonymousLogger().warning(e2.getMessage());
return "";
}
Expand Down

0 comments on commit 4facf58

Please sign in to comment.