I'm going insane [No errors, I've been trying to get it work all week]

Discussion in 'Plugin Development' started by BrushPainter, Mar 9, 2014.

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

    BrushPainter

    Hey guys...
    I really can't get this plugin to work, there are absolutely no errors in my console onEnable, onDisable, onCommand, in the server.log, in Eclipse. NOTHING. I seriously can't figure it out... I'm going insane... Here it is:

    Main.java:
    Code:java
    1. package me.BrushPainter.PBGunShop;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Entity;
    11. import org.bukkit.entity.EntityType;
    12. import org.bukkit.entity.LivingEntity;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.entity.Villager;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    18. import org.bukkit.event.inventory.InventoryClickEvent;
    19. import org.bukkit.event.player.PlayerInteractEntityEvent;
    20. import org.bukkit.inventory.Inventory;
    21. import org.bukkit.inventory.ItemStack;
    22. import org.bukkit.inventory.meta.ItemMeta;
    23. import org.bukkit.plugin.java.JavaPlugin;
    24. import org.bukkit.potion.PotionEffect;
    25. import org.bukkit.potion.PotionEffectType;
    26.  
    27. public class Main extends JavaPlugin implements Listener{
    28.  
    29. public void onEnable() {
    30.  
    31. Bukkit.getPluginManager().registerEvents(this, this);
    32.  
    33. getLogger().info("PBGunShop Enabled");
    34.  
    35. }
    36.  
    37. public void onDisable() {
    38.  
    39. getLogger().info("PBGunShop Disabled");
    40.  
    41. }
    42. public static Inventory PaintballGunShop = Bukkit.createInventory(null, 9, "Inventory");
    43.  
    44. @EventHandler
    45. public void onInventoryClick(InventoryClickEvent event) {
    46. Player player = (Player) event.getWhoClicked();
    47. Player buyer = (Player) event.getWhoClicked();
    48. ItemStack clicked = event.getCurrentItem();
    49. Inventory inventory = event.getInventory();
    50. ItemStack is = new ItemStack(Material.WOOL );
    51. is.setDurability((byte) 14);
    52. ItemMeta im = is.getItemMeta();
    53. im.setDisplayName(ChatColor.DARK_RED + "Close");
    54. ArrayList<String> lore = new ArrayList<String>();
    55. lore.add(ChatColor.DARK_GRAY + "Closes the PB Shop.");
    56. im.setLore(lore);
    57. is.setItemMeta(im);
    58. if (inventory.getName().equals(PaintballGunShop.getName())) {
    59. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Close")) {
    60. event.setCancelled(true);
    61. player.closeInventory();
    62. }
    63.  
    64. ItemStack fullyauto = new ItemStack(Material.DIAMOND_BARDING, 1);
    65. ItemMeta im1 = fullyauto.getItemMeta();
    66. im1.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun");
    67. fullyauto.setItemMeta(im1);
    68. lore.add(ChatColor.WHITE + "500 Coins");
    69. im1.setLore(lore);
    70. PaintballGunShop.setItem(0,fullyauto);
    71. if (inventory.getName().equals(PaintballGunShop.getName())) {
    72. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun")) {
    73. event.setCancelled(true);
    74. player.closeInventory();
    75. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.fullyauto");
    76. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.fullyauto");
    77. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 500");
    78. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the fully-auto paintball gun!");
    79. buyer.sendMessage(ChatColor.YELLOW + "You can now use /fullyauto to get your gun!");
    80. }
    81.  
    82. ItemStack threeburst = new ItemStack(Material.GOLD_BARDING, 1);
    83. ItemMeta im2 = fullyauto.getItemMeta();
    84. im2.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun");
    85. threeburst.setItemMeta(im2);
    86. lore.add(ChatColor.WHITE + "1000 Coins");
    87. im2.setLore(lore);
    88. PaintballGunShop.setItem(8,threeburst);
    89. if (inventory.getName().equals(PaintballGunShop.getName())) {
    90. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun")) {
    91. event.setCancelled(true);
    92. player.closeInventory();
    93. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.threeburst");
    94. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.threeburst");
    95. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 1000");
    96. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the three-burst paintball gun!");
    97. buyer.sendMessage(ChatColor.YELLOW + "You can now use /threeburst to get your gun!");
    98. }
    99. }
    100. }
    101. }
    102. }
    103.  
    104. ArrayList<String> Damagers = new ArrayList<String>();
    105. @EventHandler
    106. public void onEntityDamage(EntityDamageByEntityEvent event) {
    107.  
    108. Player player = (Player) event.getDamager();
    109. LivingEntity entity = (LivingEntity)event.getEntity();
    110. Villager zinc = (Villager) entity;
    111.  
    112. if (entity.getLastDamageCause().getEntity() instanceof Player) {
    113. event.setCancelled(true);
    114. } else if(zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    115. event.setCancelled(true);
    116. } else {
    117. if(Damagers.contains(player.getName())) {
    118. event.setCancelled(true);
    119. }
    120. }
    121. }
    122.  
    123. public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    124. Entity entity = event.getRightClicked();
    125. Villager zinc = (Villager) entity;
    126. Player player = event.getPlayer();
    127.  
    128. if(zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    129.  
    130.  
    131. player.openInventory(PaintballGunShop);
    132. }
    133. else{
    134.  
    135. }
    136. }
    137.  
    138. public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args){
    139.  
    140. if (cmd.getName().equalsIgnoreCase("spbshop")) {
    141. if (sender instanceof Player) {
    142. Player p = (Player) sender;
    143.  
    144. Villager e = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
    145.  
    146. e.setBreed(true);
    147. e.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 6));
    148. e.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -6));
    149. e.setCustomName(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer");
    150. e.setCustomNameVisible(true);
    151. e.getEquipment().getItemInHand().setType(Material.GOLD_BARDING);
    152.  
    153. }
    154. }
    155. return false;
    156. }
    157. }

    How I am exporting it:
    [​IMG]

    plugin.yml:
    Code:
    name: PBGunShop
    version: 1.0.1
    main: me.BrushPainter.PBGunShop.Main
     
    permissions:
      pbgunshop.buy.threeburst:
        description: Allows you to buy a threeburst pb gun.
        default: true
     
      pbgunshop.buy.fullyauto:
        description: Allows you to buy a fullyauto pb gun.
        default: true
     
      signshop.pb.create:
        description: Create a PB Shop sign.
        default: op
     
  2. Offline

    GameplayJDK

    BrushPainter
    What exactly does not work?
    I just nötigen you're returning false, no matter what result the on command has.
     
  3. Offline

    viper_monster

    BrushPainter you didnt put @EventHandler above onPlayerInteractEntityEvent method :)
     
  4. Offline

    guitargun

    Your event dens;t register proberly I think.
    try putting this in your onEnable instead of the

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

    Code:java
    1. PluginManager pm = getServer().getPluginManager();
    2. pm.registerEvents(new Main(this), this);


    edit 3:

    youre commands wont work either. This is because the commands need to be registerd as executor in the onEnable. And in the plugin.yml you need to describe it
    Code:java
    1. getCommand("yourecommand").setExecutor(new Main(this));


    and in the plugin.yml
    Code:
    commands:
        yourecommand:
                description: youre description
                usage: /<command>
     
  5. Offline

    Rainy37

    your plugin.yml is in wrong spot
     
  6. Offline

    BrushPainter

    spoljo666 guitargun Rainy37 GameplayJDK It's still not working, here's a picture:
    [​IMG]

    I took all of your suggestions and fixed them, here is my new code and my new plugin.yml:
    Code:java
    1. package me.BrushPainter.PBGunShop;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Entity;
    11. import org.bukkit.entity.EntityType;
    12. import org.bukkit.entity.LivingEntity;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.entity.Villager;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    18. import org.bukkit.event.inventory.InventoryClickEvent;
    19. import org.bukkit.event.player.PlayerInteractEntityEvent;
    20. import org.bukkit.inventory.Inventory;
    21. import org.bukkit.inventory.ItemStack;
    22. import org.bukkit.inventory.meta.ItemMeta;
    23. import org.bukkit.plugin.PluginManager;
    24. import org.bukkit.plugin.java.JavaPlugin;
    25. import org.bukkit.potion.PotionEffect;
    26. import org.bukkit.potion.PotionEffectType;
    27.  
    28. public class Main extends JavaPlugin implements Listener{
    29.  
    30. public void onEnable() {
    31.  
    32. getCommand("spbshop").setExecutor(this);
    33.  
    34. PluginManager pm = getServer().getPluginManager();
    35. pm.registerEvents(this, this);
    36.  
    37. getLogger().info("PBGunShop Enabled");
    38.  
    39. }
    40.  
    41. public void onDisable() {
    42.  
    43. getLogger().info("PBGunShop Disabled");
    44.  
    45. }
    46. public static Inventory PaintballGunShop = Bukkit.createInventory(null, 9, "Inventory");
    47.  
    48. @EventHandler
    49. public void onInventoryClick(InventoryClickEvent event) {
    50. Player player = (Player) event.getWhoClicked();
    51. Player buyer = (Player) event.getWhoClicked();
    52. ItemStack clicked = event.getCurrentItem();
    53. Inventory inventory = event.getInventory();
    54. ItemStack is = new ItemStack(Material.WOOL );
    55. is.setDurability((byte) 14);
    56. ItemMeta im = is.getItemMeta();
    57. im.setDisplayName(ChatColor.DARK_RED + "Close");
    58. ArrayList<String> lore = new ArrayList<String>();
    59. lore.add(ChatColor.DARK_GRAY + "Closes the PB Shop.");
    60. im.setLore(lore);
    61. is.setItemMeta(im);
    62. if (inventory.getName().equals(PaintballGunShop.getName())) {
    63. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Close")) {
    64. event.setCancelled(true);
    65. player.closeInventory();
    66. }
    67.  
    68. ItemStack fullyauto = new ItemStack(Material.DIAMOND_BARDING, 1);
    69. ItemMeta im1 = fullyauto.getItemMeta();
    70. im1.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun");
    71. fullyauto.setItemMeta(im1);
    72. lore.add(ChatColor.WHITE + "500 Coins");
    73. im1.setLore(lore);
    74. PaintballGunShop.setItem(0,fullyauto);
    75. if (inventory.getName().equals(PaintballGunShop.getName())) {
    76. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun")) {
    77. event.setCancelled(true);
    78. player.closeInventory();
    79. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.fullyauto");
    80. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.fullyauto");
    81. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 500");
    82. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the fully-auto paintball gun!");
    83. buyer.sendMessage(ChatColor.YELLOW + "You can now use /fullyauto to get your gun!");
    84. }
    85.  
    86. ItemStack threeburst = new ItemStack(Material.GOLD_BARDING, 1);
    87. ItemMeta im2 = fullyauto.getItemMeta();
    88. im2.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun");
    89. threeburst.setItemMeta(im2);
    90. lore.add(ChatColor.WHITE + "1000 Coins");
    91. im2.setLore(lore);
    92. PaintballGunShop.setItem(8,threeburst);
    93. if (inventory.getName().equals(PaintballGunShop.getName())) {
    94. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun")) {
    95. event.setCancelled(true);
    96. player.closeInventory();
    97. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.threeburst");
    98. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.threeburst");
    99. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 1000");
    100. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the three-burst paintball gun!");
    101. buyer.sendMessage(ChatColor.YELLOW + "You can now use /threeburst to get your gun!");
    102. }
    103. }
    104. }
    105. }
    106. }
    107.  
    108. ArrayList<String> Damagers = new ArrayList<String>();
    109. @EventHandler
    110. public void onEntityDamage(EntityDamageByEntityEvent event) {
    111.  
    112. Player player = (Player) event.getDamager();
    113. LivingEntity entity = (LivingEntity)event.getEntity();
    114. Villager zinc = (Villager) entity;
    115.  
    116. if (entity.getLastDamageCause().getEntity() instanceof Player) {
    117. event.setCancelled(true);
    118. } else if(zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    119. event.setCancelled(true);
    120. } else {
    121. if(Damagers.contains(player.getName())) {
    122. event.setCancelled(true);
    123. }
    124. }
    125. }
    126.  
    127. @EventHandler
    128. public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    129. Entity entity = event.getRightClicked();
    130. Villager zinc = (Villager) entity;
    131. Player player = event.getPlayer();
    132.  
    133. if(zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    134.  
    135.  
    136. player.openInventory(PaintballGunShop);
    137. }
    138. else{
    139.  
    140. }
    141. }
    142.  
    143. public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args){
    144.  
    145. if (sender.hasPermission("pbgunshop.spawn")){
    146. if (cmd.getName().equalsIgnoreCase("spbshop")) {
    147. if (sender instanceof Player) {
    148. Player p = (Player) sender;
    149.  
    150. Villager e = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
    151.  
    152. e.setBreed(true);
    153. e.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 6));
    154. e.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -6));
    155. e.setCustomName(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer");
    156. e.setCustomNameVisible(true);
    157. e.getEquipment().getItemInHand().setType(Material.GOLD_BARDING);
    158.  
    159. }
    160. }
    161. }
    162. return true;
    163. }
    164. }


    Code:
    name: PBGunShop
    version: 1.0.1
    main: me.BrushPainter.PBGunShop.Main
     
    commands:
      spbshop:
        description: Spawn Zinc, the paintballer.
        permission:
     
    permissions:
      pbgunshop.buy.threeburst:
        description: Allows you to buy a threeburst pb gun.
        default: true
     
      pbgunshop.buy.fullyauto:
        description: Allows you to buy a fullyauto pb gun.
        default: true
     
      pbgunshop.spawn:
        description: Allows you to spawn Zinc.
        default: op
    Here's my log:
    Code:
    [22:24:41] [Server thread/INFO]: BrushPainter issued server command: /spbshop
    [22:24:45] [Server thread/INFO]: CONSOLE issued server command: /list
    [22:24:45] [Server thread/INFO]: There are 1 out of maximum 25 players online.
    [22:24:45] [Server thread/INFO]: Players: BrushPainter
    [22:24:49] [Server thread/INFO]: BrushPainter issued server command: /spbshop
    [22:24:53] [Server thread/INFO]: BrushPainter issued server command: /help spbshop
    [22:25:05] [Server thread/INFO]: BrushPainter issued server command: /spbshop
    [22:25:14] [Server thread/INFO]: BrushPainter issued server command: /spbshop
     
  7. Offline

    GameplayJDK

    BrushPainter
    Add this
    Code:
    return true;
    Below the e.getEquipment line in the onCommand method.
    What happens is, that you're executing the onCommand and the server doesn't know that it was executed successfully.
    You should also check if the sender is instance of Player before checking the permission.
    Then change the old return true in onCommand to return false and fill the properie permission in the plugin.yml
     
  8. Offline

    timtower Administrator Administrator Moderator

    BrushPainter Tried adding debug lines?
    You probably don't want to create a new instance of a plugin just to hold the listener. And linking the functions is just as good.
    Don't need to register the executor if it is the main class
     
  9. Offline

    Rocoty

    Do you know if the player has the right permissions? And as timtower said. Debugging lines helps a lot
     
  10. Offline

    MrInspector

    Not really, all of this isn't really necessary at all. :p
     
  11. Offline

    tomudding

    Maybe you need to implements CommandExecutor if you do
    Code:java
    1. getCommand("yourecommand").setExecutor(new Main(this));
    2.  

    like this
    Code:java
    1. public class Main extends JavaPlugin implements Listener, CommandExecutor {
    2.  
     
  12. Offline

    Syd

    1. Format your source code, it's very hard to read
    2. Organize your variables on the top of the class
    3. What are you doing, what happens and what should have happend?
     
    StealerSlain likes this.
  13. Offline

    StealerSlain

    Every answer above +
    1. Where's EventHandler on onPlayerInteract?
    2. Don't recommend importing with .classpath, .DS_Store, .project etc.
    3. Yeah, format your source code to make it readable
     
  14. Offline

    1Rogue

    tomudding
    This is unnecessary for JavaPlugin. The real problem is he is deferring execution of events and commands to a class outside of his original.
     
  15. Offline

    BrushPainter

    Here is my new code: (I organized it a bit, tried to make it readable for you guys)
    Code:java
    1. package me.BrushPainter.PBGunShop;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Entity;
    11. import org.bukkit.entity.EntityType;
    12. import org.bukkit.entity.LivingEntity;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.entity.Villager;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    18. import org.bukkit.event.inventory.InventoryClickEvent;
    19. import org.bukkit.event.player.PlayerInteractEntityEvent;
    20. import org.bukkit.inventory.Inventory;
    21. import org.bukkit.inventory.ItemStack;
    22. import org.bukkit.inventory.meta.ItemMeta;
    23. import org.bukkit.plugin.PluginManager;
    24. import org.bukkit.plugin.java.JavaPlugin;
    25. import org.bukkit.potion.PotionEffect;
    26. import org.bukkit.potion.PotionEffectType;
    27.  
    28. public class Main extends JavaPlugin implements Listener{
    29.  
    30. public void onEnable() {
    31.  
    32. PluginManager pm = getServer().getPluginManager();
    33. pm.registerEvents(this, this);
    34.  
    35. getLogger().info("PBGunShop Enabled");
    36.  
    37. }
    38.  
    39. public void onDisable() {
    40.  
    41. getLogger().info("PBGunShop Disabled");
    42.  
    43. }
    44. public static Inventory PaintballGunShop = Bukkit.createInventory(null, 9, "Inventory");
    45.  
    46. ArrayList<String> lore = new ArrayList<String>();
    47.  
    48. @EventHandler
    49. public void onInventoryClick(InventoryClickEvent event) {
    50.  
    51. Player player = (Player) event.getWhoClicked();
    52. Player buyer = (Player) event.getWhoClicked();
    53.  
    54. ItemStack clicked = event.getCurrentItem();
    55. Inventory inventory = event.getInventory();
    56. ItemStack is = new ItemStack(Material.WOOL );
    57. is.setDurability((byte) 14);
    58. ItemMeta im = is.getItemMeta();
    59. im.setDisplayName(ChatColor.DARK_RED + "Close");
    60.  
    61. lore.add(ChatColor.DARK_GRAY + "Closes the PB Shop.");
    62. im.setLore(lore);
    63. is.setItemMeta(im);
    64.  
    65. if (inventory.getName().equals(PaintballGunShop.getName())) {
    66. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Close")) {
    67.  
    68. event.setCancelled(true);
    69. player.closeInventory();
    70.  
    71. }
    72.  
    73. ItemStack fullyauto = new ItemStack(Material.DIAMOND_BARDING, 1);
    74.  
    75. ItemMeta im1 = fullyauto.getItemMeta();
    76. im1.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun");
    77. fullyauto.setItemMeta(im1);
    78. lore.add(ChatColor.WHITE + "500 Coins");
    79. im1.setLore(lore);
    80.  
    81. PaintballGunShop.setItem(0,fullyauto);
    82.  
    83. if (inventory.getName().equals(PaintballGunShop.getName())) {
    84.  
    85. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun")) {
    86.  
    87. event.setCancelled(true);
    88. player.closeInventory();
    89.  
    90. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.fullyauto");
    91. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.fullyauto");
    92. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 500");
    93.  
    94. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the fully-auto paintball gun!");
    95. buyer.sendMessage(ChatColor.YELLOW + "You can now use /fullyauto to get your gun!");
    96.  
    97. }
    98.  
    99. ItemStack threeburst = new ItemStack(Material.GOLD_BARDING, 1);
    100.  
    101. ItemMeta im2 = fullyauto.getItemMeta();
    102. im2.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun");
    103. threeburst.setItemMeta(im2);
    104. lore.add(ChatColor.WHITE + "1000 Coins");
    105. im2.setLore(lore);
    106.  
    107. PaintballGunShop.setItem(8,threeburst);
    108.  
    109. if (inventory.getName().equals(PaintballGunShop.getName())) {
    110.  
    111. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun")) {
    112.  
    113. event.setCancelled(true);
    114. player.closeInventory();
    115.  
    116. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.threeburst");
    117. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.threeburst");
    118. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 1000");
    119.  
    120. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the three-burst paintball gun!");
    121. buyer.sendMessage(ChatColor.YELLOW + "You can now use /threeburst to get your gun!");
    122. }
    123. }
    124. }
    125. }
    126. }
    127.  
    128. ArrayList<String> Damagers = new ArrayList<String>();
    129.  
    130. @EventHandler
    131. public void onEntityDamage(EntityDamageByEntityEvent event) {
    132.  
    133. Player player = (Player) event.getDamager();
    134. LivingEntity entity = (LivingEntity)event.getEntity();
    135. Villager zinc = (Villager) entity;
    136.  
    137. if (entity.getLastDamageCause().getEntity() instanceof Player) {
    138. event.setCancelled(true);
    139.  
    140. } else if
    141. (zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    142. event.setCancelled(true);
    143.  
    144. } else {
    145.  
    146. if(Damagers.contains(player.getName())) {
    147. event.setCancelled(true);
    148.  
    149. }
    150. }
    151. }
    152.  
    153. @EventHandler
    154. public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    155.  
    156. Entity entity = event.getRightClicked();
    157. Villager zinc = (Villager) entity;
    158. Player player = event.getPlayer();
    159.  
    160. if(zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    161.  
    162.  
    163. player.openInventory(PaintballGunShop);
    164. }
    165. else{
    166.  
    167. }
    168. }
    169.  
    170. public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args){
    171.  
    172. if (sender instanceof Player) {
    173. if (sender.hasPermission("pbgunshop.spawn")){
    174. if (cmd.getName().equalsIgnoreCase("spbshop")) {
    175.  
    176. Player p = (Player) sender;
    177.  
    178. Villager e = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
    179.  
    180. e.setBaby();
    181.  
    182. e.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 6));
    183. e.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -6));
    184.  
    185. e.setCustomName(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer");
    186. e.setCustomNameVisible(true);
    187.  
    188. e.getEquipment().getItemInHand().setType(Material.GOLD_BARDING);
    189. return true;
    190.  
    191. }
    192. }
    193. }
    194. return true;
    195. }
    196. }


    timtower GameplayJDK Rocoty MrInspector tomudding Syd StealerSlain 1Rogue spoljo666 Thank you all for the replies, I truly appreciate it. I tried almost every single piece of advice, but about the debugging, I've never tried it before, I know it can be done with System.out.println() but I don't really know how and which lines I should put it on. Also 1Rogue How should I fix this problem?
     
  16. Offline

    timtower Administrator Administrator Moderator

    BrushPainter The debug should go before each if statement, it is just looking till where the function is working.
     
  17. Offline

    BrushPainter

    timtower Mind giving me an example please?
     
  18. Offline

    timtower Administrator Administrator Moderator

    Debugging shouldn't be something so ask an example for to be honest.
    Show Spoiler
    Code:java
    1. package me.BrushPainter.PBGunShop;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Entity;
    11. import org.bukkit.entity.EntityType;
    12. import org.bukkit.entity.LivingEntity;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.entity.Villager;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    18. import org.bukkit.event.inventory.InventoryClickEvent;
    19. import org.bukkit.event.player.PlayerInteractEntityEvent;
    20. import org.bukkit.inventory.Inventory;
    21. import org.bukkit.inventory.ItemStack;
    22. import org.bukkit.inventory.meta.ItemMeta;
    23. import org.bukkit.plugin.PluginManager;
    24. import org.bukkit.plugin.java.JavaPlugin;
    25. import org.bukkit.potion.PotionEffect;
    26. import org.bukkit.potion.PotionEffectType;
    27.  
    28. public class Main extends JavaPlugin implements Listener{
    29.  
    30. public void onEnable() {
    31.  
    32. PluginManager pm = getServer().getPluginManager();
    33. pm.registerEvents(this, this);
    34.  
    35. getLogger().info("PBGunShop Enabled");
    36.  
    37. }
    38.  
    39. public void onDisable() {
    40.  
    41. getLogger().info("PBGunShop Disabled");
    42.  
    43. }
    44. public static Inventory PaintballGunShop = Bukkit.createInventory(null, 9, "Inventory");
    45.  
    46. ArrayList<String> lore = new ArrayList<String>();
    47.  
    48. @EventHandler
    49. public void onInventoryClick(InventoryClickEvent event) {
    50.  
    51. Player player = (Player) event.getWhoClicked();
    52. Player buyer = (Player) event.getWhoClicked();
    53.  
    54. ItemStack clicked = event.getCurrentItem();
    55. Inventory inventory = event.getInventory();
    56. ItemStack is = new ItemStack(Material.WOOL );
    57. is.setDurability((byte) 14);
    58. ItemMeta im = is.getItemMeta();
    59. im.setDisplayName(ChatColor.DARK_RED + "Close");
    60.  
    61. lore.add(ChatColor.DARK_GRAY + "Closes the PB Shop.");
    62. im.setLore(lore);
    63. is.setItemMeta(im);
    64.  
    65. if (inventory.getName().equals(PaintballGunShop.getName())) {
    66. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Close")) {
    67.  
    68. event.setCancelled(true);
    69. player.closeInventory();
    70.  
    71. }
    72.  
    73. ItemStack fullyauto = new ItemStack(Material.DIAMOND_BARDING, 1);
    74.  
    75. ItemMeta im1 = fullyauto.getItemMeta();
    76. im1.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun");
    77. fullyauto.setItemMeta(im1);
    78. lore.add(ChatColor.WHITE + "500 Coins");
    79. im1.setLore(lore);
    80.  
    81. PaintballGunShop.setItem(0,fullyauto);
    82. System.out.print("Checking inventory name");
    83. if (inventory.getName().equals(PaintballGunShop.getName())) {
    84. System.out.println("Checking item");
    85. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun")) {
    86. System.out.println("Fully automatic");
    87. event.setCancelled(true);
    88. player.closeInventory();
    89.  
    90. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.fullyauto");
    91. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.fullyauto");
    92. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 500");
    93.  
    94. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the fully-auto paintball gun!");
    95. buyer.sendMessage(ChatColor.YELLOW + "You can now use /fullyauto to get your gun!");
    96. return;
    97. }
    98.  
    99. ItemStack threeburst = new ItemStack(Material.GOLD_BARDING, 1);
    100.  
    101. ItemMeta im2 = fullyauto.getItemMeta();
    102. im2.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun");
    103. threeburst.setItemMeta(im2);
    104. lore.add(ChatColor.WHITE + "1000 Coins");
    105. im2.setLore(lore);
    106.  
    107. PaintballGunShop.setItem(8,threeburst);
    108.  
    109. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun")) {
    110. System.out.println("3 burst automatic");
    111. event.setCancelled(true);
    112. player.closeInventory();
    113.  
    114. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.threeburst");
    115. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.threeburst");
    116. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 1000");
    117.  
    118. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the three-burst paintball gun!");
    119. buyer.sendMessage(ChatColor.YELLOW + "You can now use /threeburst to get your gun!");
    120. return;
    121. }
    122. }
    123. }
    124. }
    125.  
    126. ArrayList<String> Damagers = new ArrayList<String>();
    127.  
    128. @EventHandler
    129. public void onEntityDamage(EntityDamageByEntityEvent event) {
    130.  
    131. Player player = (Player) event.getDamager();
    132. LivingEntity entity = (LivingEntity)event.getEntity();
    133. Villager zinc = (Villager) entity;
    134.  
    135. if (entity.getLastDamageCause().getEntity() instanceof Player) {
    136. event.setCancelled(true);
    137.  
    138. } else if
    139. (zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    140. event.setCancelled(true);
    141.  
    142. } else {
    143.  
    144. if(Damagers.contains(player.getName())) {
    145. event.setCancelled(true);
    146.  
    147. }
    148. }
    149. }
    150.  
    151. @EventHandler
    152. public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    153.  
    154. Entity entity = event.getRightClicked();
    155. Villager zinc = (Villager) entity;
    156. Player player = event.getPlayer();
    157.  
    158. if(zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    159.  
    160.  
    161. player.openInventory(PaintballGunShop);
    162. }
    163. else{
    164.  
    165. }
    166. }
    167.  
    168. public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args){
    169.  
    170. if (sender instanceof Player) {
    171. if (sender.hasPermission("pbgunshop.spawn")){
    172. if (cmd.getName().equalsIgnoreCase("spbshop")) {
    173.  
    174. Player p = (Player) sender;
    175.  
    176. Villager e = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
    177.  
    178. e.setBaby();
    179.  
    180. e.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 6));
    181. e.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -6));
    182.  
    183. e.setCustomName(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer");
    184. e.setCustomNameVisible(true);
    185.  
    186. e.getEquipment().getItemInHand().setType(Material.GOLD_BARDING);
    187. return true;
    188.  
    189. }
    190. }
    191. }
    192. return true;
    193. }
    194. }
     
    caelum19 likes this.
  19. Offline

    BrushPainter

  20. Offline

    EnderPilot105

  21. Offline

    BrushPainter

    EnderPilot105 What should I replace it with then? Also thanks for the reply! :D

    EDIT: What should I replace it with SIZE, valueOf etc?
     
  22. Offline

    EnderPilot105

    How long you want.
    20 ticks - 1 second
    1000 Minutes - gives unlimited
    1,200,000 ticks - unlimited
    Put 1,200,000 in there
    BrushPainter
     
  23. Offline

    Garris0n

    What if he wants Integer.MAX_VALUE ticks...
     
    BrushPainter likes this.
  24. Offline

    GameplayJDK

    BrushPainter
    Also the last return true; should be a return false. Because when the end of the onCommand is reached, the query for a fitting command wasn't successful.
     
  25. Offline

    Garris0n

    I'd just like to point out that creating that inventory in the class body probably isn't a good idea.
     
  26. Offline

    GameplayJDK

  27. Offline

    Jake6177

    Off topic, but I just thought you'd like to know that Integer.MAX_VALUE ticks is about 3.4 years. :D

    (Which xTrollxDudex I'm sure you'd like to know...squared is very close to 6.9 years ;))
     
  28. Offline

    BrushPainter

    Garris0n I might make a new class for it now.

    Jake6177 Garris0n EnderPilot105 timtower 1Rogue GameplayJDK Ok so to see if it was the plugin itself not working or if it was a problem with the actual villager not spawning what I did was I made it so if you type the command it spawns the villager and sends you a message notifying you that it spawned. And then when I tried it, the message worked, but the villager still didn't spawn, so I feel like it's something to do with this part of the code:

    Code:java
    1. p.sendMessage(ChatColor.YELLOW + "You have spawned Zinc, The Paintballer!");
    2.  
    3. Villager v = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
    4.  
    5. v.setBaby();
    6.  
    7. v.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 6));
    8. v.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -6));
    9.  
    10. v.setCustomName(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer");
    11. v.setCustomNameVisible(true);
    12.  
    13. v.getEquipment().getItemInHand().setType(Material.GOLD_BARDING);
    14. return true;


    Now here is my full code:
    Code:java
    1. package me.BrushPainter.PBGunShop;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Entity;
    11. import org.bukkit.entity.EntityType;
    12. import org.bukkit.entity.LivingEntity;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.entity.Villager;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    18. import org.bukkit.event.inventory.InventoryClickEvent;
    19. import org.bukkit.event.player.PlayerInteractEntityEvent;
    20. import org.bukkit.inventory.Inventory;
    21. import org.bukkit.inventory.ItemStack;
    22. import org.bukkit.inventory.meta.ItemMeta;
    23. import org.bukkit.plugin.PluginManager;
    24. import org.bukkit.plugin.java.JavaPlugin;
    25. import org.bukkit.potion.PotionEffect;
    26. import org.bukkit.potion.PotionEffectType;
    27.  
    28. public class Main extends JavaPlugin implements Listener{
    29.  
    30. public void onEnable() {
    31.  
    32. PluginManager pm = getServer().getPluginManager();
    33. pm.registerEvents(this, this);
    34.  
    35. getLogger().info("PBGunShop Enabled");
    36.  
    37. }
    38.  
    39. public void onDisable() {
    40.  
    41. getLogger().info("PBGunShop Disabled");
    42.  
    43. }
    44. public static Inventory PaintballGunShop = Bukkit.createInventory(null, 9, "Inventory");
    45.  
    46. ArrayList<String> lore = new ArrayList<String>();
    47.  
    48. @EventHandler
    49. public void onInventoryClick(InventoryClickEvent event) {
    50.  
    51. Player player = (Player) event.getWhoClicked();
    52. Player buyer = (Player) event.getWhoClicked();
    53.  
    54. ItemStack clicked = event.getCurrentItem();
    55. Inventory inventory = event.getInventory();
    56. ItemStack is = new ItemStack(Material.WOOL );
    57. is.setDurability((byte) 14);
    58. ItemMeta im = is.getItemMeta();
    59. im.setDisplayName(ChatColor.DARK_RED + "Close");
    60.  
    61. lore.add(ChatColor.DARK_GRAY + "Closes the PB Shop.");
    62. im.setLore(lore);
    63. is.setItemMeta(im);
    64.  
    65. if (inventory.getName().equals(PaintballGunShop.getName())) {
    66. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Close")) {
    67.  
    68. event.setCancelled(true);
    69. player.closeInventory();
    70.  
    71. }
    72.  
    73. ItemStack fullyauto = new ItemStack(Material.DIAMOND_BARDING, 1);
    74.  
    75. ItemMeta im1 = fullyauto.getItemMeta();
    76. im1.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun");
    77. fullyauto.setItemMeta(im1);
    78. lore.add(ChatColor.WHITE + "500 Coins");
    79. im1.setLore(lore);
    80.  
    81. PaintballGunShop.setItem(0,fullyauto);
    82.  
    83. if (inventory.getName().equals(PaintballGunShop.getName())) {
    84.  
    85. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.AQUA + "" + ChatColor.BOLD + "Fully-Automatic Paintball Gun")) {
    86.  
    87. event.setCancelled(true);
    88. player.closeInventory();
    89.  
    90. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.fullyauto");
    91. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.fullyauto");
    92. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 500");
    93.  
    94. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the fully-auto paintball gun!");
    95. buyer.sendMessage(ChatColor.YELLOW + "You can now use /fullyauto to get your gun!");
    96.  
    97. }
    98.  
    99. ItemStack threeburst = new ItemStack(Material.GOLD_BARDING, 1);
    100.  
    101. ItemMeta im2 = fullyauto.getItemMeta();
    102. im2.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun");
    103. threeburst.setItemMeta(im2);
    104. lore.add(ChatColor.WHITE + "1000 Coins");
    105. im2.setLore(lore);
    106.  
    107. PaintballGunShop.setItem(8,threeburst);
    108.  
    109. if (inventory.getName().equals(PaintballGunShop.getName())) {
    110.  
    111. if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "" + ChatColor.BOLD + "3-Burst Paintball Gun")) {
    112.  
    113. event.setCancelled(true);
    114. player.closeInventory();
    115.  
    116. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " paintballguns.getgun.threeburst");
    117. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + buyer + " -pbgunshop.buy.threeburst");
    118. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco take " + buyer + " 1000");
    119.  
    120. buyer.sendMessage(ChatColor.YELLOW + "Congratulations! You purchased the three-burst paintball gun!");
    121. buyer.sendMessage(ChatColor.YELLOW + "You can now use /threeburst to get your gun!");
    122. }
    123. }
    124. }
    125. }
    126. }
    127.  
    128. ArrayList<String> Damagers = new ArrayList<String>();
    129.  
    130. @EventHandler
    131. public void onEntityDamage(EntityDamageByEntityEvent event) {
    132.  
    133. Player player = (Player) event.getDamager();
    134. LivingEntity entity = (LivingEntity)event.getEntity();
    135. Villager zinc = (Villager) entity;
    136.  
    137. if (entity.getLastDamageCause().getEntity() instanceof Player) {
    138. event.setCancelled(true);
    139.  
    140. } else if
    141. (zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    142. event.setCancelled(true);
    143.  
    144. } else {
    145.  
    146. if(Damagers.contains(player.getName())) {
    147. event.setCancelled(true);
    148.  
    149. }
    150. }
    151. }
    152.  
    153. @EventHandler
    154. public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    155.  
    156. Entity entity = event.getRightClicked();
    157. Villager zinc = (Villager) entity;
    158. Player player = event.getPlayer();
    159.  
    160. if(zinc.getCustomName() != null && zinc.getCustomName().equals(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer")){
    161.  
    162.  
    163. player.openInventory(PaintballGunShop);
    164. }
    165. else{
    166.  
    167. }
    168. }
    169.  
    170. public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args){
    171.  
    172. if (sender instanceof Player) {
    173. if (sender.hasPermission("pbgunshop.spawn")){
    174. if (cmd.getName().equalsIgnoreCase("spbshop")) {
    175.  
    176. Player p = (Player) sender;
    177.  
    178. p.sendMessage(ChatColor.YELLOW + "You have spawned Zinc, The Paintballer!");
    179.  
    180. Villager v = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
    181.  
    182. v.setBaby();
    183.  
    184. v.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 6));
    185. v.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -6));
    186.  
    187. v.setCustomName(ChatColor.BLUE + "" + ChatColor.BOLD + "Zinc - The Paintballer");
    188. v.setCustomNameVisible(true);
    189.  
    190. v.getEquipment().getItemInHand().setType(Material.GOLD_BARDING);
    191. return true;
    192.  
    193. }
    194. }
    195. }
    196. return false;
    197. }
    198. }


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

    timtower Administrator Administrator Moderator

    BrushPainter Or a different plugin is blocking the spawn.
     
  30. Offline

    GameplayJDK

    BrushPainter
    Have you tried to use p.getWorld().spawnCreature(p.getLocation(), EntityType.VILLAGER); ?
    Also use setBaby(true); (I don't think it would make any difference..)
     
Thread Status:
Not open for further replies.

Share This Page