Skip to content

Instantly share code, notes, and snippets.

@aadnk
aadnk / PlayerDisplayModifier.java
Last active April 18, 2024 08:43
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 / EntityHider.java
Last active April 7, 2024 21:38
Hide or show entities
package com.comphenix.example;
import static com.comphenix.protocol.PacketType.Play.Server.*;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Map;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@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;
@aadnk
aadnk / injectApi.py
Last active March 6, 2024 06:20
Inject a REST API into Streamlit by injecting into Tornado
import logging
import threading
from typing import Any, Dict, Iterable, Optional, Union
from tornado.routing import Rule, Matcher
_global_tornado_hook = None
_global_hook_lock = threading.RLock()
class CustomRule:
def __init__(self, path_pattern: Union[str, Matcher], handler_class: Any,
@aadnk
aadnk / FakeEquipment.java
Last active January 7, 2024 15:37
Modify the displayed armor and held item depending on the observing player.
/* The MIT License (MIT)
*
* Copyright (c) 2014 Kristian S. Stangeland
*
* 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:
@aadnk
aadnk / AABB.java
Created October 23, 2013 18:25
A simple AABB intersection algorithm for Bukkit. Returns the intersection point as well.
/**
* Represents an axix-aligned bounding box.
*
* @author Kristian
*/
public class AABB {
public static class Vec3D {
/**
* Point with the coordinate (1, 1, 1).
*/
@aadnk
aadnk / YouTube Comment.md
Last active November 11, 2023 10:57
Comment from 2022-06-20 on The REASON Google Translate FAILS at Japanese from 2022

Comment

Looks like Google translate has improved since 2020 - it's no longer inventing puppy ramen out of nowhere, and it's using more correct pronouns. Or someone at Google was embarrassed after watching this video, and made the necessary bug fixes. Still, I'd give DeepL a slight edge when compared to Google Translate.

I also tried using GPT-3 using the prompt "Translate the following restaurant review: Japanese: [TEXT] English: ", and it's arguably even better than DeepL:

  1. 隣の駐車場に停めていたらここのおばさんらしき人に何か言われた何を言っているのかは分からなかったが怒った口調だった。とても不愉快。 Google Translate: When I was parked in the parking lot next door, I didn't know what the aunt-like person was saying, but I was angry. She is very unpleasant. DeepL:
@aadnk
aadnk / Tweet Translation.md
Created November 11, 2023 10:33
Translating Japanese Tweets (X-es?) with ChatGPT

Translation of a tweet

I came upon this on Twitter/X, and I couldn't make heads or tails of it: 病院で診察待ちしてたら車当てられてさ 就活中の大学生と思われるカップルで2人ともスーツ着てて初心者マークだったから

ちゃんと申告したのえらいなぁ
事故したのショックだろうなぁ
トラウマにならなきゃいいけどなぁ
彼氏あとでフォローしてあげなよー
@aadnk
aadnk / GPT-4 comparisions.md
Last active November 8, 2023 16:42
Various versions of GPT-4 answer to "How can I check if there are non-None values in a list?"

Prompt

User: How can I check if there are non-None values in a list?

GPT-4

Here, GPT-4-1106-preview is the latest version released on 2023-11-06, then GPT-4-0614 on 2023-06-14, and finally GPT-4-0314 originally released on 2023-03-14.

GPT-4-1106-preview

@aadnk
aadnk / ItemSerialization.java
Created November 18, 2012 01:15
Serialize inventories using NBT
package com.comphenix.example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.math.BigInteger;
import net.minecraft.server.NBTBase;
import net.minecraft.server.NBTTagCompound;