mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 20:55:44 +01:00
Add /npc glowing <color>, fix waypoint editor right clicks
This commit is contained in:
parent
94dd5c4dba
commit
b13fbeddd5
@ -478,8 +478,10 @@ public class EventListen implements Listener {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
storeForRespawn(npc);
|
if (npc.isSpawned()) {
|
||||||
Messaging.debug("Despawned", npc.getId() + "due to world unload at", event.getWorld().getName());
|
storeForRespawn(npc);
|
||||||
|
Messaging.debug("Despawned", npc.getId() + "due to world unload at", event.getWorld().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -548,7 +549,7 @@ public class NPCCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "glowing",
|
usage = "glowing --color [minecraft chat color]",
|
||||||
desc = "Toggles an NPC's glowing status",
|
desc = "Toggles an NPC's glowing status",
|
||||||
modifiers = { "glowing" },
|
modifiers = { "glowing" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -556,6 +557,12 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.glowing")
|
permission = "citizens.npc.glowing")
|
||||||
@Requirements(selected = true, ownership = true)
|
@Requirements(selected = true, ownership = true)
|
||||||
public void glowing(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void glowing(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
if (args.hasValueFlag("color")) {
|
||||||
|
ChatColor chatColor = Util.matchEnum(ChatColor.values(), args.getFlag("color"));
|
||||||
|
if (chatColor == null || !(npc.getEntity() instanceof Player))
|
||||||
|
throw new CommandException();
|
||||||
|
npc.data().setPersistent(NPC.GLOWING_COLOR_METADATA, chatColor.name());
|
||||||
|
}
|
||||||
npc.data().setPersistent(NPC.GLOWING_METADATA, !npc.data().get(NPC.GLOWING_METADATA, false));
|
npc.data().setPersistent(NPC.GLOWING_METADATA, !npc.data().get(NPC.GLOWING_METADATA, false));
|
||||||
boolean glowing = npc.data().get(NPC.GLOWING_METADATA);
|
boolean glowing = npc.data().get(NPC.GLOWING_METADATA);
|
||||||
Messaging.sendTr(sender, glowing ? Messages.GLOWING_SET : Messages.GLOWING_UNSET, npc.getName());
|
Messaging.sendTr(sender, glowing ? Messages.GLOWING_SET : Messages.GLOWING_UNSET, npc.getName());
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
|
||||||
@ -15,7 +16,9 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
import org.bukkit.scoreboard.Team.Option;
|
||||||
|
import org.bukkit.scoreboard.Team.OptionStatus;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
@ -277,21 +280,22 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
if (!getNavigator().isNavigating() && updateCounter++ > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
if (!getNavigator().isNavigating() && updateCounter++ > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
||||||
updateCounter = 0;
|
updateCounter = 0;
|
||||||
if (getEntity() instanceof LivingEntity) {
|
if (getEntity() instanceof LivingEntity) {
|
||||||
|
OptionStatus nameVisibility = OptionStatus.NEVER;
|
||||||
if (!getEntity().isCustomNameVisible()) {
|
if (!getEntity().isCustomNameVisible()) {
|
||||||
if (getEntity() instanceof Player && data().has(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA)) {
|
|
||||||
String teamName = data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
|
|
||||||
Bukkit.getScoreboardManager().getMainScoreboard().getTeam(teamName)
|
|
||||||
.setNameTagVisibility(NameTagVisibility.NEVER);
|
|
||||||
}
|
|
||||||
getEntity().setCustomName("");
|
getEntity().setCustomName("");
|
||||||
} else {
|
} else {
|
||||||
if (getEntity() instanceof Player && data().has(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA)) {
|
nameVisibility = OptionStatus.ALWAYS;
|
||||||
String teamName = data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
|
|
||||||
Bukkit.getScoreboardManager().getMainScoreboard().getTeam(teamName)
|
|
||||||
.setNameTagVisibility(NameTagVisibility.ALWAYS);
|
|
||||||
}
|
|
||||||
getEntity().setCustomName(getFullName());
|
getEntity().setCustomName(getFullName());
|
||||||
}
|
}
|
||||||
|
if (getEntity() instanceof Player && data().has(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA)) {
|
||||||
|
String teamName = data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
|
||||||
|
Team team = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(teamName);
|
||||||
|
team.setOption(Option.NAME_TAG_VISIBILITY, nameVisibility);
|
||||||
|
if (data().has(NPC.GLOWING_COLOR_METADATA) && team.getPrefix() == null) {
|
||||||
|
team.setPrefix(
|
||||||
|
ChatColor.valueOf(data().<String> get(NPC.GLOWING_COLOR_METADATA)).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Player player = getEntity() instanceof Player ? (Player) getEntity() : null;
|
Player player = getEntity() instanceof Player ? (Player) getEntity() : null;
|
||||||
NMS.sendPacketNearby(player, getStoredLocation(),
|
NMS.sendPacketNearby(player, getStoredLocation(),
|
||||||
|
@ -98,22 +98,22 @@ public class HumanController extends AbstractEntityController {
|
|||||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(),
|
NMS.addOrRemoveFromPlayerList(getBukkitEntity(),
|
||||||
npc.data().get("removefromplayerlist", removeFromPlayerList));
|
npc.data().get("removefromplayerlist", removeFromPlayerList));
|
||||||
if (prefixCapture != null) {
|
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
String teamName = UUID.randomUUID().toString().substring(0, 16);
|
||||||
String teamName = UUID.randomUUID().toString().substring(0, 16);
|
|
||||||
|
|
||||||
Team team = scoreboard.getTeam(teamName);
|
Team team = scoreboard.getTeam(teamName);
|
||||||
if (team == null) {
|
if (team == null) {
|
||||||
team = scoreboard.registerNewTeam(teamName);
|
team = scoreboard.registerNewTeam(teamName);
|
||||||
|
if (prefixCapture != null) {
|
||||||
team.setPrefix(prefixCapture);
|
team.setPrefix(prefixCapture);
|
||||||
if (suffixCapture != null) {
|
|
||||||
team.setSuffix(suffixCapture);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
team.addPlayer(handle.getBukkitEntity());
|
if (suffixCapture != null) {
|
||||||
|
team.setSuffix(suffixCapture);
|
||||||
handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName);
|
}
|
||||||
}
|
}
|
||||||
|
team.addPlayer(handle.getBukkitEntity());
|
||||||
|
|
||||||
|
handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName);
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ public class GuidedWaypointProvider implements WaypointProvider {
|
|||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL
|
if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL
|
||||||
|| event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK
|
|| event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK
|
||||||
|| event.getClickedBlock() == null)
|
|| event.getClickedBlock() == null || event.getHand() == EquipmentSlot.OFF_HAND)
|
||||||
return;
|
return;
|
||||||
if (event.getPlayer().getWorld() != npc.getEntity().getWorld())
|
if (event.getPlayer().getWorld() != npc.getEntity().getWorld())
|
||||||
return;
|
return;
|
||||||
@ -133,7 +134,8 @@ public class GuidedWaypointProvider implements WaypointProvider {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
if (!event.getRightClicked().hasMetadata("citizens.waypointhashcode"))
|
if (!event.getRightClicked().hasMetadata("citizens.waypointhashcode")
|
||||||
|
|| event.getHand() == EquipmentSlot.OFF_HAND)
|
||||||
return;
|
return;
|
||||||
int hashcode = event.getRightClicked().getMetadata("citizens.waypointhashcode").get(0).asInt();
|
int hashcode = event.getRightClicked().getMetadata("citizens.waypointhashcode").get(0).asInt();
|
||||||
Iterator<Waypoint> itr = Iterables.concat(available, helpers).iterator();
|
Iterator<Waypoint> itr = Iterables.concat(available, helpers).iterator();
|
||||||
|
@ -17,6 +17,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@ -247,7 +248,8 @@ public class LinearWaypointProvider implements WaypointProvider {
|
|||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL || !npc.isSpawned()
|
if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL || !npc.isSpawned()
|
||||||
|| event.getPlayer().getWorld() != npc.getEntity().getWorld())
|
|| event.getPlayer().getWorld() != npc.getEntity().getWorld()
|
||||||
|
|| event.getHand() == EquipmentSlot.OFF_HAND)
|
||||||
return;
|
return;
|
||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||||
if (event.getClickedBlock() == null)
|
if (event.getClickedBlock() == null)
|
||||||
@ -291,7 +293,7 @@ public class LinearWaypointProvider implements WaypointProvider {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
if (!player.equals(event.getPlayer()) || !showPath)
|
if (!player.equals(event.getPlayer()) || !showPath || event.getHand() == EquipmentSlot.OFF_HAND)
|
||||||
return;
|
return;
|
||||||
if (!event.getRightClicked().hasMetadata("waypointindex"))
|
if (!event.getRightClicked().hasMetadata("waypointindex"))
|
||||||
return;
|
return;
|
||||||
|
@ -18,6 +18,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -35,6 +36,7 @@ import org.bukkit.entity.Tameable;
|
|||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.bukkit.plugin.PluginLoadOrder;
|
import org.bukkit.plugin.PluginLoadOrder;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
@ -76,6 +78,7 @@ import net.minecraft.server.v1_9_R1.EntityTameableAnimal;
|
|||||||
import net.minecraft.server.v1_9_R1.EntityTracker;
|
import net.minecraft.server.v1_9_R1.EntityTracker;
|
||||||
import net.minecraft.server.v1_9_R1.EntityTrackerEntry;
|
import net.minecraft.server.v1_9_R1.EntityTrackerEntry;
|
||||||
import net.minecraft.server.v1_9_R1.EntityTypes;
|
import net.minecraft.server.v1_9_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_9_R1.EnumChatFormat;
|
||||||
import net.minecraft.server.v1_9_R1.GenericAttributes;
|
import net.minecraft.server.v1_9_R1.GenericAttributes;
|
||||||
import net.minecraft.server.v1_9_R1.MathHelper;
|
import net.minecraft.server.v1_9_R1.MathHelper;
|
||||||
import net.minecraft.server.v1_9_R1.MobEffects;
|
import net.minecraft.server.v1_9_R1.MobEffects;
|
||||||
@ -84,6 +87,7 @@ import net.minecraft.server.v1_9_R1.NetworkManager;
|
|||||||
import net.minecraft.server.v1_9_R1.Packet;
|
import net.minecraft.server.v1_9_R1.Packet;
|
||||||
import net.minecraft.server.v1_9_R1.PacketPlayOutPlayerInfo;
|
import net.minecraft.server.v1_9_R1.PacketPlayOutPlayerInfo;
|
||||||
import net.minecraft.server.v1_9_R1.PathfinderGoalSelector;
|
import net.minecraft.server.v1_9_R1.PathfinderGoalSelector;
|
||||||
|
import net.minecraft.server.v1_9_R1.ScoreboardTeam;
|
||||||
import net.minecraft.server.v1_9_R1.Vec3D;
|
import net.minecraft.server.v1_9_R1.Vec3D;
|
||||||
import net.minecraft.server.v1_9_R1.World;
|
import net.minecraft.server.v1_9_R1.World;
|
||||||
import net.minecraft.server.v1_9_R1.WorldServer;
|
import net.minecraft.server.v1_9_R1.WorldServer;
|
||||||
@ -720,8 +724,7 @@ public class NMS {
|
|||||||
} else if (handle instanceof EntityHumanNPC) {
|
} else if (handle instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) handle).setMoveDestination(x, y, z, speed);
|
((EntityHumanNPC) handle).setMoveDestination(x, y, z, speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHeadYaw(Entity en, float yaw) {
|
public static void setHeadYaw(Entity en, float yaw) {
|
||||||
if (!(en instanceof EntityLiving))
|
if (!(en instanceof EntityLiving))
|
||||||
return;
|
return;
|
||||||
@ -890,6 +893,7 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Field CRAFT_TEAM_FIELD;
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
||||||
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
|
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
|
||||||
@ -902,11 +906,8 @@ public class NMS {
|
|||||||
private static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
|
||||||
private static Field PATHFINDING_RANGE = getField(NavigationAbstract.class, "g");
|
private static Field PATHFINDING_RANGE = getField(NavigationAbstract.class, "g");
|
||||||
private static final Field RABBIT_FIELD = getField(EntityRabbit.class, "bv");
|
private static final Field RABBIT_FIELD = getField(EntityRabbit.class, "bv");
|
||||||
|
|
||||||
private static final Random RANDOM = Util.getFastRandom();
|
private static final Random RANDOM = Util.getFastRandom();
|
||||||
|
|
||||||
private static Field SKULL_PROFILE_FIELD;
|
private static Field SKULL_PROFILE_FIELD;
|
||||||
|
|
||||||
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
|
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -48,6 +48,7 @@ public class PlayerNavigation extends NavigationAbstract {
|
|||||||
this.e = new PlayerPathfinderNormal();
|
this.e = new PlayerPathfinderNormal();
|
||||||
this.e.a(true);
|
this.e.a(true);
|
||||||
this.s = new PlayerPathfinder(this.e);
|
this.s = new PlayerPathfinder(this.e);
|
||||||
|
// this.b.C().a(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user