TF-PlotSquared/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSettings.java

215 lines
6 KiB
Java
Raw Normal View History

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
package com.intellectualcrafters.plot;
2014-11-08 20:27:09 +01:00
import org.bukkit.block.Biome;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
2014-09-22 13:02:14 +02:00
/**
* plot settings
*
2014-09-22 13:02:14 +02:00
* @author Citymonstret
*/
public class PlotSettings {
2014-11-05 14:42:08 +11:00
/**
* merged plots
*/
2014-11-08 20:27:09 +01:00
private boolean[] merged = new boolean[]{false, false, false, false};
2014-11-05 14:42:08 +11:00
/**
* plot alias
*/
2014-11-08 20:27:09 +01:00
private String alias;
2014-11-05 14:42:08 +11:00
/**
* plot biome
*/
2014-11-08 20:27:09 +01:00
private Biome biome;
2014-11-05 14:42:08 +11:00
private ArrayList<PlotComment> comments = null;
/**
*
*/
2014-11-08 20:27:09 +01:00
private Set<Flag> flags;
2014-11-05 14:42:08 +11:00
2014-11-08 20:27:09 +01:00
private PlotHomePosition position;
2014-11-05 14:42:08 +11:00
private Plot plot;
2014-11-05 14:42:08 +11:00
/**
* Constructor
*
* @param plot
*/
public PlotSettings(final Plot plot) {
this.alias = "";
this.plot = plot;
2014-11-05 14:42:08 +11: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
* @return boolean
*/
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;
}
/**
* @return
* @deprecated
*/
public Biome getBiome() {
return PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId()).add(1, 0, 1).getBlock().getBiome();
2014-11-05 14:42:08 +11:00
}
/**
* @param b
2014-11-05 14:42:08 +11:00
*/
public void setBiome(final Biome b) {
this.biome = b;
2014-11-05 14:42:08 +11:00
}
/**
* @param flag
*/
public void addFlag(final Flag flag) {
final Flag hasFlag = getFlag(flag.getKey());
if (hasFlag != null) {
this.flags.remove(hasFlag);
}
this.flags.add(flag);
}
/**
* @return
2014-11-05 14:42:08 +11:00
*/
public Set<Flag> getFlags() {
return this.flags;
2014-11-05 14:42:08 +11:00
}
/**
* @param flags
2014-11-05 14:42:08 +11:00
*/
public void setFlags(final Flag[] flags) {
this.flags = new HashSet<Flag>(Arrays.asList(flags));
2014-11-05 14:42:08 +11:00
}
/**
* @param flag
* @return
*/
public Flag getFlag(final String flag) {
for (final Flag myflag : this.flags) {
if (myflag.getKey().equals(flag)) {
return myflag;
}
}
return null;
}
public PlotHomePosition getPosition() {
return this.position;
}
public void setPosition(final PlotHomePosition position) {
this.position = position;
}
public String getAlias() {
return this.alias;
}
/**
* @param alias
*/
public void setAlias(final String alias) {
this.alias = alias;
}
2014-11-05 14:42:08 +11:00
public String getJoinMessage() {
return "";
}
public String getLeaveMessage() {
return "";
}
public ArrayList<PlotComment> getComments(final int tier) {
final ArrayList<PlotComment> c = new ArrayList<PlotComment>();
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-11-06 18:23:21 +11:00
public void removeComment(PlotComment comment) {
if (this.comments.contains(comment)) {
this.comments.remove(comment);
}
}
2014-11-05 14:42:08 +11:00
2014-11-06 18:23:21 +11:00
public void removeComments(ArrayList<PlotComment> comments) {
for (PlotComment comment : comments) {
removeComment(comment);
}
}
2014-11-08 20:27:09 +01:00
2014-11-05 14:42:08 +11:00
public void addComment(final PlotComment comment) {
if (this.comments == null) {
this.comments = new ArrayList<PlotComment>();
}
this.comments.add(comment);
2014-11-05 14:42:08 +11:00
}
2014-09-22 13:02:14 +02:00
}