Skip to content

Commit

Permalink
add location.mcmmo.is_placed, fixes #267
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 28, 2019
1 parent ce7b4bb commit 0ef97ff
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
@@ -1,8 +1,10 @@
package com.denizenscript.depenizen.bukkit.bridges;

import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.depenizen.bukkit.commands.mcmmo.McMMOCommand;
import com.denizenscript.depenizen.bukkit.events.mcmmo.*;
import com.denizenscript.depenizen.bukkit.properties.mcmmo.McMMOEntityProperties;
import com.denizenscript.depenizen.bukkit.properties.mcmmo.McMMOLocationProperties;
import com.denizenscript.depenizen.bukkit.properties.mcmmo.McMMOPlayerProperties;
import com.denizenscript.depenizen.bukkit.objects.mcmmo.PartyTag;
import com.denizenscript.depenizen.bukkit.Bridge;
Expand Down Expand Up @@ -31,6 +33,7 @@ public void run(ReplaceableTagEvent event) {
}, "party");
PropertyParser.registerProperty(McMMOPlayerProperties.class, PlayerTag.class);
PropertyParser.registerProperty(McMMOEntityProperties.class, EntityTag.class);
PropertyParser.registerProperty(McMMOLocationProperties.class, LocationTag.class);
DenizenAPI.getCurrentInstance().getCommandRegistry().registerCoreMember(McMMOCommand.class,
"MCMMO", "mcmmo [add/remove/set] [levels/xp/xprate/vampirism/hardcore/leader] (skill:<skill>) (state:{toggle}/true/false) (quantity:<#>) (party:<party>)", 1);
ScriptEvent.registerScriptEvent(new mcMMOPlayerLevelChangeScriptEvent());
Expand Down
@@ -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;
}
}

0 comments on commit 0ef97ff

Please sign in to comment.