mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Clean up PlotSettings
This commit is contained in:
parent
7dcecde8ad
commit
34291d5b4d
@ -104,15 +104,15 @@ public class Like extends SubCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (plot.getSettings().ratings == null) {
|
||||
if (plot.getSettings().getRatings() == null) {
|
||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
plot.getSettings().setRatings(DBFunc.getRatings(plot));
|
||||
run.run();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
plot.getSettings().ratings = new HashMap<>();
|
||||
plot.getSettings().setRatings(new HashMap<>());
|
||||
}
|
||||
run.run();
|
||||
return true;
|
||||
|
@ -145,15 +145,15 @@ public class Rate extends SubCommand {
|
||||
inventory.openInventory();
|
||||
}
|
||||
};
|
||||
if (plot.getSettings().ratings == null) {
|
||||
if (plot.getSettings().getRatings() == null) {
|
||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
plot.getSettings().setRatings(DBFunc.getRatings(plot));
|
||||
run.run();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
plot.getSettings().ratings = new HashMap<>();
|
||||
plot.getSettings().setRatings(new HashMap<>());
|
||||
}
|
||||
run.run();
|
||||
return true;
|
||||
@ -186,15 +186,15 @@ public class Rate extends SubCommand {
|
||||
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
||||
}
|
||||
};
|
||||
if (plot.getSettings().ratings == null) {
|
||||
if (plot.getSettings().getRatings() == null) {
|
||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
plot.getSettings().setRatings(DBFunc.getRatings(plot));
|
||||
run.run();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
plot.getSettings().ratings = new HashMap<>();
|
||||
plot.getSettings().setRatings(new HashMap<>());
|
||||
}
|
||||
run.run();
|
||||
return true;
|
||||
|
@ -542,9 +542,8 @@ public class Plot {
|
||||
* Gets or create plot settings.
|
||||
*
|
||||
* @return PlotSettings
|
||||
* @deprecated use equivalent plot method; please file github issue if one does not exist.
|
||||
*/
|
||||
@Deprecated public PlotSettings getSettings() {
|
||||
public PlotSettings getSettings() {
|
||||
if (this.settings == null) {
|
||||
this.settings = new PlotSettings();
|
||||
}
|
||||
@ -1135,12 +1134,14 @@ public class Plot {
|
||||
return this.removeFlag(getFlagContainer().queryLocal(flag));
|
||||
}
|
||||
|
||||
public Collection<PlotFlag<?, ?>> getApplicableFlags(final boolean plotOnly, final boolean ignorePluginFlags) {
|
||||
public Collection<PlotFlag<?, ?>> getApplicableFlags(final boolean plotOnly,
|
||||
final boolean ignorePluginFlags) {
|
||||
if (!hasOwner()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final Map<Class<?>, PlotFlag<?, ?>> flags = new HashMap<>();
|
||||
if (!plotOnly && getArea() != null && !getArea().getFlagContainer().getFlagMap().isEmpty()) {
|
||||
if (!plotOnly && getArea() != null && !getArea().getFlagContainer().getFlagMap()
|
||||
.isEmpty()) {
|
||||
final Map<Class<?>, PlotFlag<?, ?>> flagMap = getArea().getFlagContainer().getFlagMap();
|
||||
flags.putAll(flagMap);
|
||||
}
|
||||
@ -1478,9 +1479,9 @@ public class Plot {
|
||||
public void clearRatings() {
|
||||
Plot base = this.getBasePlot(false);
|
||||
PlotSettings baseSettings = base.getSettings();
|
||||
if (baseSettings.ratings != null && !baseSettings.getRatings().isEmpty()) {
|
||||
if (baseSettings.getRatings() != null && !baseSettings.getRatings().isEmpty()) {
|
||||
DBFunc.deleteRatings(base);
|
||||
baseSettings.ratings = null;
|
||||
baseSettings.setRatings(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1511,7 +1512,7 @@ public class Plot {
|
||||
|
||||
public boolean hasRatings() {
|
||||
Plot base = this.getBasePlot(false);
|
||||
return base.settings != null && base.settings.ratings != null;
|
||||
return base.settings != null && base.settings.getRatings() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,8 @@ package com.github.intellectualsites.plotsquared.plot.object;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -19,29 +21,24 @@ public class PlotSettings {
|
||||
|
||||
/**
|
||||
* Merged plots.
|
||||
*
|
||||
* @deprecated Raw access
|
||||
*/
|
||||
@Deprecated public boolean[] merged = new boolean[] {false, false, false, false};
|
||||
@Getter private boolean[] merged = new boolean[] {false, false, false, false};
|
||||
/**
|
||||
* Plot alias.
|
||||
*
|
||||
* @deprecated Raw access
|
||||
*/
|
||||
@Deprecated public String alias = "";
|
||||
@Getter @Setter private String alias = "";
|
||||
/**
|
||||
* The ratings for a plot.
|
||||
*
|
||||
* @deprecated Raw access
|
||||
*/
|
||||
@Deprecated public HashMap<UUID, Integer> ratings;
|
||||
private List<PlotComment> comments = null;
|
||||
@Setter private HashMap<UUID, Integer> ratings;
|
||||
/**
|
||||
* Plot comments.
|
||||
*/
|
||||
@Setter private List<PlotComment> comments = null;
|
||||
/**
|
||||
* Home Position.
|
||||
*
|
||||
* @deprecated Raw access
|
||||
*/
|
||||
@Deprecated private BlockLoc position;
|
||||
private BlockLoc position;
|
||||
|
||||
/**
|
||||
* <b>Check if the plot is merged in a direction</b><br> 0 = North<br> 1 = East<br> 2 = South<br> 3 = West<br>
|
||||
@ -53,10 +50,6 @@ public class PlotSettings {
|
||||
return this.merged[direction];
|
||||
}
|
||||
|
||||
public boolean[] getMerged() {
|
||||
return this.merged;
|
||||
}
|
||||
|
||||
public void setMerged(boolean[] merged) {
|
||||
this.merged = merged;
|
||||
}
|
||||
@ -64,7 +57,6 @@ public class PlotSettings {
|
||||
public Map<UUID, Integer> getRatings() {
|
||||
if (this.ratings == null) {
|
||||
this.ratings = new HashMap<>();
|
||||
|
||||
}
|
||||
return this.ratings;
|
||||
}
|
||||
@ -103,19 +95,6 @@ public class PlotSettings {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return this.alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the plot alias.
|
||||
*
|
||||
* @param alias alias to be used
|
||||
*/
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnstableApiUsage"}) public List<PlotComment> getComments(String inbox) {
|
||||
if (this.comments == null) {
|
||||
return Collections.emptyList();
|
||||
@ -125,10 +104,6 @@ public class PlotSettings {
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
}
|
||||
|
||||
void setComments(List<PlotComment> comments) {
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
boolean removeComment(PlotComment comment) {
|
||||
if (this.comments == null) {
|
||||
return false;
|
||||
|
@ -171,7 +171,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
|
||||
final FlagContainer oldContainer = p.getFlagContainer();
|
||||
p = new SinglePlot(p.getId(), p.owner, p.getTrusted(), p.getMembers(), p.getDenied(),
|
||||
s.alias, s.getPosition(), null, this, s.merged, p.getTimestamp(), p.temp);
|
||||
s.getAlias(), s.getPosition(), null, this, s.getMerged(), p.getTimestamp(), p.temp);
|
||||
p.getFlagContainer().addAll(oldContainer);
|
||||
|
||||
return p;
|
||||
|
@ -681,9 +681,9 @@ public class MainUtil {
|
||||
* @return
|
||||
*/
|
||||
public static double[] getAverageRatings(Plot plot) {
|
||||
HashMap<UUID, Integer> rating;
|
||||
if (plot.getSettings().ratings != null) {
|
||||
rating = plot.getSettings().ratings;
|
||||
Map<UUID, Integer> rating;
|
||||
if (plot.getSettings().getRatings() != null) {
|
||||
rating = plot.getSettings().getRatings();
|
||||
} else if (Settings.Enabled_Components.RATING_CACHE) {
|
||||
rating = new HashMap<>();
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ public class PlotAnalysis {
|
||||
" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
||||
while (iterator.hasNext()) {
|
||||
Plot plot = iterator.next();
|
||||
if (plot.getSettings().ratings == null || plot.getSettings().getRatings()
|
||||
if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings()
|
||||
.isEmpty()) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user