Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add list[] and cuboid[] tag base units
A way to easily get a cuboid or list from random tagged input, also a few corrections.
- Loading branch information
1 parent
c68b743
commit 311bb2a
Showing
4 changed files
with
102 additions
and
7 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
45 changes: 45 additions & 0 deletions
45
src/main/java/net/aufdemrand/denizen/tags/core/CuboidTags.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,45 @@ | ||
package net.aufdemrand.denizen.tags.core; | ||
|
||
import net.aufdemrand.denizen.Denizen; | ||
import net.aufdemrand.denizen.events.bukkit.ReplaceableTagEvent; | ||
import net.aufdemrand.denizen.objects.dCuboid; | ||
import net.aufdemrand.denizen.objects.dList; | ||
import net.aufdemrand.denizen.tags.Attribute; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
|
||
/** | ||
* Location tag is a starting point for getting attributes for a | ||
* | ||
*/ | ||
|
||
public class CuboidTags implements Listener { | ||
|
||
public CuboidTags(Denizen denizen) { | ||
denizen.getServer().getPluginManager().registerEvents(this, denizen); | ||
} | ||
|
||
@EventHandler | ||
public void locationTags(ReplaceableTagEvent event) { | ||
|
||
if (!event.matches("cuboid") || event.replaced()) return; | ||
|
||
dCuboid cuboid = null; | ||
|
||
String context = event.getNameContext(); | ||
if (event.hasNameContext() && dCuboid.matches(context)) | ||
cuboid = dCuboid.valueOf(context); | ||
|
||
// Check if cuboid is null, return null if it is | ||
if (cuboid == null) { | ||
event.setReplaced("null"); | ||
return; | ||
} | ||
|
||
// Build and fill attributes | ||
Attribute attribute = event.getAttributes(); | ||
event.setReplaced(cuboid.getAttribute(attribute.fulfill(1))); | ||
|
||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/net/aufdemrand/denizen/tags/core/ListTags.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,44 @@ | ||
package net.aufdemrand.denizen.tags.core; | ||
|
||
import net.aufdemrand.denizen.Denizen; | ||
import net.aufdemrand.denizen.events.bukkit.ReplaceableTagEvent; | ||
import net.aufdemrand.denizen.objects.dList; | ||
import net.aufdemrand.denizen.objects.dLocation; | ||
import net.aufdemrand.denizen.tags.Attribute; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
|
||
/** | ||
* Location tag is a starting point for getting attributes for a | ||
* | ||
*/ | ||
|
||
public class ListTags implements Listener { | ||
|
||
public ListTags(Denizen denizen) { | ||
denizen.getServer().getPluginManager().registerEvents(this, denizen); | ||
} | ||
|
||
@EventHandler | ||
public void locationTags(ReplaceableTagEvent event) { | ||
|
||
if (!event.matches("list") || event.replaced()) return; | ||
|
||
dList list = null; | ||
|
||
if (event.hasNameContext()) | ||
list = dList.valueOf(event.getNameContext()); | ||
|
||
// Check if list is null, return null if it is | ||
if (list == null) { | ||
event.setReplaced("null"); | ||
return; | ||
} | ||
|
||
// Build and fill attributes | ||
Attribute attribute = event.getAttributes(); | ||
event.setReplaced(list.getAttribute(attribute.fulfill(1))); | ||
|
||
} | ||
} |
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