Skip to content

Instantly share code, notes, and snippets.

@stephan-gh
stephan-gh / jenks.css
Last active July 29, 2019 09:00
Jenks - A simple and clean theme for the Jenkins continous integration server. (Demo: https://ci.minecrell.net)
/*
* Jenks - A simple and clean theme for the Jenkins continous integration server.
* Copyright (c) 2014, Minecrell <https://github.com/Minecrell>
* Licensed under the MIT License: http://opensource.org/licenses/MIT
*/
@import url(//fonts.googleapis.com/css?family=Open+Sans|Source+Code+Pro);
body, table, form, input, td, th, p, textarea, select {
font-family: 'Open Sans', sans-serif;
@stephan-gh
stephan-gh / Colorize.php
Last active July 6, 2021 14:10
Minecraft color parser for PHP
<?php
/*
* Minecraft Color Parser for PHP
* Copyright (c) 2013, Minecrell
* MIT License: http://opensource.org/licenses/MIT
*/
function parseMinecraftColors($string) {
$string = utf8_decode(htmlspecialchars($string, ENT_QUOTES, "UTF-8"));
$string = preg_replace('/\xA7([0-9a-f])/i', '<span class="mc-color mc-$1">', $string, -1, $count) . str_repeat("</span>", $count);
@stephan-gh
stephan-gh / [Bukkit] PlayerDamager.java
Last active December 21, 2015 04:48
Get the real player damager behind an entity, for example if an entity was damaged by an arrow.
public static Player getPlayerDamager(Entity damager) {
if (damager instanceof Player) return (Player) damager;
if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager;
Object shooter = projectile.getShooter(); // Doesn't really matter but will also make it work with pre 1.7
if (shooter != null && (shooter instanceof Player)) return (Player) shooter;
}
return null;
}
@stephan-gh
stephan-gh / [Bukkit] EntityKiller.java
Last active December 19, 2015 17:49
Get the last entity damaged another entity.
public static Entity getLastEntityDamager(Entity entity) {
EntityDamageEvent event = entity.getLastDamageCause();
if (event != null && !event.isCancelled() && (event instanceof EntityDamageByEntityEvent)) {
Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
if (damager instanceof Projectile) {
Object shooter = ((Projectile) damager).getShooter();
if (shooter != null && (shooter instanceof Entity)) return (Entity) shooter;
}
// Add other special cases if necessary
@stephan-gh
stephan-gh / ServerListAPI.java
Last active February 29, 2024 20:05
API to modify some advanced Minecraft server list data.
/*
* ServerListAPI - API to modify some advanced Minecraft server list data
* Copyright (C) 2013 Minecrell
* You are not allowed to use this API to fake online players on a production server.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*