From 6dbce01c549c4debaf66d18d881dad0d4221e025 Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 15 Oct 2012 13:18:34 +0800 Subject: [PATCH] Forgot to remove this --- .../command/command/SelectionPrompt.java | 38 +++++++++---------- .../java/net/citizensnpcs/util/Anchor.java | 10 ++--- .../java/net/citizensnpcs/util/Messages.java | 4 +- src/main/java/net/citizensnpcs/util/NMS.java | 35 +++++++++-------- 4 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/main/java/net/citizensnpcs/command/command/SelectionPrompt.java b/src/main/java/net/citizensnpcs/command/command/SelectionPrompt.java index c869eb122..c5f1a7513 100644 --- a/src/main/java/net/citizensnpcs/command/command/SelectionPrompt.java +++ b/src/main/java/net/citizensnpcs/command/command/SelectionPrompt.java @@ -26,25 +26,6 @@ public class SelectionPrompt extends NumericPrompt { this.selector = selector; } - public static void start(NPCSelector selector, Player player, List possible) { - final Conversation conversation = new ConversationFactory(CitizensAPI.getPlugin()) - .withLocalEcho(false).withEscapeSequence("exit").withModality(false) - .withFirstPrompt(new SelectionPrompt(selector, possible)).buildConversation(player); - conversation.begin(); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = Messaging.tr(Messages.SELECTION_PROMPT); - int num = 1; - for (NPC npc : choices) { - text += "
- " + npc.getId() + "(" + num + ")"; - context.setSessionData(npc.getId(), num); - num++; - } - return text; - } - @Override protected Prompt acceptValidatedInput(ConversationContext context, Number input) { Object num = context.getSessionData(input); @@ -64,4 +45,23 @@ public class SelectionPrompt extends NumericPrompt { Messaging.sendWithNPC(sender, Setting.SELECTION_MESSAGE.asString(), toSelect); return null; } + + @Override + public String getPromptText(ConversationContext context) { + String text = Messaging.tr(Messages.SELECTION_PROMPT); + int num = 1; + for (NPC npc : choices) { + text += "
- " + npc.getId() + "(" + num + ")"; + context.setSessionData(npc.getId(), num); + num++; + } + return text; + } + + public static void start(NPCSelector selector, Player player, List possible) { + final Conversation conversation = new ConversationFactory(CitizensAPI.getPlugin()) + .withLocalEcho(false).withEscapeSequence("exit").withModality(false) + .withFirstPrompt(new SelectionPrompt(selector, possible)).buildConversation(player); + conversation.begin(); + } } diff --git a/src/main/java/net/citizensnpcs/util/Anchor.java b/src/main/java/net/citizensnpcs/util/Anchor.java index 51b10b1e4..0ffb5b7da 100644 --- a/src/main/java/net/citizensnpcs/util/Anchor.java +++ b/src/main/java/net/citizensnpcs/util/Anchor.java @@ -9,8 +9,8 @@ import org.bukkit.Location; */ public class Anchor { - private final String name; private final Location location; + private final String name; public Anchor(String name, Location location) { this.location = location; @@ -30,14 +30,14 @@ public class Anchor { isEquals(); } - public String getName() { - return name; - } - public Location getLocation() { return location; } + public String getName() { + return name; + } + @Override public int hashCode() { return new HashCodeBuilder(13, 21). diff --git a/src/main/java/net/citizensnpcs/util/Messages.java b/src/main/java/net/citizensnpcs/util/Messages.java index dd2344a43..bee01b2fa 100644 --- a/src/main/java/net/citizensnpcs/util/Messages.java +++ b/src/main/java/net/citizensnpcs/util/Messages.java @@ -126,11 +126,12 @@ public class Messages { public static final String SCRIPT_COMPILED = "citizens.commands.script.compiled"; public static final String SCRIPT_COMPILING = "citizens.commands.script.compiling"; public static final String SCRIPT_FILE_MISSING = "citizens.commands.script.file-missing"; + public static final String SELECTION_PROMPT = "citizens.editors.selection.start-prompt"; public static final String SHEARED_SET = "citizens.editors.equipment.sheared-set"; public static final String SHEARED_STOPPED = "citizens.editors.equipment.sheared-stopped"; public static final String SKIPPING_BROKEN_TRAIT = "citizens.notifications.skipping-broken-trait"; - public static final String SKIPPING_INVALID_POSE = "citizens.notifications.skipping-invalid-pose"; public static final String SKIPPING_INVALID_ANCHOR = "citizens.notifications.skipping-invalid-anchor"; + public static final String SKIPPING_INVALID_POSE = "citizens.notifications.skipping-invalid-pose"; public static final String SPEED_MODIFIER_ABOVE_LIMIT = "citizens.commands.npc.speed.modifier-above-limit"; public static final String SPEED_MODIFIER_SET = "citizens.commands.npc.speed.set"; public static final String TELEPORTED_TO_NPC = "citizens.commands.npc.tp.teleported"; @@ -169,5 +170,4 @@ public class Messages { public static final String VULNERABLE_STOPPED = "citizens.commands.npc.vulnerable.stopped"; public static final String WAYPOINT_PROVIDER_SET = "citizens.waypoints.set-provider"; public static final String WRITING_DEFAULT_SETTING = "citizens.settings.writing-default"; - public static final String SELECTION_PROMPT = "citizens.editors.selection.start-prompt"; } diff --git a/src/main/java/net/citizensnpcs/util/NMS.java b/src/main/java/net/citizensnpcs/util/NMS.java index cc1c8870b..9af0936a0 100644 --- a/src/main/java/net/citizensnpcs/util/NMS.java +++ b/src/main/java/net/citizensnpcs/util/NMS.java @@ -33,8 +33,9 @@ public class NMS { // util class } - private static final float DEFAULT_SPEED = 0.4F; + private static Field DAMAGE_FIELD; + private static final float DEFAULT_SPEED = 0.4F; private static Map, Integer> ENTITY_CLASS_TO_INT; private static final Map, Constructor> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap, Constructor>(); private static Map> ENTITY_INT_TO_CLASS; @@ -45,10 +46,8 @@ public class NMS { private static Field PATHFINDING_RANGE; private static Field SPEED_FIELD; private static Field THREAD_STOPPER; - private static Field DAMAGE_FIELD; public static void attack(EntityLiving handle, EntityLiving target) { - handle.k(target); int damage = getDamage(handle); if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) { @@ -62,16 +61,6 @@ public class NMS { target.damageEntity(DamageSource.mobAttack(handle), damage); } - private static int getDamage(EntityLiving handle) { - if (DAMAGE_FIELD == null) - return 2; - try { - return DAMAGE_FIELD.getInt(handle); - } catch (Exception e) { - } - return 2; - } - public static void clearGoals(PathfinderGoalSelector... goalSelectors) { if (NMS.GOAL_FIELD == null || goalSelectors == null) return; @@ -97,6 +86,16 @@ public class NMS { return constructor; } + private static int getDamage(EntityLiving handle) { + if (DAMAGE_FIELD == null) + return 2; + try { + return DAMAGE_FIELD.getInt(handle); + } catch (Exception e) { + } + return 2; + } + private static Field getField(Class clazz, String field) { Field f = null; try { @@ -193,6 +192,11 @@ public class NMS { } } + public static void trySwim(EntityLiving handle) { + if ((handle.H() || handle.J()) && Math.random() < 0.8F) + handle.motY += 0.04; + } + public static void updateAI(EntityLiving entity) { entity.getNavigation().e(); entity.getControllerMove().c(); @@ -256,9 +260,4 @@ public class NMS { Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage()); } } - - public static void trySwim(EntityLiving handle) { - if ((handle.H() || handle.J()) && Math.random() < 0.8F) - handle.motY += 0.04; - } }