Skip to content

Commit d3842e4

Browse files
committed
Fixed a NPE and changed colors usage
1 parent 108c7de commit d3842e4

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

src/main/java/io/github/bilektugrul/simpleservertools/AsyncUserSaveThread.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.bilektugrul.simpleservertools;
22

33
import io.github.bilektugrul.simpleservertools.users.UserManager;
4+
import org.bukkit.ChatColor;
45
import org.bukkit.scheduler.BukkitRunnable;
56

67
import java.io.IOException;
@@ -20,7 +21,7 @@ public AsyncUserSaveThread(SST plugin) {
2021
}
2122

2223
public void start() {
23-
logger.info("§aAsync user saving thread is starting...");
24+
logger.info(ChatColor.GREEN + "Async user saving thread is starting...");
2425
int i = plugin.getConfig().getInt("auto-save-interval");
2526
runTaskTimerAsynchronously(plugin, 2400, (i * 60L) * 20);
2627
}

src/main/java/io/github/bilektugrul/simpleservertools/SST.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import io.github.bilektugrul.simpleservertools.utils.Utils;
3434
import io.github.bilektugrul.simpleservertools.utils.VaultManager;
3535
import org.bukkit.Bukkit;
36-
import org.bukkit.command.ConsoleCommandSender;
36+
import org.bukkit.ChatColor;
3737
import org.bukkit.entity.Player;
3838
import org.bukkit.plugin.PluginManager;
3939
import org.bukkit.plugin.java.JavaPlugin;
@@ -66,7 +66,7 @@ public class SST extends JavaPlugin {
6666
public void onEnable() {
6767
saveDefaultConfig();
6868
logger = getLogger();
69-
logger.info("§aSimpleServerTools v" + getDescription().getVersion() + " is being enabled. Thanks for using SST!");
69+
logger.info(ChatColor.GREEN + "SimpleServerTools v" + getDescription().getVersion() + " is being enabled. Thanks for using SST!");
7070
pluginManager = getServer().getPluginManager();
7171
placeholderManager = new CustomPlaceholderManager(this);
7272
languageManager = new LanguageManager(this);
@@ -81,12 +81,12 @@ public void onEnable() {
8181
if (pluginManager.isPluginEnabled("PlaceholderAPI")) {
8282
new PAPIPlaceholders(this).register();
8383
} else {
84-
logger.warning("§cPlaceholderAPI is not installed. You should check it out.");
84+
logger.warning(ChatColor.RED + "PlaceholderAPI is not installed. You should check it out.");
8585
}
8686
if (pluginManager.isPluginEnabled("Vault")) {
8787
vaultManager = new VaultManager(this);
8888
} else {
89-
logger.warning("§cVault is not installed. Some features may not work.");
89+
logger.warning(ChatColor.RED + "Vault is not installed. Some features may not work.");
9090
}
9191
announcementManager = new AnnouncementManager(this);
9292
for (Player looped : Bukkit.getOnlinePlayers()) {
@@ -129,11 +129,11 @@ public void onEnable() {
129129
asyncUserSaveThread = new AsyncUserSaveThread(this);
130130
}
131131
if (Utils.getBoolean("metrics-enabled")) {
132-
logger.info("§aEnabling metrics...");
132+
logger.info(ChatColor.GREEN + "Enabling metrics...");
133133
new Metrics(this, 11344);
134134
}
135135
checkUpdate();
136-
logger.info("§aEnabling process is done, enjoy!");
136+
logger.info(ChatColor.GREEN + "Enabling process is done, enjoy!");
137137
}
138138

139139
@Override
@@ -147,7 +147,7 @@ public void onDisable() {
147147
warpManager.saveWarps();
148148
spawnManager.saveSpawn();
149149
maintenanceManager.save();
150-
logger.info("§aEverything has been saved.");
150+
logger.info(ChatColor.GREEN + "Everything has been saved.");
151151
}
152152

153153
public void checkUpdate() {
@@ -165,16 +165,16 @@ public void checkUpdate() {
165165

166166
if (result.getNewestVersion().contains("b")) {
167167
if (getConfig().getBoolean("updates.notify-beta-versions", true)) {
168-
logger.info("§aFound a new beta version available: v" + result.getNewestVersion());
169-
logger.info("§aDownload it on SpigotMC:");
170-
logger.info("§b https://www.spigotmc.org/resources/simpleservertools-1-8-8-1-16-5.92388/");
168+
logger.info(ChatColor.GREEN + "Found a new beta version available: v" + result.getNewestVersion());
169+
logger.info(ChatColor.GREEN + "Download it on SpigotMC:");
170+
logger.info(ChatColor.BLUE + "https://www.spigotmc.org/resources/simpleservertools-1-8-8-1-16-5.92388/");
171171
}
172172
return;
173173
}
174174

175-
logger.info("§aFound a new version available: v" + result.getNewestVersion());
176-
logger.info("§aDownload it SpigotMC:");
177-
logger.info("§ahttps://www.spigotmc.org/resources/simpleservertools-1-8-8-1-16-5.92388/");
175+
logger.info(ChatColor.GREEN + "Found a new version available: v" + result.getNewestVersion());
176+
logger.info(ChatColor.GREEN + "Download it SpigotMC:");
177+
logger.info(ChatColor.BLUE + "https://www.spigotmc.org/resources/simpleservertools-1-8-8-1-16-5.92388/");
178178

179179
});
180180

@@ -235,7 +235,7 @@ public void checkAndLoadPacketListener() {
235235
}
236236

237237
public void reload(boolean first) {
238-
logger.info("§aReloading configurations from disk...");
238+
logger.info(ChatColor.GREEN + "Reloading configurations from disk...");
239239
reloadConfig();
240240
checkAndLoadPacketListener();
241241
placeholderManager.load();

src/main/java/io/github/bilektugrul/simpleservertools/commands/PingCommand.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class PingCommand implements CommandExecutor {
1212

1313
@Override
1414
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
15+
1516
if (!sender.hasPermission("sst.ping")) {
1617
sender.sendMessage(Utils.getMessage("no-permission", sender));
1718
return true;
@@ -23,7 +24,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
2324
pingPlayer = Bukkit.getPlayer(args[0]);
2425
} else if (sender instanceof Player) {
2526
pingPlayer = (Player) sender;
26-
} else {
27+
}
28+
29+
if (pingPlayer == null) {
2730
sender.sendMessage(Utils.getMessage("ping.not-found", sender));
2831
return true;
2932
}

src/main/java/io/github/bilektugrul/simpleservertools/features/language/LanguageManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.github.bilektugrul.simpleservertools.SST;
44
import me.despical.commons.configuration.ConfigUtils;
5+
import org.bukkit.ChatColor;
56
import org.bukkit.configuration.file.FileConfiguration;
67

78
import java.io.File;
@@ -25,7 +26,7 @@ public void loadLanguage() {
2526
try {
2627
language = ConfigUtils.getConfig(plugin, "language" + s + "messages_" + languageString);
2728
} catch (IllegalArgumentException ignored) {
28-
plugin.getLogger().warning("§cYou have chosen a non-existent language. Please check our Spigot page and use one of available languages. Plugin will use EN language.");
29+
plugin.getLogger().warning(ChatColor.RED + "You have chosen a non-existent language. Please check our Spigot page and use one of available languages. Plugin will use EN language.");
2930
languageString = "en";
3031
language = ConfigUtils.getConfig(plugin, "language" + s + "messages_" + languageString);
3132
}

src/main/java/io/github/bilektugrul/simpleservertools/features/spawn/SpawnManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.github.bilektugrul.simpleservertools.utils.Utils;
1010
import me.despical.commons.configuration.ConfigUtils;
1111
import org.bukkit.Bukkit;
12+
import org.bukkit.ChatColor;
1213
import org.bukkit.Location;
1314
import org.bukkit.command.CommandSender;
1415
import org.bukkit.configuration.file.FileConfiguration;
@@ -75,7 +76,7 @@ public TeleportSettings getSettings() {
7576

7677
public void saveSpawn() {
7778
if (spawn != null) {
78-
plugin.getLogger().info("§aSaving spawn...");
79+
plugin.getLogger().info(ChatColor.GREEN + "Saving spawn...");
7980
spawnFile.set("spawn.location", spawn.getLocation());
8081
ConfigUtils.saveConfig(plugin, spawnFile, "spawn");
8182
}

src/main/java/io/github/bilektugrul/simpleservertools/utils/Utils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static String getString(FileConfiguration file, String string, CommandSen
6161
public static String replacePlaceholders(String msg, CommandSender from, boolean replacePersonalPlaceholders, boolean replacePAPI) {
6262
boolean isPlayer = from instanceof Player;
6363
if (msg == null) {
64-
plugin.getLogger().warning("§cYour language file[s] is/are corrupted or old. Please reset or update them.");
64+
plugin.getLogger().warning(org.bukkit.ChatColor.RED + "Your language file[s] is/are corrupted or old. Please reset or update them.");
6565
return "";
6666
}
6767
msg = placeholderManager.replacePlaceholders(ChatColor.translateAlternateColorCodes('&', msg));

0 commit comments

Comments
 (0)