Skip to content

Instantly share code, notes, and snippets.

@Maxopoly
Maxopoly / mapping.txt
Last active April 17, 2020 19:06
Minecraft Enchantment NameSpacedKey Mapping
Enchanment enum - NameSpacedKey
---
PROTECTION_FIRE - fire_protection
DAMAGE_ALL - sharpness
ARROW_FIRE - flame
WATER_WORKER - aqua_affinity
ARROW_KNOCKBACK - punch
LOYALTY - loyalty
DEPTH_STRIDER - depth_strider
VANISHING_CURSE - vanishing_curse
@Maxopoly
Maxopoly / backup.sh
Last active November 26, 2019 01:42
Backup script
#!/bin/bash
#Adjust to your personal needs and schedule on a cronjob running every minute by running "crontab -e"
#and adding "* * * * * bash /home/max/scr/backup.sh". Obviously adjust the path as needed
cryptFolder=/home/max/crypt/vault/
#Highly recommend using a private repo here to avoid meta data extraction by third parties
remote=git@github.com:Maxopoly/files.git
branch=master
#Adjust client name for each client so you can distinguish in the commit history who made a change
@Maxopoly
Maxopoly / MaterialNames.java
Created August 30, 2019 16:22
Generates a csv with nice human readable names for each spigot material
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
for (Material mat : Material.values()) {
if (mat.toString().contains("LEGACY")) {
continue;
}
sb.append(mat.toString());
sb.append(",");
for (String part : mat.toString().split("_")) {
if (part.length() != 0) {
@Maxopoly
Maxopoly / Converter.java
Created April 22, 2019 22:24
Convert integers into english language
public static String formatNumber(int i) {
boolean bigger = false;
StringBuilder sb = new StringBuilder();
if (i >= 1000) {
int thousands = i / 1000;
i -= (thousands * 1000);
sb.append(formatNumber(thousands));
sb.append(" thousand ");
bigger = true;
}
@Maxopoly
Maxopoly / iptables.rule
Last active August 14, 2023 14:53
IP tables for Minecraft
#You probably want to do this in root to reduce the amount of sudos required
su -
#Install iptables if you haven't already
#Alternatively use packet manager of your choice
apt-get install iptables
#Allow all incoming traffic to begin with
iptables -P INPUT ACCEPT
#Clean out any existing input rules. You may also remove the "INPUT" argument and run only "iptables -F" to clear all chains. When doing so, make sure there are no rules in other chains that you still need (list via "iptables -L"), for example Oracle cloud servers will have preset rules, which should not be removed.
#!/bin/bash
#Script to automatically copy schematics from user home folders into the server folder.
#Useful, because it allows noobs to upload schematics on their own, you just need to set them up
#with an account, limit their permissions to their home folder and briefly explain Filezilla
#where to copy schematics to, edit this to fit your server
schematicFolder=/home/mc/server/plugins/WorldEdit/schematics/
#users to copy schematics from, add/remove users you want to run this for
@Maxopoly
Maxopoly / search.sh
Created February 2, 2019 02:57
Search script for compressed logs
#!/bin/bash
#Sorting will automatically sort the retrieved entries chronologically for minecraft logs,
#because the output of zgrep will be prefixed with the name of the file, which starts with a timestamp
find -name \*.log.gz -print0 | xargs -0 zgrep "$1" | sort
grep "$1" latest.log
Samplesize: 10 000 000
Chances for the final prot level of a piece of armor after X orbs:
For 4 orbs 0: 0.1976008, 1: 0.5691199, 2: 0.2123788, 3: 0.0203932, 4: 5.073E-4,
For 5 orbs 0: 0.1317572, 1: 0.5401247, 2: 0.2836533, 3: 0.0422457, 4: 0.0022191,
For 6 orbs 0: 0.0877484, 1: 0.4942443, 2: 0.3420309, 3: 0.0702157, 4: 0.0057607,
For 7 orbs 0: 0.0586344, 1: 0.4410646, 2: 0.3861019, 3: 0.1025876, 4: 0.0116115,
For 8 orbs 0: 0.0389611, 1: 0.3874494, 2: 0.4166688, 3: 0.1368146, 4: 0.0201061,
For 9 orbs 0: 0.0260465, 1: 0.3355237, 2: 0.4352486, 3: 0.1717337, 4: 0.0314475,
@Maxopoly
Maxopoly / CachedObject.java
Last active June 3, 2018 21:40 — forked from Cryptite/CachedObject.java
Cached Object
import java.util.function.Supplier;
public class CachedObject<T> {
private final Supplier<T> updateFunction;
private T cachedValue;
private boolean dirty = true;
public CachedObject(Supplier<T> updateFunction) {
this.updateFunction = updateFunction;
}
package com.github.maxopoly.WPCommon.model.areagrid;
public class AreaGrid <E extends AreaGridElement> implements AreaGridElement{
private int x;
private int z;
private int elementSize;
private AreaGridElement [] [] elements;