Skip to content

Instantly share code, notes, and snippets.

View FearMyShotz's full-sized avatar
💻
Coding...

Fear FearMyShotz

💻
Coding...
View GitHub Profile
@vorburger
vorburger / gist:3429822
Created August 22, 2012 22:03
How to find an available (free) TCP port in Java
/**
* Returns a free port number on localhost.
*
* Heavily inspired from org.eclipse.jdt.launching.SocketUtil (to avoid a dependency to JDT just because of this).
* Slightly improved with close() missing in JDT. And throws exception instead of returning -1.
*
* @return a free port number on localhost
* @throws IllegalStateException if unable to find a free port
*/
private static int findFreePort() {
@graywolf336
graywolf336 / BukkitSerialization.java
Last active August 16, 2026 20:15
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);
@Tras2
Tras2 / cloudflare-ddns-update.sh
Last active April 20, 2026 11:28
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@Mindgamesnl
Mindgamesnl / very nice.md
Last active August 18, 2023 14:52
Inventory holders, a quicky

Inventory holders can be used to register own types, handlers and data to a opened GUI for a player.

To start, we need to create our menu class that implemetns InventoryHolder and any other functions we may want. For this example, we are gonna fill the inventory and open it for player, then save the player for later ussage with our handler.

The menu

It will look something like this

import org.bukkit.Bukkit;
import org.bukkit.Material;
@Joo200
Joo200 / DynmapUsage.md
Last active January 20, 2024 20:03
Dynmap API Usage

Warning

Those examples are outdated and shouldn't be used anymore.

Use the official wiki from dynmap as api reference.

Leagacy docs:

This documentation doesn't contain full api docs for dynmap. You need a fundamental knowledge from java and the general non api usage from the dynmap.

@davidjpfeiffer
davidjpfeiffer / HowToChangePlayerGlowColor.md
Last active January 26, 2025 05:10
How to change a Minecraft player's glow color using the Bukkit / Spigot / Paper APIs

The player.setGlowing(true) method can be used to enable / disable the glowing effect for any player

The default glow color is white, but this color can be changed using Scoreboard Teams

First, obtain a reference to the main scoreboard using Bukkit.getScoreboardManager().getMainScoreboard()

You must set this as the player's scoreboard using player.setScoreboard(mainScoreboard)

Next, use the main scoreboard to create a team using mainScoreboard.registerNewTeam(ChatColor.BLUE + "team")