mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 12:15:53 +01:00
PICKUP_ITEMS now defaults to false rather than isProtected
This commit is contained in:
parent
960e1036b4
commit
8235ed160f
@ -8,6 +8,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -58,6 +59,7 @@ import net.citizensnpcs.api.trait.TraitFactory;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.api.util.NBTStorage;
|
||||
import net.citizensnpcs.api.util.Placeholders;
|
||||
import net.citizensnpcs.api.util.Storage;
|
||||
import net.citizensnpcs.api.util.Translator;
|
||||
import net.citizensnpcs.api.util.YamlStorage;
|
||||
@ -75,6 +77,8 @@ import net.citizensnpcs.npc.Template;
|
||||
import net.citizensnpcs.npc.ai.speech.CitizensSpeechFactory;
|
||||
import net.citizensnpcs.npc.profile.ProfileFetcher;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.trait.ClickRedirectTrait;
|
||||
import net.citizensnpcs.trait.CommandTrait;
|
||||
import net.citizensnpcs.trait.ShopTrait;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
@ -432,6 +436,13 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
selector = new NPCSelector(this);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new EventListen(storedRegistries), this);
|
||||
Bukkit.getPluginManager().registerEvents(new Placeholders(), this);
|
||||
Placeholders.registerNPCPlaceholder(Pattern.compile("command_[a-zA-Z_0-9]+"), (npc, sender, input) -> {
|
||||
npc = npc.hasTrait(ClickRedirectTrait.class) ? npc.getTraitNullable(ClickRedirectTrait.class).getNPC()
|
||||
: npc;
|
||||
CommandTrait trait = npc.getTraitNullable(CommandTrait.class);
|
||||
return trait == null ? "" : trait.fillPlaceholder(sender, input);
|
||||
});
|
||||
Plugin papi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
|
||||
if (papi != null && papi.isEnabled()) {
|
||||
new CitizensPlaceholders(selector).register();
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.citizensnpcs.editor;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
public interface Equipper {
|
||||
public void equip(Player equipper, NPC toEquip);
|
||||
}
|
@ -533,8 +533,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
NMS.setKnockbackResistance((LivingEntity) getEntity(), isProtected() ? 1D : 0D);
|
||||
if (SUPPORT_PICKUP_ITEMS) {
|
||||
try {
|
||||
((LivingEntity) getEntity())
|
||||
.setCanPickupItems(data().get(NPC.Metadata.PICKUP_ITEMS, !isProtected()));
|
||||
((LivingEntity) getEntity()).setCanPickupItems(data().get(NPC.Metadata.PICKUP_ITEMS, false));
|
||||
} catch (Throwable t) {
|
||||
SUPPORT_PICKUP_ITEMS = false;
|
||||
}
|
||||
|
@ -8,9 +8,6 @@ import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
|
||||
/**
|
||||
* Persists data related to {@link ArmorStand} NPCs.
|
||||
*/
|
||||
@TraitName("armorstandtrait")
|
||||
public class ArmorStandTrait extends Trait {
|
||||
@Persist
|
||||
|
@ -316,6 +316,10 @@ public class CommandTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
public String fillPlaceholder(CommandSender sender, String input) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public double getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
import net.citizensnpcs.api.util.DataKey;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.api.util.Placeholders;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
@ -310,18 +309,14 @@ public class HologramTrait extends Trait {
|
||||
|
||||
String text = line.text;
|
||||
if (ITEM_MATCHER.matcher(text).matches()) {
|
||||
text = null;
|
||||
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!updateName)
|
||||
continue;
|
||||
if (text != null && !ChatColor.stripColor(Messaging.parseComponents(text)).isEmpty()) {
|
||||
hologramNPC.setName(Placeholders.replace(text, null, npc));
|
||||
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, true);
|
||||
} else {
|
||||
hologramNPC.setName("");
|
||||
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, "hover");
|
||||
}
|
||||
hologramNPC.setName(Placeholders.replace(text, null, npc));
|
||||
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, npc.getRawName().length() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,7 +394,7 @@ public class HologramTrait extends Trait {
|
||||
}
|
||||
|
||||
public HologramLine(String text, boolean persist, int ticks) {
|
||||
this.text = text;
|
||||
this.text = text == null ? "" : text;
|
||||
this.persist = persist;
|
||||
this.ticks = ticks;
|
||||
if (ITEM_MATCHER.matcher(text).matches()) {
|
||||
|
@ -2,10 +2,10 @@ package net.citizensnpcs.trait.waypoint;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.citizensnpcs.api.event.CitizensEvent;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import net.citizensnpcs.api.event.CitizensEvent;
|
||||
|
||||
public class LinearWaypointsCompleteEvent extends CitizensEvent {
|
||||
private Iterator<Waypoint> next;
|
||||
private final WaypointProvider provider;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.citizensnpcs.trait.waypoint.triggers;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
public interface WaypointTrigger {
|
||||
String description();
|
||||
|
||||
|
@ -308,7 +308,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
cs();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||
axisalignedbb = this.getBoundingBox().a(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
@ -366,7 +366,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
ct();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
@ -394,7 +394,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
cB();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
@ -373,7 +373,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
cN();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
@ -378,7 +378,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
collideNearby();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
@ -422,7 +422,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
npc.update();
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
@ -452,7 +452,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
npc.update();
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
@ -194,7 +194,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
pushEntities();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AABB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
||||
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
||||
|
@ -195,7 +195,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
pushEntities();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AABB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
||||
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
||||
|
@ -200,7 +200,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
pushEntities();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AABB axisalignedbb;
|
||||
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
||||
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
||||
|
@ -306,7 +306,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
bL();
|
||||
}
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected())) {
|
||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||
AxisAlignedBB axisalignedbb = null;
|
||||
if (this.vehicle != null && !this.vehicle.dead) {
|
||||
axisalignedbb = this.getBoundingBox().a(this.vehicle.getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||
|
Loading…
Reference in New Issue
Block a user