Skip to content

Instantly share code, notes, and snippets.

View Scarsz's full-sized avatar
🐒
Programming Primate

Austin Shapiro Scarsz

🐒
Programming Primate
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@aadnk
aadnk / CancellationDetector.java
Last active March 30, 2024 15:23
A class that allows you to detect which plugin cancelled a given event.
package com.comphenix.example;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import org.bukkit.event.Cancellable;
@larrybolt
larrybolt / cf-ddns.sh
Last active June 16, 2024 19:06
Automatically update your CloudFlare DNS record to the IP, Dynamic DNS for Cloudflare
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# Automatically update your CloudFlare DNS record to the IP, Dynamic DNS
# Can retrieve cloudflare Domain id and list zone's, because, lazy
# Place at:
# /usr/local/bin/cf-ddns.sh
@graywolf336
graywolf336 / BukkitSerialization.java
Last active June 1, 2024 14:21
Serialize and deserialize the player's inventory, including armor and content.
/**
* Converts the player inventory to a String array of Base64 strings. First string is the content and second string is the armor.
*
* @param playerInventory to turn into an array of strings.
* @return Array of strings: [ main content, armor content ]
* @throws IllegalStateException
*/
public static String[] playerInventoryToBase64(PlayerInventory playerInventory) throws IllegalStateException {
//get the main content part, this doesn't return the armor
String content = toBase64(playerInventory);
@aadnk
aadnk / BootstrapList.java
Created February 20, 2014 21:47
Handling HTTP requests to port 25556 in Minecraft. This requires ProtocolLib (for now), but could be rewritten to avoid it.
package com.comphenix.example;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.Callable;
import com.google.common.collect.Lists;
@aadnk
aadnk / DisplayFloatingText.java
Created February 21, 2014 21:38
Display floating text. Thanks to http://www.youtube.com/watch?v=q1B19JvX5TE for the amazing trick. Uses PacketWrapper and ProtocolLib, but could be rewritten to avoid them.
package com.comphenix.example;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
@aadnk
aadnk / DisplayFloatingImage.java
Created February 21, 2014 22:27
Display a floating image with name tags. Screenshot: http://imgur.com/gF0qyzj
package com.comphenix.example;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@aadnk
aadnk / PlayerDisplayModifier.java
Last active April 25, 2024 22:44
Change the display name and skin of any player. Credit to @bigteddy98, @ferrybig and @lenis0012 for writing the original version.
package com.comphenix.example;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
@aadnk
aadnk / SimpleMinecraftClient.java
Created May 30, 2014 23:39
Testing sending custom data through ping packets.
package com.comphenix.test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
@pcan
pcan / SelfExpiringHashMap.java
Last active July 4, 2024 23:51
SelfExpiringHashMap - a Java Map which entries expire automatically after a given time; it uses a DelayQueue internally.
/*
* Copyright (c) 2019 Pierantonio Cangianiello
*
* MIT License
*
* 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