Skip to content

Instantly share code, notes, and snippets.

public boolean isForwarded(Player player) {
UUID uuid = player.getUniqueId();
UUID generatedId = UUID.nameUUIDFromBytes(("OfflinePlayer:"
+ player.getName()).getBytes(Charsets.UTF_8));
return !uuid.equals(generatedId);
}
@vemacs
vemacs / debmc.md
Created April 29, 2014 22:51
Minecraft server on Debian/Ubuntu, the minimalist (and right*) way | *Does not cover pubkey-only auth

Basic security setup

  • Log in as root (default configured)
  • Run apt-get update && apt-get dist-upgrade
  • Create a user named minecraft with adduser minecraft, and skip everything except the password
  • Run usermod -a -G sudo minecraft
  • Log off, and log back in with the minecraft account
  • Run sudo passwd -dl root
  • Disable root login via SSH by running sudo sed -i -e "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config && sudo service ssh restart
import datetime
import threading
from flask import Flask
from collections import OrderedDict
import json
import hashlib
import os
import markdown
class Entry():
@vemacs
vemacs / mcserver.py
Created August 6, 2014 02:48
Modified mcserver.py with support for max online + bugfixes
#!/usr/bin/env python
"""Checks the status (availability, logged-in players) on a Minecraft server.
Example:
$ %(prog)s host [port]
available, 3/5 online: mf, dignity, viking
or
>>> McServer('my.mcserver.com').Update().player_names_sample
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
public class RomanNumerals {
private static final BiMap<String, Integer> ROMAN_INT_MAP = new ImmutableBiMap.Builder<String, Integer>()
.put("i", 1)
.put("ii", 2)
.put("iii", 3)
.put("iv", 4)
.put("v", 5)
import mcstatus, time, threading
from bottle import route, run, response, hook
server = mcstatus.McServer('hub.thechunk.net', 25565)
def schedule_update():
threading.Timer(1, schedule_update).start()
threading.Thread(target=lambda: server.Update()).start()
@hook('after_request')
import java.util.*;
public class ItemDistribution<T> {
private Map<T, Integer> registered = new HashMap<>();
private static Random random = new Random();
int max = 0;
public void insert(T item, int weight) {
registered.put(item, registered.containsKey(item) ?
registered.get(item) + weight : weight);
import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
public class NameFetcher {
@vemacs
vemacs / gist:8869a099bae834cf7f70
Created November 26, 2014 20:07
Drama generator output
Alblaka removes compatibility between Too Many Items and BuildCraft by request of Direwolf20
SpaceToad plays OpenPeripheral on Twitch
MachineMuse confirms that OpenBlocks should be less like Chisel
kirindave threatens to complain about Shukaro until they remove Natura from Resonant Rise
nallar adds compatibility between ExtraBiomesXL and VoxelMap by request of kakermix
Sengir denies OpenPeripheral is faster than RedPower 3
MamiyaOtaru steals code from Highlands
Alblaka decides to base their entire modpack on Pixelmon
Vswe says PowerCrystals did not steal 5 lines of code from RealSketch
RWTema tweets tgame14 stole 5 lines of code from Reika
@vemacs
vemacs / EntityTypeUtil.java
Created March 28, 2015 21:46
convert Bukkit EntityType string representation to NMS string (suitable for BlockEntityTag)
private static Map<String, String> bukkitToNMS = ImmutableMap.<String, String>builder()
.put("horse", "EntityHorse")
.put("mushroom_cow", "MushroomCow")
.put("magma_cube", "LavaSlime")
.put("snowman", "SnowMan")
.put("silverfish", "Silverfish")
.put("cave_spider", "CaveSpider")
.put("iron_golem", "VillagerGolem")
.put("ender_dragon", "EnderDragon")
.put("pig_zombie", "PigZombie")