Added RTP script, spawn command, and broadcast command.
This commit is contained in:
@@ -63,4 +63,5 @@ public class Config implements JsonSerializable<Config> {
|
||||
}
|
||||
|
||||
public SerialLocation freezeLocation = new SerialLocation("unset",0,64,0,0,0);
|
||||
public SerialLocation spawnLocation = new SerialLocation("unset",0,64,0,0,0);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class GamemodeEvent implements QuickListener {
|
||||
public class JoinEvent implements QuickListener {
|
||||
|
||||
@EventHandler
|
||||
private void onJoin(PlayerJoinEvent e) {
|
||||
@@ -0,0 +1,79 @@
|
||||
package me.trouper.clonedupecore.server.gui;
|
||||
|
||||
import me.trouper.alias.server.systems.gui.QuickGui;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RtpGui {
|
||||
public ItemStack EMPTY = ItemBuilder.of(Material.LIGHT_GRAY_STAINED_GLASS_PANE)
|
||||
.displayName("")
|
||||
.build();
|
||||
|
||||
public QuickGui.GuiBuilder create() {
|
||||
QuickGui.GuiBuilder builder = QuickGui.create();
|
||||
builder.titleMini("<gray><bold>Random Teleport");
|
||||
builder.rows(3);
|
||||
|
||||
builder.item(11, ItemBuilder.headOfTexture("http://textures.minecraft.net/texture/879e54cbe87867d14b2fbdf3f1870894352048dfecd962846dea893b2154c85")
|
||||
.displayName("ᴏᴠᴇʀᴡᴏʀʟᴅ")
|
||||
.loreMiniMessage(List.of(
|
||||
"<dark_gray>Teleporter",
|
||||
"<gray>",
|
||||
"<white>Travel into the <green>Overworld <white>Dimension",
|
||||
"<white>To get new resources and explore!",
|
||||
"<gray>",
|
||||
"<green><bold>BORDER</bold> 25k x 25k",
|
||||
"<dark_gray>Click To Teleport!"
|
||||
))
|
||||
.build(),
|
||||
consoleCommand("betterrtp:rtp player %player% world")
|
||||
);
|
||||
|
||||
builder.item(13, ItemBuilder.headOfTexture("http://textures.minecraft.net/texture/e8ee8f341eabf65515718163ec3b43ed01e1cde27b3b26c4d92c607299e4d91")
|
||||
.displayName("ɴᴇᴛʜᴇʀ")
|
||||
.loreMiniMessage(List.of(
|
||||
"<dark_gray>Teleporter",
|
||||
"<gray>",
|
||||
"<white>Travel into the <red>Nether <white>Dimension",
|
||||
"<white>To get new resources and explore!",
|
||||
"<gray>",
|
||||
"<red><bold>BORDER</bold> 25k x 25k",
|
||||
"<dark_gray>Click To Teleport!"
|
||||
))
|
||||
.build(),
|
||||
consoleCommand("betterrtp:rtp player %player% world_nether")
|
||||
);
|
||||
|
||||
builder.item(15, ItemBuilder.headOfTexture("http://textures.minecraft.net/texture/b4346c5e44039a505e5b16dba5ec84b3a379709fb32b8427d29366a5ea036fb")
|
||||
.displayName("ᴇɴᴅ")
|
||||
.loreMiniMessage(List.of(
|
||||
"<dark_gray>Teleporter",
|
||||
"<red>Closed For End Fight",
|
||||
"<white>Travel into the <aqua>End <white>Dimension",
|
||||
"<white>To get new resources and explore!",
|
||||
"<gray>",
|
||||
"<aqua><bold>BORDER</bold> ∞",
|
||||
"<dark_gray>Click To Teleport!"
|
||||
))
|
||||
.build(),
|
||||
consoleCommand("betterrtp:rtp player %player% world_the_end")
|
||||
);
|
||||
|
||||
builder.fillEmpty(EMPTY);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
private QuickGui.GuiAction consoleCommand(String command) {
|
||||
return (gui, event) -> {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),command);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.trouper.clonedupecore.server.scripts;
|
||||
|
||||
import me.trouper.alias.server.commands.Args;
|
||||
import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandRegistry(
|
||||
value = "broadcast",
|
||||
permission = @Permission("clonedupe.broadcast")
|
||||
)
|
||||
public class BroadcastCommand implements QuickCommand {
|
||||
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
Text.Pallet pallet = Text.Pallet.INFO;
|
||||
String message = args.getAll(1).toString();
|
||||
try {
|
||||
pallet = args.get(0).toEnum(Text.Pallet.class);
|
||||
} catch (Exception ex) {
|
||||
message = args.get(0) + " " + message;
|
||||
}
|
||||
Component text = Text.color(message);
|
||||
Audience players = Audience.audience(Bukkit.getOnlinePlayers());
|
||||
Text.message(pallet,players,text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCompletion(CommandSender sender, Command command, String label, Args args, CompletionBuilder b) {
|
||||
b.then(
|
||||
b.argEnum(Text.Pallet.class)
|
||||
).then(
|
||||
b.arg("<message>")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.trouper.clonedupecore.server.scripts;
|
||||
|
||||
import me.trouper.alias.server.commands.Args;
|
||||
import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.clonedupecore.server.gui.RtpGui;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandRegistry(
|
||||
value = "rtp",
|
||||
permission = @Permission("clonedupe.hide"),
|
||||
blocksAllowed = false,
|
||||
consoleAllowed = false
|
||||
)
|
||||
public class RtpCommand implements QuickCommand {
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
new RtpGui().create().build().open((Player) sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCompletion(CommandSender sender, Command command, String label, Args args, CompletionBuilder b) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package me.trouper.clonedupecore.server.scripts;
|
||||
|
||||
import me.trouper.alias.server.commands.Args;
|
||||
import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommandListener;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.data.SerialLocation;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@CommandRegistry(
|
||||
value = "spawn",
|
||||
permission = @Permission("clonedupe.spawn")
|
||||
)
|
||||
public class SpawnCommand implements QuickCommandListener, Data {
|
||||
|
||||
private final Map<UUID, Long> warmups = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
if (args.getSize() > 0 || "setspawn".equals(label)) {
|
||||
if (("setspawn".equals(label) || "set".equals(args.get(0).toString())) && sender.hasPermission("clonedupe.spawn.set") && sender instanceof Player setter) {
|
||||
Location l = setter.getLocation();
|
||||
getConfig().spawnLocation = SerialLocation.translate(l);
|
||||
getConfig().save();
|
||||
info(sender, Component.text("Set the spawn location to {0}."), Text.format(Text.Pallet.LOCATION,"({0},{1},{2})",l.getBlockX(),l.getBlockY(),l.getBlockZ()));
|
||||
return;
|
||||
}
|
||||
Player target = Bukkit.getPlayerExact(args.get(0).toString());
|
||||
if (!sender.hasPermission("clonedupe.spawn.others")) return;
|
||||
if (target != null) {
|
||||
teleportToSpawn(target,false);
|
||||
infoAny(sender,"Teleported {0} to spawn.",target.getName());
|
||||
} else {
|
||||
errorAny(sender,"{0} is not an online player!",args.get(0).toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ("unset".equals(getConfig().spawnLocation.world())) {
|
||||
errorAny(sender,"Spawn is not set yet!");
|
||||
return;
|
||||
}
|
||||
if (sender instanceof Player player) {
|
||||
startSpawnWarmup(player);
|
||||
return;
|
||||
}
|
||||
errorAny(sender,"Only players may teleport to spawn!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCompletion(CommandSender sender, Command command, String label, Args args, CompletionBuilder b) {
|
||||
if (sender.hasPermission("clonedupe.spawn.set")) b.then(b.arg("set"));
|
||||
if (sender.hasPermission("clonedupe.spawn.others")) b.then(b.argOnlinePlayers());
|
||||
}
|
||||
|
||||
private void startSpawnWarmup(Player player) {
|
||||
if (player.hasPermission("clonedupe.spawn.bypass")) {
|
||||
teleportToSpawn(player, false);
|
||||
return;
|
||||
}
|
||||
|
||||
warmups.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
int WARMUP_TICKS = 100;
|
||||
successAny(player, "Teleporting to spawn in {0} seconds. Don't move or take damage!", WARMUP_TICKS / 20);
|
||||
AtomicInteger secondsLeft = new AtomicInteger((int) WARMUP_TICKS / 20);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(),(task)->{
|
||||
if (!warmups.containsKey(player.getUniqueId()) || secondsLeft.get() < 0 || !player.isOnline()) {
|
||||
task.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (secondsLeft.get() % 5 == 0 || secondsLeft.get() <= 3) {
|
||||
if (secondsLeft.get() > 0) {
|
||||
player.sendActionBar(Text.format(Text.Pallet.INFO,"Teleporting in {0}!",secondsLeft.get()));
|
||||
} else {
|
||||
warmups.remove(player.getUniqueId());
|
||||
teleportToSpawn(player, true);
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
secondsLeft.decrementAndGet();
|
||||
},20L,20L);
|
||||
}
|
||||
|
||||
private void teleportToSpawn(Player player, boolean duringWarmup) {
|
||||
Location spawnLoc = getConfig().spawnLocation.translate();
|
||||
if (spawnLoc.getWorld() == null) {
|
||||
errorAny(player, "Spawn world is not loaded.");
|
||||
return;
|
||||
}
|
||||
player.teleport(spawnLoc);
|
||||
successAny(player, "Teleported to spawn.");
|
||||
if (duringWarmup) {
|
||||
warmups.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (!warmups.containsKey(player.getUniqueId())) return;
|
||||
Location from = e.getFrom();
|
||||
Location to = e.getTo();
|
||||
|
||||
if (from.distanceSquared(to) >= 0.001) {
|
||||
warmups.remove(player.getUniqueId());
|
||||
errorAny(player, "Teleport cancelled due to movement!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent e) {
|
||||
if (!(e.getEntity() instanceof Player player)) return;
|
||||
if (!warmups.containsKey(player.getUniqueId())) return;
|
||||
|
||||
warmups.remove(player.getUniqueId());
|
||||
errorAny(player, "Teleport cancelled because you took damage!");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
if ("unset".equals(getConfig().spawnLocation.world())) return;
|
||||
Player p = e.getPlayer();
|
||||
if (p.getRespawnLocation() != null) return;
|
||||
e.setRespawnLocation(getConfig().spawnLocation.translate());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if ("unset".equals(getConfig().spawnLocation.world())) return;
|
||||
Player p = e.getPlayer();
|
||||
Location loc = getConfig().spawnLocation.translate();
|
||||
if (p.getLocation().distanceSquared(loc) > 100*100) return;
|
||||
p.teleport(loc);
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public class TrimManager implements QuickListener, Data {
|
||||
if (activeAnimation == null) {
|
||||
return;
|
||||
} else if (lastAnimationMap.containsKey(playerId) && !lastAnimationMap.get(playerId).equals(activeAnimation)) {
|
||||
lastAnimationMap.get(playerId).onRemove(player);
|
||||
lastAnimationMap.put(playerId,activeAnimation);
|
||||
} else if (!lastAnimationMap.containsKey(playerId)) {
|
||||
lastAnimationMap.put(playerId,activeAnimation);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class LiarTroll implements TrollFeature {
|
||||
activeLiars.put(target.getUniqueId(),target.getEquipment().getLeggings());
|
||||
|
||||
AtomicBoolean inverse = new AtomicBoolean(false);
|
||||
AtomicInteger timeRemaining = new AtomicInteger(30 * 20);
|
||||
AtomicInteger timeRemaining = new AtomicInteger(15 * 20);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(), (task)->{
|
||||
if (!activeLiars.containsKey(target.getUniqueId())) {
|
||||
|
||||
@@ -28,15 +28,17 @@ commands:
|
||||
- admin
|
||||
- cdc
|
||||
offend:
|
||||
usage: "/offend <player> <query|punish> <offense>"
|
||||
usage: "/offend <player> <offense>"
|
||||
permission: clonedupe.offend
|
||||
aliases:
|
||||
- punish
|
||||
trimeffect:
|
||||
usage: /trimeffect <global|self>
|
||||
description: Toggle trim effect visibility
|
||||
statedit:
|
||||
usage: /statedit <player> <statistic> <value>
|
||||
permission: clonedupe.statedit
|
||||
description: Edit minecraft's tracked statistics
|
||||
freeze:
|
||||
usage: /freeze <player>
|
||||
permission: clonedupe.freeze
|
||||
@@ -50,7 +52,43 @@ commands:
|
||||
wand:
|
||||
usage: /wand <name>
|
||||
permission: clonedupe.getwand
|
||||
description: Get any of the registered AbstractWands
|
||||
rtp:
|
||||
usage: /rtp
|
||||
description: A gui for BetterRTP
|
||||
aliases:
|
||||
- randomtp
|
||||
- betterrtp
|
||||
- wild
|
||||
- wildtp
|
||||
- tpr
|
||||
broadcast:
|
||||
usage: /broadcast [pallet] <message>
|
||||
description: Broadcast a message with the text system
|
||||
permission: clonedupe.broadcast
|
||||
aliases:
|
||||
- bc
|
||||
spawn:
|
||||
usage: /spawn [set|player]
|
||||
description: Teleport to the spawn location.
|
||||
aliases:
|
||||
- setspawn
|
||||
permissions:
|
||||
clonedupe.spawn.bypass:
|
||||
default: op
|
||||
description: Allows bypassing of the spawn warmup.
|
||||
clonedupe.spawn.others:
|
||||
default: op
|
||||
description: allows teleportation of other players to spawn.
|
||||
clonedupe.spawn.set:
|
||||
default: op
|
||||
description: Set the configurable spawn location.
|
||||
clonedupe.spawn:
|
||||
default: true
|
||||
description: Allows teleportation to spawn.
|
||||
clonedupe.broadcast:
|
||||
default: op
|
||||
description: Gives access to the broadcast command.
|
||||
clonedupe.getwand:
|
||||
default: op
|
||||
description: Get any AbstractWand registered.
|
||||
|
||||
Reference in New Issue
Block a user