mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
feat: add InteractionInteractFlag (#4538)
This commit is contained in:
parent
a11c560d4e
commit
32d36b28fa
@ -54,6 +54,7 @@ import com.plotsquared.core.plot.flag.implementations.EditSignFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.HangingBreakFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.HangingPlaceFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.HostileInteractFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.InteractionInteractFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.ItemDropFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.KeepInventoryFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.LecternReadBookFlag;
|
||||
@ -1737,6 +1738,11 @@ public class PlayerEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.INTERACTION.contains(entityType) && flagContainer
|
||||
.getFlag(InteractionInteractFlag.class).getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityCategories.VILLAGER.contains(entityType) && flagContainer
|
||||
.getFlag(VillagerInteractFlag.class).getValue()) {
|
||||
return;
|
||||
|
@ -75,6 +75,7 @@ import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.Interaction;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
@ -432,6 +433,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
@Override
|
||||
public @NonNull Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(final @NonNull String category) {
|
||||
final Collection<Class<?>> allowedInterfaces = new HashSet<>();
|
||||
final int[] version = PlotSquared.platform().serverVersion();
|
||||
switch (category) {
|
||||
case "animal" -> {
|
||||
allowedInterfaces.add(IronGolem.class);
|
||||
@ -439,7 +441,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
allowedInterfaces.add(Animals.class);
|
||||
allowedInterfaces.add(WaterMob.class);
|
||||
allowedInterfaces.add(Ambient.class);
|
||||
if (PlotSquared.platform().serverVersion()[1] >= 19) {
|
||||
if (version[1] >= 19) {
|
||||
allowedInterfaces.add(Allay.class);
|
||||
}
|
||||
}
|
||||
@ -470,6 +472,11 @@ public class BukkitUtil extends WorldUtil {
|
||||
allowedInterfaces.add(Firework.class);
|
||||
}
|
||||
case "player" -> allowedInterfaces.add(Player.class);
|
||||
case "interaction" -> {
|
||||
if ((version[1] > 19) || (version[1] == 19 && version[2] >= 4)) {
|
||||
allowedInterfaces.add(Interaction.class);
|
||||
}
|
||||
}
|
||||
default -> LOGGER.error("Unknown entity category requested: {}", category);
|
||||
}
|
||||
final Set<com.sk89q.worldedit.world.entity.EntityType> types = new HashSet<>();
|
||||
|
@ -65,6 +65,7 @@ import com.plotsquared.core.plot.flag.implementations.HostileInteractFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.IceFormFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.IceMeltFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.InstabreakFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.InteractionInteractFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.InvincibleFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.ItemDropFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
||||
@ -172,6 +173,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
this.addFlag(IceFormFlag.ICE_FORM_FALSE);
|
||||
this.addFlag(IceMeltFlag.ICE_MELT_FALSE);
|
||||
this.addFlag(InstabreakFlag.INSTABREAK_FALSE);
|
||||
this.addFlag(InteractionInteractFlag.INTERACTION_INTERACT_FALSE);
|
||||
this.addFlag(InvincibleFlag.INVINCIBLE_FALSE);
|
||||
this.addFlag(ItemDropFlag.ITEM_DROP_TRUE);
|
||||
this.addFlag(KeepInventoryFlag.KEEP_INVENTORY_FALSE);
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* PlotSquared, a land and world management plugin for Minecraft.
|
||||
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
||||
* Copyright (C) IntellectualSites team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.plot.flag.implementations;
|
||||
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.plot.flag.types.BooleanFlag;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class InteractionInteractFlag extends BooleanFlag<InteractionInteractFlag> {
|
||||
|
||||
public static final InteractionInteractFlag INTERACTION_INTERACT_TRUE = new InteractionInteractFlag(true);
|
||||
public static final InteractionInteractFlag INTERACTION_INTERACT_FALSE = new InteractionInteractFlag(false);
|
||||
|
||||
private InteractionInteractFlag(boolean value) {
|
||||
super(value, TranslatableCaption.of("flags.flag_description_interaction_interact"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InteractionInteractFlag flagOf(@NonNull Boolean value) {
|
||||
return value ? INTERACTION_INTERACT_TRUE : INTERACTION_INTERACT_FALSE;
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@ public class EntityCategories {
|
||||
public static final EntityCategory PROJECTILE = register("projectile");
|
||||
public static final EntityCategory OTHER = register("other");
|
||||
public static final EntityCategory PLAYER = register("player");
|
||||
public static final EntityCategory INTERACTION = register("interaction");
|
||||
|
||||
public static EntityCategory register(final String id) {
|
||||
final EntityCategory entityCategory = new EntityCategory(PlotSquared.platform().worldUtil(), id);
|
||||
|
@ -572,6 +572,7 @@
|
||||
"flags.flag_description_ice_form": "<gray>Set to `true` to allow ice to form in the plot.</gray>",
|
||||
"flags.flag_description_ice_melt": "<gray>Set to `false` to disable ice melting in the plot.</gray>",
|
||||
"flags.flag_description_instabreak": "<gray>Set to `true` to allow blocks to be instantaneously broken in survival mode.</gray>",
|
||||
"flags.flag_description_interaction_interact": "<gray>Set to `true` to allow guests to interact with interaction entities in the plot.</gray>",
|
||||
"flags.flag_description_invincible": "<gray>Set to `true` to prevent players from taking damage inside the plot.</gray>",
|
||||
"flags.flag_description_item_drop": "<gray>Set to `false` to prevent items from being dropped inside the plot.</gray>",
|
||||
"flags.flag_description_kelp_grow": "<gray>Set to `false` to prevent kelp from growing in the plot.</gray>",
|
||||
|
Loading…
Reference in New Issue
Block a user