Skip to content

Commit

Permalink
refractoring
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Aug 2, 2024
1 parent 4bbe860 commit 9183291
Show file tree
Hide file tree
Showing 60 changed files with 610 additions and 697 deletions.
12 changes: 7 additions & 5 deletions src/main/java/com/nexia/core/commands/player/DiscordCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Link to discord: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(NexiaDiscord.config.discordLink).color(ChatFormat.brandColor2)
.hoverEvent(HoverEvent.showText(Component.text("Click me").color(ChatFormat.greenColor)))
.clickEvent(ClickEvent.openUrl(NexiaDiscord.config.discordLink)))
));
.append(Component.text("Link to discord: ", ChatFormat.normalColor))
.append(Component.text(NexiaDiscord.config.discordLink, ChatFormat.brandColor2)
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.greenColor)))
.clickEvent(ClickEvent.openUrl(NexiaDiscord.config.discordLink))
)

);

return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/nexia/core/commands/player/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public static int run(CommandContext<CommandSourceInfo> context) throws CommandS

message = message.append(Component.text("\n/" + commandInfo[0])
.color(ChatFormat.brandColor1)
.decoration(ChatFormat.bold, false)

.decoration(ChatFormat.strikeThrough, false)
.append(Component.text(" | ").color(ChatFormat.lineColor).decoration(ChatFormat.bold, false).decoration(ChatFormat.strikeThrough, false))
.append(Component.text(commandInfo[1]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.strikeThrough, false)));
.append(Component.text(" | ").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, false))
.append(Component.text(commandInfo[1], ChatFormat.brandColor2).decoration(ChatFormat.strikeThrough, false)));

//message += "\n" + ChatFormat.brandColor1 + "/" + commandInfo[0] + ChatFormat.lineColor + " | " + ChatFormat.brandColor2 + commandInfo[1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ private static void sendMessage(NexiaPlayer sender, NexiaPlayer receiver, String
if (PlayerMutes.muted(sender) || sender.equals(receiver)) return;

sender.sendMessage(
Component.text(String.format("To %s", receiver.getRawName())).color(ChatFormat.brandColor2)
Component.text(String.format("To %s", receiver.getRawName()), ChatFormat.brandColor2)
.append(Component.text(" » ").color(ChatFormat.arrowColor)
.append(Component.text(message).color(ChatFormat.brandColor2))
.append(Component.text(message, ChatFormat.brandColor2))

));

receiver.sendMessage(
Component.text(String.format("From %s", sender.getRawName())).color(ChatFormat.brandColor2)
Component.text(String.format("From %s", sender.getRawName()), ChatFormat.brandColor2)
.append(Component.text(" » ").color(ChatFormat.arrowColor)
.append(Component.text(message).color(ChatFormat.brandColor2))
.append(Component.text(message, ChatFormat.brandColor2))

));

Expand Down
29 changes: 14 additions & 15 deletions src/main/java/com/nexia/core/commands/player/PingCommand.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.nexia.core.commands.player;

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -33,10 +32,10 @@ public static int run(CommandContext<CommandSourceInfo> context) throws CommandS

context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Your ping is ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(ping + "ms").color(ChatFormat.brandColor2))
.append(Component.text(".").color(ChatFormat.normalColor))
.append(Component.text(" (ping may not be accurate)").color(NamedTextColor.GRAY).decorate(ChatFormat.italic))
.append(Component.text("Your ping is ", ChatFormat.normalColor)
.append(Component.text(ping + "ms", ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor))
.append(Component.text(" (ping may not be accurate)", ChatFormat.Minecraft.dark_gray).decorate(ChatFormat.italic))
));

return ping;
Expand All @@ -47,12 +46,12 @@ public static int ping(CommandContext<CommandSourceInfo> context, ServerPlayer p

context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("The ping of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" is ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(ping + "ms").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(" (ping may not be accurate)").color(NamedTextColor.GRAY).decorate(ChatFormat.italic).decoration(ChatFormat.bold, false))
.append(Component.text("The ping of ", ChatFormat.normalColor))
.append(Component.text(player.getScoreboardName(), ChatFormat.brandColor2))
.append(Component.text(" is ", ChatFormat.normalColor))
.append(Component.text(ping + "ms", ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor))
.append(Component.text(" (ping may not be accurate)", ChatFormat.Minecraft.dark_gray).decorate(ChatFormat.italic))
);

