mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
Port UseFlag
This commit is contained in:
parent
55cfb7600d
commit
a00d07e1be
@ -42,6 +42,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.SoilD
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedAttackFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedAttackFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UseFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VillagerInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VillagerInteractFlag;
|
||||||
@ -2297,7 +2298,8 @@ import java.util.regex.Pattern;
|
|||||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (Flags.USE.contains(plot, BukkitAdapter.asItemType(block.getType()))) {
|
List<BlockType> use = plot.getFlag(UseFlag.class);
|
||||||
|
if (use.contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
@ -2357,9 +2359,9 @@ import java.util.regex.Pattern;
|
|||||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (!plot.isAdded(plotPlayer.getUUID())) {
|
} else if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
Optional<Set<BlockType>> use = plot.getFlag(Flags.USE);
|
List<BlockType> use = plot.getFlag(UseFlag.class);
|
||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked();
|
||||||
if (use.isPresent() && use.get().contains(BukkitAdapter.asBlockType(block.getType()))) {
|
if (use.contains(BukkitAdapter.asBlockType(block.getType()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
|
@ -622,6 +622,7 @@ public enum Captions implements Caption {
|
|||||||
FLAG_DESCRIPTION_TAMED_ATTACK("Set to `true` to allow guests to attack tamed animals in the plot.", "Flags"),
|
FLAG_DESCRIPTION_TAMED_ATTACK("Set to `true` to allow guests to attack tamed animals in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_TAMED_INTERACT("Set to `true` to allow guests to interact with tamed animals in the plot.", "Flags"),
|
FLAG_DESCRIPTION_TAMED_INTERACT("Set to `true` to allow guests to interact with tamed animals in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_TITLES("Set to `false` to disable plot titles.", "Flags"),
|
FLAG_DESCRIPTION_TITLES("Set to `false` to disable plot titles.", "Flags"),
|
||||||
|
FLAG_DESCRIPTION_USE("Define a list of materials players should be able to interact with in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_VEHICLE_BREAK("Set to `true` to allow guests to break vehicles in the plot.", "Flags"),
|
FLAG_DESCRIPTION_VEHICLE_BREAK("Set to `true` to allow guests to break vehicles in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_VEHICLE_CAP("Set to an integer value to limit the amount of vehicles on the plot.", "Flags"),
|
FLAG_DESCRIPTION_VEHICLE_CAP("Set to an integer value to limit the amount of vehicles on the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_VEHICLE_PLACE("Set to `true` to allow guests to place vehicles in the plot.", "Flags"),
|
FLAG_DESCRIPTION_VEHICLE_PLACE("Set to `true` to allow guests to place vehicles in the plot.", "Flags"),
|
||||||
|
@ -63,6 +63,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Tamed
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TamedInteractFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TitlesFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.TitlesFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UseFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleBreakFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleCapFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleCapFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehicleUseFlag;
|
||||||
@ -163,7 +164,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||||||
// Block type list flags
|
// Block type list flags
|
||||||
this.addFlag(BreakFlag.BREAK_NONE);
|
this.addFlag(BreakFlag.BREAK_NONE);
|
||||||
this.addFlag(PlaceFlag.PLACE_NONE);
|
this.addFlag(PlaceFlag.PLACE_NONE);
|
||||||
|
this.addFlag(UseFlag.USE_NONE);
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
this.addFlag(GamemodeFlag.GAMEMODE_FLAG_DEFAULT);
|
this.addFlag(GamemodeFlag.GAMEMODE_FLAG_DEFAULT);
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeListFlag;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UseFlag extends BlockTypeListFlag<UseFlag> {
|
||||||
|
public static final UseFlag USE_NONE = new UseFlag(Collections.emptyList());
|
||||||
|
|
||||||
|
protected UseFlag(List<BlockType> blockTypeList) {
|
||||||
|
super(blockTypeList, Captions.FLAG_DESCRIPTION_USE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected UseFlag flagOf(@NotNull List<BlockType> value) {
|
||||||
|
return new UseFlag(value);
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Devic
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscPlaceFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscPlaceFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UseFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehiclePlaceFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehiclePlaceFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
|
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
@ -132,10 +133,8 @@ public abstract class EventUtil {
|
|||||||
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED.getTranslated(),
|
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED.getTranslated(),
|
||||||
notifyPerms);
|
notifyPerms);
|
||||||
}
|
}
|
||||||
Optional<Set<BlockType>> flagValue = plot.getFlag(Flags.USE);
|
List<BlockType> use = plot.getFlag(UseFlag.class);
|
||||||
Set<BlockType> value = flagValue.orElse(null);
|
if (!use.contains(BlockTypes.AIR) && !use.contains(blockType)) {
|
||||||
if (value == null || !value.contains(BlockTypes.AIR) && !value
|
|
||||||
.contains(blockType)) {
|
|
||||||
return Permissions.hasPermission(player,
|
return Permissions.hasPermission(player,
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false)
|
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false)
|
||||||
|| !(!notifyPerms || MainUtil
|
|| !(!notifyPerms || MainUtil
|
||||||
@ -157,10 +156,8 @@ public abstract class EventUtil {
|
|||||||
if (plot.getFlag(DeviceInteractFlag.class)) {
|
if (plot.getFlag(DeviceInteractFlag.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Optional<Set<BlockType>> flagValue = plot.getFlag(Flags.USE);
|
List<BlockType> use = plot.getFlag(UseFlag.class);
|
||||||
Set<BlockType> value = flagValue.orElse(null);
|
if (!use.contains(BlockTypes.AIR) && !use.contains(blockType)) {
|
||||||
if (value == null || !value.contains(BlockTypes.AIR) && !value
|
|
||||||
.contains(blockType)) {
|
|
||||||
if (Permissions.hasPermission(player,
|
if (Permissions.hasPermission(player,
|
||||||
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(),
|
Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(),
|
||||||
false)) {
|
false)) {
|
||||||
|
@ -25,7 +25,6 @@ import static org.junit.Assert.assertEquals;
|
|||||||
public class FlagTest {
|
public class FlagTest {
|
||||||
|
|
||||||
private ItemType testBlock;
|
private ItemType testBlock;
|
||||||
private Flag<? extends Collection<?>> use = Flags.USE;
|
|
||||||
|
|
||||||
@Before public void setUp() throws Exception {
|
@Before public void setUp() throws Exception {
|
||||||
EventUtil.manager = new EventUtilTest();
|
EventUtil.manager = new EventUtilTest();
|
||||||
|
Loading…
Reference in New Issue
Block a user