Skip to content

Commit

Permalink
clean some mechanism handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 6, 2019
1 parent 0f534ad commit bd25ac0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ public void applyProperty(Mechanism mechanism) {
@Override
public void adjust(Mechanism mechanism) {

Element value = mechanism.getValue();

// <--[mechanism]
// @object dBiome
// @name humidity
Expand All @@ -297,7 +295,7 @@ public void adjust(Mechanism mechanism) {
// <b@biome.humidity>
// -->
if (mechanism.matches("humidity") && mechanism.requireFloat()) {
biome.setHumidity(value.asFloat());
biome.setHumidity(mechanism.getValue().asFloat());
}

// <--[mechanism]
Expand All @@ -313,7 +311,7 @@ public void adjust(Mechanism mechanism) {
// <b@biome.temperature>
// -->
if (mechanism.matches("temperature") && mechanism.requireFloat()) {
biome.setTemperature(value.asFloat());
biome.setTemperature(mechanism.getValue().asFloat());
}

}
Expand Down
14 changes: 6 additions & 8 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dCuboid.java
Original file line number Diff line number Diff line change
Expand Up @@ -1394,14 +1394,12 @@ public void applyProperty(Mechanism mechanism) {
@Override
public void adjust(Mechanism mechanism) {

Element value = mechanism.getValue();

// TODO: Better mechanisms!

if (mechanism.matches("outset")) {
int mod = 1;
if (value != null && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
mod = value.asInt();
if (mechanism.hasValue() && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
mod = mechanism.getValue().asInt();
}
for (LocationPair pair : pairs) {
pair.low.add(-1 * mod, -1 * mod, -1 * mod);
Expand All @@ -1416,8 +1414,8 @@ public void adjust(Mechanism mechanism) {

if (mechanism.matches("expand")) {
int mod = 1;
if (value != null && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
mod = value.asInt();
if (mechanism.hasValue() && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
mod = mechanism.getValue().asInt();
}
for (LocationPair pair : pairs) {
pair.low.add(-1 * mod, -1 * mod, -1 * mod);
Expand All @@ -1433,8 +1431,8 @@ public void adjust(Mechanism mechanism) {

if (mechanism.matches("set_location")) {
int mod = 1;
if (value != null && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
mod = value.asInt();
if (mechanism.hasValue() && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
mod = mechanism.getValue().asInt();
}
for (LocationPair pair : pairs) {
pair.low.add(-1 * mod, -1 * mod, -1 * mod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public String getAttribute(Attribute attribute) {

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

// <--[mechanism]
// @object dEntity
// @name boat_type
Expand All @@ -97,7 +95,7 @@ public void adjust(Mechanism mechanism) {
// -->

if (mechanism.matches("boat_type")) {
TreeSpecies type = TreeSpecies.valueOf(value.asString().toUpperCase());
TreeSpecies type = TreeSpecies.valueOf(mechanism.getValue().asString().toUpperCase());
if (type != null) {
((Boat) entity.getBukkitEntity()).setWoodType(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1302,8 +1302,6 @@ else if (attribute.startsWith("port")) {
}

public static void adjustServer(Mechanism mechanism) {
Element value = mechanism.getValue();

// <--[mechanism]
// @object server
// @name delete_file
Expand All @@ -1319,7 +1317,7 @@ public static void adjustServer(Mechanism mechanism) {
dB.echoError("File deletion disabled by administrator.");
return;
}
File file = new File(DenizenAPI.getCurrentInstance().getDataFolder(), value.asString());
File file = new File(DenizenAPI.getCurrentInstance().getDataFolder(), mechanism.getValue().asString());
if (!Utilities.isSafeFile(file)) {
dB.echoError("Cannot delete that file (unsafe path).");
return;
Expand Down

0 comments on commit bd25ac0

Please sign in to comment.