-
-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat-villager-cap-flag #4357
base: main
Are you sure you want to change the base?
feat-villager-cap-flag #4357
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
import com.plotsquared.core.plot.flag.implementations.PvpFlag; | ||
import com.plotsquared.core.plot.flag.implementations.TamedAttackFlag; | ||
import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag; | ||
import com.plotsquared.core.plot.flag.implementations.VillagerCapFlag; | ||
import com.plotsquared.core.util.EntityUtil; | ||
import com.plotsquared.core.util.entity.EntityCategories; | ||
import com.sk89q.worldedit.bukkit.BukkitAdapter; | ||
|
@@ -373,16 +374,23 @@ public static boolean checkEntity(Entity entity, Plot plot) { | |
); | ||
} | ||
|
||
// Has to go go before vehicle as horses are both | ||
// Has to go before vehicle as horses are both | ||
// animals and vehicles | ||
if (EntityCategories.ANIMAL.contains(entityType) || EntityCategories.VILLAGER | ||
.contains(entityType) || EntityCategories.TAMEABLE.contains(entityType)) { | ||
if (EntityCategories.ANIMAL.contains(entityType) | ||
|| EntityCategories.TAMEABLE.contains(entityType)) { | ||
return EntityUtil | ||
.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, MobCapFlag.MOB_CAP_UNLIMITED, | ||
AnimalCapFlag.ANIMAL_CAP_UNLIMITED | ||
); | ||
} | ||
|
||
if(EntityCategories.VILLAGER.contains(entityType)) { | ||
return EntityUtil | ||
.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, MobCapFlag.MOB_CAP_UNLIMITED, | ||
VillagerCapFlag.VILLAGER_CAP_UNLIMITED | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure we should remove villagers from the animal cap? |
||
} | ||
|
||
if (EntityCategories.HOSTILE.contains(entityType)) { | ||
return EntityUtil | ||
.checkEntity(plot, EntityCapFlag.ENTITY_CAP_UNLIMITED, MobCapFlag.MOB_CAP_UNLIMITED, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ | |
import static com.plotsquared.core.util.entity.EntityCategories.CAP_ANIMAL; | ||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_ENTITY; | ||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MISC; | ||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VILLAGER; | ||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MOB; | ||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER; | ||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE; | ||
|
@@ -122,7 +123,7 @@ public int[] countEntities(@NonNull Plot plot) { | |
} | ||
} | ||
|
||
int[] count = new int[6]; | ||
int[] count = new int[7]; | ||
if (doWhole) { | ||
for (Entity entity : entities) { | ||
org.bukkit.Location location = entity.getLocation(); | ||
|
@@ -330,7 +331,10 @@ private void count(int[] count, @NonNull Entity entity) { | |
} else if (EntityCategories.PROJECTILE.contains(entityType) || EntityCategories.OTHER.contains(entityType) || EntityCategories.HANGING | ||
.contains(entityType)) { | ||
count[CAP_MISC]++; | ||
} else if (EntityCategories.ANIMAL.contains(entityType) || EntityCategories.VILLAGER.contains(entityType) || EntityCategories.TAMEABLE | ||
} else if (EntityCategories.VILLAGER.contains(entityType)) { | ||
count[CAP_MOB]++; | ||
count[CAP_VILLAGER]++; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here for animal cap |
||
} else if (EntityCategories.ANIMAL.contains(entityType) || EntityCategories.TAMEABLE | ||
.contains(entityType)) { | ||
count[CAP_MOB]++; | ||
count[CAP_ANIMAL]++; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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.NonNegativeIntegerFlag; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
public class VillagerCapFlag extends NonNegativeIntegerFlag<VillagerCapFlag> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public static final VillagerCapFlag VILLAGER_CAP_UNLIMITED = new VillagerCapFlag(Integer.MAX_VALUE); | ||
|
||
protected VillagerCapFlag(int value) { | ||
super(value, TranslatableCaption.of("flags.flag_description_villager_cap")); | ||
} | ||
|
||
@Override | ||
protected VillagerCapFlag flagOf(@NonNull Integer value) { | ||
return new VillagerCapFlag(value); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style