I'm making a list of snippets! Please post some in the comments, ill put them up here. KeybordPiano459 StringBuilder (Make all args one string) (Move your mouse to reveal the content) StringBuilder (Make all args one string) (open) StringBuilder (Make all args one string) (close) StringBuilder str = new StringBuilder(args[0]); for(int i = 1; i < args.length; i++) { str.append(' ').append(args); } Update Notifier (Notify whenever there's an update) (Move your mouse to reveal the content) Update Notifier (Notify whenever there's an update) (open) Update Notifier (Notify whenever there's an update) (close) Replace the comments accordingly, and also in the URL it should be a .txt file and the only thing that should be in it is the version, such as 1.0.4 or 1.3. try { URL url = new URL("THE-URL"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String string; while ((string = in.readLine()) != null) { int current = Integer.parseInt(Bukkit.getServer().getPluginManager().getPlugin("YOUR-PLUGIN").getDescription().getVersion().replace(".", "")); int new = Integer.parseInt(string.replace(".", "")); if (current < new) { // NEW VERSION! } else { // THERE ISNT A NEW VERSION! } } in.close(); } catch (MalformedURLException e) { // URL IS INVALID! } catch (IOException e) { // BAD READ/WRITE! } Lolmewn MySQL Update to MySQL Insert (Move your mouse to reveal the content) MySQL Update to MySQL Insert (open) MySQL Update to MySQL Insert (close) http://dev.bukkit.org/paste/bolr6q3aj9u470i2/[/SPOILER]
Rewriting an MySQL UPDATE statement into a MySQL INSERT statement: http://pastebin.com/ks3FeDGK Not sure if useful to anyone, but cool anyway
Update notifier ^^ Do whatever you want with it, such as on player login send them a message, or anything else
For those out there who use custom files: Code:JAVA public void initializeFile() throws IOException{ File f = new File(yourjavapluginclass.getDataFolder().getAbsoluteFile(), "/somefilename.somefilextension"); File folder = new File(yourjavapluginclass.getDataFolder().getAbsoluteFile().getAbsolutePath()); if(!folder.exists()){ folder.mkdir(); } if(!f.exists()){ f.createNewFile(); } }
Funny how I have a thread just like this and you have the exact same ArgumentCollector (you called it StringBuilder), looks suspicous! http://forums.bukkit.org/threads/useful-awesome-code-snippets.104409
Oops. Well I got it from my plugin and not your thread I can even show you the source code I got it from, it's on Github.
Want to only trigger move events when players move to a new block and not just twitch/look around? Code: public void onPlayerMove(PlayerMoveEvent event) { if(event.isCancelled()==false && (event.getTo().getBlockX() != event.getFrom().getBlockX() || event.getTo().getBlockY() != event.getFrom().getBlockY() || event.getTo().getBlockZ() != event.getFrom().getBlockZ())){ //CODE GOES HERE } }
Method which will change skin of Skull: Code:java public ItemStack setSkin(ItemStack item, String nick){ CraftItemStack craftStack = null; net.minecraft.server.ItemStack itemStack = null; if (item instanceof CraftItemStack) { craftStack = (CraftItemStack) item; itemStack = craftStack.getHandle(); } else if (item instanceof ItemStack) { craftStack = new CraftItemStack(item); itemStack = craftStack.getHandle(); } NBTTagCompound tag = itemStack.tag; if (tag == null) { tag = new NBTTagCompound(); } tag.setString("SkullOwner", nick); itemStack.tag.setCompound("display", tag); itemStack.tag = tag; return craftStack; }