Hello i am remaking the plugin bananaprotect and i got stuck on a bug can any one help me, thanks. This is the class file Protection Code:java package me.nick.plugins.myblocks; import java.io.File;import java.util.ArrayList;import org.bukkit.ChatColor;import org.bukkit.Chunk;import org.bukkit.Location;import org.bukkit.World;import org.bukkit.block.Block;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.event.Event;import org.bukkit.plugin.PluginDescriptionFile;import org.bukkit.plugin.PluginManager;import org.bukkit.util.config.Configuration; public class Protection extends org.bukkit.plugin.java.JavaPlugin{ AntiGrief playerListener = new AntiGrief(this); EntityHandler playerInteract = new EntityHandler(this); ArrayList<String> exempt = new ArrayList(); ArrayList<String> exemptWorlds = new ArrayList(); public void onDisable() { PluginDescriptionFile pdfFile = getDescription(); System.out.println("[" + pdfFile.getName() + "]" + " version " + pdfFile.getVersion() + " is now disabled!"); } public Location getNextAirSpace(Location blockloc) { Location blockl = blockloc; Location blockl2 = blockl; for (int i = blockloc.getBlockY(); i < 127; i++) { blockl.setY(i); blockl2.setY(i + 1); if ((blockl.getBlock().getTypeId() == 0) && (blockl2.getBlock().getTypeId() == 0)) { return blockl; } } return null; } public String[] whoPlaced(Block block, File pluginpath) { World world = block.getWorld(); Chunk chunk = world.getChunkAt(block.getLocation()); String cname = String.valueOf(chunk.getX()) + "." + chunk.getZ() + ".yml"; String cpath = String.valueOf(block.getLocation().getBlockX()) + "," + block.getLocation().getBlockY() + "," + block.getLocation().getBlockZ(); Configuration pC = getConfig(new File(pluginpath + "/" + cname)); String[] strings = { pC.getString(String.valueOf(cpath) + ".player", ""), pC.getString(String.valueOf(cpath) + ".type", "") }; return strings; } protected Configuration getConfig(File filepath) { if (!filepath.exists()) { try { filepath.createNewFile(); } catch (java.io.IOException e) { e.printStackTrace(); } } Configuration c = new Configuration(filepath); c.load(); return c; } public void onEnable() { Configuration c = getConfiguration(); c.load(); c.setProperty("worlds." + ((World)getServer().getWorlds().get(0)).getName(), Boolean.valueOf(c.getBoolean("worlds." + ((World)getServer().getWorlds().get(0)).getName(), true))); c.save(); PluginDescriptionFile pdfFile = getDescription(); PluginManager pm = getServer().getPluginManager(); pm.registerEvent(Event.Type.BLOCK_PLACE, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PHYSICS, this.playerListener, Event.Priority.Low, this); pm.registerEvent(Event.Type.BLOCK_BREAK, this.playerListener, Event.Priority.High, this); pm.registerEvent(Event.Type.BLOCK_DAMAGE, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_IGNITE, this.playerListener, Event.Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerInteract, Event.Priority.Normal, this); System.out.println("[" + pdfFile.getName() + "]" + " version " + pdfFile.getVersion() + " is now enabled!"); if (!pdfFile.getName().equalsIgnoreCase("MyBlocks")) { System.err.print("This plugin was stolen. Report it to 544nick101"); System.exit(-1); } } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if ((cmd.getName().equalsIgnoreCase("addfriend")) && ((sender instanceof Player)) && (args.length == 1)) { Player player = (Player)sender; Configuration pC = getConfiguration(); pC.setProperty("allow." + player.getName() + "." + args[0].toLowerCase(), Boolean.valueOf(true)); pC.save(); sender.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + args[0] + " added to friend list."); return true; } if ((cmd.getName().equalsIgnoreCase("removefriend")) && ((sender instanceof Player)) && ((sender instanceof Player)) && (args.length == 1)) { Player player = (Player)sender; Configuration pC = getConfiguration(); pC.removeProperty("allow." + player.getName() + "." + args[0].toLowerCase()); try { pC.save(); } catch (Exception e) { System.err.print(String.valueOf(player.getName()) + " cannot type properly."); System.err.print(e); } sender.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + args[0] + " removed from friend list."); return true; } if ((cmd.getName().equalsIgnoreCase("protection")) && ((sender instanceof Player))) { Player player = (Player)sender; String name = player.getName(); if (this.exempt.contains(name)) { sender.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "Your protection has been toggled on."); this.exempt.remove(name); return true; } sender.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "You protection has been toggled off."); this.exempt.add(name); return true; } if (cmd.getName().equalsIgnoreCase("rollback")) { if ((sender instanceof Player)) { Player player = (Player)sender; if ((player.hasPermission("myblocks.rollback")) || (player.isOp())) { System.out.println(String.valueOf(player.getName()) + " used command /rollback at coordinates " + player.getLocation().getBlockX() + "," + player.getLocation().getBlockY() + "," + player.getLocation().getBlockZ()); if (args.length == 2) { int radius = Integer.parseInt(args[0]); if (radius > 10) radius = 10; File pluginpath = new File("plugins/MyBlocks"); Chunk chunk = player.getWorld().getChunkAt( player.getLocation()); int chunkX = chunk.getX(); int chunkZ = chunk.getZ(); int count = 0; for (int x = 0 - radius; x < radius; x++) { for (int z = 0 - radius; z < radius; z++) { String cname = String.valueOf(chunkX + x) + "." + ( chunkZ + z) + ".yml"; Configuration pC = getConfig(new File( pluginpath + "/" + player.getWorld().getName() + "/" + cname)); for (String key : pC.getKeys()) { String playername = pC.getString(String.valueOf(key) + ".player", ""); if (playername.equalsIgnoreCase(args[1])) { String[] locXYZ = key.split(","); count++; Block block = player .getWorld() .getBlockAt( Integer.parseInt(locXYZ[0]), Integer.parseInt(locXYZ[1]), Integer.parseInt(locXYZ[2])); if (block.getY() < 63) block.setTypeId(1); if (block.getY() == 63) block.setTypeId(2); if (block.getY() > 63) block.setTypeId(0); pC.removeProperty(key); } } pC.save(); } } sender.sendMessage(ChatColor.DARK_RED + "[Note] " + " changes have been rolled back."); return true; } if (args.length == 3) { int radius = Integer.parseInt(args[0]); if (radius > 10) radius = 10; File pluginpath = new File("plugins/CreativeBlocks"); Chunk chunk = player.getWorld().getChunkAt( player.getLocation()); int chunkX = chunk.getX(); int chunkZ = chunk.getZ(); int count = 0; for (int x = 0 - radius; x < radius; x++) { for (int z = 0 - radius; z < radius; z++) { String cname = String.valueOf(chunkX + x) + "." + ( chunkZ + z) + ".yml"; Configuration pC = getConfig(new File( pluginpath + "/" + cname)); for (String key : pC.getKeys()) { String playername = pC.getString(String.valueOf(key) + ".player", ""); String blocktype = pC.getString(String.valueOf(key) + ".type", ""); if ((playername.equalsIgnoreCase(args[1])) && (blocktype.equals(args[2]))) { String[] locXYZ = key.split(","); count++; Block block = player .getWorld() .getBlockAt( Integer.parseInt(locXYZ[0]), Integer.parseInt(locXYZ[1]), Integer.parseInt(locXYZ[2])); if (block.getY() < 63) block.setTypeId(1); if (block.getY() == 63) block.setTypeId(2); if (block.getY() > 63) block.setTypeId(0); pC.removeProperty(key); } } pC.save(); } } sender.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + count + " changes have been rolled back."); return true; } return false; } sender.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "You don't have permission to use this command."); return true; } return false; } if (cmd.getName().equalsIgnoreCase("regen")) { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.DARK_RED + "You have to be a player to use this command."); return true; } Player player = (Player)sender; if ((player.hasPermission("myblocks.regen")) || (player.isOp())) { player.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "Regenerating chunk..."); player.getWorld().regenerateChunk( player.getWorld().getChunkAt(player.getLocation()) .getX(), player.getWorld().getChunkAt(player.getLocation()) .getZ()); return true; } player.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "You don't have permission to use this command."); return true; } return false; }} This is the class file EntityHandler Code:java package me.nick.plugins.myblocks; import java.io.File;import org.bukkit.ChatColor;import org.bukkit.Material;import org.bukkit.entity.Player;import org.bukkit.event.block.Action;import org.bukkit.event.player.PlayerInteractEvent; public class EntityHandler extends org.bukkit.event.player.PlayerListener{ private final Protection plugin; public EntityHandler(Protection callbackPlugin) { this.plugin = callbackPlugin; } public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); File pluginpath = new File("plugins/MyBlocks"); if ((event.getAction() == Action.LEFT_CLICK_BLOCK) || (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getClickedBlock().getType()==Material.CHEST || event.getClickedBlock().getType()==Material.FURNACE || event.getClickedBlock().getType()==Material.DISPENSER || event.getClickedBlock().getType()==Material.JUKEBOX || event.getClickedBlock().getType()==Material.CAKE)) { if ((event.getClickedBlock().getType() != Material.LEVER) && (event.getClickedBlock().getType() != Material.STONE_BUTTON) && (event.getClickedBlock().getTypeId() != 64)) { if ((event.getClickedBlock().getTypeId() == 71) || (event.getClickedBlock().getType() == Material.CHEST) || (event.getClickedBlock().getType() == Material.FURNACE) || (event.getClickedBlock().getType() == Material.DISPENSER || event.getClickedBlock().getType()==Material.JUKEBOX || event.getClickedBlock().getType()==Material.CAKE)) { if ((!player.hasPermission("myblocks.admin")) && (!player.isOp())) { String[] whostuff = this.plugin.whoPlaced(event.getClickedBlock(), new File(pluginpath + "/" + event.getClickedBlock().getWorld().getName() + "/")); String whoplaced = whostuff[0]; if (whoplaced.length() > 0) { if (!whoplaced.equals(player.getName())) { player.sendMessage(ChatColor.DARK_RED + "That " + ChatColor.DARK_RED + "is locked with a magical spell."); event.setCancelled(true); } } } } } } if (((player.hasPermission("myblocks.admin")) || (player.isOp())) && (event.getAction() == Action.RIGHT_CLICK_BLOCK) && (player.getItemInHand().getType() == Material.IRON_PICKAXE)) { String[] whostuff = this.plugin.whoPlaced(event.getClickedBlock(), new File(pluginpath + "/" + player.getWorld().getName())); String whoplaced = whostuff[0]; if (whoplaced.length() == 0) player.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "The block at " + event.getClickedBlock().getLocation().getBlockX() + "," + event.getClickedBlock().getLocation().getBlockY() + "," + event.getClickedBlock().getLocation().getBlockZ() + " is native."); else { player.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "The " + event.getClickedBlock().getType().name().toLowerCase().replace("_", " ") + " at " + event.getClickedBlock().getLocation().getBlockX() + "," + event.getClickedBlock().getLocation().getBlockY() + "," + event.getClickedBlock().getLocation().getBlockZ() + " was placed by " + whoplaced + "."); } } }} This is the class file AntiGrief Code:java package me.nick.plugins.myblocks; import java.io.File;import org.bukkit.ChatColor;import org.bukkit.Chunk;import org.bukkit.Material;import org.bukkit.World;import org.bukkit.block.Block;import org.bukkit.entity.Player;import org.bukkit.event.block.BlockBreakEvent;import org.bukkit.event.block.BlockPlaceEvent;import org.bukkit.util.config.Configuration; public class AntiGrief extends org.bukkit.event.block.BlockListener{ private final Protection plugin; private final String pluginpath = "plugins/MyBlocks"; public AntiGrief(Protection callbackPlugin) { this.plugin = callbackPlugin; } { } public void onBlockBreak(BlockBreakEvent event) { if (!this.plugin.getConfiguration().getBoolean("worlds." + event.getBlock().getWorld().getName(), true)) { return; } Player player = event.getPlayer(); if ((!player.hasPermission("myblocks.admin")) && (!player.isOp())) { Block block = event.getBlock(); World world = block.getWorld(); File worldpath = new File("plugins/MyBlocks/" + world.getName()); Chunk chunk = world.getChunkAt(block.getLocation()); String cname = String.valueOf(chunk.getX()) + "." + chunk.getZ() + ".yml"; String cpath = String.valueOf(block.getLocation().getBlockX()) + "," + block.getLocation().getBlockY() + "," + block.getLocation().getBlockZ(); String cpath2 = String.valueOf(block.getLocation().getBlockX()) + "," + (block.getLocation().getBlockY() + 1) + "," + block.getLocation().getBlockZ(); Configuration pC = this.plugin.getConfig(new File(worldpath + "/" + cname)); if ((!this.plugin.getConfiguration().getBoolean("allow." + pC.getString(new StringBuilder(String.valueOf(cpath)).append(".player").toString(), "") + "." + player.getName().toLowerCase(), false)) && (pC.getString(String.valueOf(cpath) + ".player", "").length() > 0)) { if ((!pC.getString(String.valueOf(cpath) + ".player", "").equals(player.getName())) && (pC.getString(String.valueOf(cpath) + ".player", "").length() != 0)) { event.setCancelled(true); } else if ((block.getRelative(0, 1, 0).getTypeId() == 71) || (block.getRelative(0, 1, 0).getTypeId() == 64)) if ((!pC.getString(String.valueOf(cpath2) + ".player", "").equals(player.getName())) && (pC.getString(String.valueOf(cpath2) + ".player", "").length() != 0)) { event.setCancelled(true); } else { pC.removeProperty(cpath); pC.save(); } } } } public void onBlockPlace(BlockPlaceEvent event) { if (event.getBlock().getType() == Material.SAPLING) { return; } if (!this.plugin.getConfiguration().getBoolean("worlds." + event.getBlock().getWorld().getName(), true)) { return; } if (!this.plugin.exempt.contains(event.getPlayer().getName())) { Player player = event.getPlayer(); if (((player.hasPermission("myblocks.admin")) || (player.isOp())) && (event.getBlock().getTypeId() == 95)) { event.setCancelled(true); String[] whostuff = this.plugin.whoPlaced(event.getBlock().getLocation().getBlock(), new File("plugins/BananaProtect/" + player.getWorld().getName())); String whoplaced = whostuff[0]; if (whoplaced.length() == 0) player.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "The block at " + event.getBlock().getLocation().getBlockX() + "," + event.getBlock().getLocation().getBlockY() + "," + event.getBlock().getLocation().getBlockZ() + " is native."); else { player.sendMessage(ChatColor.DARK_RED + "[Note] " + ChatColor.DARK_BLUE + "The " + Material.getMaterial(Integer.parseInt(whostuff[1])).name().toLowerCase().replace("_", " ") + " at " + event.getBlock().getLocation().getBlockX() + "," + event.getBlock().getLocation().getBlockY() + "," + event.getBlock().getLocation().getBlockZ() + " was placed by " + whoplaced + "."); } } else if (event.getBlock().getTypeId() == 52) { if ((!player.hasPermission("myblcks.admin")) && (!player.isOp())) event.setCancelled(true); } else { Block block = event.getBlock(); World world = block.getWorld(); File worldpath = new File("plugins/MyBlocks/" + world.getName()); Chunk chunk = world.getChunkAt(block.getLocation()); String cname = String.valueOf(chunk.getX()) + "." + chunk.getZ() + ".yml"; String cpath = String.valueOf(block.getLocation().getBlockX()) + "," + block.getLocation().getBlockY() + "," + block.getLocation().getBlockZ(); if (!worldpath.exists()) worldpath.mkdir(); Configuration pC = this.plugin.getConfig(new File(worldpath + "/" + cname)); pC.setProperty(String.valueOf(cpath) + ".player", player.getName()); pC.setProperty(String.valueOf(cpath) + ".type", Integer.valueOf(event.getBlock().getTypeId())); if ((block.getTypeId() == 71) || (block.getTypeId() == 64)) { String cpath2 = String.valueOf(block.getLocation().getBlockX()) + "," + (block.getLocation().getBlockY() + 1) + "," + block.getLocation().getBlockZ(); pC.setProperty(String.valueOf(cpath2) + ".player", player.getName()); pC.setProperty(String.valueOf(cpath2) + ".type", Integer.valueOf(event.getBlock().getTypeId())); } pC.save(); } } if (event.getBlock().getType() == Material.CHEST) { Block chest = event.getBlock(); Block closeby1 = chest.getRelative(-1, 0, 0); Block closeby2 = chest.getRelative(1, 0, 0); Block closeby3 = chest.getRelative(0, 0, 1); Block closeby4 = chest.getRelative(0, 0, -1); World world = chest.getWorld(); Player player = event.getPlayer(); File worldpath = new File("plugins/MyBlocks/" + world.getName()); Chunk chunk = world.getChunkAt(chest.getLocation()); String cname = String.valueOf(chunk.getX()) + "." + chunk.getZ() + ".yml"; String cpath = String.valueOf(closeby1.getLocation().getBlockX()) + "," + closeby1.getLocation().getBlockY() + "," + closeby1.getLocation().getBlockZ(); String cpath1 = String.valueOf(closeby2.getLocation().getBlockX()) + "," + closeby2.getLocation().getBlockY() + "," + closeby2.getLocation().getBlockZ(); String cpath2 = String.valueOf(closeby3.getLocation().getBlockX()) + "," + closeby3.getLocation().getBlockY() + "," + closeby3.getLocation().getBlockZ(); String cpath3 = String.valueOf(closeby4.getLocation().getBlockX()) + "," + closeby4.getLocation().getBlockY() + "," + closeby4.getLocation().getBlockZ(); if (!worldpath.exists()) worldpath.mkdir(); Configuration pC = this.plugin.getConfig(new File(worldpath + "/" + cname)); if ((!this.plugin.getConfiguration().getBoolean("allow." + pC.getString(new StringBuilder(String.valueOf(cpath)).append(".player").toString(), "") + "." + player.getName().toLowerCase(), false)) && (pC.getString(String.valueOf(cpath) + ".player", "").length() > 0)) { if ((!pC.getString(String.valueOf(cpath) + ".player", "").equals(player.getName())) && (pC.getString(String.valueOf(cpath) + ".player", "").length() != 0)) event.setCancelled(true); } if ((!this.plugin.getConfiguration().getBoolean("allow." + pC.getString(new StringBuilder(String.valueOf(cpath1)).append(".player").toString(), "") + "." + player.getName().toLowerCase(), false)) && (pC.getString(String.valueOf(cpath1) + ".player", "").length() > 0)) { if ((!pC.getString(String.valueOf(cpath1) + ".player", "").equals(player.getName())) && (pC.getString(String.valueOf(cpath1) + ".player", "").length() != 0)) event.setCancelled(true); } if ((!this.plugin.getConfiguration().getBoolean("allow." + pC.getString(new StringBuilder(String.valueOf(cpath2)).append(".player").toString(), "") + "." + player.getName().toLowerCase(), false)) && (pC.getString(String.valueOf(cpath2) + ".player", "").length() > 0)) { if ((!pC.getString(String.valueOf(cpath2) + ".player", "").equals(player.getName())) && (pC.getString(String.valueOf(cpath2) + ".player", "").length() != 0)) event.setCancelled(true); } if ((!this.plugin.getConfiguration().getBoolean("allow." + pC.getString(new StringBuilder(String.valueOf(cpath3)).append(".player").toString(), "") + "." + player.getName().toLowerCase(), false)) && (pC.getString(String.valueOf(cpath3) + ".player", "").length() > 0)) { if ((!pC.getString(String.valueOf(cpath3) + ".player", "").equals(player.getName())) && (pC.getString(String.valueOf(cpath3) + ".player", "").length() != 0)) event.setCancelled(true); } if ((closeby1.getType() != Material.CHEST) && (closeby2.getType() != Material.CHEST) && (closeby3.getType() != Material.CHEST)) closeby4.getType(); } }} This is the plugin.yml Code: name: MyBlocks author: 544nick101 website: http://nickcraftsmp.weebly.com/ description: MyBlocks - Protects every block any one places main: me.plugins.nick.myblocks.Protection version: 1.0 load: startup commands: addfriend: description: Lets you add people. usage: <command> playername removefriend: description: Lets you remove people. usage: <command> playername rollback: description: Lets you rollback a player. usage: <command> chunks name (type id) protection: description: Toggles your block protection. usage: <command> regen: description: Regernates a chunck. usage: <command>
Gets a error on start up Code: [SEVERE] Could not load 'plugins\MyBlocks.jar' in folder 'plugins': java.lang.ClassNotFoundException: nickcraftsmp.net.Protection at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) And there is yellow errors in eclipse
You don't have a class called "Protection". [SEVERE] Could not load 'plugins\MyBlocks.jar' in folder 'plugins': java.lang.ClassNotFoundException: nickcraftsmp.net.Protection
But i do... Can you copy and paste my code in your eclipse and see if you can fix it?(If you do ill make sure to list you as a myblocks author.) EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I have every thing clicked but .settings And do yellow errors mean anything?(Sorry i'm kinda a noob to java) EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Ok now i get this error(its called myblock1 becuse i can't have 2 named my blocks) Code: [SEVERE] Error occurred while enabling MyBlocks1 v1.0 (Is it up to date?): Index: 0, Size: 0 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at com.nick.myblocks.Protection.onEnable(Protection.java:81) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:188) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:968) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:280) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:186) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:169) at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:128) at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52) at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399) at net.minecraft.server.ThreadServerApplication.run(SourceFile:457) They are(its not my first plugin, lol...) And i am using the newest RB of bukkit EDIT by Moderator: merged posts, please use the edit button instead of double posting.
When you initialized the ArrayList fields exempt and exemptWorlds you left off the second <String> For example: Replace this: Code:java ArrayList<String> exempt=new ArrayList(); With this: Code:java ArrayList<String> exempt=new ArrayList<String>();
Did that still getting Code: [SEVERE] Error occurred while enabling MyBlocks1 v1.0 (Is it up to date?): Index: 0, Size: 0 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at com.nick.myblocks.Protection.onEnable(Protection.java:81) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:188) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:968) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:280) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:186) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:169) at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:128) at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52) at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399) at net.minecraft.server.ThreadServerApplication.run(SourceFile:457) Yeah i know i just want to do this quick....
spacing? Also, you should probably tell him where he puts the ; before the () so that he can fix the problem, right?
Not understanding stuff is NOT quick at all. For example, that error you're getting says exacly what's wrong with your code. You're using get(0) on a array that has 0 records, meaning you can't use get() on it ! Find where you're using get() without checking if size() > 0. EDIT: @tomjw64 He posted another reply just before mine but then he deleted it, he wrote something about what to do between: Code: ArrayList<String> exempt=new ArrayList<String>;() // that's how he wrote it // or ArrayList<String> exempt = new ArrayList<String>;() And that's why I posted that and it was addressed to him, not you ... confusion on deleted posts I should probably delete mine too
I deleted it because i realized it was a stupid question. So if i'm hearing you right my code should be Code: ArrayList<String> exempt = new ArrayList<String>; I'm not that sure.... Sorry for me not knowing much(if anything) about java. Any good guides on java? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Books work great. And no, keep it like i said, it was just a misunderstanding. Also, many of these things could be fixed by using a decent IDE. There are some good AND free ones out there. @Digi Sorry for the misunderstanding
Your not that sure how to construct objects? Lets go over basic Java. Declaring a variable of type 'ArrayList of String' Code: ArrayList<String> list; Initializing the variable with a new ArrayList of String Code: list = new ArrayList<String>(); Initializing the variable with a new ArrayList of String with an initial capacity of 10 Code: list = new ArrayList<String>(10); If you want you can declare and initialize in one line. Code: ArrayList<String> list = new ArrayList<String>();
Well this is the code i have Code: ArrayList<String> exempt = new ArrayList<String>(); Isn't that whats suppose to be there?