Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Start of PlotSquared Support Not Finished yet!! But its the start of plotsquared add-ons. * More plotsquared stuff still not finished yet * Finishing Support of PlotSquared Everything should work now! Yay! * Remove old repo This should have been the normal way, but plotsquared has not yet included their api * Comment Cleanup and few changes
- Loading branch information
Showing
9 changed files
with
385 additions
and
4 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
60 changes: 60 additions & 0 deletions
60
...m/denizenscript/depenizen/bukkit/extensions/plotsquared/PlotSquaredLocationExtension.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,60 @@ | ||
package com.denizenscript.depenizen.bukkit.extensions.plotsquared; | ||
|
||
|
||
import com.denizenscript.depenizen.bukkit.extensions.dObjectExtension; | ||
import com.denizenscript.depenizen.bukkit.objects.dPlotSquaredPlot; | ||
import com.intellectualcrafters.plot.api.PlotAPI; | ||
import net.aufdemrand.denizen.objects.dLocation; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.Mechanism; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.tags.Attribute; | ||
|
||
|
||
public class PlotSquaredLocationExtension extends dObjectExtension { | ||
|
||
public static boolean describes(dObject object) { | ||
return object instanceof dLocation; | ||
} | ||
|
||
public static PlotSquaredLocationExtension getFrom(dObject object) { | ||
if (!describes(object)) { | ||
return null; | ||
} | ||
else { | ||
return new PlotSquaredLocationExtension((dLocation) object); | ||
} | ||
} | ||
|
||
/////////////////// | ||
// Instance Fields and Methods | ||
///////////// | ||
|
||
private PlotSquaredLocationExtension(dLocation location) { | ||
this.location = location; | ||
} | ||
|
||
dLocation location; | ||
|
||
@Override | ||
public String getAttribute(Attribute attribute) { | ||
// <--[tag] | ||
// @attribute <l@location.plotsquared_plot> | ||
// @returns dPlotSquaredPlot | ||
// @description | ||
// Returns the plot contained by this location. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("plotsquared_plot")) { | ||
org.bukkit.Location loca = new org.bukkit.Location(location.getWorld(),location.getBlockX(),location.getBlockY(),location.getBlockZ(),location.getYaw(),location.getPitch()); | ||
return new dPlotSquaredPlot(new PlotAPI().getPlot(loca)).getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
Element value = mechanism.getValue(); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...com/denizenscript/depenizen/bukkit/extensions/plotsquared/PlotSquaredPlayerExtension.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,82 @@ | ||
package com.denizenscript.depenizen.bukkit.extensions.plotsquared; | ||
|
||
import com.denizenscript.depenizen.bukkit.extensions.dObjectExtension; | ||
import com.denizenscript.depenizen.bukkit.objects.dPlotSquaredPlot; | ||
import com.intellectualcrafters.plot.api.PlotAPI; | ||
import com.intellectualcrafters.plot.object.Plot; | ||
import net.aufdemrand.denizen.objects.dPlayer; | ||
import net.aufdemrand.denizen.objects.dWorld; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.Mechanism; | ||
import net.aufdemrand.denizencore.objects.dList; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.tags.Attribute; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.UUID; | ||
|
||
public class PlotSquaredPlayerExtension extends dObjectExtension { | ||
|
||
public static boolean describes(dObject object) { | ||
return object instanceof dPlayer; | ||
} | ||
|
||
public static PlotSquaredPlayerExtension getFrom(dObject object) { | ||
if (!describes(object)) { | ||
return null; | ||
} | ||
else { | ||
return new PlotSquaredPlayerExtension((dPlayer) object); | ||
} | ||
} | ||
|
||
|
||
/////////////////// | ||
// Instance Fields and Methods | ||
///////////// | ||
|
||
private PlotSquaredPlayerExtension(dPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
dPlayer player; | ||
|
||
@Override | ||
public String getAttribute(Attribute attribute) { | ||
|
||
// <--[tag] | ||
// @attribute <p@player.plotsquared_plots> | ||
// @returns dList(dPlotSquaredPlot) | ||
// @description | ||
// Returns all the plots a player has. Add a world to only get the plots in that specific world. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("plotsquared_plots")) { | ||
if (attribute.hasContext(1)) { | ||
dWorld world = dWorld.valueOf(attribute.getContext(1)); | ||
if (world == null) { | ||
return null; | ||
} | ||
dList plots = new dList(); | ||
for (Plot plays : new PlotAPI().getPlayerPlots(world.getWorld(),player.getPlayerEntity())) { | ||
plots.add(new dPlotSquaredPlot(plays).identify()); | ||
} | ||
return plots.getAttribute(attribute.fulfill(1)); | ||
} | ||
else { | ||
dList plots = new dList(); | ||
for (Plot plays : new PlotAPI().getPlayerPlots(player.getPlayerEntity())) { | ||
plots.add(new dPlotSquaredPlot(plays).identify()); | ||
} | ||
return plots.getAttribute(attribute.fulfill(1)); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
Element value = mechanism.getValue(); | ||
} | ||
} |
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
214 changes: 214 additions & 0 deletions
214
bukkit/src/main/java/com/denizenscript/depenizen/bukkit/objects/dPlotSquaredPlot.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,214 @@ | ||
package com.denizenscript.depenizen.bukkit.objects; | ||
|
||
import com.intellectualcrafters.plot.api.PlotAPI; | ||
import com.intellectualcrafters.plot.object.Plot; | ||
import net.aufdemrand.denizen.objects.dCuboid; | ||
import net.aufdemrand.denizen.objects.dLocation; | ||
import net.aufdemrand.denizen.objects.dPlayer; | ||
import net.aufdemrand.denizen.objects.dWorld; | ||
import net.aufdemrand.denizencore.objects.*; | ||
import net.aufdemrand.denizencore.tags.Attribute; | ||
import net.aufdemrand.denizencore.tags.TagContext; | ||
import net.aufdemrand.denizencore.utilities.CoreUtilities; | ||
import org.bukkit.*; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class dPlotSquaredPlot implements dObject { | ||
|
||
///////////////////// | ||
// OBJECT FETCHER | ||
///////////////// | ||
|
||
public static dPlotSquaredPlot valueOf(String string) { | ||
return valueOf(string, null); | ||
} | ||
|
||
@Fetchable("plotsquaredplot") | ||
public static dPlotSquaredPlot valueOf(String string, TagContext context) { | ||
if (string == null) { | ||
return null; | ||
} | ||
|
||
//////// | ||
// Match plotsquaredplot name | ||
|
||
string = string.replace("plotsquaredplot@", ""); | ||
try { | ||
List<String> split = CoreUtilities.split(string, ','); | ||
return new dPlotSquaredPlot(new PlotAPI().getPlot(dWorld.valueOf(split.get(2)).getWorld() ,aH.getIntegerFrom(split.get(0)), aH.getIntegerFrom(split.get(1)))); | ||
} | ||
catch (Throwable e) { | ||
return null; | ||
} | ||
} | ||
|
||
public static boolean matches(String arg) { | ||
return arg.startsWith("plotsquaredplot@"); | ||
} | ||
|
||
///////////////////// | ||
// STATIC CONSTRUCTORS | ||
///////////////// | ||
|
||
Plot plot = null; | ||
|
||
public dPlotSquaredPlot(Plot pl) { | ||
plot = pl; | ||
} | ||
|
||
///////////////////// | ||
// dObject Methods | ||
///////////////// | ||
|
||
private String prefix = "PlotSquaredPlot"; | ||
|
||
@Override | ||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
@Override | ||
public dPlotSquaredPlot setPrefix(String prefix) { | ||
this.prefix = prefix; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String debug() { | ||
return (prefix + "='<A>" + identify() + "<G>' "); | ||
} | ||
|
||
@Override | ||
public boolean isUnique() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getObjectType() { | ||
return "PlotSquaredPlot"; | ||
} | ||
|
||
@Override | ||
public String identify() { | ||
return "plotsquaredplot@" + plot.getId().x + "," + plot.getId().y + "," + plot.getDefaultHome().getWorld(); | ||
} | ||
|
||
@Override | ||
public String identifySimple() { | ||
return identify(); | ||
} | ||
|
||
@Override | ||
public String getAttribute(Attribute attribute) { | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.id_x> | ||
// @returns Element(Number) | ||
// @description | ||
// Returns the plot's X coordinate portion of its ID. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("x")) { | ||
return new Element(plot.getId().x).getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.id_Z> | ||
// @returns Element(Number) | ||
// @description | ||
// Returns the plot's Z coordinate portion of its ID. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("z")) { | ||
return new Element(plot.getId().y).getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.home> | ||
// @returns dLocation | ||
// @description | ||
// Returns the plot's current home location. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("home")) { | ||
return new dLocation(new Location(Bukkit.getWorld(plot.getHome().getWorld()), plot.getHome().getX(),plot.getHome().getY(),plot.getHome().getZ())).getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.world> | ||
// @returns dWorld | ||
// @description | ||
// Returns the plot's world. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("world")) { | ||
return dWorld.valueOf(plot.getDefaultHome().getWorld()).getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.owners> | ||
// @returns dList(dPlayer) | ||
// @description | ||
// Returns a list of all owners of the plot. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("owners")) { | ||
dList players = new dList(); | ||
for (UUID uuid : plot.getOwners()) { | ||
players.add(dPlayer.valueOf(uuid.toString()).identify()); | ||
} | ||
return players.getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.trusted> | ||
// @returns dList(dPlayer) | ||
// @description | ||
// Returns a list of all trusted of the plot. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("trusted")) { | ||
dList players = new dList(); | ||
for (UUID uuid : plot.getTrusted()) { | ||
players.add(dPlayer.valueOf(uuid.toString()).identify()); | ||
} | ||
return players.getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.members> | ||
// @returns dList(dPlayer) | ||
// @description | ||
// Returns a list of all members of the plot. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("members")) { | ||
dList players = new dList(); | ||
for (UUID uuid : plot.getMembers()) { | ||
players.add(dPlayer.valueOf(uuid.toString()).identify()); | ||
} | ||
return players.getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <plotsquaredplot@plot.cuboid> | ||
// @returns dCuboid | ||
// @description | ||
// Returns the plot's cuboid. | ||
// @Plugin DepenizenBukkit, PlotSquared | ||
// --> | ||
if (attribute.startsWith("cuboid")) { | ||
dWorld world = dWorld.valueOf(plot.getCenter().getWorld()); | ||
Location l1 = new Location(world.getWorld(), plot.getBottomAbs().getX(), 0, plot.getBottomAbs().getZ()); | ||
Location l2 = new Location(world.getWorld(), plot.getTopAbs().getX(), 255, plot.getTopAbs().getZ()); | ||
return new dCuboid(l1, l2).getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
return new Element(identify()).getAttribute(attribute); | ||
|
||
} | ||
|
||
} | ||
|
Oops, something went wrong.