Skip to content

Instantly share code, notes, and snippets.

public Inventory getTeamChoosingInv(){
Inventory i = Bukkit.createInventory(null, 9, "§6§l Choose Teams");
ItemStack star = new ItemStack(Material.NETHER_STAR, 1);
ItemMeta starMeta = star.getItemMeta();
starMeta.setDisplayName("§lAuto Join");
star.setItemMeta(starMeta);
i.setItem(2, star);
ItemStack red = new ItemStack(Material.WOOL, 1, (byte) 14);
public static ItemStack createItem(Material m, int amount, byte data, String name, String... lore){
ItemStack item = new ItemStack(m, amount, data);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
List<String> list = new ArrayList<String>();
for(String l : lore)
list.add(l);
meta.setLore(list);
item.setItemMeta(meta);
return item;
@EventHandler
public void invClick(InventoryClickEvent e){
if(e.getInventory().getItem(16).getType() == Material.WOOD_PICKAXE &&
e.getCurrentItem().getType() == Material.WOOL &&
e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("Next Page")){
e.setCancelled(true);
((Player)e.getWhoClicked()).openInventory(getRecipeLookupInventory(new ItemStack(Material.WOOD_AXE)));
}
}
@phase
phase / Kill Streaks
Created July 24, 2014 01:54
Kill Streaks up to 20
private String getKillStreak(int score) {
switch(score){
case 2: return "Double";
case 3: return "Triple";
case 4: return "Quadruple";
case 5: return "Penta";
case 6: return "Hexa";
case 7: return "Hepta";
case 8: return "Octo";
case 9: return "Ennea";
@phase
phase / GetFile.js
Last active August 29, 2015 14:13
The following code retrieves the file called "log.txt", its contents are read using the FileReader API and appended to a new <textarea> on the page. If log.txt doesn't exist, an error is thrown.
// Note: The file system has been prefixed as of Google Chrome 12:
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
function errorHandler(e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
@phase
phase / getSiteContents.java
Created January 23, 2015 01:32
Gets the contents of a site.
URL url = new URL("http://www.website.com/");
BufferedReader br = new BufferedReader(
new InputStreamReader(
url .openStream()));
String line;
String contents;
while ((line= br.readLine()) != null)
contents += line + "\n";
@phase
phase / generatePassword.java
Last active August 29, 2015 14:14
Instead of random number generation, use this. It's a LITTLE more secure.
//Make static if going to be used static, but you might want to put the Random instance outside the class
public String generatePassword(int characterLimit){
Random r = new Random(); //New Random instance
String u = UUID.randomUUID().toString().replaceAll("-", ""); //Get random Base64 string from a random UUID
return u.substring(0, r.getNetInt(characterLimit-3)+3); //Returns a substring of the UUID
}
@phase
phase / MultiMap.java
Last active August 29, 2015 14:15
A multidimensional map (made a class cause easy implementation)
public class MultiMap<J, K, L>{
private HashMap<J, L> m1;
private HashMap<K, L> m2;
public MultiMap(){
m1 = new HashMap<J, L>();
m2 = new HashMap<K, L>();
}
@phase
phase / FiddBudd.java
Last active August 29, 2015 14:16
The easiest thing I've ever made....
public class FiddBudd{
public static void main(String... args){
for(int i = 1; i <= 100; i++){
if(i % 4 == 0 && i % 6){
System.out.println("FiddBudd");
}
else if(i % 4 == 0){
System.out.println("Fidd");
}
@phase
phase / minigame.md
Created May 24, 2015 03:57
How to make a Bukkit Minigame

#How to make a Bukkit minigame This is a tutorial on how to make a Bukkit minigame plugin for 1.7/1.8. You should have some basic knowledge of Java, OOP, and Bukkit.

##Arenas Arenas are the base to any minigame (unless you only want one instance of the game). These can be implemented in many different ways, but my favorite is to have an Arena class with a static ArrayList<Arena> inside it.

public class Arena {
  //global list
 private static ArrayList arenaList = new ArrayList();