Skip to content

Instantly share code, notes, and snippets.

"""
Helpers to define enumeration classes.
An enumeration is a "namespace" or "class" of constants that define a number
of values within that namespace that are canonical or descriptive, and usually
represent the full range of possible values within that realm. This allows for
having more descriptive and clear code and also helps prevent errors due to
mis-spelling of constants.
Simple Example::
class MyPlugin {
public boolean onCommand(CommandSender sender, Command cmd,
String commandLabel, String[] args) {
if (args[0].equals("eat")) {
// do something
return false; // wait is it false or true?
} else if (args[0].equals("sleep")) {
// do something else
} else if (args[0].equals("code")) {
// I'm getting tired of else ifs :(
package org.bukkit.craftbukkit.metadata;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.Validate;
class CraftServer {
/** etc */
public boolean registerPlayerMetadataProvider(String metadataKey, MetadataProvider<OfflinePlayer> provider) {
return playerMetadata.registerProvider(metadataKey, provider);
}
public boolean registerWorldMetadataProvider(String metadataKey, MetadataProvider<World> provider) {
return worldMetadata.registerProvider(metadataKey, provider);
}
package us.crast.mondochest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import org.bukkit.util.BlockVector;
import us.crast.utils.CollectionUtil;
@crast
crast / gist:5024885
Created February 24, 2013 18:13
Results from running static-metadata-perf-tests bukkit branch on Linux (x86_64) and Java JDK7u15
FixedMetadataValue:
phase1: 143 MB
phase2: 214 MB
StaticMetadataValue:
phase1: 70 MB
phase2: 70 MB
Testing value FixedMetadataValue: 10000000 iterations
public @interface Sub {
String name();
String description();
String usage();
int minArgs() default 0;
boolean allowConsole() default true;
}
@crast
crast / config.yml
Created August 5, 2012 08:20
MineralManager example Configuration
######### MineralManager 2.1 config
# The DEFAULT section sets the defaults for the application.
DEFAULT:
# If true, only applies to blocks which were there, not placed.
mineOriginalOnly: false
# If true, you need the MineralManager.User permission for mining
# to cause respawn.
usePermissions: false
class Form(object):
def __init__(self):
print "Form init called"
class SessionSecureForm(Form):
def __init__(self):
print "SessionSecureForm about to call super"
super(SessionSecureForm, self).__init__()
print "SessionSecureForm returned from super"
#!/bin/bash
# Test Edit
# Builds and installs the python bindings for protobuf
# If $INSTALL_PROTOC is set, also installs the protobuf lib and
# The protobuf tools. Set $PROTOC_PREFIX to customise that.
#
# To install to a virtualenv, pass the path to the virtualenv as
# the first argument to this script:
# $ install_protobuf.sh $HOME/live/python_env