Some optimization, fixed copyright.

This commit is contained in:
Sauilitired
2014-11-08 20:27:09 +01:00
parent bcc34e7cd8
commit f71fabbfbf
143 changed files with 5090 additions and 4580 deletions

View File

@ -1,16 +1,29 @@
/*
* 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
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// 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. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.api;
import java.util.ArrayList;
import java.util.Set;
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;
@ -18,33 +31,22 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.plot.AbstractFlag;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotManager;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SchematicHandler;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.SubCommand;
import java.util.ArrayList;
import java.util.Set;
/**
* The plotMain api class.
*
* @author Citymonstret, Empire92
*/
@SuppressWarnings({ "unused", "javadoc" })
@SuppressWarnings({"unused", "javadoc"})
public class PlotAPI {
private static PlotHelper plotHelper;
private static PlayerFunctions playerFunctions;
private static FlagManager flagManager;
private static PlotHelper plotHelper;
private static PlayerFunctions playerFunctions;
private static FlagManager flagManager;
private static SchematicHandler schematicHandler;
private static C c;
private static C c;
// Methods/fields in PlotMain class
@ -63,13 +65,13 @@ public class PlotAPI {
// PlotMain.updatePlot(plot);
// To access plotMain stuff.
private final PlotMain plotMain;
private final PlotMain plotMain;
// Reference
/**
* Admin Permission
*/
public static final String ADMIN_PERMISSION = "plots.admin";
public static final String ADMIN_PERMISSION = "plots.admin";
/**
* Get all plots
@ -93,39 +95,36 @@ public class PlotAPI {
/**
* Add a plotoworld
*
* @param world World Name
* @param plotWorld Plot World Object
* @param manager World Manager
* @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
* com.intellectualcrafters.plot.PlotWorld,
* com.intellectualcrafters.plot.PlotManager)
*/
public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) {
PlotMain.addPlotWorld(world, plotWorld, manager);
}
/**
* @see com.intellectualcrafters.plot.PlotMain#config
* @return main configuration
* @see com.intellectualcrafters.plot.PlotMain#config
*/
public YamlConfiguration getConfig() {
return PlotMain.config;
}
/**
* @see com.intellectualcrafters.plot.PlotMain#translations
* @return translation configuration
* @see com.intellectualcrafters.plot.PlotMain#translations
*/
public YamlConfiguration getTranslations() {
return PlotMain.translations;
}
/**
* @see com.intellectualcrafters.plot.PlotMain#storage
* @return storage configuration
* @see com.intellectualcrafters.plot.PlotMain#storage
*/
public YamlConfiguration getStorage() {
return PlotMain.storage;
@ -135,8 +134,7 @@ public class PlotAPI {
* Constructor. Insert any Plugin.
* (Optimally the plugin that is accessing the method)
*
* @param plugin
* Plugin used to access this method
* @param plugin Plugin used to access this method
*/
public PlotAPI(final JavaPlugin plugin) {
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
@ -226,10 +224,9 @@ public class PlotAPI {
* will need to downcast for the specific settings a Generator has. e.g.
* DefaultPlotWorld class implements PlotWorld
*
* @param world
* (to get settings of)
* @param world (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
* world world
*/
public PlotWorld getWorldSettings(final World world) {
return PlotMain.getWorldSettings(world);
@ -238,10 +235,9 @@ public class PlotAPI {
/**
* Get the settings for a world (settings bundled in PlotWorld class)
*
* @param world
* (to get settings of)
* @param world (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
* world world
*/
public PlotWorld getWorldSettings(final String world) {
return PlotMain.getWorldSettings(world);
@ -251,8 +247,7 @@ public class PlotAPI {
* Send a message to a player.
*
* @param player
* @param c
* (Caption)
* @param c (Caption)
*/
public void sendMessage(final Player player, final C c) {
PlayerFunctions.sendMessage(player, c);
@ -280,8 +275,7 @@ public class PlotAPI {
/**
* Send a message to the console
*
* @param c
* (Caption)
* @param c (Caption)
*/
public void sendConsoleMessage(final C c) {
sendConsoleMessage(c.s());
@ -350,10 +344,8 @@ public class PlotAPI {
/**
* Get all plots for the player
*
* @param plr
* to search for
* @param just_owner
* should we just search for owner? Or with rights?
* @param plr to search for
* @param just_owner should we just search for owner? Or with rights?
*/
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
final ArrayList<Plot> pPlots = new ArrayList<>();
@ -362,8 +354,7 @@ public class PlotAPI {
if ((plot.owner != null) && (plot.owner == plr.getUniqueId())) {
pPlots.add(plot);
}
}
else {
} else {
if (plot.hasRights(plr)) {
pPlots.add(plot);
}
@ -375,8 +366,7 @@ public class PlotAPI {
/**
* Get all plots for the world
*
* @param world
* to get plots of
* @param world to get plots of
* @return Plot[] - array of plot objects in world
*/
public Plot[] getPlots(final World world) {
@ -395,8 +385,7 @@ public class PlotAPI {
/**
* Get if plot world
*
* @param world
* (to check if plot world)
* @param world (to check if plot world)
* @return boolean (if plot world or not)
*/
public boolean isPlotWorld(final World world) {
@ -411,7 +400,7 @@ public class PlotAPI {
*/
public Location[] getLocations(final Plot p) {
final World world = Bukkit.getWorld(p.world);
return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id) };
return new Location[]{PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id)};
}
/**