Solved Internal Error explanation

Discussion in 'Plugin Development' started by king_of_all96543, Oct 24, 2013.

Thread Status:
Not open for further replies.
  1. Hello guys/ girls i need a quick explanation what may cause an internal error for my commands on my plugin i just want to make sure i stop getting them other then having to redo my whole command so if you would please explain this to me that would be lovely THANKS
     
  2. Offline

    SwiftDev

    That's really not enough data to be working with. Can I get a stack trace and the entire classes source?
     
  3. SwiftDev
    Code:java
    1. package me.toxic.PvP;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Material;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandSender;
    11. import org.bukkit.enchantments.Enchantment;
    12. import org.bukkit.entity.LivingEntity;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.event.EventHandler;
    15. import org.bukkit.event.Listener;
    16. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    17. import org.bukkit.event.entity.PlayerDeathEvent;
    18. import org.bukkit.event.player.PlayerFishEvent;
    19. import org.bukkit.event.player.PlayerJoinEvent;
    20. import org.bukkit.event.player.PlayerQuitEvent;
    21. import org.bukkit.inventory.ItemStack;
    22. import org.bukkit.inventory.PlayerInventory;
    23. import org.bukkit.plugin.java.JavaPlugin;
    24. import org.bukkit.potion.PotionEffect;
    25. import org.bukkit.potion.PotionEffectType;
    26.  
    27. public class pvp extends JavaPlugin implements Listener {
    28.  
    29. List<String> canusekit = new ArrayList<String>();
    30. List<String> fisherman = new ArrayList<String>();
    31. List<String> Ender = new ArrayList<String>();
    32.  
    33. public int chance = 3;
    34. public int length = 5;
    35. public int multiplier = 0;
    36.  
    37. public void onEnable() {
    38. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    39. getLogger().info("ToxicPvP was Enabled!");
    40. }
    41.  
    42. public void onDisable() {
    43. }
    44.  
    45. @EventHandler
    46. public void onPlayerJoin(final PlayerJoinEvent e) {
    47. final Player player = e.getPlayer();
    48. e.setJoinMessage(ChatColor.GREEN + player.getName()
    49. + " Has Joined ToxicPvP!");
    50.  
    51. }
    52.  
    53. @EventHandler
    54. public void onPlayerDeath(PlayerDeathEvent e) {
    55. Player p = e.getEntity();
    56. Player k = e.getEntity().getKiller();
    57. e.setDeathMessage(ChatColor.GREEN + p.getName() + " Was Slain By"
    58. + k.getName());
    59. }
    60.  
    61. @EventHandler
    62. public void onPlayerQuit(PlayerQuitEvent e) {
    63. Player p = e.getPlayer();
    64. e.setQuitMessage(ChatColor.GREEN + p.getName() + " Has Left ToxicPvP!");
    65. }
    66.  
    67. @EventHandler
    68. public void onEntityDamage(EntityDamageByEntityEvent event) {
    69. if (event.isCancelled())
    70. return;
    71. if (event.getDamager() instanceof Player
    72. && event.getEntity() instanceof LivingEntity) {
    73. LivingEntity entity = (LivingEntity) event.getEntity();
    74.  
    75. Player p = (Player) event.getDamager();
    76. entity.addPotionEffect(new PotionEffect(PotionEffectType.POISON,
    77. length * 20, multiplier), true);
    78. }
    79. }
    80.  
    81. @EventHandler
    82. public void onPlayerFish(final PlayerFishEvent event) {
    83. final Player player = event.getPlayer();
    84. if (event.getCaught() instanceof Player) {
    85. final Player caught = (Player) event.getCaught();
    86. if (canusekit.contains(player.getName())) {
    87. if (fisherman.contains(player.getName())) {
    88. if (player.getItemInHand().getType() == Material.FISHING_ROD) {
    89. caught.teleport(player.getLocation());
    90. }
    91. }
    92. }
    93. }
    94. }
    95.  
    96. public boolean onCommand(CommandSender sender, Command cmd,
    97. String commandLabel, String[] args) {
    98. final Player player = (Player) sender;
    99. final PlayerInventory inv = (PlayerInventory) sender;
    100. if (cmd.getName().equalsIgnoreCase("pvp")) {
    101. if (!(player.hasPermission("toxic.pvp"))) {
    102. player.sendMessage(ChatColor.RED
    103. + "You don't have access to this command!");
    104. } else {
    105. if (canusekit.contains(player.getName())) {
    106.  
    107. player.sendMessage(ChatColor.RED
    108. + "You cannot pick a kit Until Death!");
    109. } else {
    110. player.sendMessage(ChatColor.DARK_GRAY
    111. + "You Have Recieved Kit PvP");
    112. player.addPotionEffect(new PotionEffect(
    113. PotionEffectType.INCREASE_DAMAGE, 10000000, 3));
    114. ItemStack pvpsword = new ItemStack(Material.DIAMOND_SWORD);
    115. pvpsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
    116. ItemStack pvphelm = new ItemStack(Material.IRON_HELMET);
    117. pvphelm.addEnchantment(
    118. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    119. ItemStack pvpchest = new ItemStack(Material.IRON_LEGGINGS);
    120. pvpchest.addEnchantment(
    121. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    122. ItemStack pvplegs = new ItemStack(Material.IRON_BOOTS);
    123. pvplegs.addEnchantment(
    124. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    125. ItemStack pvpboots = new ItemStack(Material.IRON_BOOTS);
    126. pvpboots.addEnchantment(
    127. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    128. inv.addItem(new ItemStack[] { pvpsword });
    129. ItemStack[] armor = { pvpboots, pvplegs, pvpchest, pvphelm };
    130. inv.setArmorContents(armor);
    131. for (int i = 0; i < 32; i++)
    132. inv.addItem(new ItemStack[] { new ItemStack(
    133. Material.MUSHROOM_SOUP) });
    134.  
    135. }
    136. }
    137. if (cmd.getName().equalsIgnoreCase("archer")) {
    138. if (!(player.hasPermission("toxic.archer"))) {
    139. player.sendMessage(ChatColor.RED
    140. + "You don't have access to this command!");
    141. } else {
    142. if (canusekit.contains(player.getName())) {
    143.  
    144. player.sendMessage(ChatColor.RED
    145. + "You cannot pick a kit Until Death!");
    146. } else {
    147. canusekit.add(player.getName());
    148. player.sendMessage(ChatColor.DARK_GRAY
    149. + "You Have Recieved Kit Archer");
    150. ItemStack ahelm = new ItemStack(
    151. Material.CHAINMAIL_HELMET);
    152. ahelm.addEnchantment(
    153. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    154. ItemStack achest = new ItemStack(
    155. Material.CHAINMAIL_CHESTPLATE);
    156. achest.addEnchantment(
    157. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    158. ItemStack alegs = new ItemStack(
    159. Material.CHAINMAIL_LEGGINGS);
    160. alegs.addEnchantment(
    161. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    162. ItemStack aboots = new ItemStack(
    163. Material.CHAINMAIL_BOOTS);
    164. aboots.addEnchantment(
    165. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    166. ItemStack[] armor = { aboots, alegs, achest, ahelm };
    167. inv.setArmorContents(armor);
    168. ItemStack abow = new ItemStack(Material.BOW);
    169. abow.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
    170. abow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    171. inv.addItem(new ItemStack[] { abow });
    172. inv.addItem(new ItemStack[] { new ItemStack(
    173. Material.ARROW) });
    174. for (int i = 0; i < 32; i++)
    175. inv.addItem(new ItemStack[] { new ItemStack(
    176. Material.MUSHROOM_SOUP) });
    177. }
    178. }
    179. if (cmd.getName().equalsIgnoreCase("fisherman")) {
    180. if (!(player.hasPermission("toxic.fisherman"))) {
    181. player.sendMessage(ChatColor.RED
    182. + "You don't have access to this command!");
    183. } else {
    184. if (canusekit.contains(player.getName())) {
    185.  
    186. player.sendMessage(ChatColor.RED
    187. + "You cannot pick a kit Until Death!");
    188. } else {
    189. canusekit.add(player.getName());
    190. fisherman.add(player.getName());
    191. player.sendMessage(ChatColor.DARK_GRAY
    192. + "You Have Recieved Kit Fisherman");
    193. ItemStack hel = new ItemStack(
    194. Material.LEATHER_HELMET);
    195. hel.addEnchantment(
    196. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    197. ItemStack achest = new ItemStack(
    198. Material.LEATHER_CHESTPLATE);
    199. achest.addEnchantment(
    200. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    201. ItemStack alegs = new ItemStack(
    202. Material.LEATHER_LEGGINGS);
    203. alegs.addEnchantment(
    204. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    205. ItemStack aboots = new ItemStack(
    206. Material.LEATHER_BOOTS);
    207. aboots.addEnchantment(
    208. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    209. ItemStack[] armor = { aboots, alegs, achest, hel };
    210. inv.setArmorContents(armor);
    211. ItemStack abow = new ItemStack(Material.FISHING_ROD);
    212. abow.addEnchantment(Enchantment.DURABILITY, 5);
    213. inv.addItem(new ItemStack[] { abow });
    214. for (int i = 0; i < 32; i++)
    215. inv.addItem(new ItemStack[] { new ItemStack(
    216. Material.MUSHROOM_SOUP) });
    217. }
    218. }
    219. if (cmd.getName().equalsIgnoreCase("viper")) {
    220. if (!(player.hasPermission("toxic.viper"))) {
    221. player.sendMessage(ChatColor.RED
    222. + "You don't have access to this command!");
    223. } else {
    224. if (canusekit.contains(player.getName())) {
    225.  
    226. player.sendMessage(ChatColor.RED
    227. + "You cannot pick a kit Until Death!");
    228. } else {
    229. canusekit.add(player.getName());
    230. fisherman.add(player.getName());
    231. player.sendMessage(ChatColor.DARK_GRAY
    232. + "You Have Recieved Kit Viper");
    233. ItemStack hel = new ItemStack(
    234. Material.LEATHER_HELMET);
    235. hel.addEnchantment(
    236. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    237. ItemStack achest = new ItemStack(
    238. Material.LEATHER_CHESTPLATE);
    239. achest.addEnchantment(
    240. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    241. ItemStack alegs = new ItemStack(
    242. Material.LEATHER_LEGGINGS);
    243. alegs.addEnchantment(
    244. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    245. ItemStack aboots = new ItemStack(
    246. Material.LEATHER_BOOTS);
    247. aboots.addEnchantment(
    248. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    249. ItemStack[] armor = { aboots, alegs, achest,
    250. hel };
    251. inv.setArmorContents(armor);
    252. ItemStack abow = new ItemStack(
    253. Material.STONE_SWORD);
    254. abow.addEnchantment(Enchantment.DURABILITY, 1);
    255. inv.addItem(new ItemStack[] { abow });
    256. for (int i = 0; i < 32; i++)
    257. inv.addItem(new ItemStack[] { new ItemStack(
    258. Material.MUSHROOM_SOUP) });
    259. }
    260. }
    261. }
    262. }
    263. }
    264. }
    265. return false;
    266. }
    267. }
     
  4. Offline

    mattrick

    Do you have the stack trace? I think it as something to do with your damage resistance 1000000...
     
  5. Offline

    SwiftDev

    Well firstly in your code here:
    Code:java
    1. public void onEntityDamage(EntityDamageByEntityEvent event) {
    2. if (event.isCancelled())
    3. return;

    returning anything doesn't make sense considering it's a void method.
    Other than that niggle I don't see any outstanding issues, can I get a stacktrace/error log?

    Yeah, that doesn't sound quite tangible..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  6. mattrick16 did i make it to long i didnt know how many 0's to make it infinite
     
  7. Offline

    mattrick

    Integer.MaxValue I think. Give us the stack trace it is easier....
     
  8. Offline

    SwiftDev

    Kinda.. Because of the way MC handles potion timers Integer.MaxValue will only stay for around 16 hours(according to my tests) before wearing off, not entirely infinite, but unless players are AFKing for inane amounts of time you should encounter any issues
     
  9. Offline

    maxben34

    In case you didn't know the stack trace is the error lines in your console. If you paste that here, we could decipher your problem better and likely come up with a solution.
     
  10. maxben34 ok but i think i fixed thanks though
     
Thread Status:
Not open for further replies.

Share This Page