Skip to content

Instantly share code, notes, and snippets.

@whilb
whilb / gist:8500779
Last active January 3, 2016 18:09
Example flight toggle command for bukkit
public boolean onCommand(CommandSender sender1, Command cmd1, String label, String[] args) {
if(sender1 instanceof Player) {
Player p = (Player)sender;
if (CommandLabel.equalsIgnoreCase("fly")) {
if (!p.isFlying()) {
p.setFlying(true);
p.sendMessage(ChatColor.DARK_AQUA + "[Fly] " + ChatColor.YELLOW + "Flight mode enabled!");
} else {
p.setFlying(false);
p.sendMessage(ChatColor.DARK_AQUA + "[Fly] " + ChatColor.YELLOW + "Flight mode disabled!");
@whilb
whilb / example.java
Last active January 3, 2016 19:49
Example usage for ReefMC
package me.PlayinCOD3142.Reef;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.EventHandler;
@whilb
whilb / example
Last active January 3, 2016 23:09
FriendsAPI example implementation
public class MyPlugin extends JavaPlugin {
Connection c = null;
DatabaseInterface dbi;
public void onEnable() {
dbi = new DatabaseInterface();
c = dbi.openConnection(this, String DBHost, String DBPort, String DBDatabase, String DBUser, String DBPass);
doTheExample("boink");
}
@whilb
whilb / example.java
Last active January 4, 2016 13:18
example of an abstract class
package net.aerenserve.melded.requirements;
import org.bukkit.plugin.Plugin;
public abstract class Requirement {
protected Plugin plugin;
public RequirementType type;
protected Requirement(Plugin plugin, RequirementType type) {
@whilb
whilb / example.java
Last active January 4, 2016 13:19
implementing an abstract class
package net.aerenserve.melded.requirements;
import org.bukkit.Location;
import org.bukkit.plugin.Plugin;
public class LocationRequirement extends Requirement {
String name;
Location loc;
double distance;
@whilb
whilb / example.java
Created February 5, 2014 00:07
Kits Example
public enum KitType {
MEMBER,
VIP,
VIPPLUS,
MVP,
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Player p = e.getWhoClicked();
@whilb
whilb / example.java
Last active August 29, 2015 13:56
Custom region and selection object example
//REGION CLASS
import org.bukkit.Location;
public class Region {
private Selection sel;
public Region(Selection sel) {
this.sel = sel;
@whilb
whilb / example.java
Created February 12, 2014 22:56
ItemStackManager example
package net.aerenserve.example;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
@whilb
whilb / mapsystem.java
Created February 18, 2014 20:46
Shows the gist (geddit? XD) of how to draw on a map the players location.
public void drawMap(Player player) {
MapCanvas myCanvas;
int playerX = player.getLocation().getX(); //the 'true' coordinates
int playerZ = player.getLocation().getZ();
/* Assumes that you have a class PartyManager which has a method to get the Party of a player
The Party class has a method called getPlayers(), which returns an ArrayList of players in the party. Simple.
*/
@whilb
whilb / team.java
Created March 16, 2014 15:57
Example team object
package net.aerenserve.teamapi;
import java.util.ArrayList;
public class Team {
String name = null;
Game game = null;
ArrayList<String> players = new ArrayList<String>();