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) {
|
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
plot.getSettings().setRatings(DBFunc.getRatings(plot));
|
||||||
run.run();
|
run.run();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.getSettings().ratings = new HashMap<>();
|
plot.getSettings().setRatings(new HashMap<>());
|
||||||
}
|
}
|
||||||
run.run();
|
run.run();
|
||||||
return true;
|
return true;
|
||||||
|
@ -145,15 +145,15 @@ public class Rate extends SubCommand {
|
|||||||
inventory.openInventory();
|
inventory.openInventory();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (plot.getSettings().ratings == null) {
|
if (plot.getSettings().getRatings() == null) {
|
||||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
plot.getSettings().setRatings(DBFunc.getRatings(plot));
|
||||||
run.run();
|
run.run();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.getSettings().ratings = new HashMap<>();
|
plot.getSettings().setRatings(new HashMap<>());
|
||||||
}
|
}
|
||||||
run.run();
|
run.run();
|
||||||
return true;
|
return true;
|
||||||
@ -186,15 +186,15 @@ public class Rate extends SubCommand {
|
|||||||
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (plot.getSettings().ratings == null) {
|
if (plot.getSettings().getRatings() == null) {
|
||||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
plot.getSettings().setRatings(DBFunc.getRatings(plot));
|
||||||
run.run();
|
run.run();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.getSettings().ratings = new HashMap<>();
|
plot.getSettings().setRatings(new HashMap<>());
|
||||||
}
|
}
|
||||||
run.run();
|
run.run();
|
||||||
return true;
|
return true;
|
||||||
|
@ -542,9 +542,8 @@ public class Plot {
|
|||||||
* Gets or create plot settings.
|
* Gets or create plot settings.
|
||||||
*
|
*
|
||||||
* @return PlotSettings
|
* @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) {
|
if (this.settings == null) {
|
||||||
this.settings = new PlotSettings();
|
this.settings = new PlotSettings();
|
||||||
}
|
}
|
||||||
@ -1099,7 +1098,7 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* Sets a flag for this plot
|
* Sets a flag for this plot
|
||||||
*
|
*
|
||||||
* @param flag Flag to set
|
* @param flag Flag to set
|
||||||
*/
|
*/
|
||||||
public <V> boolean setFlag(PlotFlag<V, ?> flag) {
|
public <V> boolean setFlag(PlotFlag<V, ?> flag) {
|
||||||
if (!EventUtil.manager.callFlagAdd(flag, origin)) {
|
if (!EventUtil.manager.callFlagAdd(flag, origin)) {
|
||||||
@ -1135,12 +1134,14 @@ public class Plot {
|
|||||||
return this.removeFlag(getFlagContainer().queryLocal(flag));
|
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()) {
|
if (!hasOwner()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
final Map<Class<?>, PlotFlag<?, ?>> flags = new HashMap<>();
|
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();
|
final Map<Class<?>, PlotFlag<?, ?>> flagMap = getArea().getFlagContainer().getFlagMap();
|
||||||
flags.putAll(flagMap);
|
flags.putAll(flagMap);
|
||||||
}
|
}
|
||||||
@ -1478,9 +1479,9 @@ public class Plot {
|
|||||||
public void clearRatings() {
|
public void clearRatings() {
|
||||||
Plot base = this.getBasePlot(false);
|
Plot base = this.getBasePlot(false);
|
||||||
PlotSettings baseSettings = base.getSettings();
|
PlotSettings baseSettings = base.getSettings();
|
||||||
if (baseSettings.ratings != null && !baseSettings.getRatings().isEmpty()) {
|
if (baseSettings.getRatings() != null && !baseSettings.getRatings().isEmpty()) {
|
||||||
DBFunc.deleteRatings(base);
|
DBFunc.deleteRatings(base);
|
||||||
baseSettings.ratings = null;
|
baseSettings.setRatings(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1511,7 +1512,7 @@ public class Plot {
|
|||||||
|
|
||||||
public boolean hasRatings() {
|
public boolean hasRatings() {
|
||||||
Plot base = this.getBasePlot(false);
|
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.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -19,29 +21,24 @@ public class PlotSettings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Merged plots.
|
* 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.
|
* Plot alias.
|
||||||
*
|
|
||||||
* @deprecated Raw access
|
|
||||||
*/
|
*/
|
||||||
@Deprecated public String alias = "";
|
@Getter @Setter private String alias = "";
|
||||||
/**
|
/**
|
||||||
* The ratings for a plot.
|
* The ratings for a plot.
|
||||||
*
|
|
||||||
* @deprecated Raw access
|
|
||||||
*/
|
*/
|
||||||
@Deprecated public HashMap<UUID, Integer> ratings;
|
@Setter private HashMap<UUID, Integer> ratings;
|
||||||
private List<PlotComment> comments = null;
|
/**
|
||||||
|
* Plot comments.
|
||||||
|
*/
|
||||||
|
@Setter private List<PlotComment> comments = null;
|
||||||
/**
|
/**
|
||||||
* Home Position.
|
* 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>
|
* <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];
|
return this.merged[direction];
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean[] getMerged() {
|
|
||||||
return this.merged;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMerged(boolean[] merged) {
|
public void setMerged(boolean[] merged) {
|
||||||
this.merged = merged;
|
this.merged = merged;
|
||||||
}
|
}
|
||||||
@ -64,7 +57,6 @@ public class PlotSettings {
|
|||||||
public Map<UUID, Integer> getRatings() {
|
public Map<UUID, Integer> getRatings() {
|
||||||
if (this.ratings == null) {
|
if (this.ratings == null) {
|
||||||
this.ratings = new HashMap<>();
|
this.ratings = new HashMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
return this.ratings;
|
return this.ratings;
|
||||||
}
|
}
|
||||||
@ -103,19 +95,6 @@ public class PlotSettings {
|
|||||||
this.position = position;
|
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) {
|
@SuppressWarnings({"UnstableApiUsage"}) public List<PlotComment> getComments(String inbox) {
|
||||||
if (this.comments == null) {
|
if (this.comments == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@ -125,10 +104,6 @@ public class PlotSettings {
|
|||||||
.collect(ImmutableList.toImmutableList());
|
.collect(ImmutableList.toImmutableList());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setComments(List<PlotComment> comments) {
|
|
||||||
this.comments = comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean removeComment(PlotComment comment) {
|
boolean removeComment(PlotComment comment) {
|
||||||
if (this.comments == null) {
|
if (this.comments == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -171,7 +171,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
|
|
||||||
final FlagContainer oldContainer = p.getFlagContainer();
|
final FlagContainer oldContainer = p.getFlagContainer();
|
||||||
p = new SinglePlot(p.getId(), p.owner, p.getTrusted(), p.getMembers(), p.getDenied(),
|
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);
|
p.getFlagContainer().addAll(oldContainer);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
@ -681,9 +681,9 @@ public class MainUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double[] getAverageRatings(Plot plot) {
|
public static double[] getAverageRatings(Plot plot) {
|
||||||
HashMap<UUID, Integer> rating;
|
Map<UUID, Integer> rating;
|
||||||
if (plot.getSettings().ratings != null) {
|
if (plot.getSettings().getRatings() != null) {
|
||||||
rating = plot.getSettings().ratings;
|
rating = plot.getSettings().getRatings();
|
||||||
} else if (Settings.Enabled_Components.RATING_CACHE) {
|
} else if (Settings.Enabled_Components.RATING_CACHE) {
|
||||||
rating = new HashMap<>();
|
rating = new HashMap<>();
|
||||||
} else {
|
} else {
|
||||||
|
@ -84,7 +84,7 @@ public class PlotAnalysis {
|
|||||||
" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Plot plot = iterator.next();
|
Plot plot = iterator.next();
|
||||||
if (plot.getSettings().ratings == null || plot.getSettings().getRatings()
|
if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings()
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user