Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add location.mcmmo.is_placed, fixes #267
- Loading branch information
1 parent
ce7b4bb
commit 0ef97ff
Showing
2 changed files
with
79 additions
and
0 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
76 changes: 76 additions & 0 deletions
76
...ain/java/com/denizenscript/depenizen/bukkit/properties/mcmmo/McMMOLocationProperties.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,76 @@ | ||
package com.denizenscript.depenizen.bukkit.properties.mcmmo; | ||
|
||
import com.denizenscript.denizen.objects.LocationTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
import com.denizenscript.denizencore.tags.Attribute; | ||
import com.gmail.nossr50.mcMMO; | ||
|
||
public class McMMOLocationProperties implements Property { | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "McMMOLocation"; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
// None | ||
} | ||
|
||
public static boolean describes(ObjectTag object) { | ||
return object instanceof LocationTag; | ||
} | ||
|
||
public static McMMOLocationProperties getFrom(ObjectTag object) { | ||
if (!describes(object)) { | ||
return null; | ||
} | ||
else { | ||
return new McMMOLocationProperties((LocationTag) object); | ||
} | ||
} | ||
|
||
public static final String[] handledTags = new String[] { | ||
"mcmmo" | ||
}; | ||
|
||
public static final String[] handledMechs = new String[] { | ||
}; // None | ||
|
||
private McMMOLocationProperties(LocationTag location) { | ||
this.location = location; | ||
} | ||
|
||
LocationTag location = null; | ||
|
||
@Override | ||
public String getAttribute(Attribute attribute) { | ||
|
||
if (attribute.startsWith("mcmmo")) { | ||
|
||
attribute = attribute.fulfill(1); | ||
|
||
// <--[tag] | ||
// @attribute <LocationTag.mcmmo.is_placed> | ||
// @returns ElementTag(Boolean) | ||
// @description | ||
// Returns whether the location is tracked by McMMO as a player-placed block (might only apply to certain block types). | ||
// @Plugin Depenizen, mcMMO | ||
// --> | ||
if (attribute.startsWith("is_placed")) { | ||
return new ElementTag(mcMMO.getPlaceStore().isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) | ||
.getAttribute(attribute.fulfill(1)); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |