mirror of
https://github.com/Freezy-Studios/BlazeSMP.git
synced 2025-04-21 16:44:04 +02:00
commit
25f52857e2
4 changed files with 56 additions and 17 deletions
|
@ -7,7 +7,6 @@ import me.freezy.plugins.papermc.blazesmp.module.manager.Clans;
|
||||||
import me.freezy.plugins.papermc.blazesmp.module.manager.L4M4;
|
import me.freezy.plugins.papermc.blazesmp.module.manager.L4M4;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -20,6 +19,8 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||||
|
|
||||||
public class ClanCommand extends SimpleCommand {
|
public class ClanCommand extends SimpleCommand {
|
||||||
|
|
||||||
private final Clans clans;
|
private final Clans clans;
|
||||||
|
@ -66,7 +67,8 @@ public class ClanCommand extends SimpleCommand {
|
||||||
}
|
}
|
||||||
String clanName = args[1];
|
String clanName = args[1];
|
||||||
String clanTag = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
String clanTag = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||||
Component tagComponent = miniMessage().deserialize(clanTag);
|
String formattedMessage = clanTag.replaceAll("<click:[^>]+>(.*?)</click>", "$1");
|
||||||
|
Component tagComponent = miniMessage().deserialize(formattedMessage);
|
||||||
|
|
||||||
Clan newClan = new Clan(clanName, tagComponent, playerUUID);
|
Clan newClan = new Clan(clanName, tagComponent, playerUUID);
|
||||||
clans.addClan(newClan);
|
clans.addClan(newClan);
|
||||||
|
@ -678,6 +680,7 @@ public class ClanCommand extends SimpleCommand {
|
||||||
}
|
}
|
||||||
String whatToModify = args[1].toLowerCase();
|
String whatToModify = args[1].toLowerCase();
|
||||||
String newValue = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
String newValue = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||||
|
String formattedMessage = newValue.replaceAll("<click:[^>]+>(.*?)</click>", "$1");
|
||||||
Clan currentClan = clans.getClanByMember(playerUUID);
|
Clan currentClan = clans.getClanByMember(playerUUID);
|
||||||
if (currentClan == null) {
|
if (currentClan == null) {
|
||||||
player.sendMessage(miniMessage().deserialize(L4M4.get("error.clan_not_found")));
|
player.sendMessage(miniMessage().deserialize(L4M4.get("error.clan_not_found")));
|
||||||
|
@ -692,11 +695,11 @@ public class ClanCommand extends SimpleCommand {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
case "tag" -> {
|
case "tag" -> {
|
||||||
Component newTag = miniMessage().deserialize(newValue);
|
Component newTag = miniMessage().deserialize(formattedMessage);
|
||||||
currentClan.setTag(newTag);
|
currentClan.setTag(newTag);
|
||||||
currentClan.save();
|
currentClan.save();
|
||||||
player.sendMessage(miniMessage().deserialize(
|
player.sendMessage(miniMessage().deserialize(
|
||||||
String.format("<green>Clan tag changed to %s.</green>", newValue)
|
String.format("<green>Clan tag changed to %s.</green>", formattedMessage)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
default -> player.sendMessage(miniMessage().deserialize(L4M4.get("error.modify_invalid")));
|
default -> player.sendMessage(miniMessage().deserialize(L4M4.get("error.modify_invalid")));
|
||||||
|
@ -778,7 +781,8 @@ public class ClanCommand extends SimpleCommand {
|
||||||
.filter(s -> s.startsWith(args[1]))
|
.filter(s -> s.startsWith(args[1]))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
default -> {}
|
default -> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (clans.isVice(playerUUID)) {
|
} else if (clans.isVice(playerUUID)) {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
|
@ -809,7 +813,8 @@ public class ClanCommand extends SimpleCommand {
|
||||||
List<String> joins = getClanJoinRequests(args, playerUUID);
|
List<String> joins = getClanJoinRequests(args, playerUUID);
|
||||||
if (joins != null) return joins;
|
if (joins != null) return joins;
|
||||||
}
|
}
|
||||||
default -> {}
|
default -> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
|
@ -829,7 +834,8 @@ public class ClanCommand extends SimpleCommand {
|
||||||
case "create" -> {
|
case "create" -> {
|
||||||
return Collections.singletonList("<name>");
|
return Collections.singletonList("<name>");
|
||||||
}
|
}
|
||||||
default -> {}
|
default -> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,10 @@ public class PlayerChatListener implements Listener {
|
||||||
public void onChat(AsyncChatEvent event) {
|
public void onChat(AsyncChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
Component messageComponent = MiniMessage.miniMessage().deserialize(PlainTextComponentSerializer.plainText().serialize(event.message()));
|
String message = PlainTextComponentSerializer.plainText().serialize(event.message());
|
||||||
|
String formattedMessage = message.replaceAll("<click:[^>]+>(.*?)</click>", "$1");
|
||||||
|
|
||||||
|
Component messageComponent = MiniMessage.miniMessage().deserialize(formattedMessage);
|
||||||
|
|
||||||
Component chatComponent = Component.empty()
|
Component chatComponent = Component.empty()
|
||||||
.append(player.playerListName())
|
.append(player.playerListName())
|
||||||
|
|
|
@ -2,9 +2,12 @@ package me.freezy.plugins.papermc.blazesmp.listener;
|
||||||
|
|
||||||
import me.freezy.plugins.papermc.blazesmp.BlazeSMP;
|
import me.freezy.plugins.papermc.blazesmp.BlazeSMP;
|
||||||
import me.freezy.plugins.papermc.blazesmp.module.manager.L4M4;
|
import me.freezy.plugins.papermc.blazesmp.module.manager.L4M4;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -23,14 +26,14 @@ public class PressurePlateListener implements Listener {
|
||||||
private final Location pressurePlateLocation;
|
private final Location pressurePlateLocation;
|
||||||
private final Location spawnLocation;
|
private final Location spawnLocation;
|
||||||
private final Map<UUID, BukkitRunnable> playerTasks = new HashMap<>();
|
private final Map<UUID, BukkitRunnable> playerTasks = new HashMap<>();
|
||||||
private final String teleportMessage;
|
private final Component teleportMessage;
|
||||||
private final long teleportDelay;
|
private final long teleportDelay;
|
||||||
|
|
||||||
public PressurePlateListener() {
|
public PressurePlateListener() {
|
||||||
FileConfiguration config = plugin.getConfig();
|
FileConfiguration config = plugin.getConfig();
|
||||||
pressurePlateLocation = new Location(
|
pressurePlateLocation = new Location(
|
||||||
Bukkit.getWorld(config.getString("pressure-plate.world", "world")),
|
Bukkit.getWorld(config.getString("pressure-plate.world", "world")),
|
||||||
config.getDouble("pressure-plate.x", 1),
|
config.getDouble("pressure-plate.x", 0),
|
||||||
config.getDouble("pressure-plate.y", 68),
|
config.getDouble("pressure-plate.y", 68),
|
||||||
config.getDouble("pressure-plate.z", 0)
|
config.getDouble("pressure-plate.z", 0)
|
||||||
);
|
);
|
||||||
|
@ -40,9 +43,8 @@ public class PressurePlateListener implements Listener {
|
||||||
config.getDouble("spawn-location.y", 200),
|
config.getDouble("spawn-location.y", 200),
|
||||||
config.getDouble("spawn-location.z", 0)
|
config.getDouble("spawn-location.z", 0)
|
||||||
);
|
);
|
||||||
// Verwende die zentrale Nachricht aus der messages.json
|
teleportMessage = MiniMessage.miniMessage().deserialize(L4M4.get("pressureplate.teleport"));
|
||||||
teleportMessage = L4M4.get("pressureplate.teleport");
|
teleportDelay = 5 * 20L;
|
||||||
teleportDelay = 5*20L; // Default to 5 seconds (100 ticks)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -59,14 +61,29 @@ public class PressurePlateListener implements Listener {
|
||||||
};
|
};
|
||||||
task.runTaskLater(plugin, teleportDelay);
|
task.runTaskLater(plugin, teleportDelay);
|
||||||
playerTasks.put(event.getPlayer().getUniqueId(), task);
|
playerTasks.put(event.getPlayer().getUniqueId(), task);
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (playerTasks.containsKey(event.getPlayer().getUniqueId())) {
|
||||||
|
event.getPlayer().getWorld().spawnParticle(Particle.PORTAL, event.getPlayer().getLocation(), 30, 0.5, 0.5, 0.5, 0.1);
|
||||||
|
} else {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 0, 10);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (playerTasks.containsKey(event.getPlayer().getUniqueId())) {
|
if (playerTasks.containsKey(event.getPlayer().getUniqueId())) {
|
||||||
|
if (event.getFrom().getBlockX() != event.getTo().getBlockX() ||
|
||||||
|
event.getFrom().getBlockY() != event.getTo().getBlockY() ||
|
||||||
|
event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
||||||
playerTasks.get(event.getPlayer().getUniqueId()).cancel();
|
playerTasks.get(event.getPlayer().getUniqueId()).cancel();
|
||||||
playerTasks.remove(event.getPlayer().getUniqueId());
|
playerTasks.remove(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
|
|
@ -3,3 +3,16 @@ player-prefix: '<color:dark_gray>[</color><gradient:#747e80:#828d8f><b>Player</b
|
||||||
discord-report-webhook: ''
|
discord-report-webhook: ''
|
||||||
discord-url: 'https://discord.gg/cww2YDt2bx'
|
discord-url: 'https://discord.gg/cww2YDt2bx'
|
||||||
tab_update_interval: 5 #Seconds
|
tab_update_interval: 5 #Seconds
|
||||||
|
isEndOpen: false
|
||||||
|
|
||||||
|
pressure-plate:
|
||||||
|
world: "world"
|
||||||
|
x: 0
|
||||||
|
y: 68
|
||||||
|
z: 0
|
||||||
|
|
||||||
|
spawn-location:
|
||||||
|
world: "world"
|
||||||
|
x: 0
|
||||||
|
y: 200
|
||||||
|
z: 0
|
Loading…
Add table
Add a link
Reference in a new issue