Skip to content

Commit

Permalink
Bump version number and clean up code. Also add saving on disable.
Browse files Browse the repository at this point in the history
  • Loading branch information
kolinkrewinkel committed Sep 23, 2013
1 parent b8e0e5f commit 8c298c9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 48 deletions.
96 changes: 72 additions & 24 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>com.bitlimit.NPCs</groupId>
<artifactId>NPCs</artifactId>
<version>0.6.0</version>
<version>0.6.1</version>
<name>NPCs</name>
<description>Non-playing characters.</description>

Expand Down
24 changes: 1 addition & 23 deletions src/main/java/com/bitlimit/NPCs/NPCs.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,12 @@ public class NPCs extends JavaPlugin implements Listener {
@Override
public void onEnable() {
try {
// this.manager = RemoteEntities.createManager(this);
// this.manager.setEntitySerializer(new YMLSerializer(this));
// this.manager.saveEntities();
//
// this.manager.setSaveOnDisable(true);
// this.manager.loadEntities();

this.manager = RemoteEntities.createManager(this);

//First we register the serializer that should be used
//In this case we use the YML serializer, but you can also use your own as well as the json serializer
this.manager.setEntitySerializer(new YMLSerializer(this));
//To load the entities we saved, you can just do this:
this.manager.setSaveOnDisable(true);
this.manager.loadEntities();

//If we want to save all current entities, it's pretty easy:
// this.manager.saveEntities();
//
// //Some serializers allow single entities to be saved, i.e. the YML serializer
// //But first, we need to create an entitiy.
// RemoteEntity entity = this.manager.createNamedEntity(RemoteEntityType.Human, Bukkit.getWorld("world").getSpawnLocation(), "Smith");
// //Now we can just call the save method. Keep in mind that it will not work when the serializer doesn't support single entity serialization
// entity.save();

//Now all the entities should be back like you never removed them
} catch (Exception e) {
this.manager = null;
e.printStackTrace();
}

Expand Down Expand Up @@ -78,7 +57,6 @@ public void saveData() {

@EventHandler
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {

if (!(event.getEntity() instanceof LivingEntity)) {
return;
}
Expand Down

0 comments on commit 8c298c9

Please sign in to comment.