mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-13 06:07:26 +01:00
Implement new trait methods
This commit is contained in:
parent
45e44d8d68
commit
0fb2be3a77
4
pom.xml
4
pom.xml
@ -6,13 +6,13 @@
|
||||
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizens</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>2.0.2</version>
|
||||
<name>Citizens</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<craftbukkit.version>LATEST</craftbukkit.version>
|
||||
<citizensapi.version>LATEST</citizensapi.version>
|
||||
<citizensapi.version>2.0.2</citizensapi.version>
|
||||
<vault.version>1.2.18-SNAPSHOT</vault.version>
|
||||
<build.number>Unknown</build.number>
|
||||
</properties>
|
||||
|
@ -17,6 +17,7 @@ import com.google.common.collect.Maps;
|
||||
|
||||
public abstract class CitizensMobNPC extends CitizensNPC {
|
||||
private final Constructor<? extends EntityLiving> constructor;
|
||||
|
||||
protected CitizensMobNPC(int id, String name, Class<? extends EntityLiving> clazz) {
|
||||
super(id, name);
|
||||
this.constructor = getConstructor(clazz);
|
||||
|
@ -45,6 +45,8 @@ public abstract class CitizensNPC extends AbstractNPC {
|
||||
boolean keepSelected = getTrait(Spawned.class).shouldSpawn();
|
||||
if (!keepSelected)
|
||||
data().remove("selectors");
|
||||
for (Trait trait : traits.values())
|
||||
trait.onDespawn();
|
||||
getBukkitEntity().remove();
|
||||
mcEntity = null;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.citizensnpcs.trait;
|
||||
|
||||
public interface Toggleable {
|
||||
|
||||
public boolean toggle();
|
||||
}
|
@ -101,6 +101,12 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
||||
range = key.getDouble("range", range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach() {
|
||||
if (text.isEmpty())
|
||||
populateDefaultText();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRightClick(NPCRightClickEvent event) {
|
||||
if (!event.getNPC().equals(npc))
|
||||
@ -109,12 +115,6 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
||||
sendText(event.getClicker());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
if (text.isEmpty())
|
||||
populateDefaultText();
|
||||
}
|
||||
|
||||
private void populateDefaultText() {
|
||||
text.addAll(Setting.DEFAULT_TEXT.asList());
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ public class TextEditPrompt extends StringPrompt {
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
int index = (Integer) context.getSessionData("index");
|
||||
text.edit(index, input);
|
||||
Messaging.send((Player) context.getForWhom(), "<a>Changed entry at index <e>" + index + " <a>to <e>" + input
|
||||
+ "<a>.");
|
||||
Messaging.send((Player) context.getForWhom(), "<a>Changed entry at index <e>" + index + " <a>to <e>"
|
||||
+ input + "<a>.");
|
||||
return new StartPrompt(text);
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ public class WanderingWaypointProvider implements WaypointProvider {
|
||||
xrange = key.getInt("xrange", DEFAULT_XRANGE);
|
||||
yrange = key.getInt("yrange", DEFAULT_YRANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn(NPC npc) {
|
||||
this.npc = npc;
|
||||
|
@ -20,7 +20,8 @@ public class Paginator {
|
||||
}
|
||||
|
||||
public boolean sendPage(CommandSender sender, int page) {
|
||||
int pages = (int) ((lines.size() / LINES_PER_PAGE == 0) ? 1 : Math.ceil((double) lines.size() / LINES_PER_PAGE));
|
||||
int pages = (int) ((lines.size() / LINES_PER_PAGE == 0) ? 1 : Math.ceil((double) lines.size()
|
||||
/ LINES_PER_PAGE));
|
||||
if (page < 0 || page > pages)
|
||||
return false;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Citizens
|
||||
authors: [aPunch, fullwall]
|
||||
softdepend: [Vault]
|
||||
version: 2.0.1
|
||||
version: 2.0.2
|
||||
main: net.citizensnpcs.Citizens
|
||||
website: http://www.citizensnpcs.net
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user