Search in sources :

Example 36 with PlayerTag

use of com.denizenscript.denizen.objects.PlayerTag in project Denizen-For-Bukkit by DenizenScript.

the class FakeEntity method showFakeEntityTo.

public static FakeEntity showFakeEntityTo(List<PlayerTag> players, EntityTag typeToSpawn, LocationTag location, DurationTag duration) {
    NetworkInterceptHelper.enable();
    FakeEntity fakeEntity = NMSHandler.getPlayerHelper().sendEntitySpawn(players, typeToSpawn.getEntityType(), location, typeToSpawn.mechanisms == null ? null : new ArrayList<>(typeToSpawn.mechanisms), -1, null, true);
    idsToEntities.put(fakeEntity.overrideUUID == null ? fakeEntity.entity.getUUID() : fakeEntity.overrideUUID, fakeEntity);
    for (PlayerTag player : players) {
        UUID uuid = player.getPlayerEntity().getUniqueId();
        FakeEntity.FakeEntityMap playerEntities = playersToEntities.get(uuid);
        if (playerEntities == null) {
            playerEntities = new FakeEntity.FakeEntityMap();
            playersToEntities.put(uuid, playerEntities);
        }
        playerEntities.byId.put(fakeEntity.id, fakeEntity);
    }
    fakeEntity.updateEntity(fakeEntity.entity, duration);
    return fakeEntity;
}
Also used : PlayerTag(com.denizenscript.denizen.objects.PlayerTag)

Example 37 with PlayerTag

use of com.denizenscript.denizen.objects.PlayerTag in project Denizen-For-Bukkit by DenizenScript.

the class FakeEntity method cancelEntity.

public void cancelEntity() {
    if (currentTask != null) {
        currentTask.cancel();
        currentTask = null;
    }
    idsToEntities.remove(overrideUUID == null ? entity.getUUID() : overrideUUID);
    if (triggerDestroyPacket != null) {
        triggerDestroyPacket.run();
    } else {
        for (PlayerTag player : players) {
            if (player.isOnline()) {
                NMSHandler.getPlayerHelper().sendEntityDestroy(player.getPlayerEntity(), entity.getBukkitEntity());
            }
        }
    }
    for (PlayerTag player : players) {
        FakeEntity.FakeEntityMap mapping = playersToEntities.get(player.getUUID());
        mapping.remove(this);
    }
    entity.isFakeValid = false;
}
Also used : PlayerTag(com.denizenscript.denizen.objects.PlayerTag)

Example 38 with PlayerTag

use of com.denizenscript.denizen.objects.PlayerTag in project Denizen-For-Bukkit by DenizenScript.

the class FakeBlock method showFakeBlockTo.

public static void showFakeBlockTo(List<PlayerTag> players, LocationTag location, MaterialTag material, DurationTag duration, boolean sendNow) {
    NetworkInterceptHelper.enable();
    for (PlayerTag player : players) {
        if (!player.isOnline() || !player.isValid()) {
            continue;
        }
        UUID uuid = player.getPlayerEntity().getUniqueId();
        FakeBlockMap playerBlocks = blocks.get(uuid);
        if (playerBlocks == null) {
            playerBlocks = new FakeBlockMap();
            blocks.put(uuid, playerBlocks);
        }
        FakeBlock block = playerBlocks.getOrAdd(player, location);
        block.updateBlock(material, duration, sendNow);
    }
}
Also used : PlayerTag(com.denizenscript.denizen.objects.PlayerTag)

Example 39 with PlayerTag

use of com.denizenscript.denizen.objects.PlayerTag in project Denizen-For-Bukkit by DenizenScript.

