Skip to content

Instantly share code, notes, and snippets.

View dumptruckman's full-sized avatar
💭
I may be slow to respond.

Jeremy Wood dumptruckman

💭
I may be slow to respond.
View GitHub Profile
@dumptruckman
dumptruckman / ActionBarUtil.java
Created January 19, 2016 15:08
A simple utility class for sending action bar messages.
/* Copyright (c) dumptruckman 2016
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package net.dawnofages.util;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
@dumptruckman
dumptruckman / ImmutableBlockLocation.java
Created July 11, 2019 19:22
A simple immutable block Location replacement for Bukkit that lacks references to Bukkit objects.
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.LinkedHashMap;
@dumptruckman
dumptruckman / CommandBase.java
Last active January 24, 2023 17:22
Simple Sub Commands
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import java.util.HashMap;
import java.util.Map;
/**
* A simple class for implementing sub commands.
@dumptruckman
dumptruckman / DebugLogHandler.java
Last active April 25, 2022 06:40
A simple option for enabling debug logging in your Bukkit plugin,
/**
* Copyright 2019 dumptruckman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
@dumptruckman
dumptruckman / snake_case.py
Created November 18, 2020 17:43
Python class decorator for accessing lowerCamelCase attributes using snake_case.
from typing import Any
def snake_to_camel(name):
components = name.split('_')
return components[0] + ''.join(x.title() for x in components[1:])
def snake_case_attrs(klass):
"""A class decorator that enables getting and setting of attributes with lowerCamelCase names using snake_case."""
@dumptruckman
dumptruckman / PlayerDataFactory.java
Last active May 1, 2020 05:05
Safe Player Data Map
/* Copyright (C) dumptruckman 2014
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
@dumptruckman
dumptruckman / AFKPoolListener.java
Last active May 1, 2020 05:02
Punishes players who stand in liquid for too long.
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
@dumptruckman
dumptruckman / SpawnLocationSharable.java
Created August 16, 2019 06:17
Spawn Location Sharable
public class SpawnLocationSharable {
public static final Sharable<Location> SPAWN_LOCATION = new Sharable.Builder<Location>("spawn_location", Location.class,
new SharableHandler<Location>() {
@Override
public void updateProfile(PlayerProfile profile, Player player) {
profile.set(SPAWN_LOCATION, getPlayerSpawnLocation(player));
}
@Override
@dumptruckman
dumptruckman / core.clj
Last active July 27, 2018 23:48
A0A0 interp clojure
(require '[clojure.string :as s])
(use 'clojure.zip)
(defn vectorize-program [code]
(let [t #(read-string (.substring % 1))]
(mapv #(mapv (juxt first t) (into [] (re-seq #"\w-?\d+" %)))
(s/split-lines code))))
(defn prep-code [code]
(down (vector-zip (vectorize-program code))))
@dumptruckman
dumptruckman / Interpreter.kt
Created July 26, 2018 23:41
A0A0 Interpreter in Kotlin
package com.dumptruckman.a0a0
import java.util.LinkedList
import java.util.Scanner
fun main(args: Array<String>) {
// Example usage with cat program
Interpreter.interpret("A0 A0\n" +
"A0 C3 G1 G1 A0\n" +
"A0 I0 V0 P0 A0\n" +