Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from ausFort/master
Start to make progress again.
- Loading branch information
Showing
6 changed files
with
124 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/main/java/net/aufdemrand/denizen/objects/properties/entity/EntityBoatType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters