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;
}
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;
}
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);
}
}
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;
}
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);
}
Aggregations