mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Fix MainUtil.java
This commit is contained in:
parent
eeb814fb8f
commit
948bd39224
@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.flag;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
|
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.InternalFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
@ -12,6 +13,8 @@ import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -170,30 +173,24 @@ public class FlagManager {
|
|||||||
return getSettingFlags(plot.getArea(), plot.getSettings());
|
return getSettingFlags(plot.getArea(), plot.getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Flag<?>, Object> getPlotFlags(PlotArea area, PlotSettings settings,
|
public static Collection<PlotFlag<?, ?>> getPlotFlags(final Plot plot, final boolean ignorePluginFlags) {
|
||||||
boolean ignorePluginflags) {
|
final Map<Class<?>, PlotFlag<?, ?>> flags = new HashMap<>();
|
||||||
HashMap<Flag<?>, Object> flags = null;
|
if (plot.getArea() != null && !plot.getArea().getFlagContainer().getFlagMap().isEmpty()) {
|
||||||
if (area != null && !area.DEFAULT_FLAGS.isEmpty()) {
|
final Map<Class<?>, PlotFlag<?, ?>> flagMap = plot.getArea().getFlagContainer().getFlagMap();
|
||||||
flags = new HashMap<>(area.DEFAULT_FLAGS.size());
|
flags.putAll(flagMap);
|
||||||
flags.putAll(area.DEFAULT_FLAGS);
|
|
||||||
}
|
}
|
||||||
if (ignorePluginflags) {
|
final Map<Class<?>, PlotFlag<?, ?>> flagMap = plot.getFlagContainer().getFlagMap();
|
||||||
if (flags == null) {
|
if (ignorePluginFlags) {
|
||||||
flags = new HashMap<>(settings.flags.size());
|
for (final PlotFlag<?, ?> flag : flagMap.values()) {
|
||||||
}
|
if (flag instanceof InternalFlag) {
|
||||||
for (Map.Entry<Flag<?>, Object> flag : settings.flags.entrySet()) {
|
|
||||||
if (flag.getKey().isReserved()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
flags.put(flag.getKey(), flag.getValue());
|
flags.put(flag.getClass(), flag);
|
||||||
}
|
}
|
||||||
return flags;
|
|
||||||
} else if (flags == null) {
|
|
||||||
return settings.flags;
|
|
||||||
} else {
|
} else {
|
||||||
flags.putAll(settings.flags);
|
flags.putAll(flagMap);
|
||||||
}
|
}
|
||||||
return flags;
|
return flagMap.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) {
|
public static Map<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) {
|
||||||
|
@ -8,10 +8,11 @@ import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ServerPlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ServerPlotFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.DoubleFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
@ -60,6 +61,11 @@ import java.util.stream.IntStream;
|
|||||||
*/
|
*/
|
||||||
public class MainUtil {
|
public class MainUtil {
|
||||||
|
|
||||||
|
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
|
||||||
|
static {
|
||||||
|
FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the NMS code for sending chunk updates is functional<br>
|
* If the NMS code for sending chunk updates is functional<br>
|
||||||
* - E.g. If using an older version of Bukkit, or before the plugin is updated to 1.5<br>
|
* - E.g. If using an older version of Bukkit, or before the plugin is updated to 1.5<br>
|
||||||
@ -778,22 +784,18 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder flags = new StringBuilder();
|
StringBuilder flags = new StringBuilder();
|
||||||
HashMap<Flag<?>, Object> flagMap =
|
Collection<PlotFlag<?, ?>> flagCollection = FlagManager.getPlotFlags(plot, true);
|
||||||
FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true);
|
if (flagCollection.isEmpty()) {
|
||||||
if (flagMap.isEmpty()) {
|
|
||||||
flags.append(Captions.NONE.getTranslated());
|
flags.append(Captions.NONE.getTranslated());
|
||||||
} else {
|
} else {
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
for (Entry<Flag<?>, Object> entry : flagMap.entrySet()) {
|
for (final PlotFlag<?, ?> flag : flagCollection) {
|
||||||
Object value = entry.getValue();
|
Object value = flag.getValue();
|
||||||
if (entry.getKey() instanceof DoubleFlag && !Settings.General.SCIENTIFIC) {
|
if (flag instanceof DoubleFlag && !Settings.General.SCIENTIFIC) {
|
||||||
DecimalFormat df = new DecimalFormat("0");
|
value = FLAG_DECIMAL_FORMAT.format(value);
|
||||||
df.setMaximumFractionDigits(340);
|
|
||||||
value = df.format(value);
|
|
||||||
}
|
}
|
||||||
flags.append(prefix).append(CaptionUtility
|
flags.append(prefix).append(CaptionUtility.format(Captions.PLOT_FLAG_LIST.getTranslated(),
|
||||||
.format(Captions.PLOT_FLAG_LIST.getTranslated(), entry.getKey().getName(),
|
flag.getName(), value));
|
||||||
value));
|
|
||||||
prefix = ", ";
|
prefix = ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user