Skip to content

Instantly share code, notes, and snippets.

View dumptruckman's full-sized avatar
💭
I may be slow to respond.

Jeremy Wood dumptruckman

💭
I may be slow to respond.
View GitHub Profile
@dumptruckman
dumptruckman / PbExample.java
Last active August 29, 2015 13:56
PluginBase usage example
public interface MyInterface { }
public class SomePlugin extends JavaPlugin implements MyInterface {
static {
SerializationRegistrar.registerClass(Config.class);
SerializationRegistrar.registerClass(Config.Time.class);
}
private JdbcAgent jdbcAgent;
@dumptruckman
dumptruckman / TargetFinder.java
Last active August 29, 2015 13:56
A utility for finding the target entity of an entity.
/* Copyright (C) dumptruckman 2014
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@dumptruckman
dumptruckman / CountdownTask.java
Created July 25, 2012 04:18
A class for a Bukkit countdown task complete with warnings and "events" for doing stuff when started/finished
public abstract class CountdownTask implements Runnable {
private boolean started = false;
private boolean dead = false;
private int countdown;
private long lastTime = 0L;
private final Set<Integer> warnings = new HashSet<Integer>();
private final Plugin plugin;
public CountdownTask(final Plugin plugin, final int countdown) {
@dumptruckman
dumptruckman / TestModeListener.java
Created July 31, 2012 20:43
A bukkit Listener for multi-boxing with same username. Useful for testing.
import net.minecraft.server.EntityPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
@dumptruckman
dumptruckman / InventoryTools.java
Created October 10, 2012 19:44
Useful tools for dealing with Bukkit Inventory objects.
/* Copyright (C) dumptruckman 2012
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>non-aggregate</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
public abstract class QueryGen {
public abstract String createXTable();
public String selectPlayerData(String playerName) {
return "SELECT...";
}
}
public class MySqlQueryGen extends QueryGen {
protected void checkGameEnd() {
Set<GamePlayer> onlinePlayers = getOnlinePlayers();
List<GamePlayer> onlineZombies = new LinkedList<GamePlayer>();
List<GamePlayer> onlineHumans = new LinkedList<GamePlayer>();
for (GamePlayer player : onlinePlayers) {
if (player.isZombie()) {
onlineZombies.add(player);
} else {
onlineHumans.add(player);
}
@dumptruckman
dumptruckman / TicksPerSecondTask.java
Created August 6, 2013 17:31
Calculates a rolling average for ticks per second.
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.text.DecimalFormat;
import java.util.LinkedList;
import java.util.ListIterator;
public class TicksPerSecondTask extends BukkitRunnable {
private static final long NUM_TICKS = 20L;