Skip to content

Instantly share code, notes, and snippets.

@WizardlyBump17
WizardlyBump17 / basic.ini
Created May 23, 2024 19:43
Profile for Linux, 2160x1080, mpeg2video, bitrate 150M, pcm_s32le 192Kbps. Works on Davinci Resolve
[General]
Name=Profile name
[Output]
Mode=Advanced
FilenameFormatting=%CCYY-%MM-%DD %hh-%mm-%ss
DelayEnable=false
DelaySec=20
DelayPreserve=true
Reconnect=true
@WizardlyBump17
WizardlyBump17 / Main.java
Created February 11, 2024 01:22
a command parser sytem
import lombok.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
@WizardlyBump17
WizardlyBump17 / Main.java
Created October 12, 2023 19:04
Getting the inventory after the InventoryClickEvent
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, List.of(PacketType.fromClass(ServerboundContainerClickPacket.class)), ListenerOptions.SYNC) {
@Override
public void onPacketReceiving(PacketEvent event) {
ServerboundContainerClickPacket packet = (ServerboundContainerClickPacket) event.getPacket().getHandle();
ServerPlayer serverPlayer = ((CraftPlayer) event.getPlayer()).getHandle();
PacketUtil.handleContainerClick(packet, serverPlayer);
event.setCancelled(true);
@WizardlyBump17
WizardlyBump17 / buildtools.sh
Created September 23, 2023 19:50
Utility script to easily run the BuildTools provided by Spigot
#!/bin/bash
# checks if this script was executed correctly
if (( $# == 0 )); then
echo -e "Usage: $0 <version> [Java path]"
exit 2
fi
digit_regex="^[0-9]+$"
@WizardlyBump17
WizardlyBump17 / SuperBigWorld2023WorkingVersion.java
Created March 24, 2023 22:09
change world height (client only)
@Override
public void onPacketSending(PacketEvent event) {
ClientboundLoginPacket packet = (ClientboundLoginPacket) event.getPacket().getHandle();
Holder.Reference<DimensionType> dimensionType = (Holder.Reference<DimensionType>) clone((Holder.Reference<?>) packet.dimensionType(), clone(packet.dimensionType().value()));
event.setPacket(new PacketContainer(
PacketType.fromClass(packet.getClass()),
new ClientboundLoginPacket(
packet.playerId(),
packet.hardcore(),
packet.gameType(),
@WizardlyBump17
WizardlyBump17 / BuildToolsRunner.java
Created October 21, 2022 22:18
Simple Java utility class to download and run BuildTools
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
public class BuildToolsExecutor {
//java -Dversion=1.19.2 BuildToolsExecutor.java
//java -Djava=custom_path -Dversion=1.19.2 BuildToolsExecutor.java
@WizardlyBump17
WizardlyBump17 / Example.java
Created September 20, 2022 20:02
makes it possible to use almost any object in the PersistentDataContainer API
PersistentDataContainer container = /*your container*/;
container.set(KEY, SerializableDataType.INSTANCE, new Location(Bukkit.getWorld("world"), 0, 64, 0));
container.set(KEY, SerializableDataType.INSTANCE, Map.of("test key", "test value"));
@WizardlyBump17
WizardlyBump17 / InventoryFit.java
Created July 6, 2022 18:17
simple method to check if the given items can fully fit in the given inventory
// Method copied from CraftInventory#addItem, but I removed the code that adds items to the inventory
public static boolean canFit(Inventory inventory, ItemStack... items) {
Validate.noNullElements(items, "Item cannot be null");
ItemStack[] inventoryItems = getContents(inventory);
for (ItemStack item : items) {
while (true) {
int firstPartial = firstPartial(inventoryItems, item);
@WizardlyBump17
WizardlyBump17 / Example.java
Created June 18, 2022 02:10
Simple utility class to create and update scoreboards
private Scoreboard getPlayerScoreboard(Player player) {
GamePlayer gamePlayer = getPlayer(player);
List<GamePlayer> bestPlayers = getBestPlayers(3);
Scoreboard scoreboard = ScoreboardUtil.create(
"§c§lSolo §e§lMode",
"§aYour kills: §f" + gamePlayer.getKills(),
"§aYour lives: " + (gamePlayer.getLives() == 0 ? "§cDEAD" : "§f" + gamePlayer.getLives()),
"",
"§61. " + (bestPlayers.get(0) == null ? "None" : bestPlayers.get(0).getName() + ": §f" + bestPlayers.get(0).getKills()),
@WizardlyBump17
WizardlyBump17 / Example.java
Last active June 15, 2022 00:22
Simple packet listener for 1.17.1
@RequiredArgsConstructor
public class Example extends PacketListener {
private static final java.lang.Class<?> CLAZZ;
static {
try {
CLAZZ = java.lang.Class.forName("net.minecraft.network.protocol.game.PacketPlayInUseEntity$d");
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(e);