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