Player Input for Config

Discussion in 'Plugin Development' started by FlipSide_Mike, Oct 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    FlipSide_Mike

    So I'm working on a large scale plugin, and one of my goals is to have blood on entity and player damage. What I want is a configurable item id upon command.
    Code:java
    1. @Override
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    3. if (sender instanceof Player) {
    4. Player player = (Player) sender;
    5. if ((label.equalsIgnoreCase("bloodparticles")) || (label.equalsIgnoreCase("bp"))) {
    6. if (args.length == 0) {
    7. sender.sendMessage(ChatColor.GREEN + "============================");
    8. sender.sendMessage(ChatColor.GREEN + "Blood Particles 1.0.0");
    9. sender.sendMessage(ChatColor.GREEN + "By: PetroSwag");
    10. sender.sendMessage(ChatColor.YELLOW + "/bloodparticles " + ChatColor.GREEN + "Brings up this page");
    11. sender.sendMessage(ChatColor.YELLOW + "/bloodparticles block <BlockID> " + ChatColor.GREEN + "Sets the color of blood particles");
    12. sender.sendMessage(ChatColor.YELLOW + "/bloodparticles reload " + ChatColor.GREEN + "Reloads the config file");
    13. sender.sendMessage(ChatColor.GREEN + "============================");
    14. } else if (args.length == 1) {
    15. if (args[0].equalsIgnoreCase("block")) {
    16. player.sendMessage(ChatColor.RED + "Please input a block ID");
    17. }
    18. if (args[0].equalsIgnoreCase("reload")) {
    19. reloadConfig();
    20. sender.sendMessage(ChatColor.AQUA + "Config reloaded");
    21. }
    22. } else if (args.length == 2) {
    23. if (args[0].equalsIgnoreCase("block")) {
    24.  
    25. getConfig().set("blockid", blockid);
    26. saveConfig();
    27. sender.sendMessage(ChatColor.GREEN + "Block ID successfully changed!");
    28. return true;
    29. }else{
    30. sender.sendMessage(ChatColor.RED + "Invalid block ID");
    31. }
    32. }
    33. }
    34. }
    35. }
    36. }
    37. return false;
    38. }
    39. }
    40.  


    My first attempt was to use

    Code:java
    1. int blockid = Integer.parseInt(args[1]));
    2. if(new ItemStack(blockid).getType.isBlock)){

    But ItemStack(Int) was deprecated, any other ideas?
     
  2. Offline

    SleepyDog

    You should really tab your if statements, it makes them easier to read.
     
  3. Offline

    FlipSide_Mike

    Had them tabbed, not sure what happened though
     
  4. Offline

    eyamaz

    Moved to Dev
     
  5. Offline

    tcvs

    FlipSide_Mike it is deprecated because it is trying to be fazed out since vanilla minecraft is also fazing out item ids.
     
  6. Offline

    FlipSide_Mike

    tcvs Yeah I was talking to someone about that earlier, any idea of a work around? I was thinking having them enter the material name, but I'm unsure if thats the most efficient/effective
     
  7. Offline

    Funergy

Thread Status:
Not open for further replies.

Share This Page