Added maven support, removed camera subcommand

This commit is contained in:
Sauilitired
2014-10-28 10:20:52 +01:00
parent 595db4a51f
commit 3c5eead8c7
147 changed files with 116 additions and 102 deletions

View File

@ -0,0 +1,486 @@
/*
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* and/or monetize any of our intellectual property. IntellectualCrafters is not
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = PlotAPI.java >> Generated by: Citymonstret at 2014-08-09 01:44
*/
package com.intellectualcrafters.plot.api;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.SubCommand;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Set;
/**
* The plotMain api class.
*
* @author Citymonstret, Empire92
*/
@SuppressWarnings({ "unused", "javadoc" })
public class PlotAPI {
private static PlotHelper plotHelper;
private static PlayerFunctions playerFunctions;
private static FlagManager flagManager;
private static SchematicHandler schematicHandler;
private static C c;
// Methods/fields in PlotMain class
// PlotMain.checkForExpiredPlots(); #Ignore
// PlotMain.killAllEntities(); #Ignore
//
// PlotMain.createConfiguration(plotworld);
// PlotMain.getPlots(player)
// PlotMain.getPlots(world)
// PlotMain.getPlots(world, player)
// PlotMain.getWorldPlots(world)
// PlotMain.getPlotWorlds()
// PlotMain.isPlotWorld(world)
// PlotMain.removePlot(world, id, callEvent)
// PlotMain.teleportPlayer(player, from, plot)
// PlotMain.updatePlot(plot);
// To access plotMain stuff.
private PlotMain plotMain;
// Reference
/**
* Admin Permission
*/
public static final String ADMIN_PERMISSION = "plots.admin";
/**
* Get all plots
* @return all plots
*/
public Set<Plot> getAllPlots() {
return PlotMain.getPlots();
}
/**
* Return all plots for a player
* @param player
* @return all plots that a player owns
*/
public Set<Plot> getPlayerPlots(Player player) {
return PlotMain.getPlots(player);
}
/**
* Add a plotoworld
* @see com.intellectualcrafters.plot.PlotMain#addPlotWorld(String, com.intellectualcrafters.plot.PlotWorld, com.intellectualcrafters.plot.PlotManager)
* @param world World Name
* @param plotWorld Plot World Object
* @param manager World Manager
*/
public void addPlotWorld(String world, PlotWorld plotWorld, PlotManager manager) {
PlotMain.addPlotWorld(world, plotWorld, manager);
}
/**
* @see com.intellectualcrafters.plot.PlotMain#config
* @return main configuration
*/
public YamlConfiguration getConfig() {
return PlotMain.config;
}
/**
* @see com.intellectualcrafters.plot.PlotMain#translations
* @return translation configuration
*/
public YamlConfiguration getTranslations() {
return PlotMain.translations;
}
/**
* @see com.intellectualcrafters.plot.PlotMain#storage
* @return storage configuration
*/
public YamlConfiguration getStorage() {
return PlotMain.storage;
}
/**
* Constructor. Insert any Plugin.
* (Optimally the plugin that is accessing the method)
* @param plugin Plugin used to access this method
*/
public PlotAPI(JavaPlugin plugin) {
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
}
/**
* Get the main class for this plugin <br>
* - Contains a lot of fields and methods - not very well organized
* <br>
* Only use this if you really need it
* @return PlotMain PlotSquared Main Class
*/
public PlotMain getMain() {
return plotMain;
}
/**
* PlotHelper class contains useful methods relating to plots.
*
* @return PlotHelper
*/
public PlotHelper getPlotHelper() {
return plotHelper;
}
/**
* PlayerFunctions class contains useful methods relating to players - Some
* player/plot methods are here as well
*
* @return PlayerFunctions
*/
public PlayerFunctions getPlayerFunctions() {
return playerFunctions;
}
/**
* FlagManager class contains methods relating to plot flags
*
* @return FlagManager
*/
public FlagManager getFlagManager() {
return flagManager;
}
/**
* SchematicHandler class contains methods related to pasting schematics
*
* @return SchematicHandler
*/
public SchematicHandler getSchematicHandler() {
return schematicHandler;
}
/**
* C class contains all the captions from the translations.yml file.
*
* @return C
*/
public C getCaptions() {
return c;
}
/**
* Get the plot manager for a world. - Most of these methods can be accessed
* through the PlotHelper
*
* @param world
* @return PlotManager
*/
public PlotManager getPlotManager(World world) {
return PlotMain.getPlotManager(world);
}
/**
* Get the plot manager for a world. - Contains useful low level methods for
* plot merging, clearing, and tessellation
*
* @param world
* @return PlotManager
*/
public PlotManager getPlotManager(String world) {
return PlotMain.getPlotManager(world);
}
/**
* Get the settings for a world (settings bundled in PlotWorld class) - You
* will need to downcast for the specific settings a Generator has. e.g.
* DefaultPlotWorld class implements PlotWorld
*
* @param world
* (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
*/
public PlotWorld getWorldSettings(World world) {
return PlotMain.getWorldSettings(world);
}
/**
* Get the settings for a world (settings bundled in PlotWorld class)
*
* @param world
* (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
*/
public PlotWorld getWorldSettings(String world) {
return PlotMain.getWorldSettings(world);
}
/**
* Send a message to a player.
*
* @param player
* @param c
* (Caption)
*/
public void sendMessage(Player player, C c) {
PlayerFunctions.sendMessage(player, c);
}
/**
* Send a message to a player. - Supports color codes
*
* @param player
* @param string
*/
public void sendMessage(Player player, String string) {
PlayerFunctions.sendMessage(player, string);
}
/**
* Send a message to the console. - Supports color codes
*
* @param msg
*/
public void sendConsoleMessage(String msg) {
PlotMain.sendConsoleSenderMessage(msg);
}
/**
* Send a message to the console
*
* @param c
* (Caption)
*/
public void sendConsoleMessage(C c) {
sendConsoleMessage(c.s());
}
/**
* Register a flag for use in plots
*
* @param flag
*/
public void addFlag(AbstractFlag flag) {
FlagManager.addFlag(flag);
}
/**
* get all the currently registered flags
*
* @return array of Flag[]
*/
public AbstractFlag[] getFlags() {
return FlagManager.getFlags().toArray(new AbstractFlag[0]);
}
/**
* Get a plot based on the ID
*
* @param world
* @param x
* @param z
* @return plot, null if ID is wrong
*/
public Plot getPlot(World world, int x, int z) {
return PlotHelper.getPlot(world, new PlotId(x, z));
}
/**
* Get a plot based on the location
*
* @param l
* @return plot if found, otherwise it creates a temporary plot-
*/
public Plot getPlot(Location l) {
return PlotHelper.getCurrentPlot(l);
}
/**
* Get a plot based on the player location
*
* @param player
* @return plot if found, otherwise it creates a temporary plot
*/
public Plot getPlot(Player player) {
return this.getPlot(player.getLocation());
}
/**
* Check whether or not a player has a plot
*
* @param player
* @return true if player has a plot, false if not.
*/
public boolean hasPlot(World world, Player player) {
return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0);
}
/**
* Get all plots for the player
*
* @param plr
* to search for
* @param just_owner
* should we just search for owner? Or with rights?
*/
public Plot[] getPlots(World world, Player plr, boolean just_owner) {
ArrayList<Plot> pPlots = new ArrayList<>();
for (Plot plot : PlotMain.getPlots(world).values()) {
if (just_owner) {
if ((plot.owner != null) && (plot.owner == plr.getUniqueId())) {
pPlots.add(plot);
}
}
else {
if (plot.hasRights(plr)) {
pPlots.add(plot);
}
}
}
return (Plot[]) pPlots.toArray();
}
/**
* Get all plots for the world
*
* @param world
* to get plots of
* @return Plot[] - array of plot objects in world
*/
public Plot[] getPlots(World world) {
return PlotMain.getWorldPlots(world);
}
/**
* Get all plot worlds
*
* @return World[] - array of plot worlds
*/
public String[] getPlotWorlds() {
return PlotMain.getPlotWorlds();
}
/**
* Get if plot world
*
* @param world
* (to check if plot world)
* @return boolean (if plot world or not)
*/
public boolean isPlotWorld(World world) {
return PlotMain.isPlotWorld(world);
}
/**
* Get plot locations
*
* @param p
* @return [0] = bottomLc, [1] = topLoc, [2] = home
*/
public Location[] getLocations(Plot p) {
World world = Bukkit.getWorld(p.world);
return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id),
PlotHelper.getPlotHome(world, p.id) };
}
/**
* Get home location
*
* @param p
* @return plot bottom location
*/
public Location getHomeLocation(Plot p) {
return PlotHelper.getPlotHome(p.getWorld(), p.id);
}
/**
* Get Bottom Location
*
* @param p
* @return plot bottom location
*/
public Location getBottomLocation(Plot p) {
World world = Bukkit.getWorld(p.world);
return PlotHelper.getPlotBottomLoc(world, p.id);
}
/**
* Get Top Location
*
* @param p
* @return plot top location
*/
public Location getTopLocation(Plot p) {
World world = Bukkit.getWorld(p.world);
return PlotHelper.getPlotTopLoc(world, p.id);
}
/**
* Check whether or not a player is in a plot
*
* @param player
* @return true if the player is in a plot, false if not-
*/
public boolean isInPlot(Player player) {
return PlayerFunctions.isInPlot(player);
}
/**
* Register a subcommand
*
* @param c
*/
public void registerCommand(SubCommand c) {
MainCommand.subCommands.add(c);
}
/**
* Get the plotMain class
*
* @return PlotMain Class
*/
public PlotMain getPlotMain() {
return this.plotMain;
}
/**
* Get the player plot count
*
* @param player
* @return
*/
public int getPlayerPlotCount(World world, Player player) {
return PlayerFunctions.getPlayerPlotCount(world, player);
}
/**
* Get a players plots
*
* @param player
* @return a set containing the players plots
*/
public Set<Plot> getPlayerPlots(World world, Player player) {
return PlayerFunctions.getPlayerPlots(world, player);
}
/**
* Get the allowed plot count for a player
*
* @param player
* @return the number of allowed plots
*/
public int getAllowedPlots(Player player) {
return PlayerFunctions.getAllowedPlots(player);
}
}