mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-10 10:28:12 +01:00
Add PlayerAnimation.START_ELYTRA
This commit is contained in:
parent
e4f059683a
commit
23f03c1fd8
@ -256,9 +256,9 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
CitizensAPI.setImplementation(this);
|
||||
config = new Settings(getDataFolder());
|
||||
setupTranslator();
|
||||
CitizensAPI.setImplementation(this);
|
||||
// Disable if the server is not using the compatible Minecraft version
|
||||
String mcVersion = Util.getMinecraftRevision();
|
||||
compatible = true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.citizensnpcs.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.citizensnpcs.Citizens;
|
||||
import net.citizensnpcs.api.command.Command;
|
||||
@ -28,6 +29,7 @@ public class AdminCommands {
|
||||
Messaging.send(sender, " <7>-- <c>Written by fullwall and aPunch");
|
||||
Messaging.send(sender, " <7>-- <c>Source Code: http://github.com/CitizensDev");
|
||||
Messaging.send(sender, " <7>-- <c>Website: " + plugin.getDescription().getWebsite());
|
||||
Messaging.log(((Player) sender).getInventory().getItemInOffHand());
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -503,8 +503,7 @@ public class NPCCommands {
|
||||
public void flyable(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
boolean flyable = args.argsLength() == 2 ? args.getString(1).equals("true") : !npc.isFlyable();
|
||||
npc.setFlyable(flyable);
|
||||
flyable = npc.isFlyable(); // may not have applied, eg bats always
|
||||
// flyable
|
||||
flyable = npc.isFlyable(); // may not have applied, eg bats always flyable
|
||||
Messaging.sendTr(sender, flyable ? Messages.FLYABLE_SET : Messages.FLYABLE_UNSET, npc.getName());
|
||||
}
|
||||
|
||||
|
@ -354,6 +354,10 @@ public class CitizensNPC extends AbstractNPC {
|
||||
if (Util.isAlwaysFlyable(type)) {
|
||||
data().setPersistent(NPC.FLYABLE_METADATA, true);
|
||||
}
|
||||
if (type == EntityType.PLAYER) {
|
||||
Player player = (Player) getEntity();
|
||||
player.getInventory().getExtraContents();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String NPC_METADATA_MARKER = "NPC";
|
||||
|
@ -4,8 +4,12 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -19,11 +23,13 @@ import net.citizensnpcs.api.astar.AStarMachine;
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.ChunkBlockSource;
|
||||
import net.citizensnpcs.api.astar.pathfinder.FlyingBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.Path;
|
||||
import net.citizensnpcs.api.astar.pathfinder.VectorGoal;
|
||||
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.PlayerAnimation;
|
||||
|
||||
public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
||||
private final NPC npc;
|
||||
@ -114,6 +120,18 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
||||
npc.getEntity().getWorld().playEffect(vector.toLocation(npc.getEntity().getWorld()), Effect.ENDER_SIGNAL,
|
||||
0);
|
||||
}
|
||||
if (npc.getEntity().getType() == EntityType.PLAYER) {
|
||||
ItemStack stack = ((Player) npc.getEntity()).getInventory().getChestplate();
|
||||
if (!MinecraftBlockExaminer.canStandOn(current.getBlock().getRelative(BlockFace.DOWN))) {
|
||||
try {
|
||||
if (stack != null && stack.getType() == Material.ELYTRA) {
|
||||
PlayerAnimation.START_ELYTRA.play((Player) npc.getEntity());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// 1.8 compatibility
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double d0 = vector.getX() + 0.5D - current.getX();
|
||||
double d1 = vector.getY() + 0.1D - current.getY();
|
||||
|
@ -201,6 +201,5 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
}
|
||||
};
|
||||
private static final Location HANDLE_LOCATION = new Location(null, 0, 0, 0);
|
||||
|
||||
private static final Location TARGET_LOCATION = new Location(null, 0, 0, 0);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public enum PlayerAnimation {
|
||||
SIT,
|
||||
SLEEP,
|
||||
SNEAK,
|
||||
START_ELYTRA,
|
||||
START_USE_MAINHAND_ITEM,
|
||||
START_USE_OFFHAND_ITEM,
|
||||
STOP_SITTING,
|
||||
|
@ -87,6 +87,9 @@ public class PlayerAnimationImpl {
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
radius);
|
||||
break;
|
||||
case START_ELYTRA:
|
||||
player.M();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
@ -77,6 +77,9 @@ public class PlayerAnimationImpl {
|
||||
}
|
||||
}.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
|
||||
break;
|
||||
case START_ELYTRA:
|
||||
player.M();
|
||||
break;
|
||||
case SLEEP:
|
||||
PacketPlayOutBed packet = new PacketPlayOutBed(player,
|
||||
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
|
||||
|
@ -86,6 +86,9 @@ public class PlayerAnimationImpl {
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
radius);
|
||||
break;
|
||||
case START_ELYTRA:
|
||||
player.N();
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
|
Loading…
Reference in New Issue
Block a user