Skip to content

Instantly share code, notes, and snippets.

View hugo4715's full-sized avatar
😁
Always coding

hugo4715

😁
Always coding
View GitHub Profile
@hugo4715
hugo4715 / ItemSerialization.java
Created December 30, 2015 14:30 — forked from aadnk/ItemSerialization.java
Only use this version if you've used ItemSerialization before, and want backwards compatibility. This Bukkit-only version is far superior: https://gist.github.com/aadnk/8138186
package com.comphenix.example;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.lang.reflect.Method;
private static Object minecraftServer;
private static Field recentTps;
public static double[] getRecentTps() {
try {
if (minecraftServer == null) {
Server server = Bukkit.getServer();
Field consoleField = server.getClass().getDeclaredField("console");
consoleField.setAccessible(true);
minecraftServer = consoleField.get(server);
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class AIUtils {
private static Field fromMobSpawner;
private static Method getHandle;
private static Method getHandleMethod;
private static Field pingField;
private static int getPing(Player player) {
try {
if (getHandleMethod == null) {
getHandleMethod = player.getClass().getDeclaredMethod("getHandle");
getHandleMethod.setAccessible(true);
}
Object entityPlayer = getHandleMethod.invoke(player);
import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.*;
import java.lang.reflect.Constructor;
@hugo4715
hugo4715 / HotbarMessage.java
Created February 14, 2016 14:38
An easy way to send over-hotbar-messages to players!
// package tld.domain.project.name;
import net.minecraft.server.v1_8_R1.ChatSerializer;
import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.util.HashMap;
@hugo4715
hugo4715 / ParticleEffect.java
Created February 17, 2016 10:23 — forked from DarkBlade12/ParticleEffect.java
This is a little library which allows you to display all possible particle effects in Minecraft with your plugin.
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
@hugo4715
hugo4715 / .LICENSE.TXT
Last active February 21, 2016 12:00 — forked from DarkSeraphim/.LICENSE.TXT
NPC library written for MC 1.8 - spawns and maintains human NPCs
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
package fr.epicube.epicubeapi.scoreboard;
import net.minecraft.server.v1_8_R2.*;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
/**
* @author zyuiop
@hugo4715
hugo4715 / PastebinReporter.java
Created March 31, 2016 11:15 — forked from CaptainBern/PastebinReporter.java
A little class which allows one to easily create pastes on Pastebin.
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
public class PastebinReporter {