return ping;
Expand Down
47 changes: 18 additions & 29 deletions src/main/java/com/nexia/core/commands/player/ReportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.NexiaDiscord;
import com.nexia.nexus.api.world.entity.player.Player;
import com.nexia.nexus.builder.implementation.world.entity.player.WrappedPlayer;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.arguments.EntityArgument;
Expand Down Expand Up @@ -59,48 +61,35 @@ public static int report(CommandContext<CommandSourceInfo> context, ServerPlayer
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());

if(((CoreSavedPlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(executor).savedData).isReportBanned()) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You are report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)
)

);
executor.sendNexiaMessage("You are report banned!");
return 1;
}

if(executor.getUUID().equals(player.getUUID())){
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You cannot report yourself!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))

);
executor.sendNexiaMessage("You cannot report yourself!");
return 1;
}

executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have reported ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2))
.append(Component.text(" for ").color(ChatFormat.normalColor))
.append(Component.text(reason).color(ChatFormat.brandColor2))
executor.sendNexiaMessage(
Component.text("You have reported ", ChatFormat.normalColor)
.append(Component.text(player.getScoreboardName(), ChatFormat.brandColor2))
.append(Component.text(" for ", ChatFormat.normalColor))
.append(Component.text(reason, ChatFormat.brandColor2))
);

if(!sendWebhook(executor.getRawName(), player.getScoreboardName(), reason)) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Failed to send webhook! Don't worry, staff who are currently online will see your report!").decoration(ChatFormat.bold, false).color(ChatFormat.normalColor))
);
executor.sendNexiaMessage("Failed to send webhook! Don't worry, staff who are currently online will see your report!");
}

Component staffReportMessage = ChatFormat.nexiaMessage
.append(Component.text(executor.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" has reported ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(reason).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false));

for (ServerPlayer staffPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()){
if(Permissions.check(staffPlayer, "nexia.staff.report", 1)) ServerTime.nexusServer.getPlayer(staffPlayer.getUUID()).sendMessage(staffReportMessage);
.append(Component.text(executor.getRawName(), ChatFormat.brandColor2))
.append(Component.text(" has reported ", ChatFormat.normalColor))
.append(Component.text(player.getScoreboardName(), ChatFormat.brandColor2))
.append(Component.text(" for ", ChatFormat.normalColor))
.append(Component.text(reason, ChatFormat.brandColor2));

for (Player staffPlayer : ServerTime.nexusServer.getPlayers()){
if(Permissions.check(((WrappedPlayer) staffPlayer).unwrap(), "nexia.staff.report", 1)) staffPlayer.sendMessage(staffReportMessage);
}

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static int run(CommandContext<CommandSourceInfo> context) {
Component message = Component.text("")
.append(Component.text(" ").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, true))
.append(Component.text("[ ").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, false)
.append(Component.text("Rules").color(ChatFormat.brandColor1).decoration(ChatFormat.strikeThrough, false))
.append(Component.text("Rules", ChatFormat.brandColor1).decoration(ChatFormat.strikeThrough, false))
.append(Component.text(" ]").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, false))
.append(Component.text(" ").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, true)));

Expand All @@ -38,10 +38,10 @@ public static int run(CommandContext<CommandSourceInfo> context) {
.decoration(ChatFormat.strikeThrough, false)
.append(Component.text("» ")
.color(ChatFormat.arrowColor)
.decoration(ChatFormat.bold, false)

.decoration(ChatFormat.strikeThrough, false)
.append(Component.text(NexiaCore.config.rules[i])
.decoration(ChatFormat.bold, false)

.decoration(ChatFormat.strikeThrough, false)
.color(ChatFormat.normalColor)
)
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/nexia/core/commands/player/ShoutCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@ public static int shout(CommandContext<CommandSourceInfo> context, String messag

if(longTime - System.currentTimeMillis() > 0) {
String time = ShoutCommand.timeToText(longTime - System.currentTimeMillis());
executor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("You are still on cooldown, you have ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(time).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
.append(Component.text(" left!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
));
executor.sendNexiaMessage(
Component.text("You are still on cooldown, you have ", ChatFormat.normalColor)
.append(Component.text(time, ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
.append(Component.text(" left!", ChatFormat.normalColor))
);
return 0;
}

Component cmessage = Component.text(executor.getRawName()).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true)
.append(Component.text( " shouts: " + message).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
);
Component cmessage = Component.text(executor.getRawName(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true)
.append(Component.text( " shouts: " + message, ChatFormat.normalColor));

for(Player player : ServerTime.nexusServer.getPlayers()) {
player.sendMessage(cmessage);
Expand Down
Loading

0 comments on commit 9183291

Please sign in to comment.