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 / Rows.java
Created August 11, 2018 22:57
Enum to prevent illegal arguments when creating an inventory
/**
* A quick enum for getting the amount of slots in an inventory row.
* Used to prevent illegal arguments when creating an inventory.
*
* @author Justis
*
*/
public enum Rows {
@justisr
justisr / UUIDProvider.java
Last active August 29, 2022 11:39
Get the real UUID from a player name. Requires internet connection.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@justisr
justisr / EventProvider.java
Last active September 11, 2018 18:44
Quickly support all of your listeners in an efficient and reload safe way
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@justisr
justisr / Unit.java
Created September 7, 2018 18:53
BigDecimal wrapper which prioritizes the re-use of existing instances and removes trailing zeros.
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.ConcurrentMap;
import com.google.common.collect.MapMaker;
public class Unit {
private static ConcurrentMap<String, Unit> POOL = new MapMaker().weakValues().concurrencyLevel(1).initialCapacity(666).makeMap();
@justisr
justisr / Minifier.java
Last active January 25, 2020 17:43
Strip comments and minify your JSON strings with O(n) performance
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public final class Minifier {
@justisr
justisr / hmff.sublime-syntax
Created September 20, 2018 00:22
Sublime text syntax file for HMFF
%YAML 1.2
---
name: HMFF
file_extensions: [hmff]
scope: source.c
contexts:
main:
- match: "^\\s*?(#).*"
scope: comment.line
@justisr
justisr / AESystem.java
Last active December 21, 2018 17:20
Managing a large project’s systems, and ensuring their enable/disable ordering can be tiresome. Automate the process.
package com.gmail.justisroot.autoecon;
import java.util.ArrayList;
import java.util.List;
import com.gmail.justisroot.autoecon.command.SoftCommand;
import com.gmail.justisroot.autoecon.data.EventProvider;
import com.gmail.justisroot.autoecon.data.FilePool;
import com.gmail.justisroot.autoecon.data.ScheduledSave;
import com.gmail.justisroot.autoecon.data.file.UserData;
final class AccessorTest {
@Test // SUCCESS
@DisplayName("Verify MethodHandles.Lookup constructor")
void lookupConstructorAvailabilityTest() {
Assertions.assertDoesNotThrow(() -> Accessor.newLookupConstructor());
}
@Test // SUCCESS
@DisplayName("Verify available matching instance method is called")
package com.gmail.justisroot.broker;
import java.math.BigDecimal;
import java.util.UUID;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
public interface Broker {
@justisr
justisr / gist:72423b92e1880c8f0a1cbdfcaa75da1d
Created August 13, 2021 00:46 — forked from dsci/gist:1347672
Delete commits from repository.
# First, check out the commit you wish to go back to (get sha-1 from git log)
git reset --hard 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a
# Then do a forced update.
git push origin +9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a^:develop
# Push specific commit
git push origin 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a:develop -f