Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mcmonkey4eva/Denizen
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 13, 2016
2 parents ab2c0c0 + fbedc2f commit 6d2d1a2
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
Denizen: Helpful Citizens for Bukkit!
-------------------------------------

**Version 0.9.8**: Compatible with Spigot 1.9.4 -- Working towards the Denizen 1.0 release!
**Version 0.9.8**: Compatible with Spigot 1.10 -- Working towards the Denizen 1.0 release!

**Download (Developmental builds)**: http://ci.citizensnpcs.co/job/Denizen/
**Download (VERY Developmental builds)**: http://ci.mineconomy.org/job/Denizen_Developmental/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -791,6 +791,7 @@ public void onEnable() {
propertyParser.registerProperty(EntityArmorPose.class, dEntity.class);
propertyParser.registerProperty(EntityArms.class, dEntity.class);
propertyParser.registerProperty(EntityBasePlate.class, dEntity.class);
propertyParser.registerProperty(EntityBoatType.class, dEntity.class);
propertyParser.registerProperty(EntityChestCarrier.class, dEntity.class);
propertyParser.registerProperty(EntityColor.class, dEntity.class);
propertyParser.registerProperty(EntityCritical.class, dEntity.class);
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/net/aufdemrand/denizen/objects/dWorld.java
@@ -1,5 +1,6 @@
package net.aufdemrand.denizen.objects;

import net.aufdemrand.denizen.Settings;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.properties.Property;
Expand All @@ -10,11 +11,7 @@
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -925,10 +922,15 @@ public void adjust(Mechanism mechanism) {
// @input None
// @description
// Unloads the world from the server without saving chunks, then destroys all data that is part of the world.
// Require config setting 'Commands.Delete.Allow file deletion'.
// @tags
// None
// -->
if (mechanism.matches("destroy")) {
if (!Settings.allowDelete()) {
dB.echoError("Unable to delete due to config.");
return;
}
File folder = new File(getWorld().getName());
Bukkit.getServer().unloadWorld(getWorld(), false);
try {
Expand Down
@@ -0,0 +1,98 @@
package net.aufdemrand.denizen.objects.properties.entity;

import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.Mechanism;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.tags.Attribute;
import org.bukkit.TreeSpecies;
import org.bukkit.entity.Boat;
import org.bukkit.entity.EntityType;

public class EntityBoatType implements Property {

public static boolean describes(dObject object) {
return object instanceof dEntity && ((dEntity) object).getBukkitEntityType() == EntityType.BOAT;
}

public static EntityBoatType getFrom(dObject object) {
if (!describes(object)) {
return null;
}

else {
return new EntityBoatType((dEntity) object);
}
}

///////////////////
// Instance Fields and Methods
/////////////

private EntityBoatType(dEntity entity) {
this.entity = entity;
}

dEntity entity;

/////////
// Property Methods
///////

@Override
public String getPropertyString() {
return ((Boat) entity.getBukkitEntity()).getWoodType().name();
}

@Override
public String getPropertyId() {
return "boat_type";
}

@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}

// <--[tag]
// @attribute <e@entity.boat_type>
// @returns Element
// @mechanism dEntity.boat_type
// @group properties
// @description
// Returns the wood type of the boat.
// Valid wood types: GENERIC, REDWOOD, BIRCH, JUNGLE, ACACIA, DARK_OAK.
// -->
if (attribute.startsWith("boat_type")) {
return new Element(((Boat) entity.getBukkitEntity()).getWoodType().name())
.getAttribute(attribute.fulfill(1));
}

return null;
}

@Override
public void adjust(Mechanism mechanism) {
Element value = mechanism.getValue();

// <--[mechanism]
// @object dEntity
// @name boat_type
// @input Element
// @description
// Changes the wood type of the boat.
// Valid wood types: GENERIC, REDWOOD, BIRCH, JUNGLE, ACACIA, DARK_OAK.
// @tags
// <e@entity.boat_type>
// -->

if (mechanism.matches("boat_type")) {
TreeSpecies type = TreeSpecies.valueOf(value.asString().toUpperCase());
if (type != null) {
((Boat) entity.getBukkitEntity()).setWoodType(type);
}
}
}
}
Expand Up @@ -2701,7 +2701,7 @@ public void registerCoreMembers() {

// <--[command]
// @Name Run
// @Syntax run (locally) [<script>] (path:<name>) (def:<element>|...) (id:<name>) (instantly) (delay:<value>)
// @Syntax run (locally) [<script>] (path:<name>) (def:<element>|...) (id:<name>) (instantly) (speed:<value>) (delay:<value>)
// @Required 1
// @Stable stable
// @Short Runs a script in a new ScriptQueue.
Expand Down
Expand Up @@ -138,6 +138,11 @@ else if (!scriptEntry.hasObject("script")
scriptEntry.addObject("script", arg.asType(dScript.class));
}

else if (!scriptEntry.hasObject("speed") && arg.matchesPrefix("speed")
&& arg.matchesArgumentType(Duration.class)) {
scriptEntry.addObject("speed", arg.asType(Duration.class));
}

else if (!scriptEntry.hasObject("path")) {
scriptEntry.addObject("path", arg.asElement());
}
Expand Down Expand Up @@ -167,7 +172,8 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
+ (scriptEntry.hasObject("local") ? scriptEntry.getElement("local").debug() : "")
+ (scriptEntry.hasObject("delay") ? scriptEntry.getdObject("delay").debug() : "")
+ (scriptEntry.hasObject("id") ? scriptEntry.getdObject("id").debug() : "")
+ (scriptEntry.hasObject("definitions") ? scriptEntry.getdObject("definitions").debug() : ""));
+ (scriptEntry.hasObject("definitions") ? scriptEntry.getdObject("definitions").debug() : "")
+ (scriptEntry.hasObject("speed") ? scriptEntry.getdObject("speed").debug() : ""));

// Get the script
dScript script = scriptEntry.getdObject("script");
Expand Down Expand Up @@ -204,9 +210,15 @@ else if (scriptEntry.hasObject("path") && scriptEntry.getObject("path") != null)
else {
queue = TimedQueue.getQueue(id).addEntries(entries);

// Check speed of the script if a TimedQueue -- if identified, use the speed from the script.
if (script != null && script.getContainer().contains("SPEED")) {
((TimedQueue) queue).setSpeed(Duration.valueOf(script.getContainer().getString("SPEED", "0")).getTicks());
if (scriptEntry.hasObject("speed")) {
Duration speed = scriptEntry.getdObject("speed");
((TimedQueue) queue).setSpeed(speed.getTicks());
}
else {
// Check speed of the script if a TimedQueue -- if identified, use the speed from the script.
if (script != null && script.getContainer().contains("SPEED")) {
((TimedQueue) queue).setSpeed(Duration.valueOf(script.getContainer().getString("SPEED", "0")).getTicks());
}
}

}
Expand Down

0 comments on commit 6d2d1a2

Please sign in to comment.