37 Commits
Author SHA1 Message Date
Infinityy bbed36c2ca fix kill tracker 2024-07-02 01:36:14 +02:00
NotCoded 6d13f23306 Revert "Update ListInventoriesCommand.java"
This reverts commit 4a03ef6d3e.
2024-06-26 21:24:55 +02:00
NotCoded 4a03ef6d3e Update ListInventoriesCommand.java 2024-06-26 21:24:38 +02:00
NotCoded d029db9548 rizecookey hitreg patch has moved to anticheat 2024-06-26 21:19:22 +02:00
NotCoded 6fcb105f8e I HATE LUCKPERMS LOGS THING 2024-06-26 21:00:33 +02:00
NotCoded 15fac137c6 Revert "improve detection (only works if you have fapi)"
This reverts commit 2e0875f9d3.
2024-06-21 19:07:37 +02:00
NotCoded 2e0875f9d3 improve detection (only works if you have fapi) 2024-06-21 17:13:46 +02:00
NotCoded 57756875b3 joiners and leavers yeah 2024-06-21 16:23:07 +02:00
NotCoded 9682bc95da despawn bot when no one is in ffa 2024-06-20 19:42:03 +02:00
NotCoded 1d23935568 gg ez fucked a pumpkin like it was crashing 2024-06-18 21:06:36 +02:00
NotCoded 7e2b2371a6 bruh 2024-06-17 19:05:30 +02:00
NotCoded 0ffa40ee8f eror! 2024-06-17 13:51:20 +02:00
NotCoded 91e6558986 Revert "Merge branch 'main' into old-dev"
This reverts commit 872f44006d, reversing
changes made to b6adf40eaa.
2024-06-16 21:46:28 +02:00
NotCoded 872f44006d Merge branch 'main' into old-dev
cool
2024-06-16 21:45:18 +02:00
NotCoded b6adf40eaa fix not being able to spectate in duels 2024-06-16 21:41:43 +02:00
NotCoded 387b5489bf funny 2024-06-16 21:35:00 +02:00
NotCoded 813275c0b5 that is cool 2024-06-16 20:06:53 +02:00
NotCoded aa6d814106 blumbo is cool, blumbo is life 2024-06-16 19:49:29 +02:00
NotCoded e145120da6 surge wtf is this 2024-06-16 19:32:01 +02:00
NotCoded 1d0f22dd47 my bad 2024-06-16 19:25:36 +02:00
NotCoded 724b29c132 make leaderboard look hot 2024-06-16 18:47:40 +02:00
NotCoded 6c3337cacc fix death messages 2024-06-16 18:26:28 +02:00
NotCoded 2c6fcb1248 Update RatingUtil.java 2024-06-16 18:23:18 +02:00
NotCoded 9b7c8f313a speller mistaker 2024-06-16 18:21:13 +02:00
NotCoded 51b872d3a7 grace hopper 2024-06-16 18:16:23 +02:00
NotCoded 2b8b9c40f7 i spoke too soon 2024-06-16 18:13:25 +02:00
NotCoded ef68c2a46a should work now 2024-06-16 18:12:21 +02:00
NotCoded aea5b7b7e6 oops 2024-06-16 18:05:17 +02:00
NotCoded 538055a575 🤦‍♂️ 2024-06-16 17:59:52 +02:00
NotCoded f02306468e oops 2024-06-16 17:55:51 +02:00
NotCoded 1e3a7584d7 idk 2024-06-16 17:54:17 +02:00
Infinityy 9872122fbf rating system gangy 2024-06-16 17:38:25 +02:00
NotCoded a29da8c478 fuck AccuratePlayer :finnadie: 2024-06-16 16:40:33 +02:00
NotCoded 65c447f59a Revert to commit 23d07c0
Commit 23d07c0 (adjust for anticheat) by @not-coded
2024-06-16 16:14:34 +02:00
surgeflame 25e7afd87b Create buíld.yml
water
2024-06-03 18:08:17 -04:00
NotCoded 8078b57a5e Delete .github/workflows directory 2024-06-03 20:17:41 +02:00
NotCoded 06ad0a25ef Merge pull request #11 from nexia-cts/dev
Update Main to be up to date with dev
2024-05-09 22:30:29 +02:00
285 changed files with 9270 additions and 7170 deletions

No files matched your search

