mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-18 13:21:45 +01:00
Catch protocollib errors again, change /npc list to use uuid rather than id
This commit is contained in:
parent
ea00df6c7e
commit
a9fea94c61
@ -169,7 +169,24 @@ public class ProtocolLibListener implements Listener {
|
|||||||
ListenerOptions.ASYNC) {
|
ListenerOptions.ASYNC) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
RotationTrait trait = rotationTraits.get(event.getPacket().getIntegers().readSafely(0));
|
Integer eid = null;
|
||||||
|
try {
|
||||||
|
eid = event.getPacket().getIntegers().readSafely(0);
|
||||||
|
if (eid == null)
|
||||||
|
return;
|
||||||
|
} catch (FieldAccessException | IllegalArgumentException ex) {
|
||||||
|
if (!LOGGED_ERROR) {
|
||||||
|
Messaging.severe(
|
||||||
|
"Error retrieving entity from ID: ProtocolLib error? Suppressing further exceptions unless debugging.");
|
||||||
|
ex.printStackTrace();
|
||||||
|
LOGGED_ERROR = true;
|
||||||
|
} else if (Messaging.isDebugging()) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RotationTrait trait = rotationTraits.get(eid);
|
||||||
if (trait == null)
|
if (trait == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class Settings {
|
|||||||
"The default MOVEMENT distance in blocks where the NPC will move to before considering a path finished<br>Note: this is different from the PATHFINDING distance which is specified by path-distance-margin",
|
"The default MOVEMENT distance in blocks where the NPC will move to before considering a path finished<br>Note: this is different from the PATHFINDING distance which is specified by path-distance-margin",
|
||||||
"npc.pathfinding.default-distance-margin", 1),
|
"npc.pathfinding.default-distance-margin", 1),
|
||||||
DEFAULT_LOOK_CLOSE("Enable look close by default", "npc.default.look-close.enabled", false),
|
DEFAULT_LOOK_CLOSE("Enable look close by default", "npc.default.look-close.enabled", false),
|
||||||
DEFAULT_LOOK_CLOSE_RANGE("Default look close range in blocks", "npc.default.look-close.range", 5),
|
DEFAULT_LOOK_CLOSE_RANGE("Default look close range in blocks", "npc.default.look-close.range", 10),
|
||||||
DEFAULT_NPC_HOLOGRAM_LINE_HEIGHT("Default distance between hologram lines", "npc.hologram.default-line-height",
|
DEFAULT_NPC_HOLOGRAM_LINE_HEIGHT("Default distance between hologram lines", "npc.hologram.default-line-height",
|
||||||
0.4D),
|
0.4D),
|
||||||
DEFAULT_NPC_LIMIT(
|
DEFAULT_NPC_LIMIT(
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.conversations.NumericPrompt;
|
|||||||
import org.bukkit.conversations.Prompt;
|
import org.bukkit.conversations.Prompt;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
@ -99,31 +100,31 @@ public class NPCCommandSelector extends NumericPrompt {
|
|||||||
return;
|
return;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
int id = Integer.parseInt(raw);
|
Integer id = Ints.tryParse(raw);
|
||||||
|
if (id != null) {
|
||||||
callback.run(npcRegistry.getById(id));
|
callback.run(npcRegistry.getById(id));
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException ex) {
|
}
|
||||||
String name = args.getString(1);
|
String name = args.getString(1);
|
||||||
List<NPC> possible = Lists.newArrayList();
|
List<NPC> possible = Lists.newArrayList();
|
||||||
double range = -1;
|
double range = -1;
|
||||||
if (args.hasValueFlag("range")) {
|
if (args.hasValueFlag("range")) {
|
||||||
range = Math.abs(args.getFlagDouble("range"));
|
range = Math.abs(args.getFlagDouble("range"));
|
||||||
}
|
}
|
||||||
for (NPC test : npcRegistry) {
|
|
||||||
if (test.getName().equalsIgnoreCase(name)) {
|
for (NPC test : npcRegistry) {
|
||||||
if (range > 0 && test.isSpawned() && !Util.locationWithinRange(args.getSenderLocation(),
|
if (test.getName().equalsIgnoreCase(name)) {
|
||||||
test.getEntity().getLocation(), range))
|
if (range > 0 && test.isSpawned()
|
||||||
continue;
|
&& !Util.locationWithinRange(args.getSenderLocation(), test.getEntity().getLocation(), range))
|
||||||
possible.add(test);
|
continue;
|
||||||
}
|
possible.add(test);
|
||||||
}
|
|
||||||
if (possible.size() == 1) {
|
|
||||||
callback.run(possible.get(0));
|
|
||||||
} else if (possible.size() > 1) {
|
|
||||||
NPCCommandSelector.start(callback, (Conversable) sender, possible);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (possible.size() == 1) {
|
||||||
|
callback.run(possible.get(0));
|
||||||
|
} else if (possible.size() > 1) {
|
||||||
|
NPCCommandSelector.start(callback, (Conversable) sender, possible);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1476,10 +1476,10 @@ public class NPCCommands {
|
|||||||
Paginator paginator = new Paginator().header("NPCs").console(sender instanceof ConsoleCommandSender)
|
Paginator paginator = new Paginator().header("NPCs").console(sender instanceof ConsoleCommandSender)
|
||||||
.enablePageSwitcher('/' + args.getRawCommand() + " --page $page");
|
.enablePageSwitcher('/' + args.getRawCommand() + " --page $page");
|
||||||
for (int i = 0; i < npcs.size(); i++) {
|
for (int i = 0; i < npcs.size(); i++) {
|
||||||
int id = npcs.get(i).getId();
|
String id = npc.getUniqueId().toString();
|
||||||
String line = StringHelper.wrap(id) + " " + npcs.get(i).getName() + " (<click:run_command:/npc tp --id "
|
String line = StringHelper.wrap(id) + " " + npcs.get(i).getName() + " (<click:run_command:/npc tp --uuid "
|
||||||
+ id
|
+ id
|
||||||
+ "><hover:show_text:Teleport to this NPC>[[tp]]</hover></click>) (<click:run_command:/npc tph --id "
|
+ "><hover:show_text:Teleport to this NPC>[[tp]]</hover></click>) (<click:run_command:/npc tph --uuid "
|
||||||
+ id
|
+ id
|
||||||
+ "><hover:show_text:Teleport NPC to me>[[summon]]</hover></click>) (<click:run_command:/npc remove "
|
+ "><hover:show_text:Teleport NPC to me>[[summon]]</hover></click>) (<click:run_command:/npc remove "
|
||||||
+ id + "><hover:show_text:Remove this NPC><red>-</red></hover></click>)";
|
+ id + "><hover:show_text:Remove this NPC><red>-</red></hover></click>)";
|
||||||
|
Loading…
Reference in New Issue
Block a user