Skip to content

Commit

Permalink
Added small things to different plugins
Browse files Browse the repository at this point in the history
Added self arguement to disguise command

Some likes seeing their own disguise, some does not

Added ignore mech and tag

Added warp tags for Essentials
  • Loading branch information
Mwthorn committed May 15, 2018
1 parent 7a11d1c commit 9e157c8
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 8 deletions.
Expand Up @@ -15,7 +15,7 @@
public class DisguiseCommands extends AbstractCommand {
// <--[command]
// @Name disguise
// @Syntax disguise [remove/player/mob/misc] (type:<entity type>) (target:<entity>) (name:<text>) (baby:true/false) (id:<number>) (data:<number>)
// @Syntax disguise [remove/player/mob/misc] (type:<entity type>) (target:<entity>) (name:<text>) (baby:true/false) (id:<number>) (data:<number>) (self:true/false)
// @Group Depenizen
// @Plugin DepenizenBukkit, LibsDisguises
// @Required 2
Expand All @@ -37,6 +37,8 @@ public class DisguiseCommands extends AbstractCommand {
// Specify id and/or data for misc disguises. Default is 1 and 0 respectively.
// Removing a disgsuise shows the true entity again for all players.
// Only one disguise can be allowed, if another one is set, the preious disguise is removed.
// Specify self arguement, if it is set to true, the disguise will be hidden from the player who is disguised.
// Otherwise it is default set to false, showing the disguised character the player is disguising as.

// @Tags
// <e@entity.is_disguised>
Expand All @@ -48,7 +50,7 @@ public class DisguiseCommands extends AbstractCommand {

// @Usage
// Use to disguise the attached player in the queue as a Zombie.
// - disguise mob type:ZOMBIE baby:true
// - disguise mob type:ZOMBIE baby:true self:true

// @Usage
// Use to disguise the attached player in the queue as a Boat.
Expand Down Expand Up @@ -109,6 +111,11 @@ else if (!scriptEntry.hasObject("baby")
scriptEntry.addObject("baby", arg.asElement());
}

else if (!scriptEntry.hasObject("self")
&& arg.matchesPrefix("self")) {
scriptEntry.addObject("self", arg.asElement());
}

else if (!scriptEntry.hasObject("action")
&& arg.matchesEnum(Action.values())) {
scriptEntry.addObject("action", arg.asElement());
Expand All @@ -120,7 +127,7 @@ else if (!scriptEntry.hasObject("action")

}
if (!scriptEntry.hasObject("action")) {
throw new InvalidArgumentsException("Action not specified! (add/remove)");
throw new InvalidArgumentsException("Action not specified! (remove/mob/player/misc)");
}

if (!scriptEntry.hasObject("baby")) {
Expand All @@ -135,6 +142,10 @@ else if (!scriptEntry.hasObject("action")
scriptEntry.addObject("data", new Element(0));
}

if (!scriptEntry.hasObject("self")) {
scriptEntry.addObject("self", new Element(false));
}

if (!scriptEntry.hasObject("target")) {
if (((BukkitScriptEntryData) scriptEntry.entryData).hasPlayer()) {
scriptEntry.addObject("target", ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getDenizenEntity());
Expand All @@ -155,6 +166,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Element id = scriptEntry.getdObject("id");
Element data = scriptEntry.getdObject("data");
Element baby = scriptEntry.getdObject("baby");
Element self = scriptEntry.getdObject("self");

// Report to dB
dB.report(scriptEntry, getName(), action.debug()
Expand All @@ -165,8 +177,13 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
+ (data != null ? data.debug() : "")
+ (baby != null ? baby.debug() : ""));

if (action == null) {
dB.echoError(scriptEntry.getResidingQueue(), "Action not specified! (remove/mob/player/misc)");
if (target == null) {
dB.echoError(scriptEntry.getResidingQueue(), "Target not found!");
return;
}

if (baby == null) {
dB.echoError(scriptEntry.getResidingQueue(), "Baby not specified!");
return;
}

Expand All @@ -185,7 +202,7 @@ else if (action.asString().equalsIgnoreCase("mob")) {
watcher.setCustomNameVisible(true);
watcher.setCustomName(name.toString());
}
if (target.isPlayer()) {
if (target.isPlayer() && self.asBoolean()) {
DisguiseAPI.disguiseIgnorePlayers(target.getBukkitEntity(), mobDisguise, target.getPlayer());
}
else {
Expand All @@ -199,7 +216,7 @@ else if (action.asString().equalsIgnoreCase("player")) {
return;
}
PlayerDisguise playerDisguise = new PlayerDisguise(name.toString());
if (target.isPlayer()) {
if (target.isPlayer() && self.asBoolean()) {
DisguiseAPI.disguiseIgnorePlayers(target.getBukkitEntity(), playerDisguise, target.getPlayer());
}
else {
Expand All @@ -212,13 +229,21 @@ else if (action.asString().equalsIgnoreCase("misc")) {
dB.echoError(scriptEntry.getResidingQueue(), "Entity not specified!");
return;
}
if (id == null) {
dB.echoError(scriptEntry.getResidingQueue(), "ID not specified!");
return;
}
if (data == null) {
dB.echoError(scriptEntry.getResidingQueue(), "Data not specified!");
return;
}
MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.valueOf(type.toString().toUpperCase()),id.asInt(),data.asInt());
FlagWatcher watcher = miscDisguise.getWatcher();
if (name != null) {
watcher.setCustomNameVisible(true);
watcher.setCustomName(name.toString());
}
if (target.isPlayer()) {
if (target.isPlayer() && self.asBoolean()) {
DisguiseAPI.disguiseIgnorePlayers(target.getBukkitEntity(), miscDisguise, target.getPlayer());
}
else {
Expand Down
Expand Up @@ -10,6 +10,7 @@
import com.denizenscript.depenizen.bukkit.extensions.dObjectExtension;
import com.denizenscript.depenizen.bukkit.support.Support;
import com.denizenscript.depenizen.bukkit.support.plugins.EssentialsSupport;
import org.bukkit.entity.Player;

import java.util.GregorianCalendar;

Expand Down Expand Up @@ -147,6 +148,29 @@ public String getAttribute(Attribute attribute) {
return homes.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.ignored_players>
// @returns dList(dPlayer)
// @description
// Returns a list of the ignored players of the player.
// @Plugin DepenizenBukkit, Essentials
// -->
if (attribute.startsWith("ignored_players")) {
dList players = new dList();
Essentials essentials = Support.getPlugin(EssentialsSupport.class);
for (String player : essUser._getIgnoredPlayers()) {
try {
players.add(new dPlayer(essentials.getOfflineUser(player).getBase()).identifySimple());
}
catch (Exception e) {
if (!attribute.hasAlternative()) {
dB.echoError(e);
}
}
}
return players.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.home_name_list>
// @returns dList(Element)
Expand Down Expand Up @@ -285,5 +309,31 @@ public void adjust(Mechanism mechanism) {
essUser.setVanished(value.asBoolean());
}


// <--[mechanism]
// @object dPlayer
// @name essentials_ignore
// @input Element(dPlayer)(|Boolean)
// @description
// Sets whether the player should ignore anther player. If no boolean is provided, it is by default true.
// @tags
// <p@player.ignored_players>
// @Plugin DepenizenBukkit, Essentials
// -->
if (mechanism.matches("essentials_ignore")) {
Essentials essentials = Support.getPlugin(EssentialsSupport.class);
if (value.asString().contains("|")) {
int split = value.asString().indexOf("|");
int len = value.asString().length();
String after = value.asString().substring(split + 1 , len);
String before = value.asString().substring(0, split - 1);
essUser.setIgnoredPlayer(essentials.getUser(new Element (before).asType(dPlayer.class).getOfflinePlayer().getUniqueId()) ,new Element (after).asBoolean());
}
else {
essUser.setIgnoredPlayer(essentials.getUser(value.asType(dPlayer.class).getOfflinePlayer().getUniqueId()) ,true);
}
}


}
}
Expand Up @@ -7,17 +7,78 @@
import com.denizenscript.depenizen.bukkit.extensions.essentials.EssentialsItemExtension;
import com.denizenscript.depenizen.bukkit.extensions.essentials.EssentialsPlayerExtension;
import com.denizenscript.depenizen.bukkit.support.Support;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.commands.WarpNotFoundException;
import net.aufdemrand.denizen.objects.dItem;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.ess3.api.InvalidWorldException;
import org.bukkit.Location;

public class EssentialsSupport extends Support {

public EssentialsSupport() {
registerAdditionalTags("essentials");
registerScriptEvents(new PlayerAFKStatusScriptEvent());
registerScriptEvents(new PlayerGodModeStatusScriptEvent());
registerScriptEvents(new PlayerJailStatusScriptEvent());
registerScriptEvents(new PlayerMuteStatusScriptEvent());
registerProperty(EssentialsPlayerExtension.class, dPlayer.class);
registerProperty(EssentialsItemExtension.class, dItem.class);
}

@Override
public String additionalTags(Attribute attribute, TagContext tagContext) {
if (attribute == null) {
return null;
}

if (attribute.startsWith("essentials")) {

attribute = attribute.fulfill(1);

// <--[tag]
// @attribute <essentials.warp[<warp name>]>
// @returns dLocation
// @description
// Returns the location of the warp name.
// @Plugin DepenizenBukkit, Essentials
// -->
if (attribute.startsWith("warp")) {
if (attribute.hasContext(1)) {
Essentials essentials = Support.getPlugin(EssentialsSupport.class);
try {
Location loc = essentials.getWarps().getWarp(attribute.getContext(1));
return new dLocation(loc).getAttribute(attribute.fulfill(1));
} catch (WarpNotFoundException e) {
dB.echoError("Warp not found");
return null;
} catch (InvalidWorldException e) {
dB.echoError("Invalid world for getting warp");
return null;
}
}
}

// <--[tag]
// @attribute <essentials.list_warps>
// @returns dList(Element)
// @description
// Returns a list of all Warp names.
// @Plugin DepenizenBukkit, Essentials
// -->
if (attribute.startsWith("list_warps")) {
Essentials essentials = Support.getPlugin(EssentialsSupport.class);
dList warps = new dList();
warps.addAll(essentials.getWarps().getList());
return warps.getAttribute(attribute.fulfill(1));
}
}

return null;
}
}

0 comments on commit 9e157c8

Please sign in to comment.