mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
Fix entity util
This commit is contained in:
parent
95a1b0612f
commit
4c18214da1
@ -165,7 +165,7 @@ import java.util.Map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
protected static <V, T extends PlotFlag<V, ?>> T castUnsafe(final PlotFlag<?, ?> flag) {
|
||||
public static <V, T extends PlotFlag<V, ?>> T castUnsafe(final PlotFlag<?, ?> flag) {
|
||||
return (T) flag;
|
||||
}
|
||||
|
||||
|
@ -3167,6 +3167,12 @@ public class Plot {
|
||||
return this.flagContainer.getFlag(flagClass).getValue();
|
||||
}
|
||||
|
||||
public <T, V extends PlotFlag<T, ?>> T getFlag(final V flag) {
|
||||
final Class<?> flagClass = flag.getClass();
|
||||
final PlotFlag<?, ?> flagInstance = this.flagContainer.getFlagErased(flagClass);
|
||||
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
|
||||
}
|
||||
|
||||
public boolean setFlag(PlotFlag<?, ?> plotFlag) {
|
||||
flagContainer.addFlag(plotFlag);
|
||||
return true;
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.util;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import lombok.NonNull;
|
||||
@ -38,14 +37,14 @@ import lombok.experimental.UtilityClass;
|
||||
return i;
|
||||
}
|
||||
|
||||
public static boolean checkEntity(Plot plot, IntegerFlag... flags) {
|
||||
public static boolean checkEntity(Plot plot, PlotFlag<Integer, ?> ... flags) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||
return true;
|
||||
}
|
||||
int[] mobs = null;
|
||||
for (IntegerFlag flag : flags) {
|
||||
for (PlotFlag<Integer, ?> flag : flags) {
|
||||
final int i = capNumeral(flag.getName());
|
||||
int cap = plot.getFlag(flag, Integer.MAX_VALUE);
|
||||
int cap = plot.getFlag(flag);
|
||||
if (cap == Integer.MAX_VALUE) {
|
||||
continue;
|
||||
}
|
||||
@ -62,7 +61,7 @@ import lombok.experimental.UtilityClass;
|
||||
}
|
||||
}
|
||||
if (mobs != null) {
|
||||
for (IntegerFlag flag : flags) {
|
||||
for (PlotFlag<Integer, ?> flag : flags) {
|
||||
final int i = capNumeral(flag.getName());
|
||||
mobs[i]++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user