I need Help!

Discussion in 'Plugin Development' started by LeatholZombie, Jan 13, 2014.

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

    LeatholZombie

    1. Hi I am new and need some help. I am trying to make it where if you click this certain item you will be moved to a different group then after 30 days you will be moved back to Default. Here is my Main.Java
    2. import java.util.Arrays;
    3. import java.util.List;
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Color;
    7. import org.bukkit.FireworkEffect;
    8. import org.bukkit.Material;
    9. import org.bukkit.FireworkEffect.Type;
    10. import org.bukkit.block.Block;
    11. import org.bukkit.command.Command;
    12. import org.bukkit.command.CommandSender;
    13. import org.bukkit.entity.Firework;
    14. import org.bukkit.entity.Player;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.block.Action;
    18. import org.bukkit.event.player.PlayerInteractEvent;
    19. import org.bukkit.inventory.ItemStack;
    20. import org.bukkit.inventory.ShapedRecipe;
    21. import org.bukkit.inventory.meta.FireworkMeta;
    22. import org.bukkit.inventory.meta.ItemMeta;
    23. import org.bukkit.plugin.java.JavaPlugin;
    24. public class Main extends JavaPlugin implements Listener {
    25. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    26. if(sender instanceof Player){
    27. Player player = (Player)sender;
    28. String Name = player.getDisplayName();
    29. player.sendMessage("Your name is "+Name);
    30. }
    31. return true;
    32. }
    33. @Override
    34. public void onEnable() {
    35. getLogger().info("Plugin Enabled");
    36. Bukkit.getPluginManager().registerEvents(this, this);
    37. ItemStack dp = setMeta(new ItemStack(Material.PAPER), ChatColor.GREEN + "Donator Status",Arrays.asList("Right-Click To" , "Get Donator Status" , "For A Month"));
    38. ShapedRecipe dn = new ShapedRecipe(new ItemStack(dp));
    39. dn.shape(new String[]{"$$$","$*$","$$$"}).setIngredient('$', Material.FIRE).setIngredient('*', Material.NETHER_STAR);
    40. Bukkit.getServer().addRecipe(dn);
    41. }
    42. @SuppressWarnings("deprecation")
    43. @EventHandler
    44. public void onPlayerInteract(PlayerInteractEvent event)
    45. {
    46. Firework f = (Firework) event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(),
    47. Firework.class);
    48. FireworkMeta fm = f.getFireworkMeta();
    49. fm.addEffect(FireworkEffect.builder()
    50. .flicker(false)
    51. .trail(true)
    52. .with(Type.BALL)
    53. .with(Type.BALL_LARGE)
    54. .with(Type.STAR)
    55. .withColor(Color.BLUE)
    56. .withColor(Color.YELLOW)
    57. .withFade(Color.PURPLE)
    58. .withFade(Color.RED)
    59. .build());
    60. fm.setPower(2);
    61. f.setFireworkMeta(fm);
    62. ItemStack dp = setMeta(new ItemStack(Material.PAPER), ChatColor.GREEN + "Donator Status",
    63. Arrays.asList("Right-Click To" , "Get Donator Status" , "For A Month"));
    64. Player player = event.getPlayer();
    65. Block block = event.getClickedBlock();
    66. Action action = event.getAction();
    67. if(action.equals(Action.RIGHT_CLICK_BLOCK) && block.getType().equals(dp))
    68. {
    69. player.sendMessage(ChatColor.BLUE + "You are now a Donator");
    70. player.getInventory().removeItem(dp);
    71. player.performCommand("manuadd" + player.getDisplayName() + "V.I.P");
    72. player.updateInventory();
    73. }
    74. if(action.equals(Action.RIGHT_CLICK_AIR) && block.getType().equals(dp))
    75. {
    76. player.sendMessage(ChatColor.BLUE + "You are now a Donator");
    77. player.getInventory().removeItem(dp);
    78. player.performCommand("manuadd" + player.getDisplayName() + "V.I.P");
    79. player.updateInventory();
    80. }
    81. }
    82. public ItemStack setMeta(ItemStack material, String name, List<String> lore) {
    83. if(((material == null) || material.getType() == Material.AIR)
    84. || (name == null) && lore == null)
    85. return null;
    86. ItemMeta ph = material.getItemMeta();
    87. if(name != null)
    88. ph.setDisplayName(name);
    89. if(lore != null)
    90. ph.setLore(lore);
    91. material.setItemMeta(ph);
    92. return material;
    93. }
    94. @Override
    95. public void onDisable() {
    96. getLogger().info("Plugin Disable");
    97. Bukkit.getServer().clearRecipes();
    98. }
    99. }
     
  2. Offline

    np98765

    Moved to Plugin Development.
     
  3. Offline

    ResultStatic

  4. Offline

    xTrollxDudex

    Evildude221 likes this.
Thread Status:
Not open for further replies.

Share This Page