Skip to content

Instantly share code, notes, and snippets.

String message = "This is a test message which should span a pretty bi§ag§2 line. If I keep going like this, maybe it will wrap onto the next one. This assumes that this works, it's possible that it doesn't.";
Pattern linePattern = Pattern.compile(".{1,50}\\b");
Pattern badEnd = Pattern.compile("§[0-F]^");
Matcher matcher = linePattern.matcher(message);
String buffer = "";
while (matcher.find()) {
String line = buffer + matcher.group(0);
Matcher end = badEnd.matcher(line);
if (end.matches()) {
buffer = end.group(0);
package org.bukkit.types.block;
import java.util.HashMap;
import java.util.Map;
/**
* Represents the various types of blocks in a world.
*/
public abstract class BlockType {
public static final BlockType AIR = new BlockTypeWrapper(0);
@Dinnerbone
Dinnerbone / GreetingPlugin.java
Created February 1, 2012 01:59
Might we have made plugins a little too easy? :(
package com.dinnerbone.plugins.greetings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class GreetingPluginextends JavaPlugin implements Listener {
@Override
public void onEnable() {
@Dinnerbone
Dinnerbone / GreetingPlugin.java
Created February 1, 2012 01:59
Might we have made plugins a little too easy? :(
package com.dinnerbone.plugins.greetings;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class GreetingPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
@Dinnerbone
Dinnerbone / Since 1.2.3
Created March 4, 2012 18:16
Bugs I've fixed since 1.2.3!
Fixed:
- Fixed godmode exploit (Thanks md_5)
- Limit framerate on menu screens, no longer uses 100% cpu and make my computer melt
- Fixed fatal crash for converted worlds to anvil, when there's blocks at max height
- Fixed an old bug with signs clearing text while you're editing them in SMP
- Fixed incorrectly swapped en_GB and en_CA language details
- Fixed crash when logging in while there are blocks at maxheight at spawn
- Fixed TNT ghosts in multiplayer
- Fixed storage minecarts dropping enchanted items
- Fixed crashes on invalid server addresses when joining a server
@Dinnerbone
Dinnerbone / gist:2362538
Created April 11, 2012 20:58
Minecraft new world save directory structure
data/
idcounts.dat
map_0.dat
players/
Dinnerbone.dat
cookie_monster.dat
worlds/
overworld/
regions/
r.0.0.mca
@Dinnerbone
Dinnerbone / banned-ips.txt
Created April 19, 2012 17:38
New file formats in 1.3
#Address, Date/Time, Banned By, Until, For
#Exactly the same as banned-players, but with IP addresses.
@Dinnerbone
Dinnerbone / gist:3736487
Created September 17, 2012 09:49
New Minecraft target selector syntax!

Syntax

All target selectors start with @. The following character is the selector type. For example, @p means 'closest player'.

Target selectors may have additional, optional arguments. You can specify these in [ ], using the syntax a=0. For example, @p[a=0,b=5,c=-500].

There is a special short syntax for just specifying x, y, z and r arguments; simply list their values separated by a comma, without x=. For example: @p[100,64,-100,5] for 5 range, x=100, y=64 and z=-100. Each of these are optional and skippable by leaving them empty. For example, to just specify y coordinate: @p[,64].

Global Arguments:

  • x - X coordinate for search center. Default is senders coordinate, or 0.
  • y - Y coordinate for search center. Default is senders coordinate, or 0.
package net.minecraft.launcher.authentication;
import net.minecraft.launcher.Http;
import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@Dinnerbone
Dinnerbone / gist:5631634
Last active May 14, 2020 12:41
New chat system for Minecraft. The server won't translate any text for the client, and there'll be a proper stack based colouring/formatting system, so no more leaking colours, english-only messages, or out of date translations.
{
"color": "yellow",
"translate": "multiplayer.player.joined",
"using": [
"Dinnerbone"
]
}
{
"color": "gray",