Skip to content

Commit f623e34

Browse files
authored
v1.2.1(SNAPSHOT)
1 parent 33157ee commit f623e34

File tree

3 files changed

+938
-815
lines changed

3 files changed

+938
-815
lines changed

src/main/java/com/krayir5/stands/Plugin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public void onEnable() {
3636
LOGGER.info("You expected a message, but it was me, DIO!");
3737
getCommand("sphelp").setExecutor(new HelpCommand());
3838
getCommand("stands").setExecutor(new StandsCommand());
39-
getCommand("standp").setExecutor(new StandPCommand(this));
4039
File standFile = new File(getDataFolder(), "stands.yml");
40+
getCommand("standp").setExecutor(new StandPCommand(this, standFile));
4141
getCommand("standpick").setExecutor(new StandPick(getConfig(), standFile));
4242
getCommand("standuse").setExecutor(new StandUse(standFile));
4343
getServer().getPluginManager().registerEvents(new StandItem(), this);
@@ -80,10 +80,10 @@ private void checkForUpdates() {
8080
String remotePluginYml = fetchPluginYml(pluginYmlUrl);
8181
latestVersion = parseVersionFromPluginYml(remotePluginYml);
8282
if (latestVersion != null && !getDescription().getVersion().equals(latestVersion)) {
83-
getLogger().log(Level.WARNING, "A new version of the plugin is available: {0}", latestVersion);
83+
getLogger().log(Level.WARNING, "[Stands] A new version of the plugin is available: {0}", latestVersion);
8484
}
8585
} catch (Exception e) {
86-
getLogger().log(Level.WARNING, "Failed to check for updates: {0}", e.getMessage());
86+
getLogger().log(Level.WARNING, "[Stands] Failed to check for updates: {0}", e.getMessage());
8787
}
8888
}
8989

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
11
package com.krayir5.stands.commands;
22

3+
import java.io.File;
4+
35
import org.bukkit.ChatColor;
46
import org.bukkit.command.Command;
57
import org.bukkit.command.CommandExecutor;
68
import org.bukkit.command.CommandSender;
9+
import org.bukkit.configuration.file.FileConfiguration;
10+
import org.bukkit.configuration.file.YamlConfiguration;
711
import org.bukkit.entity.Player;
812
import org.bukkit.plugin.java.JavaPlugin;
913

1014
public class StandPCommand implements CommandExecutor {
1115

1216
private final JavaPlugin plugin;
17+
private final File standFile;
1318

14-
public StandPCommand(JavaPlugin plugin) {
19+
public StandPCommand(JavaPlugin plugin, File standFile) {
1520
this.plugin = plugin;
21+
this.standFile = standFile;
1622
}
1723

1824
@Override
1925
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
26+
@SuppressWarnings("unused")
27+
FileConfiguration stConfig = YamlConfiguration.loadConfiguration(standFile);
2028
Player player = (Player) sender;
21-
if (!player.isOp() && !player.hasPermission("standp.admin")) {
22-
player.sendMessage(ChatColor.RED + "You cant use this command!");
29+
if (!player.isOp() || !player.hasPermission("standp.admin")) {
30+
player.sendMessage(ChatColor.RED + "You don't have permission to use this command!");
2331
return true;
2432
}
2533
if (args.length == 0) {
2634
sender.sendMessage(ChatColor.RED + "Usage: /standp <reload>");
2735
return true;
2836
}
37+
2938
String subCommand = args[0].toLowerCase();
3039
switch (subCommand) {
3140
case "reload":
3241
plugin.reloadConfig();
33-
sender.sendMessage(ChatColor.GREEN + "Plugin succesfully reloaded!");
42+
if (standFile.exists()) {
43+
stConfig = YamlConfiguration.loadConfiguration(standFile);
44+
player.sendMessage(ChatColor.GREEN + "Plugin reloaded succesfully!");
45+
}else{
46+
player.sendMessage(ChatColor.RED + "Something went wrong! stand.yml file not found!");
47+
}
3448
break;
3549
default:
36-
sender.sendMessage(ChatColor.RED + "Unknown subcommand: " + subCommand);
50+
player.sendMessage(ChatColor.RED + "Unknown subcommand: " + subCommand);
3751
break;
3852
}
3953
return true;
4054
}
4155
}
56+

0 commit comments

Comments
 (0)