Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WorldEdit support (currently, only <p@player.selected_region>)
- Loading branch information
Showing
11 changed files
with
152 additions
and
35 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
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
20 changes: 20 additions & 0 deletions
20
src/main/java/net/gnomeffinway/depenizen/support/WorldEditSupport.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,20 @@ | ||
package net.gnomeffinway.depenizen.support; | ||
|
||
import net.aufdemrand.denizen.objects.dPlayer; | ||
import net.aufdemrand.denizen.utilities.DenizenAPI; | ||
import net.gnomeffinway.depenizen.Depenizen; | ||
import net.gnomeffinway.depenizen.tags.worldedit.WorldEditPlayerTags; | ||
|
||
public class WorldEditSupport { | ||
|
||
public Depenizen depenizen; | ||
|
||
public WorldEditSupport(Depenizen depenizen) { | ||
this.depenizen = depenizen; | ||
} | ||
|
||
public void register() { | ||
DenizenAPI.getCurrentInstance().getPropertyParser().registerProperty(WorldEditPlayerTags.class, dPlayer.class); | ||
} | ||
|
||
} |
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
71 changes: 71 additions & 0 deletions
71
src/main/java/net/gnomeffinway/depenizen/tags/worldedit/WorldEditPlayerTags.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,71 @@ | ||
package net.gnomeffinway.depenizen.tags.worldedit; | ||
|
||
import com.sk89q.worldedit.bukkit.selections.Selection; | ||
import net.aufdemrand.denizen.objects.*; | ||
import net.aufdemrand.denizen.objects.properties.Property; | ||
import net.aufdemrand.denizen.tags.Attribute; | ||
import net.gnomeffinway.depenizen.Depenizen; | ||
import org.bukkit.entity.Player; | ||
|
||
public class WorldEditPlayerTags implements Property { | ||
|
||
public static boolean describes(dObject pl) { | ||
return pl instanceof dPlayer | ||
&& ((dPlayer) pl).isOnline(); | ||
} | ||
|
||
public static WorldEditPlayerTags getFrom(dObject pl) { | ||
if (!describes(pl)) return null; | ||
else return new WorldEditPlayerTags((dPlayer) pl); | ||
} | ||
|
||
|
||
/////////////////// | ||
// Instance Fields and Methods | ||
///////////// | ||
|
||
private WorldEditPlayerTags(dPlayer pl) { | ||
player = pl.getPlayerEntity(); | ||
} | ||
|
||
Player player = null; | ||
|
||
///////// | ||
// Property Methods | ||
/////// | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "WorldEditPlayerTags"; | ||
} | ||
|
||
@Override | ||
public String getAttribute(Attribute attribute) { | ||
|
||
// <--[tag] | ||
// @attribute <p@player.selected_region> | ||
// @returns dCuboid | ||
// @description | ||
// Returns the player's current region selection, as a dCuboid. | ||
// @Plugin WorldEdit | ||
// --> | ||
if (attribute.startsWith("selected_region")) { | ||
Selection selection = Depenizen.worldedit.getSelection(player); | ||
if (selection != null) | ||
return new dCuboid(selection.getMinimumPoint(), selection.getMaximumPoint()).getAttribute(attribute.fulfill(1)); | ||
else | ||
return Element.NULL.getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
} | ||
} |
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