the class ExSustainedCommandHandler method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
    if (cmd.getName().equalsIgnoreCase("exs")) {
        List<Object> entries = new ArrayList<>();
        String entry = String.join(" ", args);
        boolean quiet = !Settings.showExDebug();
        if (entry.length() > 3 && entry.startsWith("-q ")) {
            quiet = !quiet;
            entry = entry.substring("-q ".length());
        }
        if (entry.length() < 2) {
            sender.sendMessage("/exs (-q) <denizen script command> (arguments)");
            return true;
        }
        TimedQueue queue = getOrMakeQueue(sender instanceof Player ? (Player) sender : null, quiet);
        if (!quiet && sender instanceof Player) {
            Player player = (Player) sender;
            queue.debugOutput = (s) -> {
                player.spigot().sendMessage(FormattedTextHelper.parse(s, net.md_5.bungee.api.ChatColor.WHITE));
            };
        } else {
            queue.debugOutput = null;
        }
        if (queue.isPaused() || queue.isDelayed()) {
            sender.sendMessage(ChatColor.YELLOW + "Sustained queue is currently paused or waiting, adding command to queue for later execution.");
        } else if (Settings.showExHelp()) {
            if (Debug.showDebug) {
                if (quiet) {
                    sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command... check the console for full debug output!");
                } else {
                    sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command...");
                }
            } else {
                sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command... to see debug, use /denizen debug");
            }
        }
        entries.add(entry);
        NPCTag npc = null;
        if (Depends.citizens != null && Depends.citizens.getNPCSelector().getSelected(sender) != null) {
            npc = new NPCTag(Depends.citizens.getNPCSelector().getSelected(sender));
        }
        List<ScriptEntry> scriptEntries = ScriptBuilder.buildScriptEntries(entries, null, new BukkitScriptEntryData(sender instanceof Player ? new PlayerTag((Player) sender) : null, npc));
        queue.addEntries(scriptEntries);
        if (!queue.is_started) {
            queue.start();
        } else {
            queue.onStart();
        }
        return true;
    }
    return false;
}
Also used : Player(org.bukkit.entity.Player) BukkitScriptEntryData(com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) ArrayList(java.util.ArrayList) NPCTag(com.denizenscript.denizen.objects.NPCTag) TimedQueue(com.denizenscript.denizencore.scripts.queues.core.TimedQueue) ScriptEntry(com.denizenscript.denizencore.scripts.ScriptEntry)

Example 40 with PlayerTag

use of com.denizenscript.denizen.objects.PlayerTag in project Denizen-For-Bukkit by DenizenScript.

the class DenizenCommand method canSeeHelp.

public boolean canSeeHelp(CommandSender commandSender) {
    if (!script.hasAllowedHelpProcedure()) {
        return true;
    }
    if (!testPermissionSilent(commandSender)) {
        return false;
    }
    Map<String, ObjectTag> context = new HashMap<>();
    PlayerTag player = null;
    NPCTag npc = null;
    if (commandSender instanceof Player) {
        Player pl = (Player) commandSender;
        if (!EntityTag.isNPC(pl)) {
            player = PlayerTag.mirrorBukkitPlayer(pl);
        }
        context.put("server", new ElementTag(false));
    } else {
        context.put("server", new ElementTag(true));
    }
    return script.runAllowedHelpProcedure(player, npc, context);
}
Also used : Player(org.bukkit.entity.Player) HashMap(java.util.HashMap) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) NPCTag(com.denizenscript.denizen.objects.NPCTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag)

Aggregations

PlayerTag (com.denizenscript.denizen.objects.PlayerTag)81 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)41 Player (org.bukkit.entity.Player)26 List (java.util.List)23 NPCTag (com.denizenscript.denizen.objects.NPCTag)22 EntityTag (com.denizenscript.denizen.objects.EntityTag)16 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)15 ListTag (com.denizenscript.denizencore.objects.core.ListTag)15 LocationTag (com.denizenscript.denizen.objects.LocationTag)14 ItemTag (com.denizenscript.denizen.objects.ItemTag)12 InvalidArgumentsException (com.denizenscript.denizencore.exceptions.InvalidArgumentsException)11 EventHandler (org.bukkit.event.EventHandler)11 BukkitTagContext (com.denizenscript.denizen.tags.BukkitTagContext)8 ScriptTag (com.denizenscript.denizencore.objects.core.ScriptTag)8 ScriptEntry (com.denizenscript.denizencore.scripts.ScriptEntry)8 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)7 BukkitScriptEntryData (com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData)7 ObjectTag (com.denizenscript.denizencore.objects.ObjectTag)7 FakeEntity (com.denizenscript.denizen.utilities.entity.FakeEntity)6 Argument (com.denizenscript.denizencore.objects.Argument)6