2014-11-08 20:27:09 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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 /
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2014-09-22 13:02:14 +02:00
|
|
|
|
2014-11-16 10:48:18 +01:00
|
|
|
package com.intellectualcrafters.plot.object;
|
2014-09-22 13:02:14 +02:00
|
|
|
|
2015-01-13 17:38:15 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Set;
|
2015-01-08 15:08:17 +01:00
|
|
|
|
2014-12-18 03:15:11 +01:00
|
|
|
import org.bukkit.block.Biome;
|
|
|
|
|
2015-01-13 17:38:15 +01:00
|
|
|
import com.intellectualcrafters.plot.flag.Flag;
|
|
|
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
|
|
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
2014-09-23 04:08:31 +02:00
|
|
|
|
2014-09-22 13:02:14 +02:00
|
|
|
/**
|
|
|
|
* plot settings
|
2014-10-11 09:33:10 +02:00
|
|
|
*
|
2014-09-22 13:02:14 +02:00
|
|
|
* @author Citymonstret
|
2014-11-16 10:48:18 +01:00
|
|
|
* @author Empire92
|
2014-09-22 13:02:14 +02:00
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
@SuppressWarnings("unused") public class PlotSettings {
|
2014-11-21 23:45:46 +01:00
|
|
|
/**
|
|
|
|
* Plot
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
private final Plot plot;
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* merged plots
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
private boolean[] merged = new boolean[]{false, false, false, false};
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* plot alias
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
private String alias;
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
2014-11-16 10:48:18 +01:00
|
|
|
* Comments
|
2014-11-05 04:42:08 +01:00
|
|
|
*/
|
|
|
|
private ArrayList<PlotComment> comments = null;
|
|
|
|
/**
|
2014-11-16 10:48:18 +01:00
|
|
|
* Flags
|
2014-11-05 04:42:08 +01:00
|
|
|
*/
|
2015-01-08 15:08:17 +01:00
|
|
|
public Set<Flag> flags;
|
2014-11-16 10:48:18 +01:00
|
|
|
/**
|
|
|
|
* Home Position
|
|
|
|
*/
|
2015-01-12 16:52:33 +01:00
|
|
|
private BlockLoc position;
|
2014-11-16 10:48:18 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param plot object
|
2014-11-05 04:42:08 +01:00
|
|
|
*/
|
|
|
|
public PlotSettings(final Plot plot) {
|
|
|
|
this.alias = "";
|
2014-11-09 17:22:53 +01:00
|
|
|
this.plot = plot;
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-12-18 03:15:11 +01:00
|
|
|
* <b>Check if the plot is merged in a direction</b><br> 0 = North<br> 1 = East<br> 2 = South<br> 3 = West<br>
|
|
|
|
*
|
|
|
|
* @param direction Direction to check
|
2014-11-05 04:42:08 +01:00
|
|
|
*
|
2014-11-16 10:48:18 +01:00
|
|
|
* @return boolean merged
|
2014-11-05 04:42:08 +01:00
|
|
|
*/
|
|
|
|
public boolean getMerged(final int direction) {
|
|
|
|
return this.merged[direction];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the plot is merged (i.e. if it's a mega plot)
|
|
|
|
*/
|
|
|
|
public boolean isMerged() {
|
|
|
|
return (this.merged[0] || this.merged[1] || this.merged[2] || this.merged[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean[] getMerged() {
|
|
|
|
return this.merged;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMerged(final boolean[] merged) {
|
|
|
|
this.merged = merged;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMerged(final int direction, final boolean merged) {
|
|
|
|
this.merged[direction] = merged;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-09 19:27:46 +01:00
|
|
|
* @return biome at plot loc
|
2014-11-05 04:42:08 +01:00
|
|
|
*/
|
|
|
|
public Biome getBiome() {
|
2014-12-16 06:03:20 +01:00
|
|
|
return PlotHelper.getPlotBottomLoc(this.plot.getWorld(), this.plot.getId()).add(1, 0, 1).getBlock().getBiome();
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
|
|
|
|
2015-01-12 16:52:33 +01:00
|
|
|
public BlockLoc getPosition() {
|
|
|
|
if (this.position == null) {
|
|
|
|
return new BlockLoc(0, 0, 0);
|
|
|
|
}
|
2014-11-05 04:42:08 +01:00
|
|
|
return this.position;
|
|
|
|
}
|
|
|
|
|
2015-01-12 16:52:33 +01:00
|
|
|
public void setPosition(BlockLoc position) {
|
2014-11-05 04:42:08 +01:00
|
|
|
this.position = position;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getAlias() {
|
|
|
|
return this.alias;
|
|
|
|
}
|
|
|
|
|
2014-11-09 17:22:53 +01:00
|
|
|
/**
|
2014-11-16 10:48:18 +01:00
|
|
|
* Set the plot alias
|
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param alias alias to be used
|
2014-11-09 17:22:53 +01:00
|
|
|
*/
|
|
|
|
public void setAlias(final String alias) {
|
|
|
|
this.alias = alias;
|
|
|
|
}
|
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
public String getJoinMessage() {
|
2015-01-08 15:08:17 +01:00
|
|
|
final Flag greeting = FlagManager.getPlotFlag(plot, "greeting");
|
2014-11-16 10:48:18 +01:00
|
|
|
if (greeting != null) {
|
|
|
|
return greeting.getValue();
|
|
|
|
}
|
2014-11-05 04:42:08 +01:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2014-11-16 10:48:18 +01:00
|
|
|
/**
|
|
|
|
* Get the "farewell" flag value
|
|
|
|
*
|
|
|
|
* @return Farewell flag
|
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
public String getLeaveMessage() {
|
2015-01-08 15:08:17 +01:00
|
|
|
final Flag farewell = FlagManager.getPlotFlag(plot, "farewell");
|
2014-11-16 10:48:18 +01:00
|
|
|
if (farewell != null) {
|
|
|
|
return farewell.getValue();
|
|
|
|
}
|
2014-11-05 04:42:08 +01:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArrayList<PlotComment> getComments(final int tier) {
|
2014-11-16 10:48:18 +01:00
|
|
|
final ArrayList<PlotComment> c = new ArrayList<>();
|
2015-01-11 17:25:33 +01:00
|
|
|
if (this.comments == null) {
|
|
|
|
return c;
|
|
|
|
}
|
2014-11-05 04:42:08 +01:00
|
|
|
for (final PlotComment comment : this.comments) {
|
|
|
|
if (comment.tier == tier) {
|
|
|
|
c.add(comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setComments(final ArrayList<PlotComment> comments) {
|
|
|
|
this.comments = comments;
|
|
|
|
}
|
2014-11-08 20:27:09 +01:00
|
|
|
|
2014-12-16 06:03:20 +01:00
|
|
|
public void removeComment(final PlotComment comment) {
|
2014-11-06 08:23:21 +01:00
|
|
|
if (this.comments.contains(comment)) {
|
|
|
|
this.comments.remove(comment);
|
|
|
|
}
|
|
|
|
}
|
2014-11-05 04:42:08 +01:00
|
|
|
|
2014-12-16 06:03:20 +01:00
|
|
|
public void removeComments(final ArrayList<PlotComment> comments) {
|
|
|
|
for (final PlotComment comment : comments) {
|
2014-11-06 08:23:21 +01:00
|
|
|
removeComment(comment);
|
|
|
|
}
|
|
|
|
}
|
2014-11-08 20:27:09 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
public void addComment(final PlotComment comment) {
|
|
|
|
if (this.comments == null) {
|
2014-11-16 10:48:18 +01:00
|
|
|
this.comments = new ArrayList<>();
|
2014-10-22 07:21:57 +02:00
|
|
|
}
|
|
|
|
this.comments.add(comment);
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
2014-09-22 13:02:14 +02:00
|
|
|
}
|