Skip to content

Instantly share code, notes, and snippets.

View justisr's full-sized avatar
💭
Processing

Justis R justisr

💭
Processing
  • BuiltByBit
  • United States
View GitHub Profile
@justisr
justisr / Maze.java
Last active December 4, 2015 19:19
I don't even know what this is. :/ But I've got it.
public class Maze {
public static void main(String[] args){
int width = 100;
int height = 40;
Room[][] maze = new Maze().generateMaze(width, height);
for(int i = 0; i < width; i++){
System.out.print(" _");
@justisr
justisr / JsonMessage.java
Last active July 27, 2021 13:32
Send json messages to a player.
//Created by Justis Root. Released into the public domain.
//https://gist.github.com/justisr/7a7449adac931a066c51/
//
//Source is licensed for any use, provided that this copyright notice is retained.
//Modifications not expressly accepted by the author should be noted in the license of any forks.
//No warranty for any purpose whatsoever is implied or expressed,
//and the author shall not be held liable for any losses, direct or indirect as a result of using this software.
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@justisr
justisr / ActionBar.java
Last active August 7, 2016 13:49
Send messages to the player's action bar.
package com.justisroot.actionutil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public abstract class ActionBar {
public static Class<?> getNmsClass(String nmsClassName) throws ClassNotFoundException {
return Class.forName("net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3] + "." + nmsClassName);
}
@justisr
justisr / TimeUnit.java
Last active December 16, 2015 13:37
Convert a single number into a readable, formatted time stamp, and back again.
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public enum TimeUnit {
SEC("second", 1, 's'),
MIN("minute", 60, 'm'),
HOUR("hour", 3600, 'h'),
@justisr
justisr / Pane.java
Last active December 26, 2015 23:32
Simple stained glass pain enum for all the available colors.
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public enum Pane {
WHITE(0),
ORANGE(1),
LIGHT_PURPLE(2),
LIGHT_BLUE(3),
YELLOW(4),
LIGHT_GREEN(5),
@justisr
justisr / BungeeCom.java
Last active April 14, 2021 20:37
Bungee communications wrapper util
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@justisr
justisr / PotionResults.java
Last active August 7, 2016 14:02
A single method util for getting the resulting potion from a potion brew
@EventHandler
public void brew(BrewEvent e) {
ItemStack[] contents = e.getContents().getContents();
for (int i = 2; i >= 0; i--) {
PotionType type = result(contents[i], contents[3]);
if (type == null) continue;
}
}
private static PotionType result(ItemStack potion, ItemStack ing) {
@justisr
justisr / TitleUpdater.java
Last active July 6, 2023 03:26
Update an inventory name while opened without NMS
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.gmail.justisroot.autoecon.data.ServerSpecs;
//Created by Justis Root. Released into the public domain.
//https://gist.github.com/justisr
//
//Source is licensed for any use, provided that this copyright notice is retained.
//Modifications not expressly accepted by the author should be noted in the license of any forks.
//No warranty for any purpose whatsoever is implied or expressed,
//and the author shall not be held liable for any losses, direct or indirect as a result of using this software.
import java.io.File;
@justisr
justisr / MathEval.java
Last active February 24, 2017 14:23
Evaluate algebraic equations from a string
// Created by Lawrence PC Dol. Released into the public domain.
// http://tech.dolhub.com
//
// Contributions by Carlos Gómez of Asturias, Spain, in the area of unary operators
// and right-to-left evaluations proved invaluable to implementing these features.
// Thanks Carlos!
//
// Source is licensed for any use, provided this copyright notice is retained.
// No warranty for any purpose whatsoever is implied or expressed. The author