-1
View File
@@ -1 +0,0 @@
.gitea/CODEOWNERS linguist-detectable=false
-3
View File
@@ -1,3 +0,0 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
+1 -1
View File
@@ -36,4 +36,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: build/${{ github.ref_name }}/libs
path: build/${{ github.ref_name }}/libs
-1
View File
@@ -93,4 +93,3 @@ bin/
# fabric
run/
.nexuspath
+3 -1
View File
@@ -4,7 +4,6 @@
<br>
# Nexia
using **Nexus API**
The mod for the Nexia CTS server.
@@ -15,6 +14,9 @@ The mod for the Nexia CTS server.
- Java 21
- Gradle 8.7
### Documentation
- Read [documentation](https://github.com/nexia-cts/Nexia-Mod/tree/documentation)
### Build
- Clone the repository
- `git clone https://github.com/nexia-cts/Nexia-Mod`
+31 -24
View File
@@ -50,46 +50,53 @@ repositories {
}
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Important!
modImplementation("com.nexia.nexus:nexus-api:${project.nexus_version}-full")
modImplementation("com.nexia.nexus:nexus-builder:${project.nexus_version}-${project.minecraft_version}-full")
modImplementation("com.combatreforged.factory:factory-api:${project.factory_version}-full")
modImplementation("com.combatreforged.factory:factory-builder:${project.factory_version}-1.16_combat-6")
include(implementation("com.google.code.gson:gson:${project.gson_version}"))
include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}")))
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${project.mixin_extras_version}")))
// MongoDB
include(implementation("org.mongodb:mongodb-driver-sync:${project.mongodb_version}"))
include(implementation("org.mongodb:mongodb-driver-core:${project.mongodb_version}"))
include(implementation("org.mongodb:bson:${project.mongodb_version}"))
//include(modApi("eu.pb4:hologram-api:0.1.0") { exclude(group: "net.fabricmc.fabric-api") })
//include(modApi("eu.pb4:sidebar-api:0.0.2") { exclude(group: "net.fabricmc.fabric-api") })
// Will be replaced by Nexus
include(modApi("eu.pb4:sgui:${project.sgui_version}") { exclude(group: "net.fabricmc.fabric-api") })
modApi("xyz.nucleoid:fantasy:${project.fantasy_version}") {exclude(group: "net.fabricmc.fabric-api") }
include(modApi("io.github.blumbo:inventory-merger:${project.inventory_merger_version}"))
// Should probably be removed/replaced
include(modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u_version}") { exclude(group: "net.fabricmc.fabric-api") })
modImplementation("com.natamus:saveandloadinventories_fabric:${project.saveandloadinventories_version}")
modApi("com.natamus.collective:collective-fabric:${project.collective_version}")
// somewhat useful stuff
modApi("xyz.nucleoid:fantasy:${project.fantasy_version}") {exclude(group: "net.fabricmc.fabric-api") }
include(modApi("eu.pb4:sgui:${project.sgui_version}") { exclude(group: "net.fabricmc.fabric-api") })
include(modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u_version}") { exclude(group: "net.fabricmc.fabric-api") })
//include(modApi("xyz.nucleoid:plasmid:${project.plasmid_version}"))
include(implementation("com.googlecode.json-simple:json-simple:${project.json_simple_version}"))
modApi("me.lucko:fabric-permissions-api:${project.fabric_permissions_api_version}")
include(implementation("net.kyori:adventure-text-minimessage:${project.adventure_version}"))
include(implementation("net.kyori:adventure-text-serializer-gson:${project.adventure_version}"))
include(compileOnly("de.themoep:minedown-adventure:${project.minedown_adventure_version}"))
compileOnly("net.luckperms:api:${project.luckperms_api_version}")
modApi("com.nexia:gato-anticheat:${project.gato_anticheat_version}+${project.minecraft_version}")
include(modApi("net.blumbo:blfscheduler:${project.blfscheduler_version}"))
include(modApi("io.github.blumbo:inventory-merger:${project.inventory_merger_version}"))
include(modApi("net.notcoded:codelib:${project.codelib_version}+${project.minecraft_version}"))
include(implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT"))
include(implementation("net.kyori:adventure-text-serializer-gson:4.1.0-SNAPSHOT"))
include(compileOnly("de.themoep:minedown-adventure:1.7.3-SNAPSHOT"))
// discord shit
include(api("net.dv8tion:JDA:${project.jda_version}"))
include(api("club.minnced:discord-webhooks:${project.discord_webhooks_version}") { exclude(group: "org.json") })
include(api("org.json:json:${project.json_version}"))
// useless libraries
include(implementation("com.google.code.gson:gson:${project.gson_version}"))
include(implementation("com.googlecode.json-simple:json-simple:${project.json_simple_version}"))
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}
// Custom Manifest and Intermediary mappings declaration
+11 -10
View File
@@ -9,31 +9,32 @@ yarn_mappings=1.16_combat-6+build.2
loader_version=0.14.21
# Mod Properties
mod_version = 2.0.0
mod_version = 1.2.1
maven_group = com.nexia
archives_base_name = nexia
# Dependencies
fabric_version=0.42.0+1.16
mongodb_version=5.1.2
fabric_version= 0.42.0+1.16
plasmid_version=0.4.0
jda_version=5.0.0-beta.20
mixin_extras_version=0.4.0
nexus_version=0.1.15
mixin_extras_version=0.2.0-beta.9
factory_version=0.1.13
gson_version=2.10.1
saveandloadinventories_version=1.16.5-2.4
collective_version=1.16.5-5.50
fantasy_version=0.4.3
fantasy_version=0.4.2
sgui_version=0.5.0
autoconfig1u_version=3.3.1
fabric_permissions_api_version=0.2-SNAPSHOT
blfscheduler_version=1.0.0-1.16_combat-6
inventory_merger_version=1.3.1-1.16_combat-6
luckperms_api_version=5.4
adventure_version=4.1.0-SNAPSHOT
minedown_adventure_version=1.7.3-SNAPSHOT
codelib_version=1.0.3
gato_anticheat_version=1.0.4
# Useless dependencies
json_simple_version=1.1.1
discord_webhooks_version=0.8.4
json_version=20230227
gson_version=2.10.1
Vendored Executable → Regular
View File
File mode changed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,257 +0,0 @@
package com.nexia.base.player;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.pos.EntityPos;
import com.nexia.core.utilities.ranks.NexiaRank;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.bedwars.util.BwScoreboard;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.nexus.api.world.effect.StatusEffectInstance;
import com.nexia.nexus.api.world.entity.player.Player;
import com.nexia.nexus.api.world.item.ItemStack;
import com.nexia.nexus.api.world.types.Minecraft;
import com.nexia.nexus.builder.implementation.world.entity.player.WrappedPlayer;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.core.NonNullList;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.Item;
import org.jetbrains.annotations.NotNull;
public class NexiaPlayer extends WrappedPlayer {
public NexiaPlayer(ServerPlayer wrappedPlayer) {
super(wrappedPlayer);
}
public NexiaPlayer(Player player) {
super(PlayerUtil.getMinecraftPlayer(player.getUUID()));
}
public void reset(boolean heal, Minecraft.GameMode gameMode) {
this.setInvulnerabilityTime(0);
this.clearEffects();
this.getInventory().clear();
this.setRemainingFireTicks(0);
this.setExperienceLevel(0);
this.setExperiencePoints(0);
this.getInventory().setCursorStack(ItemStack.create(Minecraft.Item.AIR));
this.unwrap().getEnderChestInventory().clearContent();
this.setGlowing(false);
this.stopAllSounds();
this.setGameMode(gameMode);
if (heal) {
this.setHealth(this.getMaxHealth());
this.setFoodLevel(20);
}
this.setAbleToFly(false);
this.unwrap().onUpdateAbilities();
ServerTime.minecraftServer.getPlayerList().sendPlayerPermissionLevel(this.unwrap());
}
public PlayerGameMode getCurrentGameMode() {
return ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(this)).gameMode;
}
public NexiaPlayer refreshPlayer() {
return new NexiaPlayer(PlayerUtil.getMinecraftPlayer(this.getUUID()));
}
public boolean isInGameMode(PlayerGameMode gameMode) {
return this.getCurrentGameMode().equals(gameMode);
}
public void safeReset(boolean heal, Minecraft.GameMode gameMode) {
this.setGameMode(gameMode);
this.setInvulnerabilityTime(0);
this.clearEffects();
this.setRemainingFireTicks(0);
this.setGlowing(false);
if (heal) {
this.setHealth(this.getMaxHealth());
this.setFoodLevel(20);
}
this.setAbleToFly(false);
this.unwrap().onUpdateAbilities();
ServerTime.minecraftServer.getPlayerList().sendPlayerPermissionLevel(this.unwrap());
}
/**
* Sends a parsed <a href="https://docs.advntr.dev/minimessage/index.html">MiniMessage</a> message to the player.
* @param message The message that's going to get parsed
* @apiNote Check out the <a href="https://docs.advntr.dev/minimessage/format.html">MiniMessage docs</a>.
*/
public void sendMiniMessage(String message, Object... args) {
this.sendMessage(MiniMessage.get().parse(String.format(message, args)));
}
/**
* Sends a message with the prefix <code>Nexia » </code> to the player.
* @apiNote The message is going to get sent in white ({@link ChatFormat.Minecraft}).
*/
public void sendNexiaMessage(String message, Object... args) {
this.sendMessage(ChatFormat.nexiaMessage.append(Component.text(String.format(message, args), ChatFormat.Minecraft.white)));
}
/**
* Sends a Component with the prefix <code>Nexia » </code> to the player.
*/
public void sendNexiaMessage(Component component) {
this.sendMessage(ChatFormat.nexiaMessage.append(component));
}
public boolean hasPermission(@NotNull String permission) {
return Permissions.check(this.unwrap(), permission);
}
public boolean hasPermission(@NotNull String permission, int defaultRequiredLevel) {
return Permissions.check(this.unwrap(), permission, defaultRequiredLevel);
}
public boolean hasEffect(Minecraft.Effect effect) {
for(StatusEffectInstance effectInstance : this.getActiveEffects()) {
if(effectInstance.getStatusEffect().getType().equals(effect.getType())) {
return true;
}
}
return false;
}
public void leaveAllGames() {
if (BwUtil.isInBedWars(this)) {
BwPlayerEvents.leaveInBedWars(this);
} else if (FfaUtil.isFfaPlayer(this)) {
FfaUtil.leaveOrDie(this, this.unwrap().getLastDamageSource(), true);
} else if (this.isInGameMode(PlayerGameMode.LOBBY)) {
DuelGameHandler.leave(this, false);
} else if (this.isInGameMode(PlayerGameMode.OITC)) {
OitcGame.leave(this);
} else if (this.isInGameMode(PlayerGameMode.SKYWARS)) {
SkywarsGame.leave(this);
} else if (this.isInGameMode(PlayerGameMode.FOOTBALL)) {
FootballGame.leave(this);
}
// sometimes those do not get removed
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, this, true);
BwScoreboard.removeScoreboardFor(this);
for (String tag : LobbyUtil.removedTags) {
if (this.hasTag(tag)) this.removeTag(tag);
}
}
public void refreshInventory() {
NonNullList<net.minecraft.world.item.ItemStack> i = NonNullList.create();
for (int j = 0; j < this.unwrap().containerMenu.slots.size(); ++j) {
net.minecraft.world.item.ItemStack itemStack = this.unwrap().containerMenu.slots.get(j).getItem();
i.add(itemStack.isEmpty() ? net.minecraft.world.item.ItemStack.EMPTY : itemStack);
}
this.unwrap().refreshContainer(this.unwrap().containerMenu, i);
}
public void sendHandItemPacket(InteractionHand hand) {
if (hand == InteractionHand.MAIN_HAND) {
sendInvSlotPacket(this.unwrap().inventory.selected);
} else if (hand == InteractionHand.OFF_HAND) {
sendInvSlotPacket(40);
}
}
public void sendHandItemPacket() {
this.sendHandItemPacket(this.unwrap().getUsedItemHand());
}
public void sendInvSlotPacket(int slot) {
int packetSlot;
if (slot < 9) {
packetSlot = 36 + slot;
} else if (slot < 36) {
packetSlot = slot;
} else if (slot < 40) {
packetSlot = 44 - slot;
} else if (slot == 40) {
packetSlot = 45;
} else {
return;
}
this.unwrap().connection.send(new ClientboundContainerSetSlotPacket(0, packetSlot, this.unwrap().inventory.getItem(slot)));
}
public boolean hasRank(NexiaRank rank) {
return this.hasPermission(rank.groupID);
}
public boolean hasPrefix(NexiaRank rank) {
return this.hasPermission("nexia.prefix." + rank.id);
}
public void removeItem(Item item, int count) {
for (net.minecraft.world.item.ItemStack itemStack : ItemStackUtil.getInvItems(this.unwrap())) {
if (itemStack.getItem() != item) continue;
if (itemStack.getCount() >= count) {
itemStack.shrink(count);
break;
} else {
count -= itemStack.getCount();
itemStack.shrink(itemStack.getCount());
}
}
}
public void sendSound(SoundEvent soundEvent, SoundSource soundSource, float volume, float pitch) {
sendSound(new EntityPos(this), soundEvent, soundSource, volume, pitch);
}
public void sendSound(EntityPos position, SoundEvent soundEvent, SoundSource soundSource, float volume, float pitch) {
this.unwrap().connection.send(new ClientboundSoundPacket(soundEvent, soundSource,
position.x, position.y, position.z, 16f * volume, pitch));
}
public boolean setBedrockBridging(boolean allowed) {
if (ServerPlayNetworking.canSend(this.unwrap(), NexiaCore.CONVENTIONAL_BRIDGING_UPDATE_ID)) {
FriendlyByteBuf buf = PacketByteBufs.create();
buf.writeBoolean(allowed);
ServerPlayNetworking.send(this.unwrap(), NexiaCore.CONVENTIONAL_BRIDGING_UPDATE_ID, buf);
return true;
}
return false;
}
}
@@ -1,140 +0,0 @@
package com.nexia.base.player;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mongodb.client.model.Filters;
import com.mongodb.client.result.UpdateResult;
import com.nexia.core.NexiaCore;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.CoreSavedPlayerData;
import com.nexia.discord.utilities.player.DiscordSavedPlayerData;
import com.nexia.ffa.base.player.FFASavedPlayerData;
import com.nexia.ffa.kits.utilities.player.KitFFAPlayerData;
import com.nexia.minigames.games.base.player.WLKSavedPlayerData;
import com.nexia.minigames.games.bedwars.util.player.BedwarsPlayerData;
import com.nexia.minigames.games.bedwars.util.player.BedwarsSavedPlayerData;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.minigames.games.duels.util.player.DuelsSavedPlayerData;
import com.nexia.minigames.games.football.util.player.FootballPlayerData;
import com.nexia.minigames.games.football.util.player.FootballSavedPlayerData;
import com.nexia.minigames.games.oitc.util.player.OITCPlayerData;
import com.nexia.minigames.games.skywars.util.player.SkywarsPlayerData;
import net.minecraft.resources.ResourceLocation;
import org.bson.Document;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class PlayerDataManager {
public static Map<ResourceLocation, PlayerDataManager> dataManagerMap = new HashMap<>();
private final String collectionName;
HashMap<UUID, PlayerData> allPlayerData = new HashMap<>();
public Class<? extends SavedPlayerData> savedPlayerDataClass;
public Class<? extends PlayerData> playerDataClass;
public PlayerDataManager(ResourceLocation id, String collectionName, Class<? extends SavedPlayerData> savedPlayerDataClass, Class<? extends PlayerData> playerDataClass) {
this.collectionName = collectionName;
this.savedPlayerDataClass = savedPlayerDataClass;
this.playerDataClass = playerDataClass;
dataManagerMap.put(id, this);
}
public static PlayerDataManager getDataManager(ResourceLocation identifier) {
return dataManagerMap.get(identifier);
}
public static void init() {
// <----------- Core --------------->
new PlayerDataManager(NexiaCore.CORE_DATA_MANAGER, "core", CoreSavedPlayerData.class, CorePlayerData.class);
// <----------- Discord --------------->
new PlayerDataManager(NexiaCore.DISCORD_DATA_MANAGER, "discord", DiscordSavedPlayerData.class, PlayerData.class);
// <----------- FFAs --------------->
new PlayerDataManager(NexiaCore.FFA_CLASSIC_DATA_MANAGER, "ffa_classic", FFASavedPlayerData.class, PlayerData.class);
new PlayerDataManager(NexiaCore.FFA_KITS_DATA_MANAGER, "ffa_kits", FFASavedPlayerData.class, KitFFAPlayerData.class);
new PlayerDataManager(NexiaCore.FFA_POT_DATA_MANAGER, "ffa_pot", FFASavedPlayerData.class, PlayerData.class);
new PlayerDataManager(NexiaCore.FFA_SKY_DATA_MANAGER, "ffa_sky", FFASavedPlayerData.class, PlayerData.class);
new PlayerDataManager(NexiaCore.FFA_UHC_DATA_MANAGER, "ffa_uhc", FFASavedPlayerData.class, PlayerData.class);
// <----------- BedWars --------------->
new PlayerDataManager(NexiaCore.BEDWARS_DATA_MANAGER, "bedwars", BedwarsSavedPlayerData.class, BedwarsPlayerData.class);
// <----------- Duels --------------->
new PlayerDataManager(NexiaCore.DUELS_DATA_MANAGER, "duels", DuelsSavedPlayerData.class, DuelsPlayerData.class);
// <----------- Football --------------->
new PlayerDataManager(NexiaCore.FOOTBALL_DATA_MANAGER, "football", FootballSavedPlayerData.class, FootballPlayerData.class);
// <----------- OITC --------------->
new PlayerDataManager(NexiaCore.OITC_DATA_MANAGER, "oitc", WLKSavedPlayerData.class, OITCPlayerData.class);
// <----------- SkyWars --------------->
new PlayerDataManager(NexiaCore.SKYWARS_DATA_MANAGER, "skywars", WLKSavedPlayerData.class, SkywarsPlayerData.class);
}
public PlayerData get(NexiaPlayer player) {
return get(player.getUUID());
}
public void addPlayerData(NexiaPlayer player) {
addPlayerData(player.getUUID());
}
public void removePlayerData(NexiaPlayer player) {
removePlayerData(player.getUUID());
}
public PlayerData get(UUID uuid) {
if (!allPlayerData.containsKey(uuid)) {
addPlayerData(uuid);
}
return allPlayerData.get(uuid);
}
public void addPlayerData(UUID uuid) {
PlayerData playerData;
try {
playerData = playerDataClass.getConstructor(SavedPlayerData.class).newInstance(loadPlayerData(uuid, savedPlayerDataClass));
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException(e);
}
allPlayerData.put(uuid, playerData);
}
public void removePlayerData(UUID uuid) {
if (!allPlayerData.containsKey(uuid)) return;
savePlayerData(uuid);
allPlayerData.remove(uuid);
}
private void savePlayerData(UUID uuid) {
Document document = NexiaCore.mongoManager.toDocument(get(uuid).savedData);
document.append("uuid", uuid.toString());
document.remove("data");
UpdateResult isReplaced = NexiaCore.mongoManager.getCollection(collectionName).replaceOne(Filters.eq("uuid", uuid.toString()), document);
if (isReplaced.getMatchedCount() == 0) {
NexiaCore.mongoManager.getCollection(collectionName).insertOne(document);
}
}
private <T extends SavedPlayerData> T loadPlayerData(UUID uuid, Class<T> toLoad) throws InstantiationException, IllegalAccessException {
T savedPlayerData = NexiaCore.mongoManager.getObject(collectionName, Filters.eq("uuid", uuid.toString()), toLoad);
if (savedPlayerData != null) {
return savedPlayerData;
}
try {
return toLoad.getDeclaredConstructor().newInstance();
} catch (InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
}
@@ -1,56 +0,0 @@
package com.nexia.base.player;
import java.lang.reflect.Field;
@SuppressWarnings("unchecked")
public abstract class SavedPlayerData {
private final Data data;
public SavedPlayerData() {
this.data = new Data();
}
public void incrementInteger(String name) {
Integer val = get(Integer.class, name);
set(Integer.class, name, val + 1);
}
public void decrementInteger(String name) {
Integer val = get(Integer.class, name);
set(Integer.class, name, val - 1);
}
public <T> void set(Class<T> type, String name, T value) {
try {
data.append(type, name, value, getClass().getField(name), this);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
public <T> T get(Class<T> type, String name) {
try {
return data.retrieve(type, name, getClass().getField(name), this);
} catch (IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
public static class Data {
public Data() {
}
public <T> void append(Class<T> type, String name, T value, Field field, SavedPlayerData data) {
if (field != null) {
try {
field.set(data, value);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} else throw new NullPointerException("The field " + name + " in " + data.getClass().getSimpleName() + " must not be null!");
}
public <T> T retrieve(Class<T> type, String name, Field field, SavedPlayerData data) throws IllegalAccessException, NoSuchFieldException {
if (field != null) {
return (T) field.get(data);
} else throw new NullPointerException("The field " + name + " in " + data.getClass().getSimpleName() + " must not be null!");
}
}
}
+69
View File
@@ -0,0 +1,69 @@
package com.nexia.core;
import com.combatreforged.factory.api.FactoryAPI;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.entrypoint.FactoryPlugin;
import com.nexia.core.config.ModConfig;
import com.nexia.core.listeners.ListenerHelper;
import com.nexia.core.loader.CommandLoader;
import com.nexia.core.networking.NetworkingHandler;
import com.nexia.core.utilities.misc.NxFileUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Main implements ModInitializer, FactoryPlugin {
public static ModConfig config;
public static final String MOD_NAME = "Nexia";
public static Logger logger = LogManager.getLogger(MOD_NAME);
public static final String modConfigDir = NxFileUtil.makeDir(FabricLoader.getInstance().getConfigDir().toString() + "/nexia");
public NetworkingHandler networkingHandler;
@Override
public void onInitialize() {
AutoConfig.register(ModConfig.class, GsonConfigSerializer::new);
config = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
logger.info("Loading mod...");
logger.info("Registering commands....");
CommandLoader.registerCommands();
logger.info("Registered commands.");
/*
PlayerDetectionEvent.REACH.register((player, entity) -> {
Punishment punishment = PlayerDataManager.get(player).punishment;
punishment.reachOffences++;
punishment.check((ServerPlayer) player);
});
PlayerDetectionEvent.NO_SWING.register((player, entity) -> {
Punishment punishment = PlayerDataManager.get(player).punishment;
punishment.noSwingOffences++;
punishment.check((ServerPlayer) player);
});
*/
networkingHandler = new NetworkingHandler();
}
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void onFactoryLoad(FactoryAPI api, FactoryServer server) {
Main.logger.info("Loading factory version...");
ServerTime.factoryServer = server;
ServerTime.factoryAPI = api;
ServerTime.scheduler = api.getScheduler();
Main.logger.info("Registering listeners....");
ListenerHelper.registerListeners();
Main.logger.info("Registered listeners.");
}
}
@@ -1,88 +0,0 @@
package com.nexia.core;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.utilities.database.MongoManager;
import com.nexia.nexus.api.NexusAPI;
import com.nexia.nexus.api.NexusServer;
import com.nexia.nexus.api.entrypoint.NexusPlugin;
import com.nexia.core.config.ModConfig;
import com.nexia.core.listeners.ListenerHelper;
import com.nexia.core.loader.CommandLoader;
import com.nexia.core.networking.NetworkingHandler;
import com.nexia.core.utilities.misc.NxFileUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.resources.ResourceLocation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class NexiaCore implements ModInitializer, NexusPlugin {
public static ModConfig config;
public static final String MOD_NAME = "Nexia";
public static Logger logger = LogManager.getLogger(MOD_NAME);
public static final String modConfigDir = NxFileUtil.makeDir(FabricLoader.getInstance().getConfigDir().toString() + "/nexia");
public NetworkingHandler networkingHandler;
public static MongoManager mongoManager;
public static final ResourceLocation CONVENTIONAL_BRIDGING_UPDATE_ID = new ResourceLocation("c", "update_status");
public static final ResourceLocation CORE_DATA_MANAGER = id("core");
public static final ResourceLocation DISCORD_DATA_MANAGER = id("discord");
public static final ResourceLocation FFA_CLASSIC_DATA_MANAGER = id("ffa_classic");
public static final ResourceLocation FFA_KITS_DATA_MANAGER = id("ffa_kits");
public static final ResourceLocation FFA_POT_DATA_MANAGER = id("ffa_pot");
public static final ResourceLocation FFA_SKY_DATA_MANAGER = id("ffa_sky");
public static final ResourceLocation FFA_UHC_DATA_MANAGER = id("ffa_uhc");
public static final ResourceLocation BEDWARS_DATA_MANAGER = id("bedwars");
public static final ResourceLocation DUELS_DATA_MANAGER = id("duels");
public static final ResourceLocation FOOTBALL_DATA_MANAGER = id("football");
public static final ResourceLocation OITC_DATA_MANAGER = id("oitc");
public static final ResourceLocation SKYWARS_DATA_MANAGER = id("skywars");
@Override
public void onInitialize() {
AutoConfig.register(ModConfig.class, GsonConfigSerializer::new);
config = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
logger.info("Loading mod...");
PlayerDataManager.init();
logger.info("Registering commands...");
CommandLoader.registerCommands();
logger.info("Registered commands.");
networkingHandler = new NetworkingHandler();
mongoManager = new MongoManager();
}
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void onNexusLoad(NexusAPI api, NexusServer server) {
logger.info("Loading Nexus API...");
ServerTime.nexusServer = server;
ServerTime.nexusAPI = api;
ServerTime.scheduler = api.getScheduler();
logger.info("Registering listeners...");
ListenerHelper.registerListeners();
logger.info("Registered listeners.");
logger.info("Registering Nexus commands...");
CommandLoader.registerNexusCommands();
logger.info("Registered Nexus commands.");
}
public static ResourceLocation id(String path) {
return new ResourceLocation("nexia", path);
}
}
@@ -1,33 +1,32 @@
package com.nexia.core.commands.player;
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.core.utilities.chat.ChatFormat;
import com.nexia.discord.NexiaDiscord;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.discord.Main;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class DiscordCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("discord").executes(DiscordCommand::run));
dispatcher.register(CommandUtils.literal("dc").executes(DiscordCommand::run));
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("discord").executes(DiscordCommand::run));
dispatcher.register(Commands.literal("dc").executes(DiscordCommand::run));
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
context.getSource().sendMessage(
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(
ChatFormat.nexiaMessage
.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))
)
);
.append(Component.text("Link to discord: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(com.nexia.discord.Main.config.discordLink).color(ChatFormat.brandColor2)
.hoverEvent(HoverEvent.showText(Component.text("Click me").color(ChatFormat.greenColor)))
.clickEvent(ClickEvent.openUrl(Main.config.discordLink)))
));
return 1;
}
@@ -1,17 +1,18 @@
package com.nexia.core.commands.player;
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.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class HelpCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("help").executes(HelpCommand::run));
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("help").executes(HelpCommand::run));
}
static String commandSeparator = ": ";
@@ -37,7 +38,7 @@ public class HelpCommand {
"sprintfix" + commandSeparator + "toggle the sprint fix"
};
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
Component message = ChatFormat.separatorLine("Commands");
@@ -47,17 +48,17 @@ public class HelpCommand {
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.strikeThrough, false))
.append(Component.text(commandInfo[1], ChatFormat.brandColor2).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)));
//message += "\n" + ChatFormat.brandColor1 + "/" + commandInfo[0] + ChatFormat.lineColor + " | " + ChatFormat.brandColor2 + commandInfo[1];
}
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
context.getSource().sendMessage(message);
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
return 1;
}
@@ -1,29 +1,26 @@
package com.nexia.core.commands.player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class LeaveCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "leave");
register(dispatcher, "lobby");
register(dispatcher, "l");
register(dispatcher, "hub");
}
private static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
dispatcher.register(CommandUtils.literal(string).executes(LeaveCommand::run));
private static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string).executes(LeaveCommand::run));
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
LobbyUtil.returnToLobby(player, true);
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
LobbyUtil.leaveAllGames(context.getSource().getPlayerOrException(), true);
return 1;
}
@@ -1,36 +1,36 @@
package com.nexia.core.commands.player;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class MessageCommand {
public static void registerMsg(CommandDispatcher<CommandSourceInfo> commandDispatcher) {
public static void registerMsg(CommandDispatcher<CommandSourceStack> commandDispatcher, boolean bl) {
registerMsg(commandDispatcher, "msg");
registerMsg(commandDispatcher, "message");
registerMsg(commandDispatcher, "tell");
registerMsg(commandDispatcher, "whisper");
}
public static void registerMsg(CommandDispatcher<CommandSourceInfo> commandDispatcher, String string) {
commandDispatcher.register(CommandUtils.literal(string)
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
public static void registerMsg(CommandDispatcher<CommandSourceStack> commandDispatcher, String string) {
commandDispatcher.register(Commands.literal(string)
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::msgCommand)
)
)
@@ -39,21 +39,21 @@ public class MessageCommand {
public static void registerReply(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("r")
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
public static void registerReply(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("r")
.then(Commands.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::replyCommand)
));
dispatcher.register(CommandUtils.literal("reply")
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
dispatcher.register(Commands.literal("reply")
.then(Commands.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::replyCommand)
)
);
}
private static int msgCommand(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer sender = new NexiaPlayer(context.getSource().getPlayerOrException());
NexiaPlayer receiver = new NexiaPlayer(context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)));
private static int msgCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer sender = context.getSource().getPlayerOrException();
ServerPlayer receiver = EntityArgument.getPlayer(context, "player");
String message = StringArgumentType.getString(context, "message");
sendMessage(sender, receiver, message);
@@ -61,13 +61,13 @@ public class MessageCommand {
return 1;
}
private static int replyCommand(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer sender = new NexiaPlayer(context.getSource().getPlayerOrException());
CorePlayerData senderData = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(sender);
NexiaPlayer receiver = senderData.lastMessageSender;
private static int replyCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer sender = context.getSource().getPlayerOrException();
PlayerData senderData = PlayerDataManager.get(sender);
ServerPlayer receiver = PlayerUtil.getFixedPlayer(senderData.lastMessageSender);
if (receiver == null) {
sender.sendMessage(Component.text("Nobody to reply to.", ChatFormat.systemColor));
sender.sendMessage(LegacyChatFormat.format("{s}Nobody to reply to"), Util.NIL_UUID);
return 1;
}
@@ -77,24 +77,24 @@ public class MessageCommand {
return 1;
}
private static void sendMessage(NexiaPlayer sender, NexiaPlayer receiver, String message) {
if (PlayerMutes.muted(sender) || sender.equals(receiver)) return;
private static void sendMessage(ServerPlayer sender, ServerPlayer receiver, String message) {
if (PlayerMutes.muted(sender) || sender == receiver) return;
sender.sendMessage(
Component.text(String.format("To %s", receiver.getRawName()), ChatFormat.brandColor2)
PlayerUtil.getFactoryPlayer(sender).sendMessage(
Component.text(String.format("To %s", receiver.getScoreboardName())).color(ChatFormat.brandColor2)
.append(Component.text(" » ").color(ChatFormat.arrowColor)
.append(Component.text(message, ChatFormat.brandColor2))
.append(Component.text(message).color(ChatFormat.brandColor2))
));
receiver.sendMessage(
Component.text(String.format("From %s", sender.getRawName()), ChatFormat.brandColor2)
PlayerUtil.getFactoryPlayer(receiver).sendMessage(
Component.text(String.format("From %s", sender.getScoreboardName())).color(ChatFormat.brandColor2)
.append(Component.text(" » ").color(ChatFormat.arrowColor)
.append(Component.text(message, ChatFormat.brandColor2))
.append(Component.text(message).color(ChatFormat.brandColor2))
));
((CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(receiver)).lastMessageSender = sender;
PlayerDataManager.get(receiver).lastMessageSender = sender;
}
}
@@ -3,55 +3,65 @@ package com.nexia.core.commands.player;
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 com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class PingCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("ping").executes(PingCommand::run)
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("ping").executes(PingCommand::run)
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
)
);
dispatcher.register(CommandUtils.literal("latency").executes(PingCommand::run)
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
dispatcher.register(Commands.literal("latency").executes(PingCommand::run)
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
)
);
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
int ping = new NexiaPlayer(context.getSource().getPlayerOrException()).getLatency();
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer executer = context.getSource().getPlayerOrException();
int ping = executer.latency;
context.getSource().sendMessage(
PlayerUtil.getFactoryPlayer(executer).sendMessage(
ChatFormat.nexiaMessage
.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))
.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))
));
return ping;
}
public static int ping(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
public static int ping(CommandContext<CommandSourceStack> context, ServerPlayer player) {
CommandSourceStack cmdExecutor = context.getSource();
ServerPlayer executor;
int ping = player.latency;
context.getSource().sendMessage(
try {
executor = cmdExecutor.getPlayerOrException();
} catch(Exception ignored){
cmdExecutor.sendSuccess(LegacyChatFormat.format("{b1}The ping of {} is {b2}{}ms{b1}.", player.getScoreboardName(), ping), false);
return ping;
}
PlayerUtil.getFactoryPlayer(executor).sendMessage(
ChatFormat.nexiaMessage
.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))
.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))
);
return ping;
@@ -5,61 +5,104 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.gui.PlayGUI;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
public class PlayCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "play");
register(dispatcher, "join");
dispatcher.register(CommandUtils.literal("ffa").executes(PlayCommand::openFFAGui)
.then(CommandUtils.literal("kits").executes(context -> playGame(context, "kits ffa")))
.then(CommandUtils.literal("pot").executes(context -> playGame(context, "pot ffa")))
.then(CommandUtils.literal("sky").executes(context -> playGame(context, "sky ffa")))
.then(CommandUtils.literal("uhc").executes(context -> playGame(context, "uhc ffa")))
.then(CommandUtils.literal("classic").executes(context -> playGame(context, "classic ffa")))
dispatcher.register(Commands.literal("ffa").executes(PlayCommand::openFFAGui)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("sky").executes(PlayCommand::playSkyFFA))
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA))
);
}
private static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
dispatcher.register(CommandUtils.literal(string).executes(PlayCommand::openGUI)
.then(CommandUtils.literal("ffa").executes(PlayCommand::openFFAGui)
.then(CommandUtils.literal("kits").executes(context -> playGame(context, "kits ffa")))
.then(CommandUtils.literal("pot").executes(context -> playGame(context, "pot ffa")))
.then(CommandUtils.literal("sky").executes(context -> playGame(context, "sky ffa")))
.then(CommandUtils.literal("uhc").executes(context -> playGame(context, "uhc ffa")))
.then(CommandUtils.literal("classic").executes(context -> playGame(context, "classic ffa")))
)
.then(CommandUtils.literal("bedwars").executes(context -> playGame(context, "bedwars")))
.then(CommandUtils.literal("duels").executes(context -> playGame(context, "duels")))
.then(CommandUtils.literal("skywars").executes(context -> playGame(context, "skywars")))
.then(CommandUtils.literal("sw").executes(context -> playGame(context, "skywars")))
.then(CommandUtils.literal("football").executes(context -> playGame(context, "football")))
.then(CommandUtils.literal("oitc").executes(context -> playGame(context, "oitc")))
.then(CommandUtils.literal("bw").executes(context -> playGame(context, "bedwars")))
);
private static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string).executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").executes(PlayCommand::openFFAGui)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("sky").executes(PlayCommand::playSkyFFA))
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA)))
.then(Commands.literal("bedwars").executes(PlayCommand::playBedWars))
.then(Commands.literal("duels").executes(PlayCommand::playDuels))
.then(Commands.literal("skywars").executes(PlayCommand::playSkywars))
.then(Commands.literal("sw").executes(PlayCommand::playSkywars))
.then(Commands.literal("football").executes(PlayCommand::playFootball))
.then(Commands.literal("oitc").executes(PlayCommand::playOITC))
.then(Commands.literal("bw").executes(PlayCommand::playBedWars)));
}
private static int openGUI(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
PlayGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
private static int openGUI(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
PlayGUI.openMainGUI(context.getSource().getPlayerOrException());
return 1;
}
private static int openFFAGui(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
PlayGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap()).setFFALayout();
private static int openFFAGui(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
PlayGUI.openMainGUI(context.getSource().getPlayerOrException()).setFFALayout();
return 1;
}
private static int playGame(CommandContext<CommandSourceInfo> context, String game) throws CommandSyntaxException {
return playGame(new NexiaPlayer(context.getSource().getPlayerOrException()), game);
}
private static int playGame(NexiaPlayer player, String game) {
LobbyUtil.sendGame(player, game, true, true);
private static int playNormalFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "classic ffa", true, true);
return 1;
}
private static int playKitFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "kits ffa", true, true);
return 1;
}
private static int playUhcFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "uhc ffa", true, true);
return 1;
}
private static int playSkyFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "sky ffa", true, true);
return 1;
}
private static int playBedWars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "bedwars", true, true);
return 1;
}
private static int playDuels(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "duels", true, true);
return 1;
}
private static int playOITC(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "oitc", true, true);
return 1;
}
private static int playFootball(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "football", true, true);
return 1;
}
private static int playSkywars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "skywars", true, true);
return 1;
}
}
@@ -4,17 +4,18 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.gui.PrefixGUI;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
public class PrefixCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("prefix").executes(PrefixCommand::run));
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("prefix").executes(PrefixCommand::run));
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
PrefixGUI.openRankGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer executer = context.getSource().getPlayerOrException();
PrefixGUI.openRankGUI(executer);
return 1;
}
}
@@ -4,21 +4,20 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.gui.RanksGUI;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class RanksCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("buy").executes(RanksCommand::run));
dispatcher.register(CommandUtils.literal("store").executes(RanksCommand::run));
dispatcher.register(CommandUtils.literal("ranks").executes(RanksCommand::run));
dispatcher.register(CommandUtils.literal("role").executes(RanksCommand::run));
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("buy").executes(RanksCommand::run));
dispatcher.register(Commands.literal("store").executes(RanksCommand::run));
dispatcher.register(Commands.literal("ranks").executes(RanksCommand::run));
dispatcher.register(Commands.literal("role").executes(RanksCommand::run));
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
RanksGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
RanksGUI.openMainGUI(context.getSource().getPlayerOrException());
return 1;
}
@@ -1,26 +1,21 @@
package com.nexia.core.commands.player;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.utilities.player.CoreSavedPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.http.DiscordWebhook;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
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 com.nexia.discord.Main;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
import java.awt.*;
@@ -28,7 +23,7 @@ import java.awt.*;
public class ReportCommand {
private static boolean sendWebhook(String reporter, String victim, String reason){
DiscordWebhook webhook = new DiscordWebhook(NexiaDiscord.config.reportWebhook);
DiscordWebhook webhook = new DiscordWebhook(Main.config.reportWebhook);
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setAuthor((reporter + " reported " + victim), null, null)
.setColor(Color.RED)
@@ -46,50 +41,64 @@ public class ReportCommand {
return false;
}
}
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("report")
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
.executes(context -> ReportCommand.report(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "reason")))
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("report")
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("reason", StringArgumentType.greedyString())
.executes(context -> ReportCommand.report(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "reason")))
)
)
);
}
public static int report(CommandContext<CommandSourceInfo> context, ServerPlayer player, String reason) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int report(CommandContext<CommandSourceStack> context, ServerPlayer player, String reason) throws CommandSyntaxException {
ServerPlayer mcExecutor = context.getSource().getPlayerOrException();
Player executor = PlayerUtil.getFactoryPlayer(mcExecutor);
if(((CoreSavedPlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(executor).savedData).isReportBanned()) {
executor.sendNexiaMessage("You are report banned!");
if(PlayerDataManager.get(mcExecutor).savedData.isReportBanned()) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You are report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)
)
);
return 1;
}
if(executor.getUUID().equals(player.getUUID())){
executor.sendNexiaMessage("You cannot report yourself!");
if(mcExecutor.equals(player)){
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You cannot report yourself!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
);
return 1;
}
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))
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))
);
if(!sendWebhook(executor.getRawName(), player.getScoreboardName(), reason)) {
executor.sendNexiaMessage("Failed to send webhook! Don't worry, staff who are currently online will see your report!");
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))
);
}
Component staffReportMessage = ChatFormat.nexiaMessage
.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));
.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 (Player staffPlayer : ServerTime.nexusServer.getPlayers()){
if(Permissions.check(((WrappedPlayer) staffPlayer).unwrap(), "nexia.staff.report", 1)) staffPlayer.sendMessage(staffReportMessage);
for (ServerPlayer staffPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()){
if(Permissions.check(staffPlayer, "nexia.staff.report", 1)) PlayerUtil.getFactoryPlayer(staffPlayer).sendMessage(staffReportMessage);
}
return 1;
@@ -1,20 +1,22 @@
package com.nexia.core.commands.player;
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.nexia.core.NexiaCore;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class RulesCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("rules").executes(RulesCommand::run));
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("rules").executes(RulesCommand::run));
}
public static int run(CommandContext<CommandSourceInfo> context) {
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
/*
Apparently this just doesn't work.....
@@ -26,11 +28,11 @@ public class RulesCommand {
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", ChatFormat.brandColor1).decoration(ChatFormat.strikeThrough, false))
.append(Component.text("Rules").color(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)));
for (int i = 0; i < NexiaCore.config.rules.length; i++) {
for (int i = 0; i < Main.config.rules.length; i++) {
message = message.append(Component.text("\n" + (i+1) + ". ")
.color(ChatFormat.brandColor1)
@@ -38,10 +40,10 @@ public class RulesCommand {
.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])
.append(Component.text(Main.config.rules[i])
.decoration(ChatFormat.bold, false)
.decoration(ChatFormat.strikeThrough, false)
.color(ChatFormat.normalColor)
)
@@ -50,7 +52,7 @@ public class RulesCommand {
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
context.getSource().sendMessage(message);
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
return 1;
}
@@ -1,30 +1,35 @@
package com.nexia.core.commands.player;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.nexia.nexus.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import java.util.HashMap;
import java.util.UUID;
public class ShoutCommand {
private static final HashMap<UUID, Long> cooldownTime = new HashMap<>();
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("shout")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.prefix.supporter"))
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
private static HashMap<UUID, Long> cooldownTime = new HashMap<>();
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("shout")
.requires(context -> {
try {
return Permissions.check(context.getPlayerOrException(), "nexia.prefix.supporter");
} catch (Exception ignored) { }
return false;
})
.then(Commands.argument("message", StringArgumentType.greedyString())
.executes(context -> ShoutCommand.shout(context, StringArgumentType.getString(context, "message")))
)
);
@@ -40,28 +45,30 @@ public class ShoutCommand {
}
public static int shout(CommandContext<CommandSourceInfo> context, String message) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int shout(CommandContext<CommandSourceStack> context, String message) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
if (PlayerMutes.muted(executor)) return 0;
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
if(ShoutCommand.cooldownTime.get(executor.getUUID()) == null) ShoutCommand.cooldownTime.put(executor.getUUID(), System.currentTimeMillis());
long longTime = ShoutCommand.cooldownTime.get(executor.getUUID());
if(longTime - System.currentTimeMillis() > 0) {
String time = ShoutCommand.timeToText(longTime - System.currentTimeMillis());
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))
);
factoryExecutor.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))
));
return 0;
}
Component cmessage = Component.text(executor.getRawName(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true)
.append(Component.text( " shouts: " + message, ChatFormat.normalColor));
Component cmessage = Component.text(factoryExecutor.getRawName()).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true)
.append(Component.text( " shouts: " + message).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
);
for(Player player : ServerTime.nexusServer.getPlayers()) {
for(Player player : ServerTime.factoryServer.getPlayers()) {
player.sendMessage(cmessage);
}
@@ -1,133 +1,149 @@
package com.nexia.core.commands.player;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.types.Minecraft;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.nexia.nexus.api.world.types.Minecraft;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class SpectateCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("spectate")
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("spectate")
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return (playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY) || (playerData1.gameMode == PlayerGameMode.FFA);
} catch (Exception ignored) {
return false;
}
return false;
})
.executes(SpectateCommand::gameModeSpectate)
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> SpectateCommand.spectate(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> SpectateCommand.spectate(context, EntityArgument.getPlayer(context, "player")))
)
);
}
public static int gameModeSpectate(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int gameModeSpectate(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
if(!executor.isInGameMode(PlayerGameMode.FFA)) {
executor.sendNexiaMessage("This can only be used in FFA!");
executor.sendNexiaMessage("If you are in duels then you do /spectate <player>.");
if(PlayerDataManager.get(executor).gameMode != PlayerGameMode.FFA) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
));
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("If you are in duels then you do /spectate <player>.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
));
return 0;
}
if(!executor.hasPermission("nexia.prefix.supporter")) {
executor.sendNexiaMessage(
Component.text("This feature is only available for", ChatFormat.normalColor)
if(!Permissions.check(executor, "nexia.prefix.supporter")) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("This feature is only available for").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text("Supporters")
.color(ChatFormat.brandColor1)
.decoration(ChatFormat.bold, true)
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.brandColor1)))
.clickEvent(ClickEvent.suggestCommand("/ranks"))
.append(Component.text("!", ChatFormat.normalColor))
.hoverEvent(HoverEvent.showText(Component.text("Click me").color(ChatFormat.brandColor1)))
.clickEvent(ClickEvent.suggestCommand("/ranks")
)
.append(Component.text("!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
)
)
);
}
if(LobbyUtil.checkGameModeBan(executor, "ffa")) {
if(LobbyUtil.checkGameModeBan(factoryExecutor, executor, "ffa")) {
return 0;
}
if(Math.round(executor.getHealth()) < 20) {
executor.sendNexiaMessage("You must be fully healed to go into spectator!");
if(Math.round(factoryExecutor.getHealth()) < 20) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
return 0;
}
executor.setGameMode(Minecraft.GameMode.SPECTATOR);
factoryExecutor.setGameMode(Minecraft.GameMode.SPECTATOR);
return 1;
}
public static int spectate(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer nexiaExecutor = new NexiaPlayer(context.getSource().getPlayerOrException());
NexiaPlayer nexiaPlayer = new NexiaPlayer(player);
public static int spectate(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
if(nexiaPlayer.isInGameMode(PlayerGameMode.LOBBY)) {
GamemodeHandler.spectatePlayer(nexiaExecutor, nexiaPlayer);
if(PlayerDataManager.get(player).gameMode == PlayerGameMode.LOBBY) {
GamemodeHandler.spectatePlayer(executor, player);
return 1;
}
if(!nexiaExecutor.hasPermission("nexia.prefix.supporter")) {
nexiaExecutor.sendNexiaMessage(
Component.text("This feature is only available for", ChatFormat.normalColor)
if(!Permissions.check(executor, "nexia.prefix.supporter")) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("This feature is only available for").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text("Supporters")
.color(ChatFormat.brandColor1)
.decoration(ChatFormat.bold, true)
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.brandColor1)))
.hoverEvent(HoverEvent.showText(Component.text("Click me").color(ChatFormat.brandColor1)))
.clickEvent(ClickEvent.suggestCommand("/ranks")
)
.append(Component.text("!", ChatFormat.normalColor))
.append(Component.text("!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
)
)
);
}
if(LobbyUtil.checkGameModeBan(nexiaExecutor, "ffa")) {
if(LobbyUtil.checkGameModeBan(factoryExecutor, executor, "ffa")) {
return 0;
}
if(((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(nexiaExecutor)).gameMode != PlayerGameMode.FFA) {
nexiaExecutor.sendNexiaMessage("This can only be used in FFA!");
nexiaExecutor.sendNexiaMessage("If you are in duels then you do /spectate <player>.");
if(PlayerDataManager.get(executor).gameMode != PlayerGameMode.FFA) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
));
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("If you are in duels then you do /spectate <player>.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
));
return 0;
}
if(!FfaUtil.isFfaPlayer(nexiaPlayer)) {
nexiaExecutor.sendNexiaMessage("That player is not in FFA!");
return 0;
if(!FfaUtil.isFfaPlayer(player)) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("That player is not in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
));
}
// Check if player is in combat (or full health), then put them in spectator.
if(Math.round(nexiaExecutor.getHealth()) < 20) {
nexiaExecutor.sendNexiaMessage("You must be fully healed to go into spectator!");
if(Math.round(factoryExecutor.getHealth()) < 20) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
return 0;
}
nexiaExecutor.setGameMode(Minecraft.GameMode.SPECTATOR);
nexiaExecutor.teleport(nexiaPlayer.getLocation());
factoryExecutor.setGameMode(Minecraft.GameMode.SPECTATOR);
executor.teleportTo(player.getLevel(), player.getX(), player.getY(), player.getZ(), 0, 0);
return 1;
}
@@ -3,25 +3,25 @@ package com.nexia.core.commands.player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.CoreSavedPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.player.SavedPlayerData;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
public class SprintFixCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("sprintfix").executes(SprintFixCommand::run));
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("sprintfix").executes(SprintFixCommand::run));
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
CoreSavedPlayerData data = (CoreSavedPlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player).savedData;
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
SavedPlayerData data = PlayerDataManager.get(player).savedData;
player.sendNexiaMessage(Component.text((data.setSprintFix(!data.isSprintFix()) ? "Enabled" : "Disabled") + " Sprint Fix!", ChatFormat.normalColor));
PlayerUtil.getFactoryPlayer(player).sendMessage(ChatFormat.nexiaMessage.append(Component.text((data.setSprintFix(!data.isSprintFix()) ? "Enabled" : "Disabled") + " Sprint Fix!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)));
return 1;
}
@@ -1,194 +1,217 @@
package com.nexia.core.commands.player;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.base.player.SavedPlayerData;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.FfaGameMode;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.nexia.ffa.classic.utilities.player.PlayerDataManager;
import com.nexia.ffa.classic.utilities.player.SavedPlayerData;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
import java.text.DecimalFormat;
public class StatsCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("stats").executes(StatsCommand::run)
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("gamemode", StringArgumentType.greedyString())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("stats").executes(StatsCommand::run)
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("gamemode", StringArgumentType.greedyString())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((LobbyUtil.statsGameModes), builder)))
.executes(context -> StatsCommand.other(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "gamemode")))))
.executes(context -> StatsCommand.other(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode")))))
);
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
CorePlayerData playerData = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer mcPlayer = context.getSource().getPlayerOrException();
PlayerData executerData = com.nexia.core.utilities.player.PlayerDataManager.get(mcPlayer);
Player player = PlayerUtil.getFactoryPlayer(mcPlayer);
Component start = Component.text(" »").color(ChatFormat.arrowColor);
Component start = Component.text(" »").color(NamedTextColor.GRAY);
Component user = start
.append(Component.text(" User: ", ChatFormat.brandColor2))
.append(Component.text(player.getRawName(), ChatFormat.normalColor));
.append(Component.text(" User: ").color(ChatFormat.brandColor2))
.append(Component.text(player.getRawName()).color(ChatFormat.normalColor))
;
Component message;
if (playerData.gameMode == PlayerGameMode.FFA) {
if(executerData.gameMode == PlayerGameMode.FFA){
message = ChatFormat.separatorLine("FFA Classic Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FFA_CLASSIC_DATA_MANAGER).get(player).savedData;
SavedPlayerData data = PlayerDataManager.get(mcPlayer).savedData;
if (playerData.ffaGameMode == FfaGameMode.KITS) {
int kills = data.kills;
int deaths = data.deaths;
int killstreak = data.killstreak;
int bestKillstreak = data.bestKillstreak;
long rating = Math.round(data.rating * 100);
if(executerData.ffaGameMode == FfaGameMode.KITS) {
message = ChatFormat.separatorLine("Kit FFA Stats");
data = PlayerDataManager.getDataManager(NexiaCore.FFA_KITS_DATA_MANAGER).get(player).savedData;
com.nexia.ffa.kits.utilities.player.SavedPlayerData kData = com.nexia.ffa.kits.utilities.player.PlayerDataManager.get(mcPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
bestKillstreak = kData.bestKillstreak;
}
if (playerData.ffaGameMode == FfaGameMode.UHC) {
if(executerData.ffaGameMode == FfaGameMode.UHC) {
message = ChatFormat.separatorLine("UHC FFA Stats");
data = PlayerDataManager.getDataManager(NexiaCore.FFA_UHC_DATA_MANAGER).get(player).savedData;
com.nexia.ffa.uhc.utilities.player.SavedPlayerData kData = com.nexia.ffa.uhc.utilities.player.PlayerDataManager.get(mcPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
bestKillstreak = kData.bestKillstreak;
}
if (playerData.ffaGameMode == FfaGameMode.SKY) {
if(executerData.ffaGameMode == FfaGameMode.SKY) {
message = ChatFormat.separatorLine("Sky FFA Stats");
data = PlayerDataManager.getDataManager(NexiaCore.FFA_SKY_DATA_MANAGER).get(player).savedData;
com.nexia.ffa.sky.utilities.player.SavedPlayerData kData = com.nexia.ffa.sky.utilities.player.PlayerDataManager.get(mcPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
bestKillstreak = kData.bestKillstreak;
}
int kills = data.get(Integer.class, "kills");
int deaths = data.get(Integer.class, "deaths");
int killstreak = data.get(Integer.class, "killstreak");
int bestKillstreak = data.get(Integer.class, "bestKillstreak");
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
.append(Component.text(kills).color(ChatFormat.greenColor))
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
.append(Component.text(kills).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Deaths: ", ChatFormat.brandColor2))
.append(Component.text(deaths, ChatFormat.failColor))
.append(Component.text(" Deaths: ").color(ChatFormat.brandColor2))
.append(Component.text(deaths).color(ChatFormat.failColor))
);
player.sendMessage(start
.append(Component.text(" KDR: ", ChatFormat.brandColor2))
.append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor))
.append(Component.text(" KDR: ").color(ChatFormat.brandColor2))
.append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Killstreak: ", ChatFormat.brandColor2))
.append(Component.text(killstreak).color(ChatFormat.goldColor))
.append(Component.text("/").color(ChatFormat.arrowColor))
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
.append(Component.text(" Killstreak: ").color(ChatFormat.brandColor2))
.append(Component.text(killstreak).color(ChatFormat.goldColor))
.append(Component.text("/").color(ChatFormat.arrowColor))
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
);
if (executerData.ffaGameMode == FfaGameMode.CLASSIC) {
player.sendMessage(start
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
.append(Component.text(rating).color(ChatFormat.goldColor))
);
}
}
if(playerData.gameMode == PlayerGameMode.LOBBY){
if(executerData.gameMode == PlayerGameMode.LOBBY){
message = ChatFormat.separatorLine("Duels Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player).savedData;
com.nexia.minigames.games.duels.util.player.SavedPlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(mcPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
}
if(playerData.gameMode == PlayerGameMode.BEDWARS){
if(executerData.gameMode == PlayerGameMode.BEDWARS){
message = ChatFormat.separatorLine("Bedwars Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.BEDWARS_DATA_MANAGER).get(player).savedData;
com.nexia.minigames.games.bedwars.util.player.SavedPlayerData data = com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.get(mcPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
player.sendMessage(start
.append(Component.text(" Beds broken: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "bedsBroken"), ChatFormat.failColor))
.append(Component.text(" Beds broken: ").color(ChatFormat.brandColor2))
.append(Component.text(data.bedsBroken).color(ChatFormat.failColor))
);
}
if(playerData.gameMode == PlayerGameMode.OITC){
if(executerData.gameMode == PlayerGameMode.OITC){
message = ChatFormat.separatorLine("OITC Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(player).savedData;
com.nexia.minigames.games.oitc.util.player.SavedPlayerData data = com.nexia.minigames.games.oitc.util.player.PlayerDataManager.get(mcPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
player.sendMessage(start
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
.append(Component.text(data.kills).color(ChatFormat.failColor))
);
}
if(playerData.gameMode == PlayerGameMode.FOOTBALL){
if(executerData.gameMode == PlayerGameMode.FOOTBALL){
message = ChatFormat.separatorLine("Football Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FOOTBALL_DATA_MANAGER).get(player).savedData;
com.nexia.minigames.games.football.util.player.SavedPlayerData data = com.nexia.minigames.games.football.util.player.PlayerDataManager.get(mcPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
player.sendMessage(start
.append(Component.text(" Goals: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "goals"), ChatFormat.failColor))
.append(Component.text(" Goals: ").color(ChatFormat.brandColor2))
.append(Component.text(data.goals).color(ChatFormat.failColor))
);
}
if(playerData.gameMode == PlayerGameMode.SKYWARS){
if(executerData.gameMode == PlayerGameMode.SKYWARS){
message = ChatFormat.separatorLine("SkyWars Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player).savedData;
com.nexia.minigames.games.skywars.util.player.SavedPlayerData data = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(mcPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.losses).color(ChatFormat.failColor))
);
player.sendMessage(start
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
.append(Component.text(data.kills).color(ChatFormat.failColor))
);
}
player.sendMessage(ChatFormat.separatorLine(null));
@@ -201,163 +224,184 @@ public class StatsCommand {
return Float.parseFloat(new DecimalFormat("#.##").format((float) kills / deaths));
}
public static int other(CommandContext<CommandSourceInfo> context, ServerPlayer otherPlayer, String gamemode) {
CommandSourceInfo source = context.getSource();
public static int other(CommandContext<CommandSourceStack> context, ServerPlayer otherPlayer, String gamemode) throws CommandSyntaxException {
ServerPlayer mcPlayer = context.getSource().getPlayerOrException();
Player player = PlayerUtil.getFactoryPlayer(mcPlayer);
Component start = Component.text(" »").color(ChatFormat.arrowColor);
Component start = Component.text(" »").color(NamedTextColor.GRAY);
Component user = start
.append(Component.text(" User: ", ChatFormat.brandColor2))
.append(Component.text(otherPlayer.getScoreboardName(), ChatFormat.normalColor))
.append(Component.text(" User: ").color(ChatFormat.brandColor2))
.append(Component.text(otherPlayer.getScoreboardName()).color(ChatFormat.normalColor))
;
Component message;
if (gamemode.equalsIgnoreCase("ffa classic") || gamemode.equalsIgnoreCase("kit ffa") || gamemode.equalsIgnoreCase("sky ffa") || gamemode.equalsIgnoreCase("uhc ffa")){
if(gamemode.equalsIgnoreCase("ffa classic") || gamemode.equalsIgnoreCase("kit ffa") || gamemode.equalsIgnoreCase("sky ffa") || gamemode.equalsIgnoreCase("uhc ffa")){
message = ChatFormat.separatorLine("FFA Classic Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FFA_CLASSIC_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
SavedPlayerData data = PlayerDataManager.get(otherPlayer).savedData;
if (gamemode.equalsIgnoreCase("kit ffa")) {
int kills = data.kills;
int deaths = data.deaths;
int killstreak = data.killstreak;
int bestKillstreak = data.bestKillstreak;
long rating = Math.round(data.rating * 100);
if(gamemode.equalsIgnoreCase("kit ffa")) {
message = ChatFormat.separatorLine("Kit FFA Stats");
data = PlayerDataManager.getDataManager(NexiaCore.FFA_KITS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
com.nexia.ffa.kits.utilities.player.SavedPlayerData kData = com.nexia.ffa.kits.utilities.player.PlayerDataManager.get(otherPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
bestKillstreak = kData.bestKillstreak;
}
if (gamemode.equalsIgnoreCase("sky ffa")) {
if(gamemode.equalsIgnoreCase("sky ffa")) {
message = ChatFormat.separatorLine("Sky FFA Stats");
data = PlayerDataManager.getDataManager(NexiaCore.FFA_SKY_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
com.nexia.ffa.sky.utilities.player.SavedPlayerData kData = com.nexia.ffa.sky.utilities.player.PlayerDataManager.get(otherPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
bestKillstreak = kData.bestKillstreak;
}
if (gamemode.equalsIgnoreCase("uhc ffa")) {
if(gamemode.equalsIgnoreCase("uhc ffa")) {
message = ChatFormat.separatorLine("UHC FFA Stats");
data = PlayerDataManager.getDataManager(NexiaCore.FFA_UHC_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
com.nexia.ffa.uhc.utilities.player.SavedPlayerData kData = com.nexia.ffa.uhc.utilities.player.PlayerDataManager.get(otherPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
bestKillstreak = kData.bestKillstreak;
}
int kills = data.get(Integer.class, "kills");
int deaths = data.get(Integer.class, "deaths");
int killstreak = data.get(Integer.class, "killstreak");
int bestKillstreak = data.get(Integer.class, "bestKillstreak");
source.sendMessage(message);
source.sendMessage(user);
source.sendMessage(start
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
.append(Component.text(kills).color(ChatFormat.greenColor))
);
source.sendMessage(start
.append(Component.text(" Deaths: ", ChatFormat.brandColor2))
.append(Component.text(deaths, ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Deaths: ").color(ChatFormat.brandColor2))
.append(Component.text(deaths).color(ChatFormat.failColor))
);
source.sendMessage(start
.append(Component.text(" KDR: ", ChatFormat.brandColor2))
player.sendMessage(start
.append(Component.text(" KDR: ").color(ChatFormat.brandColor2))
.append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor))
);
source.sendMessage(start
.append(Component.text(" Killstreak: ", ChatFormat.brandColor2))
player.sendMessage(start
.append(Component.text(" Killstreak: ").color(ChatFormat.brandColor2))
.append(Component.text(killstreak).color(ChatFormat.goldColor))
.append(Component.text("/").color(ChatFormat.arrowColor))
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
);
if(gamemode.equalsIgnoreCase("ffa classic")) {
player.sendMessage(start
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
.append(Component.text(rating).color(ChatFormat.goldColor))
);
}
}
if(gamemode.equalsIgnoreCase("duels")){
message = ChatFormat.separatorLine("Duels Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
source.sendMessage(message);
source.sendMessage(user);
source.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
com.nexia.minigames.games.duels.util.player.SavedPlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(otherPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
source.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
}
if(gamemode.equalsIgnoreCase("bedwars")){
message = ChatFormat.separatorLine("Bedwars Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.BEDWARS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
source.sendMessage(message);
source.sendMessage(user);
source.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
com.nexia.minigames.games.bedwars.util.player.SavedPlayerData data = com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.get(otherPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
source.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
source.sendMessage(start
.append(Component.text(" Beds broken: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "bedsBroken"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Beds broken: ").color(ChatFormat.brandColor2))
.append(Component.text(data.bedsBroken).color(ChatFormat.failColor))
);
}
if(gamemode.equalsIgnoreCase("oitc")){
message = ChatFormat.separatorLine("OITC Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
com.nexia.minigames.games.oitc.util.player.SavedPlayerData data = com.nexia.minigames.games.oitc.util.player.PlayerDataManager.get(otherPlayer).savedData;
source.sendMessage(message);
source.sendMessage(user);
source.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
source.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
source.sendMessage(start
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
.append(Component.text(data.kills).color(ChatFormat.failColor))
);
}
if(gamemode.equalsIgnoreCase("football")){
message = ChatFormat.separatorLine("Football Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FOOTBALL_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
com.nexia.minigames.games.football.util.player.SavedPlayerData data = com.nexia.minigames.games.football.util.player.PlayerDataManager.get(otherPlayer).savedData;
source.sendMessage(message);
source.sendMessage(user);
source.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
source.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
source.sendMessage(start
.append(Component.text(" Goals: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "goals"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Goals: ").color(ChatFormat.brandColor2))
.append(Component.text(data.goals).color(ChatFormat.failColor))
);
}
if(gamemode.equalsIgnoreCase("skywars")){
message = ChatFormat.separatorLine("SkyWars Stats");
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
com.nexia.minigames.games.skywars.util.player.SavedPlayerData data = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(otherPlayer).savedData;
source.sendMessage(message);
source.sendMessage(user);
source.sendMessage(start
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
source.sendMessage(start
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.losses).color(ChatFormat.failColor))
);
source.sendMessage(start
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
player.sendMessage(start
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
.append(Component.text(data.kills).color(ChatFormat.failColor))
);
}
source.sendMessage(ChatFormat.separatorLine(null));
player.sendMessage(ChatFormat.separatorLine(null));
return 1;
}
@@ -3,51 +3,42 @@ package com.nexia.core.commands.player.duels;
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.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class AcceptDuelCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "acceptduel");
register(dispatcher, "acceptchallenge");
}
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
dispatcher.register(CommandUtils.literal(string)
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> AcceptDuelCommand.accept(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> AcceptDuelCommand.accept(context, EntityArgument.getPlayer(context, "player")))
)
);
}
public static int accept(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
GamemodeHandler.acceptDuel(executor, new NexiaPlayer(player));
public static int accept(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
GamemodeHandler.acceptDuel(context.getSource().getPlayerOrException(), player);
return 1;
}
}
@@ -3,50 +3,41 @@ package com.nexia.core.commands.player.duels;
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.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class DeclineDuelCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "declineduel");
register(dispatcher, "declinechallenge");
}
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
dispatcher.register(CommandUtils.literal(string)
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> DeclineDuelCommand.decline(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> DeclineDuelCommand.decline(context, EntityArgument.getPlayer(context, "player")))
)
);
}
public static int decline(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
GamemodeHandler.declineDuel(executor, new NexiaPlayer(player));
public static int decline(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
GamemodeHandler.declineDuel(context.getSource().getPlayerOrException(), player);
return 1;
}
}
@@ -4,65 +4,52 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.gui.duels.DuelGUI;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;
public class DuelCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "duel");
register(dispatcher, "challenge");
}
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
dispatcher.register(CommandUtils.literal(string)
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
DuelGUI.openDuelGui(player.unwrap(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)));
return 1;
})
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> DuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player")))
.then(Commands.argument("gamemode", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder)))
.executes(context -> DuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "gamemode"), null))
.then(CommandUtils.argument("map", StringArgumentType.string())
.executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), null))
.then(Commands.argument("map", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
.executes(context -> DuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "map")))
.executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "map")))
))));
}
public static int challenge(CommandContext<CommandSourceInfo> context, ServerPlayer player, String gameMode, @Nullable String map) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
GamemodeHandler.challengePlayer(executor, new NexiaPlayer(player), gameMode, DuelsMap.identifyMap(map));
public static int challenge(CommandContext<CommandSourceStack> context, ServerPlayer player, String gameMode, @Nullable String map) throws CommandSyntaxException {
ServerPlayer executer = context.getSource().getPlayerOrException();
GamemodeHandler.challengePlayer(executer, player, gameMode, DuelsMap.identifyMap(map));
return 1;
}
}
@@ -4,21 +4,20 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import io.github.blumbo.inventorymerger.saving.SavableInventory;
import net.kyori.adventure.text.Component;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -28,22 +27,20 @@ import java.nio.file.Files;
import java.nio.file.Path;
public class KitLayoutCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register((CommandUtils.literal("kitlayout")
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("kitlayout")
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {}
return false;
})
.then(CommandUtils.argument("argument", StringArgumentType.string())
.then(Commands.argument("argument", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"save", "edit", "reset"}), builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), ""))
.then(CommandUtils.argument("inventory", StringArgumentType.string())
.then(Commands.argument("inventory", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(InventoryUtil.getListOfInventories("duels"), builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), StringArgumentType.getString(context, "inventory")))
)
@@ -52,24 +49,25 @@ public class KitLayoutCommand {
);
}
private static int run(CommandContext<CommandSourceInfo> context, @NotNull String argument, @NotNull String inventory) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
private static int run(CommandContext<CommandSourceStack> context, @NotNull String argument, @NotNull String inventory) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if((inventory.trim().isEmpty() || !InventoryUtil.getListOfInventories("duels").contains(inventory.toLowerCase())) && !argument.equalsIgnoreCase("save")) {
player.sendMessage(Component.text("Invalid gamemode!", ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("Invalid gamemode!"));
return 0;
}
if(argument.equalsIgnoreCase("save")) {
if(((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingLayout.isEmpty()) {
player.sendMessage(Component.text("You aren't editing a layout!", ChatFormat.failColor));
if(com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("You aren't editing a layout!"));
return 0;
}
inventory = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingLayout;
inventory = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout;
String path = InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID() + File.separator + "layout";
String path = InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID() + File.separator + "layout";
Path playerPath = Path.of(path);
File playerDir = playerPath.toFile();
@@ -77,7 +75,7 @@ public class KitLayoutCommand {
if(!playerDir.exists()) Files.createDirectory(playerPath);
} catch (IOException ignored) { }
SavableInventory savableInventory = new SavableInventory(player.unwrap().inventory);
SavableInventory savableInventory = new SavableInventory(player.inventory);
String stringInventory = savableInventory.toSave();
try {
@@ -86,43 +84,43 @@ public class KitLayoutCommand {
fileWriter.write(stringInventory);
fileWriter.close();
} catch (Exception var6) {
player.runCommand("/hub", 0, false);
player.sendMessage(Component.text(String.format("Failed to save your inventory as '%s'. Please try again or contact a developer.", inventory), ChatFormat.failColor));
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
player.sendMessage(LegacyChatFormat.format("{f}Failed to save your inventory as '{}'. Please try again or contact a developer.", inventory), Util.NIL_UUID);
return 0;
}
player.sendMessage(Component.text(String.format("Successfully saved your inventory as '%s'.", inventory), ChatFormat.brandColor1));
player.runCommand("/hub", 0, false);
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully saved your inventory as '{}'.", inventory), false);
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 1;
}
if (argument.equalsIgnoreCase("edit")) {
if(!((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingLayout.isEmpty()) {
player.sendMessage(Component.text("You are still editing a layuot! Save it run or run /hub!", ChatFormat.failColor));
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("You are still editing a layout! Save it or run /hub!"));
return 0;
}
DuelGameHandler.loadInventory(player, inventory);
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingLayout = inventory;
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout = inventory;
return 1;
}
if(argument.equalsIgnoreCase("reset")) {
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID() + File.separator + "layout" + File.separator + inventory + ".json");
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID() + File.separator + "layout" + File.separator + inventory + ".json");
if(playerFile.exists() && playerFile.delete()) {
player.sendMessage(Component.text(String.format("Successfully reset saved layout '%s'!", inventory), ChatFormat.brandColor1));
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully reset saved layout '{}'!", inventory), false);
} else {
player.sendMessage(Component.text("Saved Layout does not exist!", ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("Saved Layout does not exist!"));
}
return 1;
}
player.sendMessage(Component.text("Invalid argument!", ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("Invalid argument!"));
return 1;
}
}
@@ -3,90 +3,82 @@ package com.nexia.core.commands.player.duels;
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.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.team.DuelsTeam;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class PartyCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "party");
register(dispatcher, "duelsteam");
}
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
dispatcher.register(CommandUtils.literal(string)
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(CommandUtils.literal("invite")
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.invitePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
.then(Commands.literal("invite")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.invitePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(CommandUtils.literal("promote")
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.promotePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
.then(Commands.literal("promote")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.promotePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(CommandUtils.literal("join")
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.joinTeam(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
.then(Commands.literal("join")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.joinTeam(context, EntityArgument.getPlayer(context, "player"))))
)
.then(CommandUtils.literal("kick")
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.kickPlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
.then(Commands.literal("kick")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.kickPlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(CommandUtils.literal("decline")
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.declinePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
.then(Commands.literal("decline")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.declinePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(CommandUtils.literal("disband").executes(PartyCommand::disbandTeam))
.then(CommandUtils.literal("create").executes(PartyCommand::createTeam))
.then(CommandUtils.literal("list").executes(PartyCommand::listTeam))
.then(CommandUtils.literal("leave").executes(PartyCommand::leaveTeam))
.then(Commands.literal("disband").executes(PartyCommand::disbandTeam))
.then(Commands.literal("create").executes(PartyCommand::createTeam))
.then(Commands.literal("list").executes(PartyCommand::listTeam))
.then(Commands.literal("leave").executes(PartyCommand::leaveTeam))
);
}
public static int invitePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer invitor = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int invitePlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
ServerPlayer invitor = context.getSource().getPlayerOrException();
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(invitor);
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(invitor);
if(data.duelOptions.duelsTeam == null) {
DuelsTeam.createTeam(invitor, false);
}
data.duelOptions.duelsTeam.invitePlayer(invitor, new NexiaPlayer(player));
data.duelOptions.duelsTeam.invitePlayer(invitor, player);
return 1;
}
public static int joinTeam(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player.getUUID())).duelOptions.duelsTeam.joinTeam(executor);
public static int joinTeam(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.joinTeam(context.getSource().getPlayerOrException());
return 1;
}
public static int listTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int listTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(executor);
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
if(data.duelOptions.duelsTeam == null) {
executor.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
PlayerUtil.getFactoryPlayer(executor).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
@@ -94,72 +86,68 @@ public class PartyCommand {
return 1;
}
public static int declinePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player.getUUID())).duelOptions.duelsTeam.declineTeam(executor);
public static int declinePlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.declineTeam(context.getSource().getPlayerOrException());
return 1;
}
public static int createTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
DuelsTeam.createTeam(player, true);
public static int createTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
DuelsTeam.createTeam(context.getSource().getPlayerOrException(), true);
return 1;
}
public static int promotePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int promotePlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(executor);
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
if(data.duelOptions.duelsTeam == null) {
executor.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
PlayerUtil.getFactoryPlayer(executor).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
data.duelOptions.duelsTeam.replaceLeader(executor, new NexiaPlayer(player), true);
data.duelOptions.duelsTeam.replaceLeader(executor, player, true);
return 1;
}
public static int kickPlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int kickPlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(executor);
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
if(data.duelOptions.duelsTeam == null) {
executor.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
PlayerUtil.getFactoryPlayer(executor).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
data.duelOptions.duelsTeam.kickPlayer(executor, new NexiaPlayer(player));
data.duelOptions.duelsTeam.kickPlayer(executor, player);
return 1;
}
public static int disbandTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int disbandTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
if(data.duelOptions.duelsTeam == null) {
player.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).duelOptions.duelsTeam.disbandTeam(player, true);
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.disbandTeam(player, true);
return 1;
}
public static int leaveTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
public static int leaveTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
if(data.duelOptions.duelsTeam == null) {
player.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).duelOptions.duelsTeam.leaveTeam(player, true);
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.leaveTeam(player, true);
return 1;
}
}
@@ -4,49 +4,38 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.gui.duels.QueueGUI;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
public class QueueCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("queue")
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("queue")
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {}
return false;
})
.executes(context -> {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
QueueGUI.openQueueGUI(player.unwrap());
return 1;
})
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
.executes(context -> QueueGUI.openQueueGUI(context.getSource().getPlayerOrException()))
.then(Commands.argument("gamemode", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder)))
.executes(context -> QueueCommand.queue(context, StringArgumentType.getString(context, "gamemode"))))
);
}
public static int queue(CommandContext<CommandSourceInfo> context, String gameMode) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
GamemodeHandler.joinQueue(player, gameMode, false);
public static int queue(CommandContext<CommandSourceStack> context, String gameMode) throws CommandSyntaxException {
ServerPlayer executer = context.getSource().getPlayerOrException();
GamemodeHandler.joinQueue(executer, gameMode, false);
return 1;
}
}
@@ -1,68 +1,55 @@
package com.nexia.core.commands.player.duels.custom;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.gui.duels.CustomDuelGUI;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;
public class CustomDuelCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "customduel");
register(dispatcher, "customchallenge");
}
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
dispatcher.register(CommandUtils.literal(string)
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
CustomDuelGUI.openDuelGui(player.unwrap(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)));
return 1;
})
.then(CommandUtils.argument("kit", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((InventoryUtil.getListOfInventories("duels/custom/" + context.getSource().getPlayerOrException().getUUID())), builder)))
.executes(context -> CustomDuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "kit"), null))
.then(CommandUtils.argument("map", StringArgumentType.string())
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> CustomDuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player")))
.then(Commands.argument("kit", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((InventoryUtil.getListOfInventories("duels/custom/" + context.getSource().getPlayerOrException().getStringUUID())), builder)))
.executes(context -> CustomDuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "kit"), null))
.then(Commands.argument("map", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
.executes(context -> CustomDuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "kit"), StringArgumentType.getString(context, "map")))
.executes(context -> CustomDuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "kit"), StringArgumentType.getString(context, "map")))
))));
}
public static int challenge(CommandContext<CommandSourceInfo> context, ServerPlayer player, String kit, @Nullable String map) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
GamemodeHandler.customChallengePlayer(executor, new NexiaPlayer(player), kit, DuelsMap.identifyMap(map));
public static int challenge(CommandContext<CommandSourceStack> context, ServerPlayer player, String kit, @Nullable String map) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
GamemodeHandler.customChallengePlayer(executor, player, kit, DuelsMap.identifyMap(map));
return 1;
}
}
@@ -6,23 +6,22 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.natamus.collective_fabric.functions.PlayerFunctions;
import com.natamus.collective_fabric.functions.StringFunctions;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.CustomKitRoom;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.SmpKitRoom;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.VanillaKitRoom;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.kyori.adventure.text.Component;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
@@ -37,22 +36,20 @@ public class KitEditorCommand {
private static final List<String> slots = Arrays.asList("1", "2", "3", "smp", "vanilla");
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register((CommandUtils.literal("kiteditor")
.requires(commandSourceInfo -> {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("kiteditor")
.requires(commandSourceStack -> {
try {
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {}
return false;
})
.then(CommandUtils.argument("argument", StringArgumentType.string())
.then(Commands.argument("argument", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"save", "edit", "delete"}), builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), ""))
.then(CommandUtils.argument("slot", StringArgumentType.string())
.then(Commands.argument("slot", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(slots, builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), StringArgumentType.getString(context, "slot")))
)
@@ -61,11 +58,11 @@ public class KitEditorCommand {
);
}
private static int run(CommandContext<CommandSourceInfo> context, @NotNull String argument, String slot) throws CommandSyntaxException {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
private static int run(CommandContext<CommandSourceStack> context, @NotNull String argument, String slot) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (!slots.contains(slot) && !argument.equalsIgnoreCase("save")) {
player.sendMessage(Component.text("Invalid slot!", ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("Invalid slot!"));
return 0;
}
@@ -75,18 +72,18 @@ public class KitEditorCommand {
if(argument.equalsIgnoreCase("save")) {
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
if(playerData.editingKit.isEmpty() || playerData.kitRoom == null) {
player.sendMessage(Component.text("You aren't editing a kit!", ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("You aren't editing a kit!"));
return 0;
}
inventory = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingKit;
inventory = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingKit;
String gearstring = PlayerFunctions.getPlayerGearString(player.unwrap());
String gearstring = PlayerFunctions.getPlayerGearString(player);
Path playerPath = Path.of(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID());
Path playerPath = Path.of(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID());
File playerDir = playerPath.toFile();
try {
if(!playerDir.exists()) Files.createDirectory(playerPath);
@@ -95,34 +92,35 @@ public class KitEditorCommand {
KitRoom kitRoom = playerData.kitRoom;
if (StringFunctions.sequenceCount(gearstring, "\n") < 40 || !playerDir.exists()) {
player.sendMessage(Component.text("Something went wrong while generating the save file content for your inventory.", ChatFormat.failColor));
kitRoom.leave();
player.runCommand("/hub", 0, false);
return 0;
} else if (!InventoryUtil.writeGearStringToFile("duels/custom/" + player.getUUID(), inventory, gearstring)) {
player.sendMessage(Component.text(String.format("Something went wrong while saving the content of your inventory as '%s'.", inventory), ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while generating the save file content for your inventory."));
kitRoom.leave();
player.runCommand("/hub", 0, false);
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 0;
} else if (!InventoryUtil.writeGearStringToFile("duels/custom/" + player.getStringUUID(), inventory, gearstring)) {
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while saving the content of your inventory as '{}'.", inventory));
kitRoom.leave();
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 0;
} else {
player.sendMessage(Component.text(String.format("Successfully saved your inventory as '%s'.", inventory), ChatFormat.failColor));
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully saved your inventory as '{}'.", inventory),false);
kitRoom.leave();
player.runCommand("/hub", 0, false);
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 1;
}
}
if (argument.equalsIgnoreCase("edit")) {
if(!((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingKit.isEmpty()) {
player.sendMessage(Component.text("You are still editing a kit! Save it or run /hub!", ChatFormat.failColor));
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingKit.isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("You are still editing a kit! Save it or run /hub!"));
return 0;
}
KitRoom kitRoom;
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
switch (slot) {
@@ -130,8 +128,8 @@ public class KitEditorCommand {
case "vanilla" -> kitRoom = new VanillaKitRoom(player);
case "smp" -> kitRoom = new SmpKitRoom(player);
default -> {
player.sendMessage(Component.text("Something went wrong whilst creating your kit room.", ChatFormat.failColor));
player.runCommand("/hub", 0, false);
player.sendMessage(LegacyChatFormat.formatFail("Something went wrong whilst creating your kit room."), Util.NIL_UUID);
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 0;
}
}
@@ -141,9 +139,9 @@ public class KitEditorCommand {
if(kitRoom.generate()) kitRoom.teleport();
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID(), inventory + ".txt");
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID(), inventory + ".txt");
if(playerFile.exists()) {
InventoryUtil.loadInventory(player, "duels/custom/" + player.getUUID(), inventory.toLowerCase());
InventoryUtil.loadInventory(player, "duels/custom/" + player.getStringUUID(), inventory.toLowerCase());
}
return 1;
@@ -151,17 +149,17 @@ public class KitEditorCommand {
if(argument.equalsIgnoreCase("delete")) {
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID(), inventory + ".txt");
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID(), inventory + ".txt");
if(playerFile.exists() && playerFile.delete()) {
player.sendMessage(Component.text(String.format("Successfully deleted slot '%s’!", slot), ChatFormat.brandColor1));
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully deleted slot '{}'!", slot), false);
} else {
player.sendMessage(Component.text(String.format("The saved kit for that slot (%s) does not exist!", slot), ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("The saved kit for that slot ({}) does not exist!", slot));
}
return 1;
}
player.sendMessage(Component.text("Invalid argument!", ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("Invalid argument!"));
return 1;
}
}
@@ -2,54 +2,55 @@ package com.nexia.core.commands.player.ffa;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.gui.ffa.KitGUI;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.kits.FfaKit;
import com.nexia.ffa.kits.utilities.FfaKitsUtil;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
public class KitCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("kit")
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("kit")
.executes(context -> {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
if(!FfaKitsUtil.INSTANCE.canGoToSpawn(player)) {
player.sendMessage(Component.text("You must be fully healed to change kits!", ChatFormat.failColor));
return 0;
ServerPlayer player = context.getSource().getPlayerOrException();
if(!FfaKitsUtil.canGoToSpawn(player)) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change kits!").color(ChatFormat.failColor));
return 1;
}
LobbyUtil.sendGame(player, "kits ffa", false, true);
run(player.unwrap());
run(context);
return 1;
})
.then(CommandUtils.argument("inventory", StringArgumentType.greedyString())
.then(Commands.argument("inventory", StringArgumentType.greedyString())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(FfaKit.stringFfaKits, builder)))
.executes(context -> {
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
if(!FfaKitsUtil.INSTANCE.canGoToSpawn(player)) {
player.sendMessage(Component.text("You must be fully healed to change kits!", ChatFormat.failColor));
ServerPlayer player = context.getSource().getPlayerOrException();
if(!FfaKitsUtil.canGoToSpawn(player)) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change kits!").color(ChatFormat.failColor));
return 1;
}
LobbyUtil.sendGame(player, "kits ffa", false, true);
selectedMap(player.unwrap(), StringArgumentType.getString(context, "inventory"));
selectedMap(context);
return 1;
})
)
);
}
public static void run(ServerPlayer player) throws CommandSyntaxException {
KitGUI.openKitGUI(player);
public static void run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
KitGUI.openKitGUI(context.getSource().getPlayerOrException());
}
public static void selectedMap(ServerPlayer player, String inventory) {
KitGUI.giveKit(player, inventory);
public static void selectedMap(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
KitGUI.giveKit(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "inventory"));
}
}
@@ -4,15 +4,16 @@ import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.NexiaDiscord;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.GameProfileArgument;
import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.UserBanList;
import net.minecraft.server.players.UserBanListEntry;
@@ -20,54 +21,62 @@ import net.minecraft.server.players.UserBanListEntry;
import java.util.Collection;
public class BanCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("ban")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
.executes(context -> BanCommand.ban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)), "No reason specified."))
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
.executes(context -> BanCommand.ban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "reason"))))
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("ban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.executes(context -> BanCommand.ban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player"), "No reason specified."))
.then(Commands.argument("reason", StringArgumentType.greedyString())
.executes(context -> BanCommand.ban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player"), StringArgumentType.getString(context, "reason"))))
)
);
}
public static int ban(CommandSourceInfo context, Collection<GameProfile> collection, String reason) {
public static int ban(CommandSourceStack context, Collection<GameProfile> collection, String reason) {
UserBanList userBanList = ServerTime.minecraftServer.getPlayerList().getBans();
int i = 0;
ServerPlayer player = null;
try {
player = context.getPlayerOrException();
} catch (Exception ignored){ }
for (GameProfile gameProfile : collection) {
if (!userBanList.isBanned(gameProfile)) {
ServerPlayer serverPlayer = ServerTime.minecraftServer.getPlayerList().getPlayer(gameProfile.getId());
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
UserBanListEntry userBanListEntry = new UserBanListEntry(gameProfile, null, null, null, reason);
UserBanListEntry userBanListEntry = new UserBanListEntry(gameProfile, null, context.getTextName(), null, reason);
userBanList.add(userBanListEntry);
++i;
context.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have banned ", ChatFormat.normalColor))
.append(Component.text(ComponentUtils.getDisplayName(gameProfile).getString(), ChatFormat.brandColor2))
.append(Component.text(" for ", ChatFormat.normalColor))
.append(Component.text(reason, ChatFormat.brandColor2))
);
if(player != null){
PlayerUtil.getFactoryPlayer(player).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have banned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(ComponentUtils.getDisplayName(gameProfile).getString()).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))
);
} else {
context.sendSuccess(LegacyChatFormat.format("{b1}You have banned {b2}{} {b1}for {b2}{}", ComponentUtils.getDisplayName(gameProfile).getString(), reason), true);
}
if (serverPlayer != null) {
nexiaPlayer.disconnect(Component.text("You have been banned.", ChatFormat.failColor)
.append(Component.text("\nReason: ", ChatFormat.systemColor))
.append(Component.text(reason, ChatFormat.brandColor2))
.append(Component.text("\nYou can appeal your ban at ", ChatFormat.systemColor))
.append(Component.text(NexiaDiscord.config.discordLink, ChatFormat.brandColor2))
);
serverPlayer.connection.disconnect(new TextComponent("§c§lYou have been banned.\n§7Reason: §d" + reason + "\n§7You can appeal your ban at §d" + com.nexia.discord.Main.config.discordLink));
}
}
}
if (i == 0) {
context.sendMessage(
ChatFormat.nexiaMessage.append(Component.text("That player is already banned.", ChatFormat.failColor))
);
if(player != null){
PlayerUtil.getFactoryPlayer(player).sendMessage(
ChatFormat.nexiaMessage.append(Component.text("That player is already banned.").color(ChatFormat.failColor))
);
} else {
context.sendFailure(LegacyChatFormat.formatFail("That player is already banned."));
}
} else {
return i;
}
@@ -1,13 +1,12 @@
package com.nexia.core.commands.staff;
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.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
@@ -19,27 +18,26 @@ public class DetectCommand {
public static final boolean enabled = false;
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
if(!enabled) return;
dispatcher.register(CommandUtils.literal("detect")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.dev.detect", 4))
dispatcher.register(Commands.literal("detect")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.detect", 4))
.executes(DetectCommand::run)
);
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
if(!enabled) return 0;
detect(new NexiaPlayer(context.getSource().getPlayerOrException()));
detect(context.getSource().getPlayerOrException());
return 1;
}
public static void detect(NexiaPlayer attacker) {
public static void detect(ServerPlayer attacker) {
String botName = ".bot";
List<Player> playersNearby = attacker.unwrap().level.getEntitiesOfClass(ServerPlayer.class, attacker.unwrap().getBoundingBox().inflate(12, 0.25, 12));
Vec3 eyePos = attacker.unwrap().getEyePosition(1);
List<Player> playersNearby = attacker.level.getEntitiesOfClass(ServerPlayer.class, attacker.getBoundingBox().inflate(12, 0.25, 12));
Vec3 eyePos = attacker.getEyePosition(1);
AtomicReference<Vec3> nearestPosition = new AtomicReference<>();
playersNearby.forEach(player -> {
Vec3 currentPos = player.getBoundingBox().getNearestPointTo(eyePos);
@@ -48,7 +46,7 @@ public class DetectCommand {
});
if(nearestPosition.get() != null) {
Vec3 nearestPos = nearestPosition.get();
ServerTime.nexusServer.runCommand("/player " + botName + " look at " + nearestPos.x + " " + nearestPos.y + " " + nearestPos.z, 4, false);
ServerTime.factoryServer.runCommand("/player " + botName + " look at " + nearestPos.x + " " + nearestPos.y + " " + nearestPos.z, 4, false);
}
}
}
@@ -1,46 +1,61 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.BanHandler;
import com.nexia.core.utilities.player.GamemodeBanHandler;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class GamemodeBanCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("gamemodeban")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("gamemodeban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("gamemode", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((PlayerGameMode.stringPlayerGameModes), builder)))
.then(CommandUtils.argument("duration", StringArgumentType.word())
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
.executes(context -> GamemodeBanCommand.ban(context.getSource(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
.then(Commands.argument("duration", StringArgumentType.word())
.then(Commands.argument("reason", StringArgumentType.greedyString())
.executes(context -> GamemodeBanCommand.ban(context.getSource(), EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
)
)
));
}
public static int ban(CommandSourceInfo sender, ServerPlayer player, String stringGameMode, String reason, String durationArg) {
public static int ban(CommandSourceStack sender, ServerPlayer player, String stringGameMode, String reason, String durationArg) {
ServerPlayer mcExecutor = null;
Player executor = null;
try {
mcExecutor = sender.getPlayerOrException();
} catch (Exception ignored){ }
if(mcExecutor != null) {
executor = PlayerUtil.getFactoryPlayer(mcExecutor);
}
PlayerGameMode gameMode = PlayerGameMode.identifyGamemode(stringGameMode);
if(gameMode == null) {
sender.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid gamemode!", ChatFormat.normalColor))
);
if(executor != null) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid gamemode!"));
}
return 1;
}
@@ -49,15 +64,19 @@ public class GamemodeBanCommand {
try {
durationInSeconds = BanHandler.parseTimeArg(durationArg);
} catch (Exception e) {
sender.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
);
if (executor != null) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
);
} else {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"));
}
return 1;
}
GamemodeBanHandler.tryGamemodeBan(sender, new NexiaPlayer(player), gameMode, durationInSeconds, reason);
GamemodeBanHandler.tryGamemodeBan(sender, player, gameMode, durationInSeconds, reason);
return 1;
}
@@ -1,53 +1,69 @@
package com.nexia.core.commands.staff;
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.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class HealCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("heal").executes(HealCommand::run)
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.heal", 1))
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> HealCommand.heal(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false))))
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("heal").executes(HealCommand::run)
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.heal", 1))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> HealCommand.heal(context, EntityArgument.getPlayer(context, "player")))
)
);
}
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
executor.setHealth(executor.getMaxHealth());
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer executer = context.getSource().getPlayerOrException();
executer.heal(executer.getMaxHealth());
executor.sendMessage(
PlayerUtil.getFactoryPlayer(executer).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have been healed.", ChatFormat.normalColor))
.append(Component.text("You have been healed.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
return 1;
}
public static int heal(CommandContext<CommandSourceInfo> context, ServerPlayer otherPlayer) {
public static int heal(CommandContext<CommandSourceStack> context, ServerPlayer otherPlayer) {
CommandSourceStack executer = context.getSource();
otherPlayer.heal(otherPlayer.getMaxHealth());
ServerPlayer player = null;
try {
player = executer.getPlayerOrException();
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have healed ", ChatFormat.normalColor))
.append(Component.text(otherPlayer.getScoreboardName(), ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor))
);
} catch(Exception ignored) { }
new NexiaPlayer(otherPlayer).sendNexiaMessage("You have been healed.");
if(player != null){
PlayerUtil.getFactoryPlayer(player).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have healed ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
executer.sendSuccess(LegacyChatFormat.format("{b1}You have healed {b2}{}{b1}.", otherPlayer.getScoreboardName()), false);
}
PlayerUtil.getFactoryPlayer(otherPlayer).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have been healed.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
return 1;
}
}
@@ -1,42 +1,44 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.commands.CommandUtil;
import net.kyori.adventure.text.Component;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import java.io.File;
import java.util.Objects;
public class ListInventoriesCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register((CommandUtils.literal("listinventories")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.inventory.list", 4))
.then(CommandUtils.argument("type", StringArgumentType.string())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("listinventories")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.inventory.list", 4);
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
.executes(ListInventoriesCommand::run)
)
));
}
private static int run(CommandContext<CommandSourceInfo> context){
private static int run(CommandContext<CommandSourceStack> context){
String type = StringArgumentType.getString(context, "type");
if(type.trim().isEmpty()) {
context.getSource().sendMessage(Component.text("Empty type!", ChatFormat.failColor));
context.getSource().sendFailure(LegacyChatFormat.format("Empty type!"));
return 0;
}
context.getSource().sendMessage(Component.text("Saved Inventories: ", ChatFormat.normalColor)
.append(Component.text(InventoryUtil.getListOfInventoriesString(type), ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor))
);
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Saved inventories: {b2}{}{b1}.", InventoryUtil.getListOfInventoriesString(type)), false);
return 1;
}
@@ -1,55 +1,74 @@
package com.nexia.core.commands.staff;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.core.utilities.world.WorldUtil;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.nexia.nexus.api.world.entity.player.Player;
import com.nexia.nexus.api.world.util.Location;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Difficulty;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.dimension.DimensionType;
import org.apache.commons.io.FileUtils;
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
import java.io.File;
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
public class MapCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register((CommandUtils.literal("map")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.map", 2))
.then(CommandUtils.argument("type", StringArgumentType.string())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("map")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.staff.map", 2);
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"delete", "create", "tp"}), builder)))
.then(CommandUtils.argument("map", StringArgumentType.greedyString())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((WorldUtil.getAllWorldsId()), builder)))
.then(Commands.argument("map", StringArgumentType.greedyString())
.executes(MapCommand::run)
)
)
));
}
private static int run(CommandContext<CommandSourceInfo> context) {
NexiaPlayer player = null;
if(context.getSource().getExecutingEntity() instanceof Player nexusPlayer) {
player = new NexiaPlayer(nexusPlayer);
}
private static int run(CommandContext<CommandSourceStack> context) {
ServerPlayer mcPlayer = null;
Player player = null;
try {
mcPlayer = context.getSource().getPlayerOrException();
player = PlayerUtil.getFactoryPlayer(mcPlayer);
} catch (Exception ignored) { }
String type = StringArgumentType.getString(context, "type");
String map = StringArgumentType.getString(context, "map");
if(map.trim().isEmpty() || type.trim().isEmpty()) {
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid name!", ChatFormat.failColor))
);
if(player != null) {
player.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid name!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
);
}
return 1;
}
@@ -57,14 +76,27 @@ public class MapCommand {
if(type.equalsIgnoreCase("create")){
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), (WorldUtil.defaultWorldConfig)).asWorld();
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), (
new RuntimeWorldConfig()
.setDimensionType(DimensionType.OVERWORLD_LOCATION)
.setGenerator(getChunkGenerator(Biomes.THE_VOID))
.setDifficulty(Difficulty.HARD)
.setGameRule(GameRules.RULE_KEEPINVENTORY, false)
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
.setGameRule(GameRules.RULE_WEATHER_CYCLE, false)
.setGameRule(GameRules.RULE_DAYLIGHT, false)
.setGameRule(GameRules.RULE_DO_IMMEDIATE_RESPAWN, false)
.setGameRule(GameRules.RULE_DOMOBSPAWNING, false)
.setGameRule(GameRules.RULE_SHOWDEATHMESSAGES, false)
.setGameRule(GameRules.RULE_SPAWN_RADIUS, 0))).asWorld();
if (player != null) {
player.teleport(new Location(0, 80, 0, 0, 0, WorldUtil.getWorld(level)));
if (mcPlayer != null && player != null) {
mcPlayer.teleportTo(level, 0, 80, 0, 0, 0);
player.sendNexiaMessage(
Component.text("Created map called: ", ChatFormat.normalColor)
.append(Component.text(map, ChatFormat.brandColor2))
player.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Created map called: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(map).color(ChatFormat.brandColor2))
);
}
@@ -75,9 +107,10 @@ public class MapCommand {
if (type.equalsIgnoreCase("delete")) {
ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), null).delete();
if(player != null) {
player.sendNexiaMessage(
Component.text("Deleted map called: ", ChatFormat.normalColor)
.append(Component.text(map, ChatFormat.brandColor2))
player.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Deleted map called: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(map).color(ChatFormat.brandColor2))
);
}
@@ -90,12 +123,13 @@ public class MapCommand {
if(type.equalsIgnoreCase("tp")) {
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), null).asWorld();
if(player != null) {
player.teleport(new Location(0, 80, 0, 0, 0, WorldUtil.getWorld(level)));
if(mcPlayer != null && player != null) {
mcPlayer.teleportTo(level, 0, 80, 0, 0, 0);
player.sendNexiaMessage(
Component.text("Teleported to map called: ", ChatFormat.normalColor)
.append(Component.text(map, ChatFormat.brandColor2))
player.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Teleported to map called: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(map).color(ChatFormat.brandColor2))
);
}
@@ -1,31 +1,32 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
import java.util.HashMap;
public class MuteCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("mute")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.mute", 1))
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("duration", StringArgumentType.word())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("mute")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.mute", 1))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("duration", StringArgumentType.word())
.executes(context -> MuteCommand.mute(context, StringArgumentType.getString(context, "duration"), "No reason specified."))
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
.then(Commands.argument("reason", StringArgumentType.greedyString())
.executes(context -> MuteCommand.mute(context,
StringArgumentType.getString(context, "duration"),
StringArgumentType.getString(context, "reason"))
@@ -36,20 +37,20 @@ public class MuteCommand {
);
}
public static int mute(CommandContext<CommandSourceInfo> context, String durationArg, String reason) throws CommandSyntaxException {
public static int mute(CommandContext<CommandSourceStack> context, String durationArg, String reason) throws CommandSyntaxException {
CommandSourceInfo sender = context.getSource();
ServerPlayer muted = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
CommandSourceStack sender = context.getSource();
ServerPlayer muted = EntityArgument.getPlayer(context, "player");
int durationInSeconds;
try {
durationInSeconds = parseTimeArg(durationArg);
} catch (Exception e) {
context.getSource().sendMessage(ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
);
PlayerUtil.safeSendMessage(sender, LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"),
ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)),false);
return 1;
}
@@ -1,58 +1,83 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
import java.util.ArrayList;
public class RankCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
ArrayList<String> arrayListRank = new ArrayList<>();
NexiaRank.ranks.forEach(rank -> arrayListRank.add(rank.id));
ArrayList<String> ranks = new ArrayList<>();
NexiaRank.ranks.forEach(rank -> ranks.add(rank.id));
dispatcher.register(CommandUtils.literal("rank")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.rank"))
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("rank", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ranks), builder)))
.executes(context -> RankCommand.give(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "rank")))))
dispatcher.register(Commands.literal("rank")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.rank"))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("rank", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((arrayListRank), builder)))
.executes(context -> RankCommand.give(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "rank")))))
);
}
public static int give(CommandContext<CommandSourceInfo> context, ServerPlayer player, String rank) {
NexiaPlayer nexiaPlayer = new NexiaPlayer(player);
public static int give(CommandContext<CommandSourceStack> context, ServerPlayer player, String rank) {
CommandSourceStack executor = context.getSource();
Player factoryExecutor = null;
Player otherFactoryPlayer = PlayerUtil.getFactoryPlayer(player);
try {
factoryExecutor = PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException());
} catch(Exception ignored) { }
NexiaRank nexiaRank = NexiaRank.identifyRank(rank);
if (nexiaRank == null) {
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid rank!", ChatFormat.normalColor))
);
if(nexiaRank == null) {
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
}
return 0;
}
nexiaPlayer.sendNexiaMessage(
Component.text("Your rank has been set to: ", ChatFormat.normalColor)
.append(Component.text(nexiaRank.name, ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".", ChatFormat.normalColor))
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have set the rank of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherFactoryPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" to ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the rank of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherFactoryPlayer.getRawName(), nexiaRank.name), false);
}
otherFactoryPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Your rank has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
NexiaRank.setRank(nexiaRank, nexiaPlayer);
NexiaRank.setRank(nexiaRank, player);
return 1;
}
}
}
@@ -1,92 +1,122 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
import java.util.ArrayList;
public class StaffPrefixCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
ArrayList<String> ranks = new ArrayList<>();
NexiaRank.ranks.forEach(rank -> ranks.add(rank.id));
dispatcher.register(CommandUtils.literal("staffprefix")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.prefix"))
.then(CommandUtils.argument("type", StringArgumentType.string())
dispatcher.register(Commands.literal("staffprefix")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.prefix"))
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"set", "add", "remove"}), builder)))
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("prefix", StringArgumentType.string())
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("prefix", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ranks), builder)))
.executes(context -> {
CommandSourceStack executor = context.getSource();
String type = StringArgumentType.getString(context, "type");
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
NexiaPlayer otherPlayer = new NexiaPlayer(mcOtherPlayer);
ServerPlayer mcOtherPlayer = EntityArgument.getPlayer(context, "player");
Player otherPlayer = PlayerUtil.getFactoryPlayer(mcOtherPlayer);
NexiaRank rank = NexiaRank.identifyRank(StringArgumentType.getString(context, "prefix"));
ServerPlayer mcExecutor;
Player factoryExecutor = null;
try {
mcExecutor = executor.getPlayerOrException();
factoryExecutor = PlayerUtil.getFactoryPlayer(mcExecutor);
} catch(Exception ignored){ }
if(rank == null) {
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid rank!", ChatFormat.normalColor))
);
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
}
return 0;
}
if(type.equalsIgnoreCase("set")){
context.getSource().sendMessage(
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have set the prefix of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2))
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the prefix of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherPlayer.getRawName(), rank.name), false);
}
otherPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have set the prefix of ", ChatFormat.normalColor))
.append(Component.text(otherPlayer.getRawName(), ChatFormat.brandColor2))
.append(Component.text(" to: ", ChatFormat.normalColor))
.append(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".", ChatFormat.normalColor).decoration(ChatFormat.bold,false))
.append(Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
otherPlayer.sendNexiaMessage(
Component.text("Your prefix has been set to: ", ChatFormat.normalColor)
.append(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".", ChatFormat.normalColor))
);
NexiaRank.setPrefix(rank, otherPlayer);
NexiaRank.setPrefix(rank, mcOtherPlayer);
}
if(type.equalsIgnoreCase("remove")){
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have removed the prefix ", ChatFormat.normalColor))
.append(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(" from: ", ChatFormat.normalColor))
.append(Component.text(otherPlayer.getRawName(), ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have removed the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
.append(Component.text(" from: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have removed the prefix {b2}{b}{} {b1}from {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
}
NexiaRank.removePrefix(rank, otherPlayer);
NexiaRank.removePrefix(rank, mcOtherPlayer);
}
if(type.equalsIgnoreCase("add")){
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have added the prefix ", ChatFormat.normalColor))
.append(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(" to: ", ChatFormat.normalColor))
.append(Component.text(otherPlayer.getRawName(), ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
NexiaRank.addPrefix(rank, otherPlayer, false);
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have added the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have added the prefix {b2}{b}{} {b1}to {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
}
NexiaRank.addPrefix(rank, mcOtherPlayer, false);
}
return Command.SINGLE_SUCCESS;
@@ -95,4 +125,4 @@ public class StaffPrefixCommand {
));
}
}
}
@@ -1,72 +1,103 @@
package com.nexia.core.commands.staff;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.utilities.player.CoreSavedPlayerData;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class StaffReportCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(CommandUtils.literal("staffreport")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.report", 3))
.then(CommandUtils.argument("type", StringArgumentType.string())
dispatcher.register(Commands.literal("staffreport")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.report", 1))
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"ban", "unban"}), builder)))
.then(CommandUtils.argument("player", EntityArgument.player())
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> {
String type = StringArgumentType.getString(context, "type");
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
NexiaPlayer otherPlayer = new NexiaPlayer(mcOtherPlayer);
CorePlayerData data = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(mcOtherPlayer.getUUID());
CommandSourceStack executor = context.getSource();
String type = StringArgumentType.getString(context, "type");
ServerPlayer mcOtherPlayer = EntityArgument.getPlayer(context, "player");
Player otherPlayer = PlayerUtil.getFactoryPlayer(mcOtherPlayer);
Player factoryExecutor = null;
try {
factoryExecutor = PlayerUtil.getFactoryPlayer(executor.getPlayerOrException());
} catch (Exception ignored) { }
PlayerData data = PlayerDataManager.get(mcOtherPlayer);
if(type.equalsIgnoreCase("ban")) {
if(((CoreSavedPlayerData)data.savedData).isReportBanned()) {
context.getSource().sendMessage(Component.text("That player is already report banned!", ChatFormat.failColor));
if(data.savedData.isReportBanned()) {
if(factoryExecutor != null) {
factoryExecutor.sendMessage(Component.text("That player is already report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
} else {
executor.sendFailure(new TextComponent("That player is already report banned!"));
}
return 0;
}
((CoreSavedPlayerData)data.savedData).setReportBanned(true);
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have report banned ", ChatFormat.normalColor)
.append(Component.text(otherPlayer.getRawName(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
.append(Component.text(".", ChatFormat.normalColor))
)
);
data.savedData.setReportBanned(true);
if(factoryExecutor != null) {
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have report banned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
.append(Component.text(".")).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
)
);
} else {
executor.sendSuccess(LegacyChatFormat.format("You have report banned {}.", otherPlayer.getRawName()), true);
}
return Command.SINGLE_SUCCESS;
}
if(type.equalsIgnoreCase("unban") || type.equalsIgnoreCase("pardon")) {
if(!((CoreSavedPlayerData)data.savedData).isReportBanned()) {
context.getSource().sendMessage(Component.text("That player is not report banned!", ChatFormat.failColor));
if(!data.savedData.isReportBanned()) {
if(factoryExecutor != null) {
factoryExecutor.sendMessage(Component.text("That player is not report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
} else {
executor.sendFailure(new TextComponent("That player is not report banned!"));
}
return 0;
}
((CoreSavedPlayerData)data.savedData).setReportBanned(false);
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have report unbanned ", ChatFormat.normalColor))
.append(Component.text(otherPlayer.getRawName(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
.append(Component.text(".", ChatFormat.normalColor))
);
data.savedData.setReportBanned(false);
if(factoryExecutor != null) {
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have report unbanned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
.append(Component.text(".")).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
)
);
} else {
executor.sendSuccess(LegacyChatFormat.format("You have report unbanned {}.", otherPlayer.getRawName()), true);
}
return Command.SINGLE_SUCCESS;
}
context.getSource().sendMessage(Component.text("Invalid argument", ChatFormat.failColor));
if(factoryExecutor != null) {
factoryExecutor.sendMessage(Component.text("Invalid argument").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
} else {
executor.sendFailure(new TextComponent("Invalid argument!"));
}
return 0;
return Command.SINGLE_SUCCESS;
}))
)
@@ -1,31 +0,0 @@
package com.nexia.core.commands.staff;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class SudoCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("sudo")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.sudo"))
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("command", StringArgumentType.greedyString())
.executes(context -> SudoCommand.execute(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "command")))))
);
}
private static int execute(CommandContext<CommandSourceInfo> context, ServerPlayer player, String command) {
NexiaPlayer nexiaPlayer = new NexiaPlayer(player);
nexiaPlayer.runCommand(command, 4, false);
return 0;
}
}
@@ -1,40 +1,42 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.BanHandler;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.GameProfileArgument;
import java.util.Collection;
public class TempBanCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("tempban")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
.then(CommandUtils.argument("duration", StringArgumentType.word())
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
.executes(context -> TempBanCommand.ban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("tempban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.then(Commands.argument("duration", StringArgumentType.word())
.then(Commands.argument("reason", StringArgumentType.greedyString())
.executes(context -> TempBanCommand.ban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
)
));
}
public static int ban(CommandSourceInfo sender, Collection<GameProfile> collection, String reason, String durationArg) {
public static int ban(CommandSourceStack sender, Collection<GameProfile> collection, String reason, String durationArg) {
int durationInSeconds;
try {
durationInSeconds = BanHandler.parseTimeArg(durationArg);
} catch (Exception e) {
sender.sendMessage(ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
);
PlayerUtil.safeSendMessage(sender, LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"), ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)), false);
return 1;
}
@@ -1,61 +1,79 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.CommandDispatcher;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.GameProfileArgument;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.UserBanList;
import java.util.Collection;
public class UnBanCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("unban")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ServerTime.minecraftServer.getPlayerList().getBans().getUserList()), builder)))
.executes(context -> UnBanCommand.unban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false))))
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("unban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((context.getSource()).getServer().getPlayerList().getBans().getUserList(), builder)))
.executes(context -> UnBanCommand.unban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player")))
)
);
dispatcher.register(CommandUtils.literal("pardon")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ServerTime.minecraftServer.getPlayerList().getBans().getUserList()), builder)))
.executes(context -> UnBanCommand.unban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false))))
dispatcher.register(Commands.literal("pardon")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((context.getSource()).getServer().getPlayerList().getBans().getUserList(), builder)))
.executes(context -> UnBanCommand.unban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player")))
)
);
}
public static int unban(CommandSourceInfo context, Collection<GameProfile> collection) {
public static int unban(CommandSourceStack context, Collection<GameProfile> collection) {
UserBanList userBanList = ServerTime.minecraftServer.getPlayerList().getBans();
int i = 0;
ServerPlayer player = null;
try {
player = context.getPlayerOrException();
} catch (Exception ignored){ }
for (GameProfile gameProfile : collection) {
if (userBanList.isBanned(gameProfile)) {
userBanList.remove(gameProfile);
++i;
if(player != null){
PlayerUtil.getFactoryPlayer(player).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have unbanned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(gameProfile.getName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
context.getSender().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have unbanned ", ChatFormat.normalColor))
.append(Component.text(gameProfile.getName(), ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor))
);
);
} else {
context.sendSuccess(LegacyChatFormat.format("{b1}You have unbanned {b2}{}{b1}.", gameProfile.getName()), true);
}
}
}
if (i == 0) {
context.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("That player is not banned.", ChatFormat.failColor))
);
if(player != null){
PlayerUtil.getFactoryPlayer(player).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("That player is not banned.").color(ChatFormat.failColor))
);
} else {
context.sendSuccess(LegacyChatFormat.formatFail("That player is not banned."), false);
}
} else {
return i;
@@ -1,28 +1,31 @@
package com.nexia.core.commands.staff;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.nexia.nexus.api.command.CommandUtils;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.GamemodeBanHandler;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class UnGamemodeBanCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("ungamemodeban")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("ungamemodeban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("gamemode", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((PlayerGameMode.stringPlayerGameModes), builder)))
.executes(UnGamemodeBanCommand::unBan)
)
@@ -30,20 +33,34 @@ public class UnGamemodeBanCommand {
);
}
public static int unBan(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
CommandSourceInfo sender = context.getSource();
public static int unBan(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
CommandSourceStack sender = context.getSource();
ServerPlayer mcExecutor = null;
Player executor = null;
try {
mcExecutor = sender.getPlayerOrException();
} catch (Exception ignored){ }
if(mcExecutor != null) {
executor = PlayerUtil.getFactoryPlayer(mcExecutor);
}
PlayerGameMode gameMode = PlayerGameMode.identifyGamemode(StringArgumentType.getString(context, "gamemode"));
if(gameMode == null) {
sender.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid gamemode!", ChatFormat.normalColor))
);
if(executor != null) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid gamemode!"));
}
return 1;
}
GamemodeBanHandler.tryUnGamemodeBan(sender, new NexiaPlayer(context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false))), gameMode);
GamemodeBanHandler.tryUnGamemodeBan(sender, EntityArgument.getPlayer(context, "player"), gameMode);
return 1;
}
@@ -1,30 +1,30 @@
package com.nexia.core.commands.staff;
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.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.commands.CommandUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.selector.EntitySelector;
import net.minecraft.server.level.ServerPlayer;
public class UnMuteCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("unmute")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.mute", 1))
.then(CommandUtils.argument("player", EntityArgument.player())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("unmute")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.mute", 1))
.then(Commands.argument("player", EntityArgument.player())
.executes(UnMuteCommand::unMute)
)
);
}
public static int unMute(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
CommandSourceInfo sender = context.getSource();
ServerPlayer muted = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
public static int unMute(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
CommandSourceStack sender = context.getSource();
ServerPlayer muted = EntityArgument.getPlayer(context, "player");
PlayerMutes.unMute(sender, muted);
@@ -1,29 +1,30 @@
package com.nexia.core.commands.staff;
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.core.utilities.commands.CommandUtil;
import com.nexia.core.utilities.player.BanHandler;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.GameProfileArgument;
public class UnTempBanCommand {
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("untempban")
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("untempban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.executes(UnTempBanCommand::unBan)
)
);
}
public static int unBan(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
CommandSourceInfo sender = context.getSource();
public static int unBan(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
CommandSourceStack sender = context.getSource();
BanHandler.tryUnBan(sender, context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)));
BanHandler.tryUnBan(sender, GameProfileArgument.getGameProfiles(context, "player"));
return 1;
}
@@ -7,18 +7,20 @@ import com.nexia.minigames.games.bedwars.players.BwTeam;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
public class BwReloadTeamColorsCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("bwreloadteamcolors")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.bwreloadteamcolors", 3))
.executes(BwReloadTeamColorsCommand::run)
);
dispatcher.register(Commands.literal("bwreloadteamcolors").executes(BwReloadTeamColorsCommand::run)
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.bwreloadteamcolors", 3)));
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
BwTeam.reloadPlayerTeamColors();
ServerPlayer player = context.getSource().getPlayerOrException();
BwTeam.reloadPlayerTeamColors(player);
return 1;
}
@@ -7,8 +7,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.misc.RandomUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.uhc.utilities.UhcFfaAreas;
import com.nexia.ffa.uhc.utilities.FfaAreas;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsMap;
import io.github.blumbo.inventorymerger.saving.SavableInventory;
@@ -24,9 +23,16 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Difficulty;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.dimension.DimensionType;
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
import java.io.FileWriter;
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
public class DevExperimentalCommandsCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("devexperimentalcmds")
@@ -52,10 +58,26 @@ public class DevExperimentalCommandsCommand {
if(name.contains("-")) name = name.split("-")[1];
if(argument.contains("cffa")){
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("ffa", name)).location(), FfaUtil.ffaWorldConfig).asWorld();
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("ffa", name)).location(), (
new RuntimeWorldConfig()
.setDimensionType(DimensionType.OVERWORLD_LOCATION)
.setGenerator(getChunkGenerator(Biomes.PLAINS))
.setDifficulty(Difficulty.HARD)
.setGameRule(GameRules.RULE_KEEPINVENTORY, true)
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
.setGameRule(GameRules.RULE_WEATHER_CYCLE, false)
.setGameRule(GameRules.RULE_DAYLIGHT, true)
.setGameRule(GameRules.RULE_DO_IMMEDIATE_RESPAWN, true)
.setGameRule(GameRules.RULE_DOMOBSPAWNING, false)
.setGameRule(GameRules.RULE_SHOWDEATHMESSAGES, false)
.setGameRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS, false)
.setGameRule(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK, true)
.setGameRule(GameRules.RULE_DROWNING_DAMAGE, true)
.setGameRule(GameRules.RULE_SPAWN_RADIUS, 0))).asWorld();
player.teleportTo(level, 0, 80, 0, 0, 0);
} else if(argument.equalsIgnoreCase("rluhc")) {
UhcFfaAreas.resetMap(true);
FfaAreas.resetMap(true);
player.sendMessage(LegacyChatFormat.format("Reloaded UHC Map."), Util.NIL_UUID);
} else if(argument.contains("swmap")) {
SkywarsMap map = SkywarsMap.identifyMap(name);
@@ -39,10 +39,7 @@ public class ForceGameEndCommand {
case "oitc" -> OitcGame.endGame(null);
case "skywars" -> SkywarsGame.winNearestCenter();
case "bedwars" -> BwGame.endBedwars();
default -> {
context.getSource().sendFailure(new TextComponent("Invalid game!"));
return 0;
}
default -> context.getSource().sendFailure(new TextComponent("Invalid game!"));
}
context.getSource().sendSuccess(new TextComponent("Game ended (if valid)."), false);
@@ -6,7 +6,6 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.base.player.NexiaPlayer;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
@@ -75,7 +74,7 @@ public class LoadInventoryCommand {
context.getSource().sendFailure(LegacyChatFormat.format("Unable to load the content of the inventory with the name '{}' in '{}'.", inventory, type));
return 0;
} else {
InventoryUtil.loadInventory(new NexiaPlayer(player), type, inventory);
InventoryUtil.loadInventory(player, type, inventory);
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully loaded '{}' in '{}' to " + ((isContextPlayer) ? "your inventory" : "the inventory of " + player.getScoreboardName()) + ".", inventory, type), false);
@@ -3,7 +3,6 @@ package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.ffa.sky.utilities.SkyFfaAreas;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
@@ -31,7 +30,7 @@ public class ProtectionMapCommand {
public static int ffa_sky(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
SkyFfaAreas.createProtectionMap(player);
com.nexia.ffa.sky.utilities.FfaAreas.createProtectionMap(player);
return 1;
}
}
@@ -3,11 +3,9 @@ package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
@@ -34,7 +32,7 @@ public class SkipQueueCommand {
private static int currentGamemode(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player.getUUID())).gameMode;
PlayerGameMode gameMode = PlayerDataManager.get(player).gameMode;
if(gameMode.equals(PlayerGameMode.SKYWARS)) return skywars(context);
if(gameMode.equals(PlayerGameMode.BEDWARS)) return bedwars(context);
@@ -11,10 +11,4 @@ public class ModConfig implements ConfigData {
public String serverType = "";
public boolean debugMode = false;
public String host = "";
public String database = "";
public String username = "";
public String password = "";
public int port = 27017;
}
@@ -1,42 +1,50 @@
package com.nexia.core.games.util;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.player.BanHandler;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.GamemodeBanHandler;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.pos.EntityPos;
import com.nexia.core.utilities.ranks.NexiaRank;
import com.nexia.core.utilities.world.WorldUtil;
import com.nexia.ffa.base.BaseFfaUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.FfaGameMode;
import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.classic.utilities.FfaAreas;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import com.nexia.ffa.kits.utilities.FfaKitsUtil;
import com.nexia.ffa.sky.utilities.FfaSkyUtil;
import com.nexia.ffa.uhc.utilities.FfaUhcUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.bedwars.util.BwScoreboard;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.football.FootballGameMode;
import com.nexia.minigames.games.football.util.player.FootballPlayerData;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.oitc.OitcGameMode;
import com.nexia.minigames.games.oitc.util.player.OITCPlayerData;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsGameMode;
import com.nexia.minigames.games.skywars.util.player.SkywarsPlayerData;
import com.nexia.nexus.api.world.World;
import com.nexia.nexus.api.world.nbt.NBTObject;
import com.nexia.nexus.api.world.nbt.NBTValue;
import com.nexia.nexus.api.world.types.Minecraft;
import com.nexia.nexus.api.world.util.Location;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import org.json.simple.JSONObject;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import static com.nexia.core.utilities.player.BanHandler.getBanTime;
@@ -45,30 +53,18 @@ public class LobbyUtil {
public static String[] statsGameModes = {"FFA CLASSIC", "SKY FFA", "UHC FFA", "KIT FFA", "BEDWARS", "OITC", "DUELS", "SKYWARS", "FOOTBALL"};
public static ServerLevel lobbyWorld = null;
public static World nexusLobbyWorld = null;
public static Location nexusLobbyLocation = null;
public static EntityPos lobbySpawn = new EntityPos(0.5, 65, 0.5, 0, 0);
public static EntityPos lobbySpawn = new EntityPos(0, 65, 0, 0, 0);
public static boolean isLobbyWorld(Level level) {
return level.dimension() == Level.OVERWORLD;
}
public static boolean isLobbyWorld(World world) {
return world.getIdentifier().pure().equals("minecraft:overworld");
}
public static void setLobbyWorld(MinecraftServer server) {
for (ServerLevel level : server.getAllLevels()) {
if (isLobbyWorld(level)) {
lobbyWorld = level;
nexusLobbyWorld = WorldUtil.getWorld(level);
break;
}
}
nexusLobbyLocation = new Location(lobbySpawn.x, lobbySpawn.y, lobbySpawn.z, lobbySpawn.yaw, lobbySpawn.pitch, nexusLobbyWorld);
}
// Players with the tag will not be affected by server rank teams given by server datapack
@@ -83,6 +79,11 @@ public class LobbyUtil {
public static String[] removedTags = {
PlayerGameMode.BEDWARS.tag,
"bedwars",
PlayerGameMode.FFA.tag,
"ffa_classic",
"ffa_kits",
"ffa_sky",
"ffa_uhc",
PlayerGameMode.FOOTBALL.tag,
"in_football_game",
"duels",
@@ -92,98 +93,138 @@ public class LobbyUtil {
"in_kitroom",
NO_RANK_DISPLAY_TAG,
NO_SATURATION_TAG,
NO_FALL_DAMAGE_TAG,
NO_DAMAGE_TAG
NO_FALL_DAMAGE_TAG
};
public static void returnToLobby(NexiaPlayer player, boolean tp) {
player.leaveAllGames();
player.reset(true, Minecraft.GameMode.ADVENTURE);
public static void leaveAllGames(ServerPlayer minecraftPlayer, boolean tp) {
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
if (BwUtil.isInBedWars(minecraftPlayer)) {
BwPlayerEvents.leaveInBedWars(minecraftPlayer);
}
else if (FfaUtil.isFfaPlayer(minecraftPlayer)) {
FfaUtil.leaveOrDie(minecraftPlayer, minecraftPlayer.getLastDamageSource(), true);
}
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.LOBBY) {
DuelGameHandler.leave(minecraftPlayer, false);
}
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.OITC) {
OitcGame.leave(minecraftPlayer);
}
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) {
SkywarsGame.leave(minecraftPlayer);
}
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.FOOTBALL) {
FootballGame.leave(minecraftPlayer);
}
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, minecraftPlayer, true);
BwScoreboard.removeScoreboardFor(minecraftPlayer);
minecraftPlayer.setGlowing(false);
minecraftPlayer.setGameMode(GameType.ADVENTURE);
for(String tag : LobbyUtil.removedTags) {
if(player.hasTag(tag)) player.removeTag(tag);
}
returnToLobby(minecraftPlayer, tp);
}
public static void returnToLobby(ServerPlayer minecraftPlayer, boolean tp) {
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
for(String tag : LobbyUtil.removedTags) {
if(player.hasTag(tag)) player.removeTag(tag);
}
minecraftPlayer.setInvulnerable(false);
minecraftPlayer.abilities.mayfly = false;
minecraftPlayer.abilities.flying = false;
Objects.requireNonNull(minecraftPlayer.getAttribute(Attributes.KNOCKBACK_RESISTANCE)).setBaseValue(0.0);
minecraftPlayer.onUpdateAbilities();
minecraftPlayer.setGlowing(false);
PlayerUtil.resetHealthStatus(player);
minecraftPlayer.setGameMode(GameType.ADVENTURE);
player.getInventory().clear();
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
minecraftPlayer.getEnderChestInventory().clearContent();
minecraftPlayer.setExperiencePoints(0);
minecraftPlayer.setExperienceLevels(0);
// Duels shit
player.addTag("duels");
DuelGameHandler.leave(player, false);
DuelGameHandler.leave(minecraftPlayer, false);
if (tp) {
player.setRespawnPosition(nexusLobbyLocation, lobbySpawn.yaw, true, false);
player.teleport(nexusLobbyLocation);
minecraftPlayer.setRespawnPosition(lobbyWorld.dimension(), lobbySpawn.toBlockPos(), lobbySpawn.yaw, true, false);
minecraftPlayer.teleportTo(lobbyWorld, lobbySpawn.x, lobbySpawn.y, lobbySpawn.z, lobbySpawn.pitch, lobbySpawn.yaw);
if(player.hasPrefix(NexiaRank.SUPPORTER)) {
player.setAbleToFly(true);
if(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
minecraftPlayer.abilities.mayfly = true;
minecraftPlayer.onUpdateAbilities();
}
LobbyUtil.giveItems(player);
LobbyUtil.giveItems(minecraftPlayer);
}
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.LOBBY;
minecraftPlayer.connection.send(new ClientboundStopSoundPacket());
player.setBedrockBridging(true);
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.LOBBY;
player.removeTag(LobbyUtil.NO_RANK_DISPLAY_TAG);
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
ServerTime.minecraftServer.getPlayerList().sendPlayerPermissionLevel(minecraftPlayer);
}
public static void giveItems(NexiaPlayer player) {
public static void giveItems(ServerPlayer minecraftPlayer) {
ItemStack compass = new ItemStack(Items.COMPASS);
compass.setHoverName(new TextComponent("§eGamemode Selector"));
ItemDisplayUtil.addGlint(compass);
ItemDisplayUtil.addLore(compass, "§eRight click §7to open the menu.", 0);
NBTObject hideAttrubtesNBTObject = NBTObject.create();
hideAttrubtesNBTObject.set("HideFlags", NBTValue.of(39));
ItemStack nameTag = new ItemStack(Items.NAME_TAG);
nameTag.setHoverName(new TextComponent("§ePrefix Selector"));
ItemDisplayUtil.addGlint(nameTag);
ItemDisplayUtil.addLore(nameTag, "§eRight click §7to open the menu.", 0);
NBTObject unbreakableNBTObject = hideAttrubtesNBTObject.copy();
unbreakableNBTObject.set("Unbreakable", NBTValue.of(1));
ItemStack queueSword = new ItemStack(Items.IRON_SWORD);
queueSword.setHoverName(new TextComponent("§eDuel Sword"));
ItemDisplayUtil.addGlint(queueSword);
ItemDisplayUtil.addLore(queueSword, "§eRight click §7to queue menu.", 0);
ItemDisplayUtil.addLore(queueSword, "§eHit a player §7to duel them.", 1);
com.nexia.nexus.api.world.item.ItemStack compass = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.COMPASS);
compass.setItemNBT(hideAttrubtesNBTObject.copy());
compass.setLore(Component.text("Right click to open the gamemode selector menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
compass.setDisplayName(Component.text("Gamemode Selector", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
ItemStack teamSword = new ItemStack(Items.IRON_AXE);
teamSword.setHoverName(new TextComponent("§eTeam Axe"));
ItemDisplayUtil.addGlint(teamSword);
ItemDisplayUtil.addLore(teamSword, "§eRight click §7to list the team.", 0);
ItemDisplayUtil.addLore(teamSword, "§eHit a player §7to invite them to your team.", 1);
ItemStack customDuelSword = new ItemStack(Items.DIAMOND_SWORD);
customDuelSword.setHoverName(new TextComponent("§eCustom Duel Sword"));
ItemDisplayUtil.addGlint(customDuelSword);
ItemDisplayUtil.addLore(customDuelSword, "§eHit a player §7to duel them in your custom kit.", 0);
com.nexia.nexus.api.world.item.ItemStack nameTag = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.NAME_TAG);
nameTag.setItemNBT(hideAttrubtesNBTObject.copy());
nameTag.setLore(Component.text("Right click to open the prefix selector menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
nameTag.setDisplayName(Component.text("Prefix Selector", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
com.nexia.nexus.api.world.item.ItemStack queueSword = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.IRON_SWORD);
queueSword.setItemNBT(unbreakableNBTObject.copy());
queueSword.setLore(new ArrayList<>(Arrays.asList(
Component.text("Right click to open the queue menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false),
Component.text("Hit a player to duel them.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false)
)));
queueSword.setDisplayName(Component.text("Duel Sword", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
com.nexia.nexus.api.world.item.ItemStack teamSword = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.IRON_AXE);
teamSword.setItemNBT(unbreakableNBTObject.copy());
teamSword.setLore(new ArrayList<>(Arrays.asList(
Component.text("Right click to list the team you're in.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false),
Component.text("Hit a player to invite them to your team.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false)
)));
teamSword.setDisplayName(Component.text("Team Axe", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
com.nexia.nexus.api.world.item.ItemStack customDuelSword = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.DIAMOND_SWORD);
customDuelSword.setItemNBT(unbreakableNBTObject.copy());
customDuelSword.setLore(Component.text("Hit a player to duel them in your custom kit.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
customDuelSword.setDisplayName(Component.text("Custom Duel Sword", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
if(player.hasPrefix(NexiaRank.SUPPORTER)) {
com.nexia.nexus.api.world.item.ItemStack elytra = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.ELYTRA);
elytra.setItemNBT(unbreakableNBTObject.copy());
elytra.setLore(Component.text("Thanks for supporting the server!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false));
elytra.setDisplayName(Component.text("Supporter Elytra", ChatFormat.brandColor2).decorate(ChatFormat.bold).decoration(ChatFormat.italic, false));
player.getInventory().setItemStack(38, elytra);
if(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
ItemStack elytra = new ItemStack(Items.ELYTRA);
elytra.setHoverName(new TextComponent("§5§lSupporter Elytra"));
ItemDisplayUtil.addGlint(elytra);
elytra.getOrCreateTag().putBoolean("Unbreakable", true);
ItemDisplayUtil.addLore(elytra, "§7Thanks for supporting the server!", 0);
elytra.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE);
minecraftPlayer.setItemSlot(EquipmentSlot.CHEST, elytra);
}
player.getInventory().setItemStack(0, customDuelSword); // 1st slot
player.getInventory().setItemStack(4, compass); // middle slot
player.getInventory().setItemStack(3, nameTag); // left
player.getInventory().setItemStack(5, queueSword); // right
player.getInventory().setItemStack(8, teamSword); // like right right not right
player.refreshInventory();
minecraftPlayer.setSlot(0, customDuelSword); // 1st slot
minecraftPlayer.setSlot(4, compass); //middle slot
minecraftPlayer.setSlot(3, nameTag); //left
minecraftPlayer.setSlot(5, queueSword); //right
minecraftPlayer.setSlot(8, teamSword); // like right right not right
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
}
public static boolean checkGameModeBan(NexiaPlayer player, String game) {
public static boolean checkGameModeBan(Player factoryPlayer, ServerPlayer player, String game) {
ArrayList<PlayerGameMode> bannedGameModes = GamemodeBanHandler.getBannedGameModes(player);
if(bannedGameModes.isEmpty()) {
return false;
@@ -192,27 +233,31 @@ public class LobbyUtil {
for(PlayerGameMode gameMode : bannedGameModes) {
if(game.toLowerCase().contains(gameMode.id.toLowerCase())) {
JSONObject banJSON = GamemodeBanHandler.getBanList(player.getUUID(), gameMode);
JSONObject banJSON = GamemodeBanHandler.getBanList(player.getStringUUID(), gameMode);
if (banJSON != null) {
LocalDateTime banTime = getBanTime((String) banJSON.get("duration"));
if(LocalDateTime.now().isAfter(banTime)) {
GamemodeBanHandler.removeBanFromList(player.getUUID(), gameMode);
GamemodeBanHandler.removeBanFromList(player.getStringUUID(), gameMode);
return false;
} else {
player.sendNexiaMessage(
Component.text("You are gamemode (" + gameMode.name + ") banned for ", ChatFormat.Minecraft.white)
.append(Component.text(BanHandler.banTimeToText(banTime), ChatFormat.brandColor2))
.append(Component.text(".\nReason: ", ChatFormat.Minecraft.white))
.append(Component.text((String) banJSON.get("reason"), ChatFormat.brandColor2))
factoryPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You are gamemode (" + gameMode.name + ") banned for ").decoration(ChatFormat.bold, false))
.append(Component.text(BanHandler.banTimeToText(banTime)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".\nReason: ").decoration(ChatFormat.bold, false))
.append(Component.text((String) banJSON.get("reason")).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
);
return true;
}
} else {
player.sendNexiaMessage("You are gamemode (%s) banned!", gameMode.name);
factoryPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You are gamemode (" + gameMode.name + ") banned!"))
);
}
LobbyUtil.returnToLobby(player, true);
factoryPlayer.runCommand("/hub");
return true;
}
@@ -221,88 +266,146 @@ public class LobbyUtil {
return false;
}
public static void sendGame(NexiaPlayer player, String game, boolean message, boolean tp) {
public static void sendGame(ServerPlayer minecraftPlayer, String game, boolean message, boolean tp){
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
if (checkGameModeBan(player, game)) {
if(checkGameModeBan(player, minecraftPlayer, game)) {
return;
}
player.setBedrockBridging(true);
minecraftPlayer.setInvulnerable(false);
for (BaseFfaUtil util : BaseFfaUtil.ffaUtils) {
if (game.equalsIgnoreCase(util.getNameLowercase() + " ffa") && !util.canGoToSpawn(player)) {
player.sendNexiaMessage("You must be fully healed to go to spawn!");
return;
}
minecraftPlayer.abilities.mayfly = false;
minecraftPlayer.onUpdateAbilities();
if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
(game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
(game.equalsIgnoreCase("sky ffa") && !FfaSkyUtil.canGoToSpawn(minecraftPlayer) ||
(game.equalsIgnoreCase("uhc ffa") && !FfaUhcUtil.canGoToSpawn(minecraftPlayer))))) {
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
return;
}
if (player.hasTag("duels")) {
if(player.hasTag("duels")) {
player.removeTag("duels");
DuelGameHandler.leave(player, true);
DuelGameHandler.leave(minecraftPlayer, true);
}
player.reset(true, Minecraft.GameMode.ADVENTURE);
player.leaveAllGames();
if (!LobbyUtil.isLobbyWorld(minecraftPlayer.getLevel())) {
LobbyUtil.leaveAllGames(minecraftPlayer, false);
} else{
PlayerUtil.resetHealthStatus(player);
minecraftPlayer.setGameMode(GameType.ADVENTURE);
if (game.equalsIgnoreCase("classic ffa") ||
player.getInventory().clear();
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
minecraftPlayer.getEnderChestInventory().clearContent();
minecraftPlayer.connection.send(new ClientboundStopSoundPacket());
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
player.removeTag("duels");
player.removeTag(LobbyUtil.NO_SATURATION_TAG);
}
if(game.equalsIgnoreCase("classic ffa") ||
game.equalsIgnoreCase("kits ffa") ||
game.equalsIgnoreCase("pot ffa") ||
game.equalsIgnoreCase("sky ffa") ||
game.equalsIgnoreCase("uhc ffa")) {
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.FFA;
if (message) { player.sendActionBarMessage(Component.text("You have joined §8🗡 §7§lFFA §b🔱")); }
player.addTag(FfaUtil.FFA_TAG);
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.FFA;
if(message){ player.sendActionBarMessage(Component.text("You have joined §8🗡 §7§lFFA §b🔱")); }
}
for (BaseFfaUtil util : BaseFfaUtil.ffaUtils) {
if (game.equalsIgnoreCase(util.getNameLowercase() + " ffa")) {
player.addTag(NO_FALL_DAMAGE_TAG);
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).ffaGameMode = util.getGameMode();
if (tp) {
player.setRespawnPosition(util.getRespawnLocation(), util.getSpawn().yaw, true, false);
}
util.join(player, tp);
util.clearProjectiles(player);
if(game.equalsIgnoreCase("classic ffa")){
player.addTag("ffa_classic");
FfaClassicUtil.wasInSpawn.add(player.getUUID());
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.CLASSIC;
if(tp){
minecraftPlayer.teleportTo(FfaAreas.ffaWorld, FfaAreas.spawn.x, FfaAreas.spawn.y, FfaAreas.spawn.z, FfaAreas.spawn.yaw, FfaAreas.spawn.pitch);
minecraftPlayer.setRespawnPosition(FfaAreas.ffaWorld.dimension(), FfaAreas.spawn.toBlockPos(), FfaAreas.spawn.yaw, true, false);
}
FfaClassicUtil.clearThrownTridents(minecraftPlayer);
FfaClassicUtil.setInventory(minecraftPlayer);
}
if (game.equalsIgnoreCase("classic ffa")) {
FfaClassicUtil.INSTANCE.setInventory(player);
if(game.equalsIgnoreCase("sky ffa")){
player.addTag("ffa_sky");
FfaSkyUtil.wasInSpawn.add(player.getUUID());
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.SKY;
if(tp){
FfaSkyUtil.sendToSpawn(minecraftPlayer);
minecraftPlayer.setRespawnPosition(com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.sky.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.sky.utilities.FfaAreas.spawn.yaw, true, false);
}
FfaSkyUtil.joinOrRespawn(minecraftPlayer);
}
if (game.equalsIgnoreCase("bedwars")) {
if(game.equalsIgnoreCase("uhc ffa")){
player.addTag("ffa_uhc");
FfaUhcUtil.wasInSpawn.add(player.getUUID());
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.UHC;
if(tp){
FfaUhcUtil.sendToSpawn(minecraftPlayer);
minecraftPlayer.setRespawnPosition(com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.yaw, true, false);
}
FfaUhcUtil.clearArrows(minecraftPlayer);
FfaUhcUtil.clearTrident(minecraftPlayer);
}
if(game.equalsIgnoreCase("kits ffa")){
player.addTag("ffa_kits");
FfaKitsUtil.wasInSpawn.add(player.getUUID());
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.KITS;
if(tp){
FfaKitsUtil.sendToSpawn(minecraftPlayer);
minecraftPlayer.setRespawnPosition(com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.kits.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.kits.utilities.FfaAreas.spawn.yaw, true, false);
}
FfaKitsUtil.clearThrownTridents(minecraftPlayer);
FfaKitsUtil.clearArrows(minecraftPlayer);
FfaKitsUtil.clearSpectralArrows(minecraftPlayer);
}
if(game.equalsIgnoreCase("bedwars")){
if(message){ player.sendActionBarMessage(Component.text("You have joined §b\uD83E\uDE93 §c§lBedwars §e⚡"));}
BwPlayerEvents.tryToJoin(player, false);
BwPlayerEvents.tryToJoin(minecraftPlayer, false);
}
if (game.equalsIgnoreCase("duels")) {
LobbyUtil.returnToLobby(player, tp);
if(game.equalsIgnoreCase("duels")){
LobbyUtil.leaveAllGames(minecraftPlayer, tp);
if(message){
player.sendActionBarMessage(Component.text("You have joined §f☯ §c§lDuels §7\uD83E\uDE93"));
player.sendNexiaMessage("Duels has now moved here. (main hub)");
player.sendMessage(Component.text("Meaning you can now use /duel, /queue and /spectate inside of the normal hub WITHOUT going to duels!"));
player.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Duels has now moved here. (main hub)").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
player.sendMessage(Component.text("Meaning you can now use /duel, /queue and /spectate inside of the normal hub WITHOUT going to duels!").decoration(ChatFormat.bold, false));
}
}
if(game.equalsIgnoreCase("oitc")){
player.addTag(OitcGame.OITC_TAG);
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.OITC;
OitcGame.death(player, null);
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.OITC;
OitcGame.death(minecraftPlayer, minecraftPlayer.getLastDamageSource());
((OITCPlayerData)PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(player)).gameMode = OitcGameMode.LOBBY;
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.get(minecraftPlayer).gameMode = OitcGameMode.LOBBY;
OitcGame.joinQueue(player);
OitcGame.joinQueue(minecraftPlayer);
if(message){player.sendActionBarMessage(Component.text("You have joined §7\uD83D\uDDE1 §f§lOITC §7\uD83C\uDFF9"));}
}
if(game.equalsIgnoreCase("football")){
player.addTag(FootballGame.FOOTBALL_TAG);
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.FOOTBALL;
((FootballPlayerData)PlayerDataManager.getDataManager(NexiaCore.FOOTBALL_DATA_MANAGER).get(player)).gameMode = FootballGameMode.LOBBY;
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.FOOTBALL;
com.nexia.minigames.games.football.util.player.PlayerDataManager.get(minecraftPlayer).gameMode = FootballGameMode.LOBBY;
FootballGame.joinQueue(player);
FootballGame.joinQueue(minecraftPlayer);
if(message){player.sendActionBarMessage(Component.text("You have joined §7○ §7§lFootball §7\uD83D\uDDE1"));}
}
@@ -310,12 +413,12 @@ public class LobbyUtil {
if(game.equalsIgnoreCase("skywars")){
player.addTag(PlayerGameMode.SKYWARS.tag);
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.SKYWARS;
SkywarsGame.death(player, null);
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.SKYWARS;
SkywarsGame.death(minecraftPlayer, minecraftPlayer.getLastDamageSource());
((SkywarsPlayerData)PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player)).gameMode = SkywarsGameMode.LOBBY;
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(minecraftPlayer).gameMode = SkywarsGameMode.LOBBY;
SkywarsGame.joinQueue(player);
SkywarsGame.joinQueue(minecraftPlayer);
if(message){player.sendActionBarMessage(Component.text("You have joined §7☐ §aSkywars §7\uD83D\uDDE1"));}
}
@@ -1,5 +1,6 @@
package com.nexia.core.games.util;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayers;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
@@ -25,7 +26,7 @@ public class PlayerGameMode {
public static final PlayerGameMode SKYWARS = new PlayerGameMode("skywars", "Skywars", SkywarsGame.SKYWARS_TAG);
public static final PlayerGameMode OITC = new PlayerGameMode("oitc", "OITC", OitcGame.OITC_TAG);
public static final PlayerGameMode FFA = new PlayerGameMode("ffa", "FFA", "ffa");
public static final PlayerGameMode FFA = new PlayerGameMode("ffa", "FFA", FfaUtil.FFA_TAG);
public static final PlayerGameMode FOOTBALL = new PlayerGameMode("football", "Football", FootballGame.FOOTBALL_TAG);
//public static final PlayerGameMode DUELS = new PlayerGameMode("duels");
@@ -46,10 +47,7 @@ public class PlayerGameMode {
if(playerGameMode.id.equalsIgnoreCase(gameMode)) return playerGameMode;
}
return null;
}
@Override
public String toString() {
return this.name;
}
}
+89 -116
View File
@@ -1,21 +1,12 @@
package com.nexia.core.gui;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.ffa.kits.utilities.KitFfaAreas;
import com.nexia.ffa.pot.utilities.PotFfaAreas;
import com.nexia.ffa.sky.utilities.SkyFfaAreas;
import com.nexia.ffa.uhc.utilities.UhcFfaAreas;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.classic.utilities.ClassicFfaAreas;
import com.nexia.ffa.classic.utilities.FfaAreas;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
@@ -28,8 +19,6 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions;
public class PlayGUI extends SimpleGui {
@@ -44,70 +33,68 @@ public class PlayGUI extends SimpleGui {
}
}
private void setMainLayout(){
int players = ClassicFfaAreas.ffaWorld.players().size();
players = players + KitFfaAreas.ffaWorld.players().size();
players = players + PotFfaAreas.ffaWorld.players().size();
players = players + SkyFfaAreas.ffaWorld.players().size();
players = players + UhcFfaAreas.ffaWorld.players().size();
int players = FfaAreas.ffaWorld.players().size();
players = players + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size();
players = players + com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.players().size();
players = players + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size();
ItemStack ffa = new ItemStack(Items.NETHERITE_SWORD, 1);
ffa.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("FFA", ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false)));
ffa.setHoverName(new TextComponent("§3FFA"));
ItemDisplayUtil.addGlint(ffa);
ffa.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(ffa, "§5", 0);
ItemDisplayUtil.addLore(ffa, net.kyori.adventure.text.Component.text("Fight players in a huge landscape", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(ffa, net.kyori.adventure.text.Component.text("and be the best player.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(ffa, "§7Fight players in a huge landscape", 1);
ItemDisplayUtil.addLore(ffa, "§7be the best player.", 2);
ItemDisplayUtil.addLore(ffa, "§f", 3);
ItemDisplayUtil.addLore(ffa, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", players), ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false), 4);
ItemDisplayUtil.addLore(ffa, "§3◆ There are " + players + " people playing this gamemode.", 4);
ItemStack other = new ItemStack(Items.DRAGON_BREATH, 1);
other.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Other Games", ChatFormat.Minecraft.dark_purple).decoration(ChatFormat.italic, false)));
other.setHoverName(new TextComponent("§5Other Games"));
other.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(other, net.kyori.adventure.text.Component.text("Discover other games.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 0);
ItemDisplayUtil.addLore(other, "§7Discover other games.", 0);
ItemStack bedwars = new ItemStack(Items.RED_BED, 1);
bedwars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Bedwars", ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false)));
bedwars.setHoverName(new TextComponent("§cBedwars"));
ItemDisplayUtil.addGlint(bedwars);
bedwars.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(bedwars, "§5", 0);
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("Protect your bed and", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("destroy other opponent's beds, and", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("kill your opponents to win!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
ItemDisplayUtil.addLore(bedwars, "§7Protect your bed and", 1);
ItemDisplayUtil.addLore(bedwars, "§7destroy other's beds, kill your", 2);
ItemDisplayUtil.addLore(bedwars, "§7opponents to win!", 3);
ItemDisplayUtil.addLore(bedwars, "§f", 4);
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", BwAreas.bedWarsWorld.players().size()), ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false), 5);
ItemDisplayUtil.addLore(bedwars, "§c◆ There are " + BwAreas.bedWarsWorld.players().size() + " people playing this gamemode.", 5);
ItemStack skywars = new ItemStack(Items.GRASS_BLOCK, 1);
skywars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Skywars", ChatFormat.Minecraft.green).decoration(ChatFormat.italic, false)));
skywars.setHoverName(new TextComponent("§aSkywars"));
skywars.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(skywars, "§5", 0);
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text("Battle against others on", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text("sky islands and be the", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text("last one standing to win!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
ItemDisplayUtil.addLore(skywars, "§7Battle against others on", 1);
ItemDisplayUtil.addLore(skywars, "§7sky islands and be the", 2);
ItemDisplayUtil.addLore(skywars, "§7last one standing to win!", 3);
ItemDisplayUtil.addLore(skywars, "§f", 4);
ItemDisplayUtil.addLore(skywars, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", SkywarsGame.world.players().size()), ChatFormat.Minecraft.green).decoration(ChatFormat.italic, false), 5);
ItemDisplayUtil.addLore(skywars, "§a◆ There are " + SkywarsGame.world.players().size() + " people playing this gamemode.", 5);
ItemStack duels = new ItemStack(Items.NETHERITE_AXE, 1);
duels.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Duels", ChatFormat.Minecraft.blue).decoration(ChatFormat.italic, false)));
duels.setHoverName(new TextComponent("§9Duels"));
ItemDisplayUtil.addGlint(duels);
duels.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
int duelsPlayers = 0;
for(ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()) {
DuelGameMode gameMode = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(serverPlayer.getUUID())).gameMode;
DuelGameMode gameMode = PlayerDataManager.get(serverPlayer).gameMode;
if(gameMode != null && (gameMode != DuelGameMode.LOBBY && gameMode != DuelGameMode.SPECTATING)) duelsPlayers++;
}
ItemDisplayUtil.addLore(duels, "§5", 0);
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text("Duel against other people", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text("or play against people in teams", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text("with team duels!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
ItemDisplayUtil.addLore(duels, "§7Duel against other people", 1);
ItemDisplayUtil.addLore(duels, "§7or play against people in teams", 2);
ItemDisplayUtil.addLore(duels, "§7with team duels!", 3);
ItemDisplayUtil.addLore(duels, "§f", 4);
ItemDisplayUtil.addLore(duels, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", (LobbyUtil.lobbyWorld.players().size() + duelsPlayers)), ChatFormat.Minecraft.blue).decoration(ChatFormat.italic, false), 5);
ItemDisplayUtil.addLore(duels, "§9◆ There are " + (LobbyUtil.lobbyWorld.players().size() + duelsPlayers) + " people playing this gamemode.", 5);
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
@@ -123,71 +110,65 @@ public class PlayGUI extends SimpleGui {
public void setFFALayout(){
ItemStack classic = new ItemStack(Items.DIAMOND_SWORD, 1);
classic.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Classic FFA", ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false)));
classic.setHoverName(new TextComponent("§bClassic FFA"));
ItemDisplayUtil.addGlint(classic);
classic.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(classic, "§b", 0);
ItemDisplayUtil.addLore(classic, net.kyori.adventure.text.Component.text("The classic snapshot", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(classic, net.kyori.adventure.text.Component.text("Free For All gamemode.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(classic, "§7The classic snapshot", 1);
ItemDisplayUtil.addLore(classic, "§7Free For All gamemode.", 2);
ItemDisplayUtil.addLore(classic, "§f", 3);
ItemDisplayUtil.addLore(classic, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", ClassicFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false), 4);
ItemDisplayUtil.addLore(classic, "§b◆ There are " + FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemStack kit = new ItemStack(Items.CROSSBOW, 1);
kit.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Kit FFA", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
kit.setHoverName(new TextComponent("§fKit FFA"));
ItemDisplayUtil.addGlint(kit);
kit.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(kit, "§5", 0);
ItemDisplayUtil.addLore(kit, net.kyori.adventure.text.Component.text("Fight against players", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(kit, net.kyori.adventure.text.Component.text("with various kits!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(kit, "§7Fight against players", 1);
ItemDisplayUtil.addLore(kit, "§7with various kits!", 2);
ItemDisplayUtil.addLore(kit, "§f", 3);
ItemDisplayUtil.addLore(kit, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", KitFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 4);
ItemDisplayUtil.addLore(kit, "§f◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemStack pot = new ItemStack(Items.POTION, 1);
PotionUtils.setPotion(pot, Potions.HEALING);
pot.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Pot FFA", ChatFormat.Minecraft.light_purple).decoration(ChatFormat.italic, false)));
pot.setHoverName(new TextComponent("§eSky FFA"));
pot.getOrCreateTag().putInt("CustomPotionColor", 16771584);
ItemDisplayUtil.addGlint(pot);
pot.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(pot, "§5", 0);
ItemDisplayUtil.addLore(pot, net.kyori.adventure.text.Component.text("Free for All: ", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(pot, net.kyori.adventure.text.Component.text("Pot Edition™!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(pot, "§f", 3);
ItemDisplayUtil.addLore(pot, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", PotFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.light_purple).decoration(ChatFormat.italic, false), 4);
ItemDisplayUtil.addLore(pot, "§7Fight people on sky islands", 1);
ItemDisplayUtil.addLore(pot, "§7and drink Piss Juice™ to survive!", 2);
ItemDisplayUtil.addLore(pot, "§5", 3);
ItemDisplayUtil.addLore(pot, "§e◆ There are " + com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemStack skyffa = new ItemStack(Items.POTION, 1);
skyffa.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Sky FFA", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false)));
skyffa.getOrCreateTag().putInt("CustomPotionColor", 16771584);
ItemDisplayUtil.addGlint(skyffa);
skyffa.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(skyffa, "§5", 0);
ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text("Fight people on sky islands", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text("and drink Piss Juice™ to survive!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(skyffa, "§5", 3);
ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", SkyFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false), 4);
ItemStack uhc = new ItemStack(Items.GOLDEN_APPLE, 1);
uhc.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("UHC FFA", ChatFormat.goldColor).decoration(ChatFormat.italic, false)));
uhc.setHoverName(new TextComponent("§6UHC FFA"));
ItemDisplayUtil.addGlint(uhc);
uhc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(uhc, "§5", 0);
ItemDisplayUtil.addLore(uhc, net.kyori.adventure.text.Component.text("A FFA to practice PvP", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(uhc, net.kyori.adventure.text.Component.text("for the UHC gamemode.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(uhc, "§7An FFA to practice pvp", 1);
ItemDisplayUtil.addLore(uhc, "§7for the UHC gamemode.", 2);
ItemDisplayUtil.addLore(uhc, "§f", 3);
ItemDisplayUtil.addLore(uhc, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", UhcFfaAreas.ffaWorld.players().size()), ChatFormat.goldColor).decoration(ChatFormat.italic, false), 4);
ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
emptySlot.setHoverName(new TextComponent(""));
fillEmptySlots(emptySlot);
this.setSlot(0, classic);
this.setSlot(2, uhc);
this.setSlot(4, pot);
this.setSlot(6, skyffa);
this.setSlot(8, kit);
this.setSlot(1, classic);
this.setSlot(3, uhc);
this.setSlot(5, pot);
this.setSlot(7, kit);
}
private void setOtherGamesLayout() {
@@ -197,37 +178,36 @@ public class PlayGUI extends SimpleGui {
unknown.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemStack back = new ItemStack(Items.DRAGON_BREATH, 1);
back.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Back", ChatFormat.Minecraft.dark_purple).decoration(ChatFormat.italic, false)));
back.setHoverName(new TextComponent("§5Back"));
back.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(back, net.kyori.adventure.text.Component.text("Go back to the main menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 0);
ItemDisplayUtil.addLore(back, "§7Go back to the main menu.", 0);
ItemStack oitc = new ItemStack(Items.BOW, 1);
oitc.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("OITC", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false)));
oitc.setHoverName(new TextComponent("§eOITC"));
ItemDisplayUtil.addGlint(oitc);
oitc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(oitc, "§5", 0);
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text("One in the chamber.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text("Try to kill as many people as possible", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text("to achieve victory!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
ItemDisplayUtil.addLore(oitc, "§7One in the chamber.", 1);
ItemDisplayUtil.addLore(oitc, "§7Try to kill as many people as possible", 2);
ItemDisplayUtil.addLore(oitc, "§7to achieve victory!", 3);
ItemDisplayUtil.addLore(oitc, "§f", 4);
ItemDisplayUtil.addLore(oitc, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", OitcGame.world.players().size()), ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false), 5);
ItemDisplayUtil.addLore(oitc, "§e◆ There are " + OitcGame.world.players().size() + " people playing this gamemode.", 5);
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
emptySlot.setHoverName(new TextComponent(""));
ItemStack football = new ItemStack(Items.ARMOR_STAND, 1);
football.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Football", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
football.setHoverName(new TextComponent("§fFootball"));
ItemDisplayUtil.addGlint(football);
football.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(football, "§f", 0);
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text("Also known as soccer.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text("You kick a ball into a goal", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text("to achieve victory!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
ItemDisplayUtil.addLore(football, "§7Also known as soccer.", 1);
ItemDisplayUtil.addLore(football, "§7You kick a ball into a goal", 2);
ItemDisplayUtil.addLore(football, "§7to achieve victory!", 3);
ItemDisplayUtil.addLore(football, "§f", 4);
ItemDisplayUtil.addLore(football, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", FootballGame.world.players().size()), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 5);
ItemDisplayUtil.addLore(football, "§f◆ There are " + FootballGame.world.players().size() + " people playing this gamemode.", 5);
fillEmptySlots(emptySlot);
@@ -243,67 +223,60 @@ public class PlayGUI extends SimpleGui {
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
ItemStack itemStack = element.getItemStack();
Component name = itemStack.getHoverName();
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
if(name.getString().contains("Classic FFA")){
LobbyUtil.sendGame(nexiaPlayer, "classic ffa", true, true);
if(name.getString().equalsIgnoreCase("§bClassic FFA")){
LobbyUtil.sendGame(this.player, "classic ffa", true, true);
this.close();
}
if(name.getString().contains("Kit FFA")){
LobbyUtil.sendGame(nexiaPlayer, "kits ffa", true, true);
if(name.getString().equalsIgnoreCase("§fKit FFA")){
LobbyUtil.sendGame(this.player, "kits ffa", true, true);
this.close();
}
if(name.getString().contains("Pot FFA")){
LobbyUtil.sendGame(nexiaPlayer, "pot ffa", true, true);
if(name.getString().equalsIgnoreCase("§eSky FFA")){
LobbyUtil.sendGame(this.player, "sky ffa", true, true);
this.close();
}
if(name.getString().contains("Sky FFA")){
LobbyUtil.sendGame(nexiaPlayer, "sky ffa", true, true);
if(name.getString().equalsIgnoreCase("§6UHC FFA")){
LobbyUtil.sendGame(this.player, "uhc ffa", true, true);
this.close();
}
if(name.getString().contains("UHC FFA")){
LobbyUtil.sendGame(nexiaPlayer, "uhc ffa", true, true);
this.close();
}
if(name.getString().contains("FFA")){
if(name.getString().equalsIgnoreCase("§3FFA")){
this.setFFALayout();
}
if(name.getString().contains("Bedwars")){
LobbyUtil.sendGame(nexiaPlayer, "bedwars", true, true);
if(name.getString().equalsIgnoreCase("§cBedwars")){
LobbyUtil.sendGame(this.player, "bedwars", true, true);
this.close();
}
if(name.getString().contains("Skywars")){
LobbyUtil.sendGame(nexiaPlayer, "skywars", true, true);
if(name.getString().equalsIgnoreCase("§aSkywars")){
LobbyUtil.sendGame(this.player, "skywars", true, true);
this.close();
}
if(name.getString().contains("OITC")){
LobbyUtil.sendGame(nexiaPlayer, "oitc", true, true);
if(name.getString().equalsIgnoreCase("§eOITC")){
LobbyUtil.sendGame(this.player, "oitc", true, true);
this.close();
}
if(name.getString().contains("Football")){
LobbyUtil.sendGame(nexiaPlayer, "football", true, true);
if(name.getString().equalsIgnoreCase("§fFootball")){
LobbyUtil.sendGame(this.player, "football", true, true);
this.close();
}
if(name.getString().contains("Duels")){
LobbyUtil.sendGame(nexiaPlayer, "duels", true, true);
if(name.getString().equalsIgnoreCase("§9Duels")){
LobbyUtil.sendGame(this.player, "duels", true, true);
this.close();
}
if(name.getString().contains("Other Games")){
if(name.getString().toLowerCase().equalsIgnoreCase("§5Other Games")){
this.setOtherGamesLayout();
}
if(name.getString().contains("Back")){
if(name.getString().toLowerCase().equalsIgnoreCase("§5Back")){
this.setMainLayout();
}
+14 -14
View File
@@ -1,15 +1,17 @@
package com.nexia.core.gui;
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.MenuType;
@@ -54,17 +56,15 @@ public class PrefixGUI extends SimpleGui {
slot = 19;
}
boolean hasPermission = Permissions.check(player, rank.groupID);
if(hasPermission && player.getTags().contains(rank.id)){
if(Permissions.check(player, "nexia.prefix." + rank.id) && player.getTags().contains(rank.id)){
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
ItemDisplayUtil.addGlint(enchantedItem);
enchantedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
this.setSlot(slot, enchantedItem);
slot++;
} else if(hasPermission){
} else if(Permissions.check(player, "nexia.prefix." + rank.id)){
ItemStack changedItem = new ItemStack(Items.NAME_TAG, 1);
changedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
changedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, NamedTextColor.WHITE).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
this.setSlot(slot, changedItem);
slot++;
} else if(player.getTags().contains(rank.id)) {
@@ -85,12 +85,13 @@ public class PrefixGUI extends SimpleGui {
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
NexiaPlayer player = new NexiaPlayer(this.player);
Player player = PlayerUtil.getFactoryPlayer(this.player);
player.sendNexiaMessage(
net.kyori.adventure.text.Component.text("Your prefix has been set to: ", ChatFormat.normalColor)
.append(net.kyori.adventure.text.Component.text(name, ChatFormat.brandColor2))
.append(net.kyori.adventure.text.Component.text(".", ChatFormat.normalColor))
player.sendMessage(
ChatFormat.nexiaMessage
.append(net.kyori.adventure.text.Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text(".").decoration(ChatFormat.bold, false))
);
for(NexiaRank rank : NexiaRank.ranks){
@@ -98,7 +99,6 @@ public class PrefixGUI extends SimpleGui {
}
if(name.equalsIgnoreCase("player")) name = "default";
if(name.equalsIgnoreCase("nexia")) name = "supporter";
player.addTag(name.toLowerCase());
this.setMainLayout(this.player);
@@ -113,4 +113,4 @@ public class PrefixGUI extends SimpleGui {
shop.setMainLayout(player);
shop.open();
}
}
}
+22 -21
View File
@@ -1,10 +1,10 @@
package com.nexia.core.gui;
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.discord.NexiaDiscord;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.discord.Main;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
@@ -32,20 +32,19 @@ public class RanksGUI extends SimpleGui {
}
private void setMainLayout(){
ItemStack supporter = new ItemStack(Items.DRAGON_BREATH, 1);
supporter.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Supporter", ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
supporter.setHoverName(new TextComponent("§5Supporter"));
ItemDisplayUtil.addGlint(supporter);
supporter.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("How to get it:", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 0);
ItemDisplayUtil.addLore(supporter, "§7How to get it:", 0);
ItemDisplayUtil.addLore(supporter, "§1", 1);
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("Patreon - Buy it from our patreon.", TextColor.fromHexString("#f96b59")).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("https://www.patreon.com/Nexia", TextColor.fromHexString("#f96b59")).decoration(ChatFormat.italic, false), 3);
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("OR", ChatFormat.Minecraft.white).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false), 4);
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("Boosting - Boost the discord server.", TextColor.fromHexString("#8c00ff")).decoration(ChatFormat.italic, false), 5);
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text(NexiaDiscord.config.discordLink, TextColor.fromHexString("#8c00ff")).decoration(ChatFormat.italic, false), 6);
ItemDisplayUtil.addLore(supporter, "§cPatreon - Buy it from our patreon.", 2);
ItemDisplayUtil.addLore(supporter, "§chttps://www.patreon.com/Nexia", 3);
ItemDisplayUtil.addLore(supporter, "§f§lOR", 4);
ItemDisplayUtil.addLore(supporter, "§dBoosting - Boost the discord server.", 5);
ItemDisplayUtil.addLore(supporter, "§d" + Main.config.discordLink, 6);
ItemDisplayUtil.addLore(supporter, "§3", 7);
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("Price: ", TextColor.fromHexString("#8c00ff")).decoration(ChatFormat.italic, false)
.append(net.kyori.adventure.text.Component.text("5.00$", ChatFormat.brandColor1).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)), 8);
ItemDisplayUtil.addLore(supporter, "§dPrice: §5§l5.00$", 8);
ItemStack purple = new ItemStack(Items.PURPLE_STAINED_GLASS_PANE, 1);
purple.setHoverName(new TextComponent(""));
@@ -85,25 +84,27 @@ public class RanksGUI extends SimpleGui {
ItemStack itemStack = element.getItemStack();
Component name = itemStack.getHoverName();
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
Player factoryPlayer = PlayerUtil.getFactoryPlayer(this.player);
if(name.getString().contains("Supporter")){
nexiaPlayer.sendNexiaMessage(
net.kyori.adventure.text.Component.text("In order to get the ", ChatFormat.normalColor)
.append(net.kyori.adventure.text.Component.text("Supporter", ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(net.kyori.adventure.text.Component.text(" rank, you need to either ", ChatFormat.normalColor))
if(name.getString().equalsIgnoreCase("§5Supporter")){
// Insert supporter thing here (link to discord and patreon)
factoryPlayer.sendMessage(ChatFormat.nexiaMessage.append(
net.kyori.adventure.text.Component.text("In order to get the ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(net.kyori.adventure.text.Component.text("Supporter").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(net.kyori.adventure.text.Component.text(" rank, you need to either ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text("buy from our patreon")
.color(TextColor.fromHexString("#f96b59"))
.decoration(ChatFormat.bold, true)
.hoverEvent(HoverEvent.showText(net.kyori.adventure.text.Component.text("Click me").color(TextColor.fromHexString("#f96b59"))))
.clickEvent(ClickEvent.openUrl("https://www.patreon.com/Nexia")))
.append(net.kyori.adventure.text.Component.text(" or ", ChatFormat.normalColor))
.append(net.kyori.adventure.text.Component.text(" or ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text("boost our discord server")
.color(TextColor.fromHexString("#8c00ff"))
.decoration(ChatFormat.bold, true)
.hoverEvent(HoverEvent.showText(net.kyori.adventure.text.Component.text("Click me").color(TextColor.fromHexString("#8c00ff"))))
.clickEvent(ClickEvent.openUrl(NexiaDiscord.config.discordLink)))
.append(net.kyori.adventure.text.Component.text(".", ChatFormat.normalColor))
.clickEvent(ClickEvent.openUrl(Main.config.discordLink)))
.append(net.kyori.adventure.text.Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
)
);
}
@@ -1,16 +1,14 @@
package com.nexia.core.gui.duels;
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
@@ -56,7 +54,7 @@ public class CustomDuelGUI extends SimpleGui {
airSlots++;
}
for(DuelsMap map : DuelsMap.duelsMaps){
this.setSlot(slot, map.item);
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
slot++;
}
}
@@ -81,9 +79,10 @@ public class CustomDuelGUI extends SimpleGui {
airSlots++;
}
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
playerHead.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(otherp.getScoreboardName(), ChatFormat.Minecraft.yellow).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)));
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
this.setSlot(4, playerHead);
@@ -97,15 +96,10 @@ public class CustomDuelGUI extends SimpleGui {
ItemDisplayUtil.removeLore(item, 0);
ItemDisplayUtil.removeLore(item, 1);
ItemDisplayUtil.addLore(item,
net.kyori.adventure.text.Component.text("Use ", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false)
.append(net.kyori.adventure.text.Component.text("/kiteditor edit <1, 2, 3, smp, vanilla>", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true))
.append(net.kyori.adventure.text.Component.text(" to edit/create a custom kit!", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false))
, 0);
ItemDisplayUtil.addLore(item, "§eUse §e§l/kiteditor edit §eto edit/create a custom kit!", 0);
ItemDisplayUtil.addGlint(item);
item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("No kits!", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
item.setHoverName(new TextComponent("§fNo kits!"));
this.setSlot(slot, item);
return;
@@ -125,25 +119,20 @@ public class CustomDuelGUI extends SimpleGui {
ItemDisplayUtil.removeLore(item, 0);
ItemDisplayUtil.removeLore(item, 1);
net.kyori.adventure.text.Component infoMsg = net.kyori.adventure.text.Component.text("INFO: ", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)
.append(net.kyori.adventure.text.Component.text("This kit is a ", ChatFormat.Minecraft.yellow)).decoration(ChatFormat.italic, false)
.append(net.kyori.adventure.text.Component.text("per-custom ", ChatFormat.Minecraft.yellow)).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)
.append(net.kyori.adventure.text.Component.text("kit.", ChatFormat.Minecraft.yellow)).decoration(ChatFormat.italic, false);
if(inventory.equalsIgnoreCase("vanilla")) {
item = new ItemStack(Items.RESPAWN_ANCHOR);
ItemDisplayUtil.addLore(item, infoMsg, 0);
ItemDisplayUtil.addLore(item, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
}
else if(inventory.equalsIgnoreCase("smp")) {
item = new ItemStack(Items.DIAMOND_CHESTPLATE);
ItemDisplayUtil.addLore(item, infoMsg, 0);
ItemDisplayUtil.addLore(item, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
}
ItemDisplayUtil.addGlint(item);
item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(inventory.toUpperCase().replaceAll("_", " "), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
item.setHoverName(new TextComponent("§f" + inventory.toUpperCase().replaceAll("_", " ")));
this.setSlot(slot, item);
slot++;
@@ -157,11 +146,11 @@ public class CustomDuelGUI extends SimpleGui {
Component name = itemStack.getHoverName();
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR && itemStack.getItem() != Items.PLAYER_HEAD && itemStack.getItem() != Items.COMMAND_BLOCK){
if(InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID()).contains(name.getString().toLowerCase().replaceAll(" ", "_"))){
this.kit = name.getString().toLowerCase().replaceAll(" ", "_");
if(InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID()).contains(name.getString().toLowerCase().substring(2).replaceAll(" ", "_"))){
this.kit = name.getString().toLowerCase().substring(2).replaceAll(" ", "_");
setMapLayout();
} else {
GamemodeHandler.customChallengePlayer(new NexiaPlayer(this.player), new NexiaPlayer(this.other), this.kit, DuelsMap.identifyMap(name.getString()));
GamemodeHandler.customChallengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString().substring(2)));
this.close();
}
@@ -1,23 +1,21 @@
package com.nexia.core.gui.duels;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import com.nexia.nexus.api.world.types.Minecraft;
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
public class DuelGUI extends SimpleGui {
static final TextComponent title = new TextComponent("Duel Menu");
@@ -55,8 +53,8 @@ public class DuelGUI extends SimpleGui {
airSlots++;
}
for(DuelsMap map : DuelsMap.duelsMaps){
if(gameMode.gameMode == Minecraft.GameMode.ADVENTURE && !map.isAdventureSupported) continue;
this.setSlot(slot, map.item);
if(gameMode.gameMode == GameType.ADVENTURE && !map.isAdventureSupported) continue;
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
slot++;
}
}
@@ -84,7 +82,7 @@ public class DuelGUI extends SimpleGui {
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
playerHead.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(otherp.getScoreboardName(), ChatFormat.Minecraft.yellow).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)));
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
this.setSlot(4, playerHead);
@@ -97,7 +95,7 @@ public class DuelGUI extends SimpleGui {
if(slot == 26) {
slot = 28;
}
item = DuelGameMode.duelsItems.get(i1);
item = DuelGameMode.duelsItems.get(i1).setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " ")));
ItemDisplayUtil.removeLore(item, 0);
ItemDisplayUtil.removeLore(item, 1);
@@ -114,11 +112,11 @@ public class DuelGUI extends SimpleGui {
Component name = itemStack.getHoverName();
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR && itemStack.getItem() != Items.PLAYER_HEAD){
if(DuelGameMode.stringDuelGameModes.contains(name.getString().replaceAll(" ", "_"))){
this.kit = name.getString().replaceAll(" ", "_");
if(DuelGameMode.stringDuelGameModes.contains(name.getString().substring(2).replaceAll(" ", "_"))){
this.kit = name.getString().substring(2).replaceAll(" ", "_");
setMapLayout(GamemodeHandler.identifyGamemode(this.kit));
} else {
GamemodeHandler.challengePlayer(new NexiaPlayer(this.player), new NexiaPlayer(this.other), this.kit, DuelsMap.identifyMap(name.getString()));
GamemodeHandler.challengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString().substring(2)));
this.close();
}
@@ -1,11 +1,9 @@
package com.nexia.core.gui.duels;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
@@ -54,27 +52,25 @@ public class QueueGUI extends SimpleGui {
slot = 28;
}
item = DuelGameMode.duelsItems.get(i1);
item = DuelGameMode.duelsItems.get(i1).setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " ")));
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(duel);
ItemDisplayUtil.removeLore(item, 0);
assert gameMode != null;
ItemDisplayUtil.addLore(item,
net.kyori.adventure.text.Component.text("There are ", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false)
.append(net.kyori.adventure.text.Component.text(gameMode.queue.size(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false))
.append(net.kyori.adventure.text.Component.text(" people queued up.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false))
, 0);
ItemDisplayUtil.addLore(item, "§7There are §7§l" + gameMode.queue.size() + " §7people queued up.", 0);
ItemDisplayUtil.removeLore(item, 1);
if(GamemodeHandler.isInQueue(new NexiaPlayer(this.player), gameMode)) {
ItemDisplayUtil.addLore(item, net.kyori.adventure.text.Component.text("Click to leave the queue.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
if(GamemodeHandler.isInQueue(player, gameMode)) {
ItemDisplayUtil.removeLore(item, 1);
ItemDisplayUtil.addLore(item, "§7Click to leave the queue.", 1);
} else {
ItemDisplayUtil.removeLore(item, 1);
}
this.setSlot(slot, item);
slot++;
i1++;
}
this.setSlot(40, new ItemStack(Items.BARRIER).setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Leave ALL Queues", ChatFormat.Minecraft.red).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false))));
this.setSlot(40, new ItemStack(Items.BARRIER).setHoverName(new TextComponent("§c§lLeave ALL Queues")));
}
public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){
@@ -83,23 +79,24 @@ public class QueueGUI extends SimpleGui {
ItemStack itemStack = element.getItemStack();
Component name = itemStack.getHoverName();
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
if(name.getString().contains("Leave ALL Queues")) {
GamemodeHandler.removeQueue(nexiaPlayer, null, false);
if(name.getString().substring(4).equalsIgnoreCase("Leave ALL Queues")) {
//PlayerUtil.getFactoryPlayer(player).runCommand("/queue LEAVE", 0, false);
LobbyUtil.leaveAllGames(this.player, true);
this.close();
return super.click(index, clickType, action);
}
String modifiedName = name.getString().replaceAll(" ", "_");
String modifiedName = name.getString().substring(2).replaceAll(" ", "_");
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(modifiedName);
if(gameMode != null && GamemodeHandler.isInQueue(nexiaPlayer, gameMode)) {
GamemodeHandler.removeQueue(nexiaPlayer, modifiedName, false);
if(gameMode != null && GamemodeHandler.isInQueue(player, gameMode)) {
GamemodeHandler.removeQueue(this.player, modifiedName, false);
this.close();
} else {
GamemodeHandler.joinQueue(nexiaPlayer, modifiedName, false);
GamemodeHandler.joinQueue(this.player, modifiedName, false);
this.close();
}
this.close();
}
}
@@ -1,9 +1,9 @@
package com.nexia.core.gui.ffa;
import com.nexia.base.player.NexiaPlayer;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.kits.FfaKit;
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
@@ -17,7 +17,6 @@ import net.minecraft.world.item.Items;
public class KitGUI extends SimpleGui {
static final TextComponent title = new TextComponent("Kits Menu");
public KitGUI(MenuType<?> type, ServerPlayer player, boolean includePlayer) {
super(type, player, includePlayer);
}
@@ -49,7 +48,7 @@ public class KitGUI extends SimpleGui {
ItemStack item = ffaKits.item;
item.setHoverName(ObjectMappings.convertComponent(Component.text(StringUtil.capitalize(ffaKits.id.replaceAll("_", " ")), ChatFormat.Minecraft.white)));
item.setHoverName(new TextComponent("§f" + StringUtil.capitalize(ffaKits.id.replaceAll("_", " "))));
this.setSlot(slot, item);
@@ -58,10 +57,10 @@ public class KitGUI extends SimpleGui {
}
public static void giveKit(ServerPlayer minecraftPlayer, String name) {
NexiaPlayer player = new NexiaPlayer(minecraftPlayer);
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
FfaKit kit = FfaKit.identifyKit(name);
if(kit != null) kit.giveKit(new NexiaPlayer(minecraftPlayer), false);
else player.sendMessage(Component.text("Invalid kit!", ChatFormat.failColor));
if(kit != null) kit.giveKit(minecraftPlayer, false);
else player.sendMessage(Component.text("Invalid kit!").color(ChatFormat.failColor));
}
public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){
@@ -71,7 +70,7 @@ public class KitGUI extends SimpleGui {
net.minecraft.network.chat.Component name = itemStack.getHoverName();
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
String modifiedName = name.getString().toLowerCase();
String modifiedName = name.getString().substring(2).toLowerCase();
giveKit(this.player, modifiedName);
this.close();
}
@@ -1,10 +1,10 @@
package com.nexia.core.gui.ffa;
import com.nexia.base.player.NexiaPlayer;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.ffa.kits.utilities.KitFfaAreas;
import com.nexia.nexus.api.world.util.Location;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.classic.utilities.FfaAreas;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
@@ -23,7 +23,7 @@ public class SpawnGUI extends SimpleGui {
super(type, player, includePlayer);
}
public static HashMap<String, Location> mapLocations = new HashMap<>();
public static HashMap<String, int[]> mapLocations = new HashMap<>();
private void fillEmptySlots(ItemStack itemStack){
for(int i = 0; i < 45; i++){
@@ -109,17 +109,18 @@ public class SpawnGUI extends SimpleGui {
}
public static void teleportPlayer(ServerPlayer minecraftPlayer, String name) {
Location pos = mapLocations.get(name);
NexiaPlayer player = new NexiaPlayer(minecraftPlayer);
int[] pos = mapLocations.get(name);
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
if(pos != null){
player.teleport(pos);
player.sendNexiaMessage(
Component.text("You have been teleported to: ", ChatFormat.normalColor)
.append(Component.text(name, ChatFormat.brandColor2))
.append(Component.text(".", ChatFormat.normalColor))
minecraftPlayer.teleportTo(FfaAreas.ffaWorld, pos[0], pos[1], pos[2], pos[3], pos[4]);
player.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have been teleported to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
player.sendMessage(Component.text("Invalid biome!", ChatFormat.failColor));
player.sendMessage(Component.text("Invalid biome!").color(ChatFormat.failColor));
}
}
@@ -157,15 +158,15 @@ public class SpawnGUI extends SimpleGui {
// 115 40 -151 | Mushrooms
// 0 40 0 | Plains (Center)
mapLocations.put("nether forest", new Location(186, 49, -71, -133, -5, KitFfaAreas.nexusFfaWorld));
mapLocations.put("blackstone", new Location(161, 57, 82, -130, -11, KitFfaAreas.nexusFfaWorld));
mapLocations.put("mesa", new Location(74, 48, 169, 130, -1, KitFfaAreas.nexusFfaWorld));
mapLocations.put("savanna", new Location(-166, 43, 50, 156, -3, KitFfaAreas.nexusFfaWorld));
mapLocations.put("snow", new Location(-35, 47, -206, 51, 1, KitFfaAreas.nexusFfaWorld));
mapLocations.put("forest", new Location(-174, 42, -38, 132, -2, KitFfaAreas.nexusFfaWorld));
mapLocations.put("desert", new Location(-73, 41, 181, 121, -2, KitFfaAreas.nexusFfaWorld));
mapLocations.put("mushrooms", new Location(115, 41, -151, -136, -1, KitFfaAreas.nexusFfaWorld));
mapLocations.put("plains", new Location(0, 41, 0, 0, 0, KitFfaAreas.nexusFfaWorld));
mapLocations.put("nether forest", new int[]{186, 49, -71, -133, -5});
mapLocations.put("blackstone", new int[]{161, 57, 82, -130, -11});
mapLocations.put("mesa", new int[]{74, 48, 169, 130, -1});
mapLocations.put("savanna", new int[]{-166, 43, 50, 156, -3});
mapLocations.put("snow", new int[]{-35, 47, -206, 51, 1});
mapLocations.put("forest", new int[]{-174, 42, -38, 132, -2});
mapLocations.put("desert", new int[]{-73, 41, 181, 121, -2});
mapLocations.put("mushrooms", new int[]{115, 41, -151, -136, -1});
mapLocations.put("plains", new int[]{0, 41, 0, 0, 0});
}
}
@@ -1,18 +1,14 @@
package com.nexia.core.listeners;
import com.nexia.core.listeners.nexus.*;
import com.nexia.core.listeners.factory.*;
public class ListenerHelper {
public static void registerListeners() {
// Nexus Listeners
new PlayerJoinListener().registerListener();
new PlayerDamageListener().registerListener();
new PlayerDeathListener().registerListener();
new PlayerHungerListener().registerListener();
new PlayerLeaveListener().registerListener();
new PlayerSwapHandItemsListener().registerListener();
new PlayerUseItemListener().registerListener();
new PlayerDropItemListener().registerListener();
new PlayerRespawnListener().registerListener();
// Factory Listeners
PlayerJoinListener.registerListener();
PlayerLeaveListener.registerListener();
UseItemListener.registerListener();
PlayerDropItemListener.registerListener();
PlayerRespawnListener.registerListener();
}
}
@@ -0,0 +1,24 @@
package com.nexia.core.listeners.factory;
import com.combatreforged.factory.api.event.player.PlayerHotbarDropItemEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.misc.EventUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import net.minecraft.server.level.ServerPlayer;
public class PlayerDropItemListener {
public static void registerListener(){
PlayerHotbarDropItemEvent.BACKEND.register(playerDropItemEvent -> {
Player player = playerDropItemEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
if (!EventUtil.dropItem(minecraftPlayer, playerDropItemEvent.getItemStack())) {
playerDropItemEvent.setCancelled(true);
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
return;
}
});
}
}
@@ -0,0 +1,138 @@
package com.nexia.core.listeners.factory;
import com.combatreforged.factory.api.event.player.PlayerJoinEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.Main;
import com.nexia.discord.utilities.player.PlayerData;
import com.nexia.ffa.classic.utilities.RatingUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.TextColor;
import net.minecraft.server.level.ServerPlayer;
import java.util.Objects;
import static com.nexia.discord.Main.jda;
public class PlayerJoinListener {
public static void registerListener() {
PlayerJoinEvent.BACKEND.register(playerJoinEvent -> {
Player player = playerJoinEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
processJoin(player, minecraftPlayer);
/*
*/
});
}
private static void sendJoinMessage(Player player){
player.sendMessage(ChatFormat.separatorLine("Welcome"));
player.sendMessage(
Component.text(" » ").color(ChatFormat.brandColor2)
.append(Component.text("Welcome ").color(ChatFormat.normalColor))
.append(Component.text(player.getRawName()).color(ChatFormat.brandColor2))
.append(Component.text(" to ").color(ChatFormat.normalColor))
.append(Component.text("Nexia").color(ChatFormat.brandColor2))
.append(Component.text("!").color(ChatFormat.normalColor))
);
player.sendMessage(
Component.text(" » ").color(ChatFormat.brandColor2)
.append(Component.text("Players online: ").color(ChatFormat.normalColor))
.append(Component.text(ServerTime.minecraftServer.getPlayerCount()).color(ChatFormat.brandColor2))
.append(Component.text("/").color(ChatFormat.lineColor))
.append(Component.text(ServerTime.factoryServer.getMaxPlayerCount()).color(ChatFormat.brandColor2))
);
player.sendMessage(
Component.text(" » ").color(ChatFormat.brandColor2)
.append(Component.text("Read the rules: ").color(ChatFormat.normalColor))
.append(Component.text("/rules")).color(ChatFormat.brandColor2).hoverEvent(HoverEvent.showText(Component.text("Click me").color(TextColor.fromHexString("#73ff54"))))
.clickEvent(ClickEvent.suggestCommand("/rules"))
);
player.sendMessage(
Component.text(" » ").color(ChatFormat.brandColor2)
.append(Component.text("Join our discord: ").color(ChatFormat.normalColor))
.append(Component.text(com.nexia.discord.Main.config.discordLink)
.color(ChatFormat.brandColor2)
.hoverEvent(HoverEvent.showText(Component.text("Click me").color(TextColor.fromHexString("#73ff54"))))
.clickEvent(ClickEvent.openUrl(com.nexia.discord.Main.config.discordLink))
)
);
player.sendMessage(ChatFormat.separatorLine(null));
}
private static void checkBooster(ServerPlayer player) {
PlayerData playerData = com.nexia.discord.utilities.player.PlayerDataManager.get(player.getUUID());
if(!playerData.savedData.isLinked) { return; }
Member discordUser = null;
try {
discordUser = Objects.requireNonNull(jda.getGuildById(Main.config.guildID)).retrieveMemberById(playerData.savedData.discordID).complete(true);
} catch (Exception ignored) { }
if(discordUser == null) {
if(Permissions.check(player, "nexia.prefix.supporter")) {
if(Permissions.check(player, "nexia.rank")) {
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
return;
}
NexiaRank.setRank(NexiaRank.DEFAULT, player);
}
return;
}
Role supporterRole = jda.getRoleById("1107264322951979110");
boolean hasRole = discordUser.getRoles().contains(supporterRole);
boolean hasSupporterPrefix = Permissions.check(player, "nexia.prefix.supporter");
if(hasRole && !hasSupporterPrefix) {
if(Permissions.check(player, "nexia.rank")) {
NexiaRank.addPrefix(NexiaRank.SUPPORTER, player, true);
return;
}
NexiaRank.setRank(NexiaRank.SUPPORTER, player);
} else if(!hasRole && hasSupporterPrefix) {
if(Permissions.check(player, "nexia.rank")) {
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
return;
}
NexiaRank.setRank(NexiaRank.DEFAULT, player);
}
}
private static void processJoin(Player player, ServerPlayer minecraftPlayer) {
if(PlayerDataManager.get(player).clientType.equals(com.nexia.core.utilities.player.PlayerData.ClientType.VIAFABRICPLUS)) return;
com.nexia.ffa.classic.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.kits.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.sky.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.discord.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer.getUUID());
com.nexia.minigames.games.duels.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.football.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
LobbyUtil.leaveAllGames(minecraftPlayer, true);
checkBooster(minecraftPlayer);
RatingUtil.checkRatingRank(minecraftPlayer);
sendJoinMessage(player);
}
}
@@ -0,0 +1,58 @@
package com.nexia.core.listeners.factory;
import com.combatreforged.factory.api.event.player.PlayerDisconnectEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import net.minecraft.server.level.ServerPlayer;
public class PlayerLeaveListener {
public static void registerListener() {
PlayerDisconnectEvent.BACKEND.register(playerDisconnectEvent -> {
Player player = playerDisconnectEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
processDisconnect(player, minecraftPlayer);
});
}
private static void processDisconnect(Player player, ServerPlayer minecraftPlayer){
if (BwUtil.isInBedWars(minecraftPlayer)) BwPlayerEvents.leaveInBedWars(minecraftPlayer);
else if (FfaUtil.isFfaPlayer(minecraftPlayer)) {
FfaUtil.leaveOrDie(minecraftPlayer, minecraftPlayer.getLastDamageSource(), true);
}
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.LOBBY) DuelGameHandler.leave(minecraftPlayer, true);
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) SkywarsGame.leave(minecraftPlayer);
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.OITC) OitcGame.leave(minecraftPlayer);
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.FOOTBALL) FootballGame.leave(minecraftPlayer);
com.nexia.ffa.classic.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.kits.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.sky.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.discord.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer.getUUID());
com.nexia.minigames.games.duels.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.football.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
//LobbyUtil.leaveAllGames(minecraftPlayer, true);
PlayerDataManager.removePlayerData(minecraftPlayer);
}
}
@@ -0,0 +1,140 @@
package com.nexia.core.listeners.factory;
import com.combatreforged.factory.api.event.player.PlayerRespawnEvent;
import com.combatreforged.factory.api.util.Identifier;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.types.Minecraft;
import com.combatreforged.factory.api.world.util.Location;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.minigames.games.duels.DuelsGame;
import com.nexia.minigames.games.duels.custom.CustomDuelsGame;
import com.nexia.minigames.games.duels.custom.team.CustomTeamDuelsGame;
import com.nexia.minigames.games.duels.team.TeamDuelsGame;
import com.nexia.minigames.games.duels.util.player.PlayerData;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsGameMode;
import com.nexia.core.utilities.world.WorldUtil;
import net.minecraft.server.level.ServerPlayer;
import java.util.Random;
public class PlayerRespawnListener {
public static void registerListener(){
PlayerRespawnEvent.BACKEND.register((respawnEvent) -> {
Player factoryPlayer = respawnEvent.getPlayer();
if(factoryPlayer == null && respawnEvent.getEntity() instanceof Player) {
factoryPlayer = (Player) respawnEvent.getEntity();
}
if(factoryPlayer == null) return;
ServerPlayer player = ServerTime.minecraftServer.getPlayerList().getPlayer(factoryPlayer.getUUID());
if(player == null) return;
PlayerData duelsData = PlayerDataManager.get(player);
com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player);
if(duelsData.gameOptions == null) return;
DuelsGame duelsGame = duelsData.gameOptions.duelsGame;
TeamDuelsGame teamDuelsGame = duelsData.gameOptions.teamDuelsGame;
CustomDuelsGame customDuelsGame = duelsData.gameOptions.customDuelsGame;
CustomTeamDuelsGame customTeamDuelsGame = duelsData.gameOptions.customTeamDuelsGame;
if(data.gameMode == PlayerGameMode.SKYWARS) {
Location respawn = new Location(0,100, 0, WorldUtil.getWorld(SkywarsGame.world));
boolean isPlaying = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(player).gameMode == SkywarsGameMode.PLAYING;
ServerPlayer serverPlayer = PlayerUtil.getPlayerAttacker(player);
if(serverPlayer != null && serverPlayer != player && isPlaying) {
respawn.setX(serverPlayer.getX());
respawn.setY(serverPlayer.getY());
respawn.setZ(serverPlayer.getZ());
}
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(respawn);
return;
}
if(duelsGame != null && duelsGame.isEnding && duelsGame.winner != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(duelsGame.level).getId()))));
} else if(teamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
Location respawn = new Location(0,80, 0, ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(teamDuelsGame.level).getId())));
ServerPlayer player1 = null;
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
if(teamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team2.alive.isEmpty()) {
player1 = teamDuelsGame.team2.alive.get(new Random().nextInt(teamDuelsGame.team2.alive.size()));
} else if(teamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team1.alive.isEmpty()){
player1 = teamDuelsGame.team1.alive.get(new Random().nextInt(teamDuelsGame.team1.alive.size()));
}
if(player1 != null) {
respawn.setX(player1.getX());
respawn.setY(player1.getY());
respawn.setZ(player1.getZ());
}
} else {
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
}
respawnEvent.setSpawnpoint(respawn);
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
} else if(customDuelsGame != null && customDuelsGame.isEnding && customDuelsGame.winner != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(new Location(customDuelsGame.winner.getX(), customDuelsGame.winner.getY(), customDuelsGame.winner.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customDuelsGame.level).getId()))));
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
} else if(customTeamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
Location respawn = new Location(0,80, 0, ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customTeamDuelsGame.level).getId())));
ServerPlayer player1 = null;
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
if(customTeamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team2.alive.isEmpty()) {
player1 = customTeamDuelsGame.team2.alive.get(new Random().nextInt(customTeamDuelsGame.team2.alive.size()));
} else if (customTeamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team1.alive.isEmpty()) {
player1 = customTeamDuelsGame.team1.alive.get(new Random().nextInt(customTeamDuelsGame.team1.alive.size()));
}
if(player1 != null) {
respawn.setX(player1.getX());
respawn.setY(player1.getY());
respawn.setZ(player1.getZ());
}
} else {
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
}
respawnEvent.setSpawnpoint(respawn);
}
});
}
}
@@ -1,25 +1,27 @@
package com.nexia.core.listeners.nexus;
package com.nexia.core.listeners.factory;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.nexus.api.event.player.PlayerUseItemEvent;
import com.nexia.nexus.api.world.item.ItemStack;
import com.combatreforged.factory.api.event.player.PlayerUseItemEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.server.level.ServerPlayer;
public class PlayerUseItemListener {
public void registerListener() {
public class UseItemListener {
public static void registerListener() {
PlayerUseItemEvent.BACKEND.register(playerUseItemEvent -> {
NexiaPlayer player = new NexiaPlayer(playerUseItemEvent.getPlayer());
Player player = playerUseItemEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
ItemStack itemStack = playerUseItemEvent.getItemStack();
Component name = itemStack.getDisplayName();
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode;
PlayerGameMode gameMode = PlayerDataManager.get(minecraftPlayer).gameMode;
String sName = name.toString().toLowerCase();
if(gameMode == PlayerGameMode.LOBBY) {
@@ -1,52 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.base.BaseFfaUtil;
import com.nexia.nexus.api.event.entity.LivingEntityDamageEvent;
import com.nexia.nexus.api.world.damage.DamageData;
import com.nexia.nexus.api.world.entity.player.Player;
public class PlayerDamageListener {
public void registerListener() {
LivingEntityDamageEvent.BACKEND.register(livingEntityDamageEvent -> {
if(!(livingEntityDamageEvent.getLivingEntity() instanceof Player nexusPlayer)) return;
NexiaPlayer player = new NexiaPlayer(nexusPlayer);
DamageData damageData = livingEntityDamageEvent.getCause();
for (BaseFfaUtil util : BaseFfaUtil.ffaUtils) {
if (util.isFfaPlayer(player) && !util.beforeDamage(player, damageData)) {
livingEntityDamageEvent.setCancelled(true);
return;
}
}
if(LobbyUtil.isLobbyWorld(player.getWorld()) && damageData.getType().equals(DamageData.Type.VOID)) {
player.teleport(LobbyUtil.nexusLobbyLocation);
livingEntityDamageEvent.setCancelled(true);
return;
}
if (player.hasTag(LobbyUtil.NO_DAMAGE_TAG)) {
livingEntityDamageEvent.setCancelled(true);
return;
}
Player attacker = PlayerUtil.getPlayerAttacker(damageData);
if(attacker != null) {
if(attacker.hasTag(LobbyUtil.NO_DAMAGE_TAG)) {
livingEntityDamageEvent.setCancelled(true);
return;
}
}
if(damageData.getType().equals(DamageData.Type.VOID) && (!player.isInGameMode(PlayerGameMode.LOBBY) || player.isInGameMode(PlayerGameMode.FFA))) {
livingEntityDamageEvent.setDamage(1000);
return;
}
});
}
}
@@ -1,57 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.nexus.api.event.player.PlayerDeathEvent;
import com.nexia.nexus.api.world.scoreboard.ScoreboardTeam;
public class PlayerDeathListener {
public void registerListener() {
PlayerDeathEvent.BACKEND.register(playerDeathEvent -> {
NexiaPlayer nexiaPlayer = new NexiaPlayer(playerDeathEvent.getPlayer());
PlayerGameMode gameMode = ((CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(nexiaPlayer)).gameMode;
DuelsPlayerData duelsData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(nexiaPlayer);
/*
if(FfaUtil.isFfaPlayer(nexiaPlayer)) {
FfaUtil.leaveOrDie(nexiaPlayer, playerDeathEvent, false);
}
*/
if (BwAreas.isBedWarsWorld(nexiaPlayer.getWorld())) {
BwPlayerEvents.death(nexiaPlayer);
playerDeathEvent.setVisibleFor(ScoreboardTeam.VisibleFor.NO_ONE);
return;
}
if(gameMode == PlayerGameMode.OITC){
OitcGame.death(nexiaPlayer, playerDeathEvent);
return;
}
if(gameMode == PlayerGameMode.SKYWARS) {
SkywarsGame.death(nexiaPlayer, playerDeathEvent);
return;
}
if(gameMode == PlayerGameMode.LOBBY && duelsData.gameOptions != null) {
if(duelsData.gameOptions.duelsGame != null) {
duelsData.gameOptions.duelsGame.death(nexiaPlayer);
return;
}
if(duelsData.gameOptions.teamDuelsGame != null) {
duelsData.gameOptions.teamDuelsGame.death(nexiaPlayer, playerDeathEvent);
}
}
});
}
}
@@ -1,19 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.nexus.api.event.player.PlayerHotbarDropItemEvent;
import com.nexia.core.utilities.misc.EventUtil;
import com.nexia.base.player.NexiaPlayer;
public class PlayerDropItemListener {
public void registerListener(){
PlayerHotbarDropItemEvent.BACKEND.register(playerDropItemEvent -> {
NexiaPlayer player = new NexiaPlayer(playerDropItemEvent.getPlayer());
if (!EventUtil.dropItem(player, playerDropItemEvent.getItemStack())) {
playerDropItemEvent.setCancelled(true);
player.refreshInventory();
}
});
}
}
@@ -1,33 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsGameMode;
import com.nexia.minigames.games.skywars.util.player.SkywarsPlayerData;
import com.nexia.nexus.api.event.player.PlayerFoodLevelsChangeEvent;
public class PlayerHungerListener {
public void registerListener(){
PlayerFoodLevelsChangeEvent.BACKEND.register(playerFoodLevelsChangeEvent -> {
NexiaPlayer player = new NexiaPlayer(playerFoodLevelsChangeEvent.getPlayer());
// SkyWars
SkywarsPlayerData playerData = (SkywarsPlayerData) PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player);
if(SkywarsGame.isSkywarsPlayer(player) && playerData.gameMode.equals(SkywarsGameMode.PLAYING)) return;
// Duels
DuelGameMode duelGameMode = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).gameMode;
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode;
if(gameMode.equals(PlayerGameMode.LOBBY) && (duelGameMode != null && !duelGameMode.hasSaturation)) return;
playerFoodLevelsChangeEvent.setFoodLevel(20);
playerFoodLevelsChangeEvent.setCancelled(true);
});
}
}
@@ -1,139 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerData;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.ranks.NexiaRank;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.NexiaDiscord;
import com.nexia.nexus.api.event.player.PlayerJoinEvent;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.minecraft.stats.Stats;
import java.util.Objects;
import static com.nexia.discord.NexiaDiscord.jda;
public class PlayerJoinListener {
public void registerListener() {
PlayerJoinEvent.BACKEND.register(playerJoinEvent -> {
NexiaPlayer player = new NexiaPlayer(playerJoinEvent.getPlayer());
if(((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).clientType.equals(CorePlayerData.ClientType.VIAFABRICPLUS)) return;
//setJoinMessage(player, playerJoinEvent);
PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.addPlayerData(player));
LobbyUtil.returnToLobby(player, true);
checkBooster(player);
ServerTime.scheduler.schedule(() -> {
sendJoinMessage(player);
}, 10);
});
}
private static void setJoinMessage(NexiaPlayer player, PlayerJoinEvent playerJoinEvent) {
if(player.unwrap().getStats().getValue(Stats.CUSTOM.get(Stats.LEAVE_GAME)) < 1) {
playerJoinEvent.setJoinMessage(
net.kyori.adventure.text.Component.text("[").color(ChatFormat.lineColor)
.append(net.kyori.adventure.text.Component.text("!").color(ChatFormat.goldColor)
.append(net.kyori.adventure.text.Component.text("] ").color(ChatFormat.lineColor))
.append(net.kyori.adventure.text.Component.text(player.getRawName()).color(ChatFormat.goldColor)))
);
} else {
playerJoinEvent.setJoinMessage(
net.kyori.adventure.text.Component.text("[").color(ChatFormat.lineColor)
.append(net.kyori.adventure.text.Component.text("+").color(ChatFormat.greenColor))
.append(net.kyori.adventure.text.Component.text("] ").color(ChatFormat.lineColor))
.append(net.kyori.adventure.text.Component.text(player.getRawName()).color(ChatFormat.greenColor))
);
}
}
private static void sendJoinMessage(NexiaPlayer player){
player.sendMessage(ChatFormat.separatorLine("Welcome"));
player.sendMessage(
Component.text(" » ", ChatFormat.brandColor2)
.append(Component.text("Welcome ", ChatFormat.normalColor))
.append(Component.text(player.getRawName(), ChatFormat.brandColor2))
.append(Component.text(" to ", ChatFormat.normalColor))
.append(Component.text("Nexia", ChatFormat.brandColor2))
.append(Component.text("!", ChatFormat.normalColor))
);
player.sendMessage(
Component.text(" » ", ChatFormat.brandColor2)
.append(Component.text("Players online: ", ChatFormat.normalColor))
.append(Component.text(ServerTime.minecraftServer.getPlayerCount(), ChatFormat.brandColor2))
.append(Component.text("/").color(ChatFormat.lineColor))
.append(Component.text(ServerTime.nexusServer.getMaxPlayerCount(), ChatFormat.brandColor2))
);
player.sendMessage(
Component.text(" » ", ChatFormat.brandColor2)
.append(Component.text("Read the rules: ", ChatFormat.normalColor))
.append(Component.text("/rules", ChatFormat.brandColor2)
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.Minecraft.green))))
.clickEvent(ClickEvent.suggestCommand("/rules"))
);
player.sendMessage(
Component.text(" » ", ChatFormat.brandColor2)
.append(Component.text("Join our discord: ", ChatFormat.normalColor))
.append(Component.text(NexiaDiscord.config.discordLink)
.color(ChatFormat.brandColor2)
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.Minecraft.green)))
.clickEvent(ClickEvent.openUrl(NexiaDiscord.config.discordLink))
)
);
player.sendMessage(ChatFormat.separatorLine(null));
}
private static void checkBooster(NexiaPlayer player) {
PlayerData playerData = PlayerDataManager.getDataManager(NexiaCore.DISCORD_DATA_MANAGER).get(player.getUUID());
if(!playerData.savedData.get(Boolean.class, "isLinked")) { return; }
Member discordUser = null;
try {
discordUser = Objects.requireNonNull(jda.getGuildById(NexiaDiscord.config.guildID)).retrieveMemberById(playerData.savedData.get(Long.class, "discordID")).complete(true);
} catch (Exception ignored) { }
if(discordUser == null) {
if(player.hasPrefix(NexiaRank.SUPPORTER)) {
if(player.hasPermission("nexia.rank")) {
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
return;
}
NexiaRank.setRank(NexiaRank.DEFAULT, player);
}
return;
}
Role supporterRole = jda.getRoleById("1107264322951979110");
boolean hasRole = discordUser.getRoles().contains(supporterRole);
boolean hasSupporterPrefix = player.hasPrefix(NexiaRank.SUPPORTER);
if(hasRole && !hasSupporterPrefix) {
if(player.hasPermission("nexia.rank")) {
NexiaRank.addPrefix(NexiaRank.SUPPORTER, player, false);
return;
}
NexiaRank.setRank(NexiaRank.SUPPORTER, player);
} else if(!hasRole && hasSupporterPrefix) {
if(player.hasPermission("nexia.rank")) {
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
return;
}
NexiaRank.setRank(NexiaRank.DEFAULT, player);
}
}
}
@@ -1,32 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.nexus.api.event.player.PlayerDisconnectEvent;
import net.kyori.adventure.text.Component;
public class PlayerLeaveListener {
public void registerListener() {
PlayerDisconnectEvent.BACKEND.register(playerDisconnectEvent -> {
NexiaPlayer player = new NexiaPlayer(playerDisconnectEvent.getPlayer());
player.leaveAllGames();
//setLeaveMessage(player, playerDisconnectEvent);
if (playerDisconnectEvent.getPlayer().hasTag("bot")) return;
PlayerDataManager.dataManagerMap.forEach((resourceLocation, playerDataManager) -> playerDataManager.removePlayerData(player));
});
}
private static void setLeaveMessage(NexiaPlayer player, PlayerDisconnectEvent playerDisconnectEvent){
playerDisconnectEvent.setLeaveMessage(
Component.text("[").color(ChatFormat.lineColor)
.append(Component.text("-", ChatFormat.failColor))
.append(Component.text("] ").color(ChatFormat.lineColor))
.append(Component.text(player.getRawName(), ChatFormat.failColor))
);
}
}
@@ -1,116 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.base.player.PlayerDataManager;
import com.nexia.core.NexiaCore;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.world.WorldUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.base.BaseFfaUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.duels.DuelsGame;
import com.nexia.minigames.games.duels.team.TeamDuelsGame;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsGameMode;
import com.nexia.minigames.games.skywars.util.player.SkywarsPlayerData;
import com.nexia.nexus.api.event.player.PlayerRespawnEvent;
import com.nexia.nexus.api.world.types.Minecraft;
import com.nexia.nexus.api.world.util.Location;
import net.minecraft.server.level.ServerPlayer;
import java.util.Random;
public class PlayerRespawnListener {
public void registerListener() {
PlayerRespawnEvent.BACKEND.register((respawnEvent) -> {
NexiaPlayer player = new NexiaPlayer(respawnEvent.getPlayer());
DuelsPlayerData duelsData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
CorePlayerData data = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
switch (data.gameMode.id) {
case "lobby":
if (duelsData.gameOptions != null) break;
LobbyUtil.returnToLobby(player, true);
return;
case "ffa":
BaseFfaUtil ffaUtil = FfaUtil.getFfaUtil(data.ffaGameMode);
if (ffaUtil != null) {
respawnEvent.setRespawnMode(ffaUtil.getMinecraftGameMode());
respawnEvent.setSpawnpoint(ffaUtil.getRespawnLocation());
respawnEvent.runAfterwards(() -> {
ffaUtil.respawn(player.refreshPlayer());
player.setInvulnerabilityTime(0);
});
}
return;
case "skywars":
Location respawn = new Location(0,100, 0, WorldUtil.getWorld(SkywarsGame.world));
boolean isPlaying = ((SkywarsPlayerData)PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player)).gameMode == SkywarsGameMode.PLAYING;
ServerPlayer serverPlayer = PlayerUtil.getPlayerAttacker(player.unwrap());
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
if(serverPlayer != null && !serverPlayer.equals(player.unwrap()) && isPlaying) {
respawn.setX(serverPlayer.getX());
respawn.setY(serverPlayer.getY());
respawn.setZ(serverPlayer.getZ());
}
respawnEvent.setSpawnpoint(respawn);
return;
case "bedwars":
BwPlayerEvents.respawned(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
return;
case "oitc":
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
return;
}
if(duelsData.gameOptions == null) return;
DuelsGame duelsGame = duelsData.gameOptions.duelsGame;
TeamDuelsGame teamDuelsGame = duelsData.gameOptions.teamDuelsGame;
if(duelsGame != null && duelsGame.isEnding && duelsGame.winner != null) {
player.getInventory().clear();
LobbyUtil.giveItems(player);
Location respawn = new Location(0,80, 0, WorldUtil.getWorld(duelsGame.level));
if(duelsGame.winner != null) {
respawn = duelsGame.winner.getLocation();
}
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(respawn);
} else if(teamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
player.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
Location respawn = new Location(0,80, 0, WorldUtil.getWorld(teamDuelsGame.level));
NexiaPlayer player1 = null;
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
if(teamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team2.alive.isEmpty()) {
player1 = teamDuelsGame.team2.alive.get(new Random().nextInt(teamDuelsGame.team2.alive.size()));
} else if(teamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team1.alive.isEmpty()){
player1 = teamDuelsGame.team1.alive.get(new Random().nextInt(teamDuelsGame.team1.alive.size()));
}
} else {
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
}
if(player1 != null) {
respawn = player1.getLocation();
}
respawnEvent.setSpawnpoint(respawn);
}
});
}
}
@@ -1,17 +0,0 @@
package com.nexia.core.listeners.nexus;
import com.nexia.nexus.api.event.player.PlayerSwapHandItemsEvent;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.base.player.NexiaPlayer;
public class PlayerSwapHandItemsListener {
public void registerListener(){
PlayerSwapHandItemsEvent.BACKEND.register(playerSwapHandItemsEvent -> {
NexiaPlayer player = new NexiaPlayer(playerSwapHandItemsEvent.getPlayer());
if(LobbyUtil.isLobbyWorld(player.getWorld())) {
playerSwapHandItemsEvent.setCancelled(true);
}
});
}
}
@@ -1,7 +1,5 @@
package com.nexia.core.loader;
import com.nexia.nexus.api.command.CommandSourceInfo;
import com.mojang.brigadier.CommandDispatcher;
import com.nexia.core.commands.player.*;
import com.nexia.core.commands.player.duels.*;
import com.nexia.core.commands.player.duels.custom.CustomDuelCommand;
@@ -9,7 +7,6 @@ import com.nexia.core.commands.player.duels.custom.KitEditorCommand;
import com.nexia.core.commands.player.ffa.KitCommand;
import com.nexia.core.commands.staff.*;
import com.nexia.core.commands.staff.dev.*;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.commands.minecraft.LinkCommand;
import com.nexia.discord.commands.minecraft.UnLinkCommand;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
@@ -17,64 +14,57 @@ import net.fabricmc.fabric.api.event.Event;
public class CommandLoader {
public static void registerNexusCommands() {
CommandDispatcher<CommandSourceInfo> commandDispatcher = ServerTime.nexusServer.getCommandDispatcher();
HelpCommand.register(commandDispatcher);
DiscordCommand.register(commandDispatcher);
LeaveCommand.register(commandDispatcher);
PrefixCommand.register(commandDispatcher);
RankCommand.register(commandDispatcher);
LinkCommand.register(commandDispatcher);
PingCommand.register(commandDispatcher);
SpectateCommand.register(commandDispatcher);
PartyCommand.register(commandDispatcher);
TempBanCommand.register(commandDispatcher);
ShoutCommand.register(commandDispatcher);
RanksCommand.register(commandDispatcher);
UnTempBanCommand.register(commandDispatcher);
UnLinkCommand.register(commandDispatcher);
GamemodeBanCommand.register(commandDispatcher);
UnGamemodeBanCommand.register(commandDispatcher);
DeclineDuelCommand.register(commandDispatcher);
AcceptDuelCommand.register(commandDispatcher);
StaffPrefixCommand.register(commandDispatcher);
KitEditorCommand.register(commandDispatcher);
KitLayoutCommand.register(commandDispatcher);
CustomDuelCommand.register(commandDispatcher);
StaffReportCommand.register(commandDispatcher);
ListInventoriesCommand.register(commandDispatcher);
DuelCommand.register(commandDispatcher);
QueueCommand.register(commandDispatcher);
MapCommand.register(commandDispatcher);
MuteCommand.register(commandDispatcher);
UnMuteCommand.register(commandDispatcher);
PlayCommand.register(commandDispatcher);
KitCommand.register(commandDispatcher);
BanCommand.register(commandDispatcher);
UnBanCommand.register(commandDispatcher);
StatsCommand.register(commandDispatcher);
RulesCommand.register(commandDispatcher);
ReportCommand.register(commandDispatcher);
SprintFixCommand.register(commandDispatcher);
MessageCommand.registerMsg(commandDispatcher);
MessageCommand.registerReply(commandDispatcher);
HealCommand.register(commandDispatcher);
DetectCommand.register(commandDispatcher);
SudoCommand.register(commandDispatcher);
}
public static void registerCommands() {
Event<CommandRegistrationCallback> callbackEvent = CommandRegistrationCallback.EVENT;
callbackEvent.register(ForceGameEndCommand::register);
callbackEvent.register(SprintFixCommand::register);
callbackEvent.register(DiscordCommand::register);
callbackEvent.register(LeaveCommand::register);
callbackEvent.register(ProtectionMapCommand::register);
callbackEvent.register(PrefixCommand::register);
callbackEvent.register(RankCommand::register);
callbackEvent.register(LinkCommand::register);
callbackEvent.register(PingCommand::register);
callbackEvent.register(ForceGameEndCommand::register);
callbackEvent.register(SpectateCommand::register);
callbackEvent.register(PartyCommand::register);
callbackEvent.register(TempBanCommand::register);
callbackEvent.register(ShoutCommand::register);
callbackEvent.register(RanksCommand::register);
callbackEvent.register(UnTempBanCommand::register);
callbackEvent.register(UnLinkCommand::register);
callbackEvent.register(GamemodeBanCommand::register);
callbackEvent.register(UnGamemodeBanCommand::register);
callbackEvent.register(AcceptDuelCommand::register);
callbackEvent.register(DeclineDuelCommand::register);
callbackEvent.register(StaffPrefixCommand::register);
callbackEvent.register(DevExperimentalCommandsCommand::register);
callbackEvent.register(LoadInventoryCommand::register);
callbackEvent.register(SaveInventoryCommand::register);
callbackEvent.register(ListInventoriesCommand::register);
callbackEvent.register(DeleteInventoryCommand::register);
callbackEvent.register(BwReloadShopCommand::register);
callbackEvent.register(KitEditorCommand::register);
callbackEvent.register(KitLayoutCommand::register);
callbackEvent.register(CustomDuelCommand::register);
callbackEvent.register(StaffReportCommand::register);
callbackEvent.register(DuelCommand::register);
callbackEvent.register(QueueCommand::register);
callbackEvent.register(MapCommand::register);
callbackEvent.register(MuteCommand::register);
callbackEvent.register(UnMuteCommand::register);
callbackEvent.register(PlayCommand::register);
callbackEvent.register(KitCommand::register);
callbackEvent.register(BanCommand::register);
callbackEvent.register(UnBanCommand::register);
callbackEvent.register(StatsCommand::register);
callbackEvent.register(RulesCommand::register);
callbackEvent.register(HelpCommand::register);
callbackEvent.register(ReportCommand::register);
callbackEvent.register(MessageCommand::registerMsg);
callbackEvent.register(MessageCommand::registerReply);
callbackEvent.register(RandomCommand::register);
callbackEvent.register(HealCommand::register);
callbackEvent.register(BwReloadShopCommand::register);
callbackEvent.register(BwReloadTeamColorsCommand::register);
callbackEvent.register(SkipQueueCommand::register);
}
@@ -0,0 +1,36 @@
package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.util.player.PlayerData;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.AnvilBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(AnvilBlock.class)
public class AnvilBlockMixin {
@Inject(method = "use", cancellable = true, at = @At("HEAD"))
private void use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
if (!(player instanceof ServerPlayer serverPlayer)) return;
PlayerData playerData = PlayerDataManager.get(serverPlayer);
if (BwUtil.isInBedWars(serverPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null || playerData.gameOptions.customDuelsGame != null || playerData.gameOptions.customTeamDuelsGame != null)) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaUtil.isFfaPlayer(player) && !serverPlayer.isCreative())) {
cir.setReturnValue(InteractionResult.FAIL);
return;
}
}
}
@@ -0,0 +1,30 @@
package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BeaconBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(BeaconBlock.class)
public class BeaconBlockMixin {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
if(!(player instanceof ServerPlayer))
return;
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) {
cir.setReturnValue(InteractionResult.FAIL);
}
}
}
@@ -1,6 +1,6 @@
package com.nexia.core.mixin.block;
import com.nexia.ffa.sky.utilities.FfaSkyUtil;
import com.nexia.ffa.sky.utilities.FfaAreas;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import net.minecraft.core.BlockPos;
@@ -25,7 +25,7 @@ public class BlockMixin {
private static void dropResources(BlockState blockState, Level level, BlockPos blockPos, BlockEntity blockEntity, Entity breakerEntity, ItemStack tool, CallbackInfo ci) {
if (!(level instanceof ServerLevel serverLevel)) return;
if ((BwAreas.isBedWarsWorld(serverLevel) && !(BwUtil.dropResources(blockState))) || FfaSkyUtil.INSTANCE.isFfaWorld(serverLevel)) {
if ((BwAreas.isBedWarsWorld(serverLevel) && !(BwUtil.dropResources(blockState))) || FfaAreas.isFfaWorld(serverLevel)) {
ci.cancel();
}
}
@@ -1,9 +1,7 @@
package com.nexia.core.mixin.block;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.ChestBlock;
@@ -35,7 +33,7 @@ public abstract class ChestBlockEntityMixin extends BlockEntity {
@Inject(method = "startOpen", at = @At("HEAD"))
public void onOpen(Player player, CallbackInfo ci) {
if (KitRoom.isInKitRoom(new NexiaPlayer((ServerPlayer) player))) {
if (KitRoom.isInKitRoom(player)) {
nbtList.put(player.getUUID(), new CompoundTag());
this.save(nbtList.get(player.getUUID()));
}
@@ -43,7 +41,7 @@ public abstract class ChestBlockEntityMixin extends BlockEntity {
@Inject(method = "stopOpen", at = @At("HEAD"))
public void onClose(Player player, CallbackInfo ci) {
if (KitRoom.isInKitRoom(new NexiaPlayer((ServerPlayer) player))) {
if (KitRoom.isInKitRoom(player)) {
BlockState blockState = this.getBlockState();
if(blockState.getBlock() instanceof ChestBlock) {
this.load(blockState, nbtList.get(player.getUUID()));
@@ -0,0 +1,30 @@
package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CraftingTableBlock.class)
public class CraftingTableMixin {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
if(!(player instanceof ServerPlayer))
return;
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) {
cir.setReturnValue(InteractionResult.FAIL);
}
}
}
@@ -0,0 +1,28 @@
package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(DispenserBlock.class)
public class DispenserBlockMixin {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
if(!(player instanceof ServerPlayer))
return;
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); }
}
}
@@ -1,16 +1,16 @@
package com.nexia.core.mixin.block;
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.util.player.PlayerData;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.GrindstoneBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
@@ -18,15 +18,18 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(TrapDoorBlock.class)
public class TrapDoorBlockMixin {
@Mixin(GrindstoneBlock.class)
public class GrindstoneBlockMixin {
@Inject(method = "use", cancellable = true, at = @At("HEAD"))
private void use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
if (!(player instanceof ServerPlayer serverPlayer)) return;
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
PlayerData playerData = PlayerDataManager.get(serverPlayer);
if ((FfaUtil.isFfaPlayer(nexiaPlayer) || KitRoom.isInKitRoom(nexiaPlayer) || LobbyUtil.isLobbyWorld(nexiaPlayer.getWorld())) && !player.isCreative()) {
cir.setReturnValue(InteractionResult.PASS);
if (BwUtil.isInBedWars(serverPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null || playerData.gameOptions.customTeamDuelsGame != null || playerData.gameOptions.customDuelsGame != null)) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel())) {
cir.setReturnValue(InteractionResult.FAIL);
return;
}
}
}
}
Loaded 100 of 285 files, more files were not shown because too many files have changed in this diff. Show more