Skip to content

Commit

Permalink
add methods for msg prefix and deny msg
Browse files Browse the repository at this point in the history
  • Loading branch information
Smartich0ke committed Aug 26, 2022
1 parent 49045f7 commit 847fb41
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

if(sender.hasPermission("minigamesmanager.create") || sender.isOp()) {
if(args.length > 1) {
sender.sendMessage(config.configFile.getString("prefix") + ChatColor.RED + "Too many args!" + ChatColor.GREEN + "(Usage:" + ChatColor.YELLOW + "/mm-create <nameOfMinigame>" + ChatColor.GREEN + ")");
sender.sendMessage(config.messagePrefix() + ChatColor.RED + "Too many args!" + ChatColor.GREEN + "(Usage:" + ChatColor.YELLOW + "/mm-create <nameOfMinigame>" + ChatColor.GREEN + ")");
return true;
}
if(args.length == 0) {
sender.sendMessage(config.configFile.getString("prefix") + ChatColor.RED + "Not enough args!!" + ChatColor.GREEN + "(Usage:" + ChatColor.YELLOW + "/mm-create <nameOfMinigame>" + ChatColor.GREEN + ")");
sender.sendMessage(config.messagePrefix() + ChatColor.RED + "Not enough args!!" + ChatColor.GREEN + "(Usage:" + ChatColor.YELLOW + "/mm-create <nameOfMinigame>" + ChatColor.GREEN + ")");
return true;
}
String minigameName = args[0];
MinigameData.createMinigameProfile(minigameName);
sender.sendMessage(config.configFile.getString("prefix") + ChatColor.GREEN + "Minigame created successfully!");
sender.sendMessage(config.messagePrefix() + ChatColor.GREEN + "Minigame created successfully!");
return true;
} else {
sender.sendMessage(config.configFile.getString("deny-message"));
sender.sendMessage(config.denyMessage());
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ public class mm_delete implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender.hasPermission("minigamesmanager.delete.minigame")){
if(args.length > 2){
sender.sendMessage(config.configFile.getString("prefix") + ChatColor.RED + "Too many args!!");
sender.sendMessage(config.messagePrefix() + ChatColor.RED + "Too many args!!");
return true;
}
if(args.length < 2) {
sender.sendMessage(config.configFile.getString("prefix") + ChatColor.RED + "not enough args!");
sender.sendMessage(config.messagePrefix() + ChatColor.RED + "not enough args!");
return true;
}
if (args[0].equals("minigame")) {
MinigameData.deleteMinigameProfile(args[1]);
sender.sendMessage(config.configFile.getString("prefix") + ChatColor.GREEN + "Minigame" + args[1] + "deleted successfully!");
sender.sendMessage(config.messagePrefix() + ChatColor.GREEN + "Minigame" + args[1] + "deleted successfully!");
return true;
}
} else {
sender.sendMessage(config.configFile.getString("deny-message"));
sender.sendMessage(config.denyMessage());
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
} catch (IOException e) {
throw new RuntimeException(e);
}
sender.sendMessage(config.configFile.get("prefix") + "§aConfiguration reloaded successfully!");
sender.sendMessage(config.messagePrefix() + "§aConfiguration reloaded successfully!");
return true;
} else {
sender.sendMessage(config.configFile.getString("deny-message"));
sender.sendMessage(config.denyMessage());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class MinigameData {
public static YamlDocument minigameDataFile;

public static void createDataFile(){

try {
Expand Down Expand Up @@ -67,9 +68,6 @@ public static void addMinigameWorld(String minigameName, String worldName, Strin
throw new RuntimeException(e);
}
}



}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nikolaipatrick.minigamesmanager2.MinigamesManager2;
import dev.dejvokep.boostedyaml.YamlDocument;
import net.md_5.bungee.api.ChatColor;

import java.io.File;
import java.io.IOException;
Expand All @@ -15,4 +16,10 @@ public static void createConfigFile() {
throw new RuntimeException(e);
}
}
public static String messagePrefix() {
return ChatColor.translateAlternateColorCodes('&', configFile.getString("prefix"));
}
public static String denyMessage() {
return ChatColor.translateAlternateColorCodes('&', configFile.getString("deny-message"));
}
}

0 comments on commit 847fb41

Please sign in to comment.