Command always returning false

Discussion in 'Plugin Development' started by ZonalYewHD, Jun 20, 2014.

Thread Status:
Not open for further replies.
  1. I'm making a voting plugin for a friend's server, but whenever I run a command, it always returns false, as in shows the 'usage' string from the plugin.yml. I registered the commands, but I don't know what to do to fix it. I can provide code if need be, but I have several classes, and I don't want to provide too much. I made sure to go back to every possible path and return true, but it still gives me the usage message.
     
  2. Offline

    Bavestry

    ZonalYewHD It's most likely a problem with your onCommand method. Maybe you returned false at the very end of it, which might be returning the command false every time.
     
  3. Offline

    Bavestry

    ZonalYewHD Hm. Can we see your command class?
     
  4. Bavestry Sorry, but I had to get off right after I posted this. I'll post all three tomorrow

    Bavestry

    Tools.java
    Code:
    package me.zonalyewhd.veritasvoting.commands;
     
    import static org.bukkit.ChatColor.BOLD;
    import static org.bukkit.ChatColor.DARK_GREEN;
    import static org.bukkit.ChatColor.GOLD;
    import static org.bukkit.ChatColor.GRAY;
    import static org.bukkit.ChatColor.GREEN;
    import static org.bukkit.ChatColor.RED;
    import static org.bukkit.ChatColor.RESET;
    import static org.bukkit.ChatColor.STRIKETHROUGH;
     
    import java.util.List;
     
    import me.zonalyewhd.veritasvoting.VeritasVoting;
    import me.zonalyewhd.veritasvoting.utils.OrderVotes;
    import me.zonalyewhd.veritasvoting.utils.ToolsUtils;
    import me.zonalyewhd.veritasvoting.utils.VoteUtils;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
     
    public class Tools implements CommandExecutor {
     
    VeritasVoting plugin;
    VoteUtils votes;
    ToolsUtils tools;
    OrderVotes order;
     
    public Tools(VeritasVoting instance, VoteUtils instance2,
    ToolsUtils instance3, OrderVotes instance4) {
    instance = plugin;
    instance2 = votes;
    instance3 = tools;
    instance4 = order;
    }
     
    public void onEnable() {
    plugin.getCommand("tools").setExecutor(this);
    }
     
    private String usage1 = "          " + GOLD + STRIKETHROUGH + "-----"
    + RESET + GREEN + BOLD + " Voting Tools " + GOLD + STRIKETHROUGH
    + "-----";
    private String usage2 = RED + "     /tools " + GRAY + "stop";
    private String usage3 = RED + "     /tools " + GRAY + "votes <player>";
     
    private List<String> allRanks = config().getStringList("ranks");
     
    private FileConfiguration config() {
    return plugin.getConfig();
    }
     
    @SuppressWarnings("deprecation")
    public boolean onCommand(CommandSender sender, Command cmd, String s,
    String[] args) {
    if (sender instanceof Player) {
    sender.sendMessage(RED
    + "You must be a player to use the vote tools!");
    return true;
    } else {
    Player player = (Player) sender;
    if (player.hasPermission("vv.tools")) {
    if (args.length == 0) {
    player.sendMessage(usage1);
    player.sendMessage(usage2);
    player.sendMessage(usage3);
    return true;
    } else if (args.length == 1) {
    if (args[0].equalsIgnoreCase("stop")) {
    tools.end();
    return true;
    } else {
    player.sendMessage(usage1);
    player.sendMessage(usage2);
    player.sendMessage(usage3);
    return true;
    }
    } else if (args.length == 2) {
    if (args[0].equalsIgnoreCase("votes")) {
    Player targetPlayer = player.getServer().getPlayer(
    args[1]);
    String rank = votes.getRank(targetPlayer.getName());
    boolean nominated = config().contains(
    "votes." + rank + "." + targetPlayer.getName());
    if (nominated == true) {
    int votes = config().getInt(
    "votes." + rank + "."
    + targetPlayer.getName());
    player.sendMessage(GREEN + "The player "
    + DARK_GREEN + targetPlayer.getName()
    + GREEN + " has " + DARK_GREEN + votes
    + GREEN + " votes");
    return true;
    } else {
    player.sendMessage(RED
    + "That player has not been nominated!");
    return true;
    }
     
    } else if (args[0].equalsIgnoreCase("winner")) {
    String rank = args[1].toLowerCase();
    if (!allRanks.contains(rank)) {
    player.sendMessage(RED + "Unknown rank!");
    return true;
    } else {
    String winner = order.getWinner(rank);
    String rankName = votes.getRank(winner);
    player.sendMessage(GREEN
    + "The current winner for the rank "
    + DARK_GREEN + rankName + GREEN + " is "
    + DARK_GREEN + winner);
    return true;
    }
     
    }
    }
    } else {
    player.sendMessage(RED
    + "You do not have permission to use that!");
    return true;
    }
    }
    return true;
    }
     
    }
    
    Vote.java
    Code:
    package me.zonalyewhd.veritasvoting.commands;
    import static org.bukkit.ChatColor.BLUE;
    import static org.bukkit.ChatColor.DARK_AQUA;
    import static org.bukkit.ChatColor.DARK_PURPLE;
    import static org.bukkit.ChatColor.DARK_RED;
    import static org.bukkit.ChatColor.GREEN;
    import static org.bukkit.ChatColor.LIGHT_PURPLE;
    import static org.bukkit.ChatColor.RED;
    import static org.bukkit.ChatColor.WHITE;
    import static org.bukkit.ChatColor.YELLOW;
    import java.util.List;
    import me.zonalyewhd.veritasvoting.VeritasVoting;
    import me.zonalyewhd.veritasvoting.utils.VoteUtils;
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    public class Vote implements CommandExecutor {
    VeritasVoting plugin;
    VoteUtils votes;
    public Vote(VeritasVoting instance, VoteUtils instance2) {
    instance = plugin;
    instance2 = votes;
    }
    private FileConfiguration config() {
    return plugin.config;
    }
    private void saveConfig() {
    plugin.saveConfig();
    }
    private void reloadConfig() {
    plugin.reloadConfig();
    }
    public void onEnable() {
    plugin.getCommand("vote").setExecutor(this);
    }
    private List<String> vipNominated = config().getStringList(
    "nominations.vip");
    private List<String> vipGoldNominated = config().getStringList(
    "nominations.vipgold");
    private List<String> vipPlatinumNominated = config().getStringList(
    "nominations.vipplatinum");
    private List<String> modNominated = config().getStringList(
    "nominations.mod");
    private List<String> adminNominated = config().getStringList(
    "nominations.admin");
    private List<String> staffNominated = config().getStringList(
    "nominations.most-helpful-staff");
    private String noNominations = RED + "There are no nominations for "
    + DARK_RED + "%rank%" + RED + " at this time!";
    private String notNominated = RED + "That player has not been nominated!";
    private String noPerm = RED + "Your ability to vote has been revoked.";
    private String playerVoteVIPPerm = "vv.vote.vip";
    private String playerVoteVIPGoldPerm = "vv.vote.vipgold";
    private String playerVoteVIPlatinumPerm = "vv.vote.vipplatinum";
    private String playerVoteModPerm = "vv.vote.mod";
    private String playerVoteAdminPerm = "vv.vote.admin";
    private String playerVoteStaffPerm = "vv.vote.staff";
    private List<String> adminVote = config().getStringList("voted.admin");
    private List<String> modVote = config().getStringList("voted.mod");
    private List<String> vipVote = config().getStringList("voted.vip");
    private List<String> vipGoldVote = config().getStringList("voted.vipgold");
    private List<String> vipPlatinumVote = config().getStringList(
    "voted.vipplatinum");
    private List<String> staffVote = config().getStringList(
    "voted.most-helpful-staff");
    private String alreadyVoted = RED + "You have already voted for "
    + DARK_RED + "%rank%";
    @SuppressWarnings("deprecation")
    public boolean onCommand(CommandSender sender, Command cmd, String s,
    String[] args) {
    if (args.length != 1) {
    sender.sendMessage(RED
    + "Invalid arguments! Use either a player or rank!");
    return true;
    } else {
    if (!(sender instanceof Player)) {
    sender.sendMessage("You must be a player to vote!");
    } else {
    Player player = (Player) sender;
    if (args[0].equalsIgnoreCase("vip")) {
    if (vipNominated.isEmpty()) {
    player.sendMessage(noNominations.replaceAll("%rank%",
    "VIP"));
    return true;
    } else {
    player.sendMessage(GREEN + "VIP Nominations:");
    for (String nominee : vipNominated) {
    player.sendMessage("    " + DARK_AQUA + nominee);
    }
    return true;
    }
    } else if (args[0].equalsIgnoreCase("vipgold")) {
    if (vipGoldNominated.isEmpty()) {
    player.sendMessage(noNominations.replaceAll("%rank%",
    "VIPGold"));
    return true;
    } else {
    player.sendMessage(YELLOW + "VIPGold Nominations:");
    for (String nominee : vipGoldNominated) {
    player.sendMessage("    " + DARK_AQUA + nominee);
    }
    return true;
    }
    } else if (args[0].equalsIgnoreCase("vipplatinum")) {
    if (vipPlatinumNominated.isEmpty()) {
    player.sendMessage(noNominations.replaceAll("%rank%",
    "VIPlatinum"));
    return true;
    } else {
    player.sendMessage(WHITE + "VIP Nominations:");
    for (String nominee : vipPlatinumNominated) {
    player.sendMessage("    " + DARK_AQUA + nominee);
    }
    return true;
    }
    } else if (args[0].equalsIgnoreCase("mod")) {
    if (modNominated.isEmpty()) {
    player.sendMessage(noNominations.replaceAll("%rank%",
    "Mod"));
    return true;
    } else {
    player.sendMessage(DARK_PURPLE + "Mod Nominations:");
    for (String nominee : modNominated) {
    player.sendMessage("    " + DARK_AQUA + nominee);
    }
    return true;
    }
    } else if (args[0].equalsIgnoreCase("admin")) {
    if (adminNominated.isEmpty()) {
    player.sendMessage(noNominations.replaceAll("%rank%",
    "Admin"));
    return true;
    } else {
    player.sendMessage(BLUE + "VIP Nominations:");
    for (String nominee : adminNominated) {
    player.sendMessage("    " + DARK_AQUA + nominee);
    }
    return true;
    }
    } else if (args[0].equalsIgnoreCase("staff")) {
    if (staffNominated.isEmpty()) {
    player.sendMessage(noNominations.replaceAll("%rank%",
    "Most Helpful Staff"));
    return true;
    } else {
    player.sendMessage(LIGHT_PURPLE
    + "Most Helpful Staff Nominations:");
    for (String nominee : staffNominated) {
    player.sendMessage("    " + DARK_AQUA + nominee);
    }
    return true;
    }
    } else {
    Player selection = Bukkit.getPlayer(args[1]);
    String playerName = player.getName();
    String selectionName = selection.getName();
    String rankName = votes.getRank(selectionName);
    if (rankName == null) {
    player.sendMessage(notNominated);
    return true;
    } else {
    if (rankName == "vip") {
    if (player.hasPermission(playerVoteVIPPerm)) {
    if (vipVote.contains(playerName)) {
    player.sendMessage(alreadyVoted.replaceAll(
    "%rank%", rankName));
    return true;
    } else {
    votes.vote(selectionName, playerName);
    saveConfig();
    reloadConfig();
    return true;
    }
    } else {
    player.sendMessage(noPerm);
    return true;
    }
    } else if (rankName == "vipgold") {
    if (player.hasPermission(playerVoteVIPGoldPerm)) {
    if (vipGoldVote.contains(playerName)) {
    player.sendMessage(alreadyVoted.replaceAll(
    "%rank%", rankName));
    return true;
    } else {
    votes.vote(selectionName, playerName);
    saveConfig();
    reloadConfig();
    return true;
    }
    } else {
    player.sendMessage(noPerm);
    return true;
    }
    } else if (rankName == "viplatinum") {
    if (player.hasPermission(playerVoteVIPlatinumPerm)) {
    if (vipPlatinumVote.contains(playerName)) {
    player.sendMessage(alreadyVoted.replaceAll(
    "%rank%", rankName));
    return true;
    } else {
    votes.vote(selectionName, playerName);
    saveConfig();
    reloadConfig();
    return true;
    }
    } else {
    player.sendMessage(noPerm);
    }
    } else if (rankName == "mod") {
    if (player.hasPermission(playerVoteModPerm)) {
    if (modVote.contains(playerName)) {
    player.sendMessage(alreadyVoted.replaceAll(
    "%rank%", rankName));
    return true;
    } else {
    votes.vote(selectionName, playerName);
    saveConfig();
    reloadConfig();
    return true;
    }
    } else {
    player.sendMessage(noPerm);
    return true;
    }
    } else if (rankName == "admin") {
    if (player.hasPermission(playerVoteAdminPerm)) {
    if (adminVote.contains(playerName)) {
    player.sendMessage(alreadyVoted.replaceAll(
    "%rank%", rankName));
    return true;
    } else {
    votes.vote(selectionName, playerName);
    saveConfig();
    reloadConfig();
    return true;
    }
    } else {
    player.sendMessage(noPerm);
    return true;
    }
    } else if (rankName == "staff") {
    if (player.hasPermission(playerVoteStaffPerm)) {
    if (staffVote.contains(playerName)) {
    player.sendMessage(alreadyVoted.replaceAll(
    "%rank%", rankName));
    return true;
    } else {
    votes.vote(selectionName, playerName);
    saveConfig();
    reloadConfig();
    return true;
    }
    } else {
    player.sendMessage(noPerm);
    return true;
    }
    } else {
    for (Player p : Bukkit.getOnlinePlayers()) {
    p.kickPlayer("A serious error occurred with Veritas Voting. Report to Zonal ASAP");
    }
    Bukkit.shutdown();
    System.out
    .println("A serious, possibly fatal error has occurred. Report to Zonal ASAP.");
    System.out.println("Check Vote.java line: 168");
    System.out
    .println("A player returned with a 'null' rank and was not caught by the first check.");
    return true;
    }
    }
    }
    }
    }
    return true;
    }
    }
    
    Nominate.java
    Code:
    package me.zonalyewhd.veritasvoting.commands;
    import java.util.List;
    import static org.bukkit.ChatColor.*;
    import me.zonalyewhd.veritasvoting.VeritasVoting;
    import me.zonalyewhd.veritasvoting.utils.NominateUtils;
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    public class Nominate implements CommandExecutor {
    VeritasVoting plugin;
    NominateUtils nominateUtils;
    public Nominate(VeritasVoting instance, NominateUtils instance2) {
    instance = plugin;
    instance2 = nominateUtils;
    }
    private FileConfiguration config() {
    return plugin.config;
    }
    public void onEnable() {
    plugin.getCommand("nominate").setExecutor(this);
    }
    private List<String> allRanks = config().getStringList("ranks");
    private String neverPlayed = RED + "That player has never played before!";
    private String usage = RED + "/nominate [rank] [player]";
    private String invalidRank = RED + "Unknown rank!";
    private String playerNominatePerm = "vv.nominate";
    private String playerNominateNoPermMsg = RED
    + "You do not have permission to nominate players in the election!";
    @SuppressWarnings({ "deprecation", "unused" })
    public boolean onCommand(CommandSender cs, Command cmd, String s,
    String[] args) {
    if (!(cs instanceof Player)) {
    if (args.length == 0) {
    cs.sendMessage(usage);
    } else if (args.length == 1) {
    cs.sendMessage(usage);
    } else if (args.length == 2) {
    Player nominee = Bukkit.getPlayer(args[1]);
    String nomineeName = nominee.getName();
    boolean playedBefore = nominee.hasPlayedBefore();
    String rankName = args[0];
    boolean rankExists = allRanks.contains(rankName);
    String success = GREEN + "You nominated " + DARK_GREEN
    + "%player%" + GREEN + " for " + DARK_GREEN + "%rank%";
    if (playedBefore = false) {
    cs.sendMessage(neverPlayed);
    return true;
    } else {
    if (rankName.equalsIgnoreCase("vip")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    plugin.saveConfig();
    plugin.reloadConfig();
    return true;
    } else if (rankName.equalsIgnoreCase("vipgold")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    plugin.saveConfig();
    plugin.reloadConfig();
    return true;
    } else if (rankName.equalsIgnoreCase("vipplatinum")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    plugin.saveConfig();
    plugin.reloadConfig();
    return true;
    } else if (rankName.equalsIgnoreCase("mod")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    plugin.saveConfig();
    plugin.reloadConfig();
    return true;
    } else if (rankName.equalsIgnoreCase("admin")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    plugin.saveConfig();
    plugin.reloadConfig();
    return true;
    } else if (rankName.equalsIgnoreCase("staff")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    plugin.saveConfig();
    plugin.reloadConfig();
    return true;
    } else {
    cs.sendMessage(invalidRank);
    return true;
    }
    }
    } else {
    cs.sendMessage(usage);
    return true;
    }
    } else {
    Player player = (Player) cs;
    if (player.hasPermission(playerNominatePerm)) {
    if (args.length == 0) {
    player.sendMessage(usage);
    return true;
    } else if (args.length == 1) {
    player.sendMessage(usage);
    return true;
    } else if (args.length == 2) {
    Player nominee = Bukkit.getPlayer(args[1]);
    String nomineeName = nominee.getName();
    String rankName = args[0];
    boolean playedBefore = nominee.hasPlayedBefore();
    boolean rankExists = allRanks.contains(rankName);
    String success = GREEN + "You nominated " + DARK_GREEN
    + "%player%" + GREEN + " for " + DARK_GREEN
    + "%rank%";
    if (playedBefore == false) {
    player.sendMessage(neverPlayed);
    } else {
    if (rankName.equalsIgnoreCase("vip")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    return true;
    } else if (rankName.equalsIgnoreCase("vipgold")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    return true;
    } else if (rankName.equalsIgnoreCase("vipplatinum")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    return true;
    } else if (rankName.equalsIgnoreCase("mod")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    return true;
    } else if (rankName.equalsIgnoreCase("admin")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    return true;
    } else if (rankName.equalsIgnoreCase("staff")) {
    nominateUtils.nominate(nomineeName, rankName);
    cs.sendMessage(success);
    return true;
    } else {
    cs.sendMessage(invalidRank);
    return true;
    }
    }
    }
    } else {
    player.sendMessage(playerNominateNoPermMsg);
    return true;
    }
    }
    return true;
    }
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    Protophite

    no one will try to figure out the problem if you post the code that way.. ZonalYewHD
     
  6. Protophite For some reason Bukkit does not keep the formatting. I may post it on pastebin later. I don't know how else to post it.

    Anyone? I made this for a friend of mine, and he needs it ASAP

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  7. Offline

    JEREMSPEED

    You never return false into your onCommand method. Add it at the very end and test again.
     
  8. JEREMSPEED I am now getting the abnormal plugin type error. Not sure how to fix
     
  9. Offline

    JEREMSPEED

    Can I see it accompagnated with your new code?
     
  10. JEREMSPEED The main class:
    Code:Java
    1.  
    2. package me.zonalyewhd.veritasvoting;
    3.  
    4. import me.zonalyewhd.veritasvoting.commands.Nominate;
    5. import me.zonalyewhd.veritasvoting.commands.Tools;
    6. import me.zonalyewhd.veritasvoting.commands.Vote;
    7.  
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class VeritasVoting extends JavaPlugin {
    11.  
    12. Vote vote;
    13. Nominate nominate;
    14. Tools tools;
    15.  
    16. public VeritasVoting(Vote votes, Nominate nominates, Tools tool) {
    17. votes = vote;
    18. nominates = nominate;
    19. tool = tools;
    20. }
    21.  
    22. public void onEnable() {
    23. System.out.println("VeritasVoting has been enabled!");
    24. getCommand("vote").setExecutor(vote);
    25. getCommand("nominate").setExecutor(nominate);
    26. getCommand("tools").setExecutor(tools);
    27. saveDefaultConfig();
    28. }
    29.  
    30. public void onDisable() {
    31. System.out.println("VeritasVoting has now been disabled!");
    32. }
    33.  
    34. }
    35.  

    Tools.java
    Code:Java
    1.  
    2. package me.zonalyewhd.veritasvoting.commands;
    3. import static org.bukkit.ChatColor.BOLD;
    4. import static org.bukkit.ChatColor.DARK_GREEN;
    5. import static org.bukkit.ChatColor.GOLD;
    6. import static org.bukkit.ChatColor.GRAY;
    7. import static org.bukkit.ChatColor.GREEN;
    8. import static org.bukkit.ChatColor.RED;
    9. import static org.bukkit.ChatColor.RESET;
    10. import static org.bukkit.ChatColor.STRIKETHROUGH;
    11. import java.util.List;
    12. import me.zonalyewhd.veritasvoting.VeritasVoting;
    13. import me.zonalyewhd.veritasvoting.utils.OrderVotes;
    14. import me.zonalyewhd.veritasvoting.utils.ToolsUtils;
    15. import me.zonalyewhd.veritasvoting.utils.VoteUtils;
    16. import org.bukkit.command.Command;
    17. import org.bukkit.command.CommandExecutor;
    18. import org.bukkit.command.CommandSender;
    19. import org.bukkit.configuration.file.FileConfiguration;
    20. import org.bukkit.entity.Player;
    21. public class Tools implements CommandExecutor {
    22. VeritasVoting plugin;
    23. VoteUtils votes;
    24. ToolsUtils tools;
    25. OrderVotes order;
    26. public Tools(VeritasVoting instance, VoteUtils instance2,
    27. ToolsUtils instance3, OrderVotes instance4) {
    28. instance = plugin;
    29. instance2 = votes;
    30. instance3 = tools;
    31. instance4 = order;
    32. }
    33. private String usage1 = " " + GOLD + STRIKETHROUGH + "-----"
    34. + RESET + GREEN + BOLD + " Voting Tools " + GOLD + STRIKETHROUGH
    35. + "-----";
    36. private String usage2 = RED + " /tools " + GRAY + "stop";
    37. private String usage3 = RED + " /tools " + GRAY + "votes <player>";
    38. private List<String> allRanks = config().getStringList("ranks");
    39. private FileConfiguration config() {
    40. return plugin.getConfig();
    41. }
    42. @SuppressWarnings("deprecation")
    43. public boolean onCommand(CommandSender sender, Command cmd, String s,
    44. String[] args) {
    45. if (s.equalsIgnoreCase("tools")) {
    46. if (sender instanceof Player) {
    47. sender.sendMessage(RED
    48. + "You must be a player to use the vote tools!");
    49. return true;
    50. } else {
    51. Player player = (Player) sender;
    52. if (player.hasPermission("vv.tools")) {
    53. if (args.length == 0) {
    54. player.sendMessage(usage1);
    55. player.sendMessage(usage2);
    56. player.sendMessage(usage3);
    57. return true;
    58. } else if (args.length == 1) {
    59. if (args[0].equalsIgnoreCase("stop")) {
    60. tools.end();
    61. return true;
    62. } else {
    63. player.sendMessage(usage1);
    64. player.sendMessage(usage2);
    65. player.sendMessage(usage3);
    66. return true;
    67. }
    68. } else if (args.length == 2) {
    69. if (args[0].equalsIgnoreCase("votes")) {
    70. Player targetPlayer = player.getServer().getPlayer(
    71. args[1]);
    72. String rank = votes.getRank(targetPlayer.getName());
    73. boolean nominated = config().contains(
    74. "votes." + rank + "."
    75. + targetPlayer.getName());
    76. if (nominated == true) {
    77. int votes = config().getInt(
    78. "votes." + rank + "."
    79. + targetPlayer.getName());
    80. player.sendMessage(GREEN + "The player "
    81. + DARK_GREEN + targetPlayer.getName()
    82. + GREEN + " has " + DARK_GREEN + votes
    83. + GREEN + " votes");
    84. return true;
    85. } else {
    86. player.sendMessage(RED
    87. + "That player has not been nominated!");
    88. return true;
    89. }
    90. } else if (args[0].equalsIgnoreCase("winner")) {
    91. String rank = args[1].toLowerCase();
    92. if (!allRanks.contains(rank)) {
    93. player.sendMessage(RED + "Unknown rank!");
    94. return true;
    95. } else {
    96. String winner = order.getWinner(rank);
    97. String rankName = votes.getRank(winner);
    98. player.sendMessage(GREEN
    99. + "The current winner for the rank "
    100. + DARK_GREEN + rankName + GREEN
    101. + " is " + DARK_GREEN + winner);
    102. return true;
    103. }
    104. }
    105. }
    106. } else {
    107. player.sendMessage(RED
    108. + "You do not have permission to use that!");
    109. return true;
    110. }
    111. }
    112. return true;
    113. }
    114. return false;
    115. }
    116. }
    117.  

    Nominate.java
    Code:Java
    1.  
    2. package me.zonalyewhd.veritasvoting.commands;
    3. import java.util.List;
    4. import static org.bukkit.ChatColor.*;
    5. import me.zonalyewhd.veritasvoting.VeritasVoting;
    6. import me.zonalyewhd.veritasvoting.utils.NominateUtils;
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandExecutor;
    10. import org.bukkit.command.CommandSender;
    11. import org.bukkit.configuration.file.FileConfiguration;
    12. import org.bukkit.entity.Player;
    13. public class Nominate implements CommandExecutor {
    14. VeritasVoting plugin;
    15. NominateUtils nominateUtils;
    16. public Nominate(VeritasVoting instance, NominateUtils instance2) {
    17. instance = plugin;
    18. instance2 = nominateUtils;
    19. }
    20. private FileConfiguration config() {
    21. return plugin.getConfig();
    22. }
    23. private List<String> allRanks = config().getStringList("ranks");
    24. private String neverPlayed = RED + "That player has never played before!";
    25. private String usage = RED + "/nominate [rank] [player]";
    26. private String invalidRank = RED + "Unknown rank!";
    27. private String playerNominatePerm = "vv.nominate";
    28. private String playerNominateNoPermMsg = RED
    29. + "You do not have permission to nominate players in the election!";
    30. @SuppressWarnings({ "deprecation", "unused" })
    31. public boolean onCommand(CommandSender cs, Command cmd, String s,
    32. String[] args) {
    33. if (s.equalsIgnoreCase("nominate")) {
    34. if (!(cs instanceof Player)) {
    35. if (args.length == 0) {
    36. cs.sendMessage(usage);
    37. } else if (args.length == 1) {
    38. cs.sendMessage(usage);
    39. } else if (args.length == 2) {
    40. Player nominee = Bukkit.getPlayer(args[1]);
    41. String nomineeName = nominee.getName();
    42. boolean playedBefore = nominee.hasPlayedBefore();
    43. String rankName = args[0];
    44. boolean rankExists = allRanks.contains(rankName);
    45. String success = GREEN + "You nominated " + DARK_GREEN
    46. + "%player%" + GREEN + " for " + DARK_GREEN
    47. + "%rank%";
    48. if (playedBefore = false) {
    49. cs.sendMessage(neverPlayed);
    50. return true;
    51. } else {
    52. if (rankName.equalsIgnoreCase("vip")) {
    53. nominateUtils.nominate(nomineeName, rankName);
    54. cs.sendMessage(success);
    55. plugin.saveConfig();
    56. plugin.reloadConfig();
    57. return true;
    58. } else if (rankName.equalsIgnoreCase("vipgold")) {
    59. nominateUtils.nominate(nomineeName, rankName);
    60. cs.sendMessage(success);
    61. plugin.saveConfig();
    62. plugin.reloadConfig();
    63. return true;
    64. } else if (rankName.equalsIgnoreCase("vipplatinum")) {
    65. nominateUtils.nominate(nomineeName, rankName);
    66. cs.sendMessage(success);
    67. plugin.saveConfig();
    68. plugin.reloadConfig();
    69. return true;
    70. } else if (rankName.equalsIgnoreCase("mod")) {
    71. nominateUtils.nominate(nomineeName, rankName);
    72. cs.sendMessage(success);
    73. plugin.saveConfig();
    74. plugin.reloadConfig();
    75. return true;
    76. } else if (rankName.equalsIgnoreCase("admin")) {
    77. nominateUtils.nominate(nomineeName, rankName);
    78. cs.sendMessage(success);
    79. plugin.saveConfig();
    80. plugin.reloadConfig();
    81. return true;
    82. } else if (rankName.equalsIgnoreCase("staff")) {
    83. nominateUtils.nominate(nomineeName, rankName);
    84. cs.sendMessage(success);
    85. plugin.saveConfig();
    86. plugin.reloadConfig();
    87. return true;
    88. } else {
    89. cs.sendMessage(invalidRank);
    90. return true;
    91. }
    92. }
    93. } else {
    94. cs.sendMessage(usage);
    95. return true;
    96. }
    97. } else {
    98. Player player = (Player) cs;
    99. if (player.hasPermission(playerNominatePerm)) {
    100. if (args.length == 0) {
    101. player.sendMessage(usage);
    102. return true;
    103. } else if (args.length == 1) {
    104. player.sendMessage(usage);
    105. return true;
    106. } else if (args.length == 2) {
    107. Player nominee = Bukkit.getPlayer(args[1]);
    108. String nomineeName = nominee.getName();
    109. String rankName = args[0];
    110. boolean playedBefore = nominee.hasPlayedBefore();
    111. boolean rankExists = allRanks.contains(rankName);
    112. String success = GREEN + "You nominated " + DARK_GREEN
    113. + "%player%" + GREEN + " for " + DARK_GREEN
    114. + "%rank%";
    115. if (playedBefore == false) {
    116. player.sendMessage(neverPlayed);
    117. } else {
    118. if (rankName.equalsIgnoreCase("vip")) {
    119. nominateUtils.nominate(nomineeName, rankName);
    120. cs.sendMessage(success);
    121. return true;
    122. } else if (rankName.equalsIgnoreCase("vipgold")) {
    123. nominateUtils.nominate(nomineeName, rankName);
    124. cs.sendMessage(success);
    125. return true;
    126. } else if (rankName.equalsIgnoreCase("vipplatinum")) {
    127. nominateUtils.nominate(nomineeName, rankName);
    128. cs.sendMessage(success);
    129. return true;
    130. } else if (rankName.equalsIgnoreCase("mod")) {
    131. nominateUtils.nominate(nomineeName, rankName);
    132. cs.sendMessage(success);
    133. return true;
    134. } else if (rankName.equalsIgnoreCase("admin")) {
    135. nominateUtils.nominate(nomineeName, rankName);
    136. cs.sendMessage(success);
    137. return true;
    138. } else if (rankName.equalsIgnoreCase("staff")) {
    139. nominateUtils.nominate(nomineeName, rankName);
    140. cs.sendMessage(success);
    141. return true;
    142. } else {
    143. cs.sendMessage(invalidRank);
    144. return true;
    145. }
    146. }
    147. }
    148. } else {
    149. player.sendMessage(playerNominateNoPermMsg);
    150. return true;
    151. }
    152. }
    153. }
    154. return false;
    155. }
    156. }
    157.  

    Vote.java
    Code:Java
    1.  
    2. package me.zonalyewhd.veritasvoting.commands;
    3. import static org.bukkit.ChatColor.BLUE;
    4. import static org.bukkit.ChatColor.DARK_AQUA;
    5. import static org.bukkit.ChatColor.DARK_PURPLE;
    6. import static org.bukkit.ChatColor.DARK_RED;
    7. import static org.bukkit.ChatColor.GREEN;
    8. import static org.bukkit.ChatColor.LIGHT_PURPLE;
    9. import static org.bukkit.ChatColor.RED;
    10. import static org.bukkit.ChatColor.WHITE;
    11. import static org.bukkit.ChatColor.YELLOW;
    12. import java.util.List;
    13. import me.zonalyewhd.veritasvoting.VeritasVoting;
    14. import me.zonalyewhd.veritasvoting.utils.VoteUtils;
    15. import org.bukkit.Bukkit;
    16. import org.bukkit.command.Command;
    17. import org.bukkit.command.CommandExecutor;
    18. import org.bukkit.command.CommandSender;
    19. import org.bukkit.configuration.file.FileConfiguration;
    20. import org.bukkit.entity.Player;
    21. public class Vote implements CommandExecutor {
    22. VeritasVoting plugin;
    23. VoteUtils votes;
    24. public Vote(VeritasVoting instance, VoteUtils instance2) {
    25. instance = plugin;
    26. instance2 = votes;
    27. }
    28. private FileConfiguration config() {
    29. return plugin.getConfig();
    30. }
    31. private void saveConfig() {
    32. plugin.saveConfig();
    33. }
    34. private void reloadConfig() {
    35. plugin.reloadConfig();
    36. }
    37. private List<String> vipNominated = config().getStringList(
    38. "nominations.vip");
    39. private List<String> vipGoldNominated = config().getStringList(
    40. "nominations.vipgold");
    41. private List<String> vipPlatinumNominated = config().getStringList(
    42. "nominations.vipplatinum");
    43. private List<String> modNominated = config().getStringList(
    44. "nominations.mod");
    45. private List<String> adminNominated = config().getStringList(
    46. "nominations.admin");
    47. private List<String> staffNominated = config().getStringList(
    48. "nominations.most-helpful-staff");
    49. private String noNominations = RED + "There are no nominations for "
    50. + DARK_RED + "%rank%" + RED + " at this time!";
    51. private String notNominated = RED + "That player has not been nominated!";
    52. private String noPerm = RED + "Your ability to vote has been revoked.";
    53. private String playerVoteVIPPerm = "vv.vote.vip";
    54. private String playerVoteVIPGoldPerm = "vv.vote.vipgold";
    55. private String playerVoteVIPlatinumPerm = "vv.vote.vipplatinum";
    56. private String playerVoteModPerm = "vv.vote.mod";
    57. private String playerVoteAdminPerm = "vv.vote.admin";
    58. private String playerVoteStaffPerm = "vv.vote.staff";
    59. private List<String> adminVote = config().getStringList("voted.admin");
    60. private List<String> modVote = config().getStringList("voted.mod");
    61. private List<String> vipVote = config().getStringList("voted.vip");
    62. private List<String> vipGoldVote = config().getStringList("voted.vipgold");
    63. private List<String> vipPlatinumVote = config().getStringList(
    64. "voted.vipplatinum");
    65. private List<String> staffVote = config().getStringList(
    66. "voted.most-helpful-staff");
    67. private String alreadyVoted = RED + "You have already voted for "
    68. + DARK_RED + "%rank%";
    69. @SuppressWarnings("deprecation")
    70. public boolean onCommand(CommandSender sender, Command cmd, String s,
    71. String[] args) {
    72. if (s.equalsIgnoreCase("vote")) {
    73. if (args.length != 1) {
    74. sender.sendMessage(RED
    75. + "Invalid arguments! Use either a player or rank!");
    76. return true;
    77. } else {
    78. if (!(sender instanceof Player)) {
    79. sender.sendMessage("You must be a player to vote!");
    80. } else {
    81. Player player = (Player) sender;
    82. if (args[0].equalsIgnoreCase("vip")) {
    83. if (vipNominated.isEmpty()) {
    84. player.sendMessage(noNominations.replaceAll(
    85. "%rank%", "VIP"));
    86. return true;
    87. } else {
    88. player.sendMessage(GREEN + "VIP Nominations:");
    89. for (String nominee : vipNominated) {
    90. player.sendMessage(" " + DARK_AQUA + nominee);
    91. }
    92. return true;
    93. }
    94. } else if (args[0].equalsIgnoreCase("vipgold")) {
    95. if (vipGoldNominated.isEmpty()) {
    96. player.sendMessage(noNominations.replaceAll(
    97. "%rank%", "VIPGold"));
    98. return true;
    99. } else {
    100. player.sendMessage(YELLOW + "VIPGold Nominations:");
    101. for (String nominee : vipGoldNominated) {
    102. player.sendMessage(" " + DARK_AQUA + nominee);
    103. }
    104. return true;
    105. }
    106. } else if (args[0].equalsIgnoreCase("vipplatinum")) {
    107. if (vipPlatinumNominated.isEmpty()) {
    108. player.sendMessage(noNominations.replaceAll(
    109. "%rank%", "VIPlatinum"));
    110. return true;
    111. } else {
    112. player.sendMessage(WHITE + "VIP Nominations:");
    113. for (String nominee : vipPlatinumNominated) {
    114. player.sendMessage(" " + DARK_AQUA + nominee);
    115. }
    116. return true;
    117. }
    118. } else if (args[0].equalsIgnoreCase("mod")) {
    119. if (modNominated.isEmpty()) {
    120. player.sendMessage(noNominations.replaceAll(
    121. "%rank%", "Mod"));
    122. return true;
    123. } else {
    124. player.sendMessage(DARK_PURPLE + "Mod Nominations:");
    125. for (String nominee : modNominated) {
    126. player.sendMessage(" " + DARK_AQUA + nominee);
    127. }
    128. return true;
    129. }
    130. } else if (args[0].equalsIgnoreCase("admin")) {
    131. if (adminNominated.isEmpty()) {
    132. player.sendMessage(noNominations.replaceAll(
    133. "%rank%", "Admin"));
    134. return true;
    135. } else {
    136. player.sendMessage(BLUE + "VIP Nominations:");
    137. for (String nominee : adminNominated) {
    138. player.sendMessage(" " + DARK_AQUA + nominee);
    139. }
    140. return true;
    141. }
    142. } else if (args[0].equalsIgnoreCase("staff")) {
    143. if (staffNominated.isEmpty()) {
    144. player.sendMessage(noNominations.replaceAll(
    145. "%rank%", "Most Helpful Staff"));
    146. return true;
    147. } else {
    148. player.sendMessage(LIGHT_PURPLE
    149. + "Most Helpful Staff Nominations:");
    150. for (String nominee : staffNominated) {
    151. player.sendMessage(" " + DARK_AQUA + nominee);
    152. }
    153. return true;
    154. }
    155. } else {
    156. Player selection = Bukkit.getPlayer(args[1]);
    157. String playerName = player.getName();
    158. String selectionName = selection.getName();
    159. String rankName = votes.getRank(selectionName);
    160. if (rankName == null) {
    161. player.sendMessage(notNominated);
    162. return true;
    163. } else {
    164. if (rankName == "vip") {
    165. if (player.hasPermission(playerVoteVIPPerm)) {
    166. if (vipVote.contains(playerName)) {
    167. player.sendMessage(alreadyVoted
    168. .replaceAll("%rank%", rankName));
    169. return true;
    170. } else {
    171. votes.vote(selectionName, playerName);
    172. saveConfig();
    173. reloadConfig();
    174. return true;
    175. }
    176. } else {
    177. player.sendMessage(noPerm);
    178. return true;
    179. }
    180. } else if (rankName == "vipgold") {
    181. if (player.hasPermission(playerVoteVIPGoldPerm)) {
    182. if (vipGoldVote.contains(playerName)) {
    183. player.sendMessage(alreadyVoted
    184. .replaceAll("%rank%", rankName));
    185. return true;
    186. } else {
    187. votes.vote(selectionName, playerName);
    188. saveConfig();
    189. reloadConfig();
    190. return true;
    191. }
    192. } else {
    193. player.sendMessage(noPerm);
    194. return true;
    195. }
    196. } else if (rankName == "viplatinum") {
    197. if (player
    198. .hasPermission(playerVoteVIPlatinumPerm)) {
    199. if (vipPlatinumVote.contains(playerName)) {
    200. player.sendMessage(alreadyVoted
    201. .replaceAll("%rank%", rankName));
    202. return true;
    203. } else {
    204. votes.vote(selectionName, playerName);
    205. saveConfig();
    206. reloadConfig();
    207. return true;
    208. }
    209. } else {
    210. player.sendMessage(noPerm);
    211. }
    212. } else if (rankName == "mod") {
    213. if (player.hasPermission(playerVoteModPerm)) {
    214. if (modVote.contains(playerName)) {
    215. player.sendMessage(alreadyVoted
    216. .replaceAll("%rank%", rankName));
    217. return true;
    218. } else {
    219. votes.vote(selectionName, playerName);
    220. saveConfig();
    221. reloadConfig();
    222. return true;
    223. }
    224. } else {
    225. player.sendMessage(noPerm);
    226. return true;
    227. }
    228. } else if (rankName == "admin") {
    229. if (player.hasPermission(playerVoteAdminPerm)) {
    230. if (adminVote.contains(playerName)) {
    231. player.sendMessage(alreadyVoted
    232. .replaceAll("%rank%", rankName));
    233. return true;
    234. } else {
    235. votes.vote(selectionName, playerName);
    236. saveConfig();
    237. reloadConfig();
    238. return true;
    239. }
    240. } else {
    241. player.sendMessage(noPerm);
    242. return true;
    243. }
    244. } else if (rankName == "staff") {
    245. if (player.hasPermission(playerVoteStaffPerm)) {
    246. if (staffVote.contains(playerName)) {
    247. player.sendMessage(alreadyVoted
    248. .replaceAll("%rank%", rankName));
    249. return true;
    250. } else {
    251. votes.vote(selectionName, playerName);
    252. saveConfig();
    253. reloadConfig();
    254. return true;
    255. }
    256. } else {
    257. player.sendMessage(noPerm);
    258. return true;
    259. }
    260. } else {
    261. for (Player p : Bukkit.getOnlinePlayers()) {
    262. p.kickPlayer("A serious error occurred with Veritas Voting. Report to Zonal ASAP");
    263. }
    264. Bukkit.shutdown();
    265. System.out
    266. .println("A serious, possibly fatal error has occurred. Report to Zonal ASAP.");
    267. System.out.println("Check Vote.java line: 168");
    268. System.out
    269. .println("A player returned with a 'null' rank and was not caught by the first check.");
    270. return true;
    271. }
    272. }
    273. }
    274. }
    275. }
    276. return true;
    277. }
    278. return false;
    279. }
    280. }
    281.  


    JEREMSPEED Moving to github to keep the formatting

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  11. Offline

    JEREMSPEED

    Please add the error. ^^
     
  12. JEREMSPEED Source, with formatting: https://github.com/ZonalYewHD/VeritasVoting
    Error:
    Code:
    24.06 12:01:38 [Server] INFO ... 20 more
    24.06 12:01:38 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_51]
    24.06 12:01:38 [Server] INFO Caused by: java.lang.InstantiationException: me.zonalyewhd.veritasvoting.VeritasVoting
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:956) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.Bukkit.reload(Bukkit.java:288) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.reload(CraftServer.java:797) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins(CraftServer.java:355) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:56) ~[craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:01:38 [Server] INFO org.bukkit.plugin.InvalidPluginException: Abnormal plugin type
    24.06 12:01:38 [Server] ERROR Could not load 'plugins/VeritasVoting.jar' in folder 'plugins'
    
     
  13. Offline

    JEREMSPEED

    I think you should add this to your onEnable()

    Code:java
    1. getServer().getPluginManager().registerEvents(this, this);


    Is this error the complete? Did you remove some part of it?
     
  14. Offline

    ZodiacTheories

    ZonalYewHD
    Code:java
    1. Vote vote;
    2.  
    3. //Do this
    4.  
    5. .setExecutor(new Vote()
    6.  
    7. //instead


    JEREMSPEED

    Are there any events in that class?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  15. JEREMSPEED None of my classes implements Listener, so I don't think I need to register any events. Everything is handled purely through commands and the config.
     
  16. Offline

    JEREMSPEED

    Yes sorry! XD
     
  17. ZodiacTheories So change it to this?
    Code:Java
    1.  
    2. package me.zonalyewhd.veritasvoting;
    3.  
    4. import me.zonalyewhd.veritasvoting.commands.Nominate;
    5. import me.zonalyewhd.veritasvoting.commands.Tools;
    6. import me.zonalyewhd.veritasvoting.commands.Vote;
    7. import me.zonalyewhd.veritasvoting.utils.NominateUtils;
    8. import me.zonalyewhd.veritasvoting.utils.OrderVotes;
    9. import me.zonalyewhd.veritasvoting.utils.ToolsUtils;
    10. import me.zonalyewhd.veritasvoting.utils.VoteUtils;
    11.  
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class VeritasVoting extends JavaPlugin {
    15.  
    16. public void onEnable() {
    17. System.out.println("VeritasVoting has been enabled!");
    18. getCommand("vote").setExecutor(new Vote(this, new VoteUtils(this)));
    19. getCommand("nominate").setExecutor(
    20. new Nominate(this, new NominateUtils(this)));
    21. getCommand("tools").setExecutor(
    22. new Tools(this, new VoteUtils(this), new ToolsUtils(this,
    23. new OrderVotes(this)), new OrderVotes(this)));
    24. saveDefaultConfig();
    25. }
    26.  
    27. public void onDisable() {
    28. System.out.println("VeritasVoting has now been disabled!");
    29. }
    30.  
    31. }
    32.  
     
  18. Offline

    ZodiacTheories

    ZonalYewHD

    No, this:

    Code:java
    1.  
    2. getCommand("vote").setExecutor(new Vote());
    3. getCommand("nominate").setExecutor(new Nominate());
    4. getCommand("tools").setExecutor(new Tools());
    5.  
     
  19. ZodiacTheories I did, but I have to add arguments to match the constructors in the other classes. You can see them at my GitHub page above.

    ZodiacTheories I had to change the constructors so that I could implement methods and the config from the main class.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  20. Offline

    ZodiacTheories

  21. ZodiacTheories When using what I posted, the stack trace is
    Code:
    24.06 12:36:17 [Server] INFO ZonalYewHD: Reload complete.
    24.06 12:36:17 [Server] INFO Server permissions file permissions.yml is empty, ignoring it
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:956) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.Bukkit.reload(Bukkit.java:288) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.reload(CraftServer.java:799) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.enablePlugins(CraftServer.java:380) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugin(CraftServer.java:446) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:36:17 [Server] INFO at me.zonalyewhd.veritasvoting.VeritasVoting.onEnable(VeritasVoting.java:17) ~[?:?]
    24.06 12:36:17 [Server] INFO at me.zonalyewhd.veritasvoting.utils.VoteUtils.<init>(VoteUtils.java:30) ~[?:?]
    24.06 12:36:17 [Server] INFO java.lang.NullPointerException
    24.06 12:36:17 [Server] ERROR Error occurred while enabling VeritasVoting v0.1 (Is it up to date?)
    
     
  22. Offline

    ZodiacTheories

    ZonalYewHD

    Remove

    Code:java
    1. System.out.println("VeritasVoting has been enabled");


    Can I see your VoteUtils class and a bit more of the stack trace?
     
  23. ZodiacTheories
    New stack trace:
    Code:
    24.06 12:48:35 [Server] INFO ZonalYewHD: Reload complete.
    24.06 12:48:35 [Server] INFO Server permissions file permissions.yml is empty, ignoring it
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:956) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.Bukkit.reload(Bukkit.java:288) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.reload(CraftServer.java:799) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.enablePlugins(CraftServer.java:380) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugin(CraftServer.java:446) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[craftbukkit_beta_3092.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    24.06 12:48:35 [Server] INFO at me.zonalyewhd.veritasvoting.VeritasVoting.onEnable(VeritasVoting.java:16) ~[?:?]
    24.06 12:48:35 [Server] INFO at me.zonalyewhd.veritasvoting.utils.VoteUtils.<init>(VoteUtils.java:30) ~[?:?]
    24.06 12:48:35 [Server] INFO java.lang.NullPointerException
    24.06 12:48:35 [Server] ERROR Error occurred while enabling VeritasVoting v0.1 (Is it up to date?)
    24.06 12:48:35 [Server] INFO Enabling VeritasVoting v0.1
    24.06 12:48:35 [Server] INFO Enabling Test v1.0
    24.06 12:48:35 [Server] INFO Loading VeritasVoting v0.1
    24.06 12:48:35 [Server] INFO Loading Test v1.0
    24.06 12:48:35 [Server] INFO Disabling Test v1.0
    24.06 12:48:35 [Server] INFO VeritasVoting has now been disabled!
    24.06 12:48:35 [Server] INFO Disabling VeritasVoting v0.1
    
    All of the classes are on my GitHub page.
     
  24. Offline

    ZodiacTheories

    ZonalYewHD

    You seem to be getting an error on this line:

    Code:java
    1. private List<String> adminVote = plugin.getConfig().getStringList(
     
  25. ZodiacTheories I'm assuming that is because there is an error with either 'plugin' or 'getConfig()', but I have no idea how to fix it.
     
  26. Offline

    ZodiacTheories

  27. Offline

    ZodiacTheories

    ZonalYewHD

    I am trying to get you to think by yourself here
     
Thread Status:
Not open for further replies.

Share This Page