mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 05:05:20 +01:00
Fix some reported issues
This commit is contained in:
parent
f021d5b855
commit
4e5348ce45
@ -22,12 +22,11 @@ public class PaymentListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerCreateNPC(PlayerCreateNPCEvent event) {
|
||||
String name = event.getCreator().getName();
|
||||
boolean hasAccount = provider.hasAccount(name);
|
||||
boolean hasAccount = provider.hasAccount(event.getCreator());
|
||||
if (!hasAccount || event.getCreator().hasPermission("citizens.npc.ignore-cost"))
|
||||
return;
|
||||
double cost = Setting.NPC_COST.asDouble();
|
||||
EconomyResponse response = provider.withdrawPlayer(name, cost);
|
||||
EconomyResponse response = provider.withdrawPlayer(event.getCreator(), cost);
|
||||
if (!response.transactionSuccess()) {
|
||||
event.setCancelled(true);
|
||||
event.setCancelReason(response.errorMessage);
|
||||
|
@ -267,7 +267,7 @@ public class NPCCommands {
|
||||
}
|
||||
|
||||
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
|
||||
: new CommandSenderCreateNPCEvent(sender, copy);
|
||||
: new CommandSenderCreateNPCEvent(sender, copy);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
event.getNPC().destroy();
|
||||
@ -343,7 +343,7 @@ public class NPCCommands {
|
||||
spawnLoc = args.getSenderLocation();
|
||||
}
|
||||
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
|
||||
: new CommandSenderCreateNPCEvent(sender, npc);
|
||||
: new CommandSenderCreateNPCEvent(sender, npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
npc.destroy();
|
||||
@ -915,13 +915,15 @@ public class NPCCommands {
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "citizens.npc.pathfindingoptions")
|
||||
public void pathfindingOptions(CommandContext args, CommandSender sender, NPC npc) {
|
||||
public void pathfindingOptions(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.hasValueFlag("avoid-water") || args.hasValueFlag("aw")) {
|
||||
String raw = args.getFlag("avoid-water", args.getFlag("aw"));
|
||||
boolean avoid = Boolean.parseBoolean(raw);
|
||||
npc.getNavigator().getDefaultParameters().avoidWater(avoid);
|
||||
Messaging.sendTr(sender, avoid ? Messages.PATHFINDING_OPTIONS_AVOID_WATER_SET
|
||||
: Messages.PATHFINDING_OPTIONS_AVOID_WATER_UNSET, npc.getName());
|
||||
} else {
|
||||
throw new CommandException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1018,7 +1020,7 @@ public class NPCCommands {
|
||||
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
|
||||
public void power(CommandContext args, CommandSender sender, NPC npc) {
|
||||
Messaging
|
||||
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
||||
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -1041,7 +1043,7 @@ public class NPCCommands {
|
||||
}
|
||||
|
||||
@Command(aliases = { "npc" }, usage = "remove|rem (all|id|name)", desc = "Remove a NPC", modifiers = { "remove",
|
||||
"rem" }, min = 1, max = 2)
|
||||
"rem" }, min = 1, max = 2)
|
||||
@Requirements
|
||||
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.argsLength() == 2) {
|
||||
|
@ -31,7 +31,6 @@ import net.minecraft.server.v1_7_R4.NetworkManager;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_7_R4.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
@ -274,8 +273,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
int useListName = removeFromPlayerList ? 0 : 1;
|
||||
if (useListName != this.useListName || this.useListName == -1) {
|
||||
this.useListName = useListName;
|
||||
//packets[5] = new PacketPlayOutPlayerInfo(getBukkitEntity().getPlayerListName(), !removeFromPlayerList,
|
||||
// removeFromPlayerList ? 9999 : ping);
|
||||
// packets[5] = new
|
||||
// PacketPlayOutPlayerInfo(getBukkitEntity().getPlayerListName(),
|
||||
// !removeFromPlayerList,
|
||||
// removeFromPlayerList ? 9999 : ping);
|
||||
}
|
||||
NMS.sendPacketsNearby(getBukkitEntity(), current, packets);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.citizensnpcs.util;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation;
|
||||
@ -58,6 +59,10 @@ public enum PlayerAnimation {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (player instanceof NPCHolder && !((NPCHolder) player).getNPC().isSpawned()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (player.passenger != player) {
|
||||
player.mount(player);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user