use of com.denizenscript.denizen.objects.WorldTag in project Denizen-For-Bukkit by DenizenScript.
the class WorldInitsScriptEvent method onWorldInits.
@EventHandler
public void onWorldInits(WorldInitEvent event) {
world = new WorldTag(event.getWorld());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.WorldTag in project Denizen-For-Bukkit by DenizenScript.
the class WorldUnloadsScriptEvent method onWorldUnloads.
@EventHandler
public void onWorldUnloads(WorldUnloadEvent event) {
world = new WorldTag(event.getWorld());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.WorldTag in project Denizen-For-Bukkit by DenizenScript.
the class MapCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
ElementTag id = scriptEntry.getElement("map-id");
WorldTag create = scriptEntry.getObjectTag("new");
ElementTag reset = scriptEntry.getElement("reset");
LocationTag resetLoc = scriptEntry.getObjectTag("reset-loc");
ElementTag image = scriptEntry.getElement("image");
ScriptTag script = scriptEntry.getObjectTag("script");
ElementTag resize = scriptEntry.getElement("resize");
ElementTag width = scriptEntry.getElement("width");
ElementTag height = scriptEntry.getElement("height");
ElementTag scale = scriptEntry.getElement("scale");
ElementTag tracking = scriptEntry.getElement("tracking");
ElementTag x = scriptEntry.getElement("x-value");
ElementTag y = scriptEntry.getElement("y-value");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), id, create, reset, resetLoc, image, script, resize, width, height, x, y);
}
MapView map;
if (create != null) {
map = Bukkit.getServer().createMap(create.getWorld());
scriptEntry.addObject("created_map", new ElementTag(map.getId()));
Debug.echoDebug(scriptEntry, "Created map with id " + map.getId() + ".");
} else if (id != null) {
map = Bukkit.getServer().getMap((short) id.asInt());
if (map == null) {
Debug.echoError("No map found for ID '" + id.asInt() + "'!");
return;
}
} else {
// not possible
return;
}
if (reset.asBoolean()) {
if (tracking != null) {
map.setTrackingPosition(true);
}
if (scale != null) {
map.setScale(MapView.Scale.valueOf(scale.asString().toUpperCase()));
}
List<MapRenderer> oldRenderers = DenizenMapManager.removeDenizenRenderers(map);
for (MapRenderer renderer : oldRenderers) {
map.addRenderer(renderer);
}
if (resetLoc != null) {
map.setCenterX(resetLoc.getBlockX());
map.setCenterZ(resetLoc.getBlockZ());
map.setWorld(resetLoc.getWorld());
}
}
if (script != null) {
DenizenMapManager.removeDenizenRenderers(map);
((MapScriptContainer) script.getContainer()).applyTo(map);
}
if (image != null) {
DenizenMapRenderer dmr = DenizenMapManager.getDenizenRenderer(map);
int wide = width != null ? width.asInt() : resize.asBoolean() ? 128 : 0;
int high = height != null ? height.asInt() : resize.asBoolean() ? 128 : 0;
if (CoreUtilities.toLowerCase(image.asString()).endsWith(".gif")) {
dmr.autoUpdate = true;
}
dmr.addObject(new MapImage(dmr, x.asString(), y.asString(), "true", false, image.asString(), wide, high));
dmr.hasChanged = true;
}
}
use of com.denizenscript.denizen.objects.WorldTag in project Denizen-For-Bukkit by DenizenScript.
the class RemoveCommand method execute.
@Override
public void execute(final ScriptEntry scriptEntry) {
List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
WorldTag world = scriptEntry.getObjectTag("world");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), world, db("entities", entities));
}
for (EntityTag entity : entities) {
if (entity.isUnique()) {
if (entity.isFake) {
FakeEntity fakeEnt = FakeEntity.idsToEntities.get(entity.getUUID());
if (fakeEnt != null) {
fakeEnt.cancelEntity();
}
} else if (entity.isCitizensNPC()) {
entity.getDenizenNPC().getCitizen().destroy();
} else if (entity.isSpawned()) {
entity.remove();
} else {
Debug.echoError("Tried to remove already-removed entity.");
}
} else {
int removed = 0;
for (Entity worldEntity : world.getEntities()) {
if (entity.getEntityType().equals(DenizenEntityType.getByEntity(worldEntity))) {
worldEntity.remove();
removed++;
}
}
Debug.echoDebug(scriptEntry, "Removed " + removed + " entities from the world.");
if (alwaysWarnOnMassRemove) {
Debug.echoError("Remove command 'Always warn on mass delete' in Denizen config is enabled - mass removal of '" + entity.getEntityType() + "' performed, removing " + removed + " entities.");
}
}
}
}
use of com.denizenscript.denizen.objects.WorldTag in project Denizen-For-Bukkit by DenizenScript.
the class PermissionCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
ElementTag action = scriptEntry.getElement("action");
ElementTag permission = scriptEntry.getElement("permission");
ElementTag group = scriptEntry.getElement("group");
WorldTag world = scriptEntry.getObjectTag("world");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), action, permission, group, world);
}
World bukkitWorld = null;
if (world != null) {
bukkitWorld = world.getWorld();
}
OfflinePlayer player = Utilities.entryHasPlayer(scriptEntry) ? Utilities.getEntryPlayer(scriptEntry).getOfflinePlayer() : null;
switch(Action.valueOf(action.asString().toUpperCase())) {
case ADD:
if (group != null) {
if (Depends.permissions.groupHas(bukkitWorld, group.asString(), permission.asString())) {
Debug.echoDebug(scriptEntry, "Group " + group + " already has permission " + permission);
} else {
Depends.permissions.groupAdd(bukkitWorld, group.asString(), permission.asString());
}
} else {
if (Depends.permissions.playerHas(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString())) {
Debug.echoDebug(scriptEntry, "Player " + player.getName() + " already has permission " + permission);
} else {
Depends.permissions.playerAdd(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString());
}
}
break;
case REMOVE:
if (group != null) {
if (!Depends.permissions.groupHas(bukkitWorld, group.asString(), permission.asString())) {
Debug.echoDebug(scriptEntry, "Group " + group + " does not have access to permission " + permission);
} else {
Depends.permissions.groupRemove(bukkitWorld, group.asString(), permission.asString());
}
} else {
if (!Depends.permissions.playerHas(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString())) {
Debug.echoDebug(scriptEntry, "Player " + player.getName() + " does not have access to permission " + permission);
} else {
Depends.permissions.playerRemove(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString());
}
}
break;
}
}
Aggregations