Compare commits
311
Commits
factory-api
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bcfacd5f5
|
||
|
|
b293aff772
|
||
|
|
809d37368d | ||
|
|
e5ce647eb7 | ||
|
|
2c1eabebf9 | ||
|
|
4ca6da0169 | ||
|
|
4ab3e836bd | ||
|
|
90b9c8dde7 | ||
|
|
a6e5133366 | ||
|
|
906f9b6a5d | ||
|
|
f8b61a877f | ||
|
|
23750fdcba | ||
|
|
42d70666ad | ||
|
|
157e53aefb | ||
|
|
0665fb8888 | ||
|
|
2e84d2d824 | ||
|
|
54b7b7d41a | ||
|
|
8073813763 | ||
|
|
21298372e5 | ||
|
|
4db4aa8c7d | ||
|
|
898d272cdf | ||
|
|
3b77ca4c6f | ||
|
|
ba1d4c1cfa | ||
|
|
19877b2ff0 | ||
|
|
408425ec3d | ||
|
|
777835edfa | ||
|
|
a07c2dd4bc | ||
|
|
c3e08a9b12 | ||
|
|
077205c9b3 | ||
|
|
dbf2044194 | ||
|
|
bde16e50ff | ||
|
|
ed30c8f5f3 | ||
|
|
12449cf2f0 | ||
|
|
5576441e62 | ||
|
|
96a07f7d08 | ||
|
|
467c07975f | ||
|
|
12339e7447 | ||
|
|
2e1959de6b | ||
|
|
8eeb17cd90 | ||
|
|
afcb80ec6b | ||
|
|
19390f3032 | ||
|
|
51ddbcb16c | ||
|
|
a16c042b76 | ||
|
|
0748d8fbc3 | ||
|
|
d2f75e067d | ||
|
|
d5838e9261 | ||
|
|
3bfc9697bb | ||
|
|
61e9e5ef22 | ||
|
|
c835b52f70 | ||
|
|
f01c06760d | ||
|
|
09b23c91b9 | ||
|
|
aa97b8a6ed | ||
|
|
e786465817 | ||
|
|
9c179d6db4 | ||
|
|
13ad388cdd | ||
|
|
374ada44fe | ||
|
|
6b3acf50d0 | ||
|
|
9183291491 | ||
|
|
4bbe860009 | ||
|
|
5daecbd1c8 | ||
|
|
0abdaf7de6 | ||
|
|
0f279428cb | ||
|
|
6418ced879 | ||
|
|
8d2eedfad2 | ||
|
|
42f7686f9b | ||
|
|
79f2802aff | ||
|
|
952118f1f1 | ||
|
|
d672356aba | ||
|
|
4c0c09040b | ||
|
|
0c9ac7c0bc | ||
|
|
eee97477c3 | ||
|
|
4134a0f485 | ||
|
|
2fbc8e4832 | ||
|
|
870e851b3a | ||
|
|
f1334d44fe | ||
|
|
3bc51b4e4f | ||
|
|
e35570ccc4 | ||
|
|
44e50087c7 | ||
|
|
d517a4ab67 | ||
|
|
eb1d4389be | ||
|
|
a67574d9f7 | ||
|
|
75f2902494 | ||
|
|
9b41293ad7 | ||
|
|
6b178d650d | ||
|
|
a950b52ac9 | ||
|
|
38eecf7d8f | ||
|
|
9aa99e3b6e | ||
|
|
ebcdd7a84a | ||
|
|
3b892202df | ||
|
|
765ec43c1b | ||
|
|
165a4bc5a8 | ||
|
|
d41c168ff6 | ||
|
|
ddb24b67ad | ||
|
|
0e7b5050eb | ||
|
|
15baca3772 | ||
|
|
1df2117d90 | ||
|
|
faf6941264 | ||
|
|
55f138bc28 | ||
|
|
1f8c5ab569 | ||
|
|
04b495fabb | ||
|
|
45f9e66e2a | ||
|
|
363b6b2ed0 | ||
|
|
513923181e | ||
|
|
efc67e323d | ||
|
|
79d25621a9 | ||
|
|
122b096200 | ||
|
|
e1d47031d4 | ||
|
|
00fd629344 | ||
|
|
636fa9c58f | ||
|
|
00c85873be | ||
|
|
f54e80bca9 | ||
|
|
470029fa53 | ||
|
|
2fe942cae2 | ||
|
|
f2ba562218 | ||
|
|
6f89ef8191 | ||
|
|
56412ef723 | ||
|
|
6fcee5f4e4 | ||
|
|
6afb981e50 | ||
|
|
626048f35a | ||
|
|
c11c38ca96 | ||
|
|
5971f58d4a | ||
|
|
305cf9bce7 | ||
|
|
b37c112c9b | ||
|
|
09d0c22894 | ||
|
|
5d93f5e828 | ||
|
|
02cd724d88 | ||
|
|
a194915ff8 | ||
|
|
566a3f62b0 | ||
|
|
7ec796a34e | ||
|
|
3fb0b66848 | ||
|
|
aebc23f8ad | ||
|
|
b81111c3ef | ||
|
|
ab3c1fda46 | ||
|
|
006d2a36c1 | ||
|
|
a69e6cf0ef | ||
|
|
13ee67031f | ||
|
|
5815cb144c | ||
|
|
06bbc113f8 | ||
|
|
1612e57576 | ||
|
|
7fb61194d1 | ||
|
|
e9da1c1293 | ||
|
|
931cd0d1df | ||
|
|
54024347c1 | ||
|
|
f8f6ae7fd6 | ||
|
|
865e2f86f0 | ||
|
|
eda218c318 | ||
|
|
1159809d8d | ||
|
|
8d5daa77fc | ||
|
|
8f817b8244 | ||
|
|
6afed694af | ||
|
|
ec345bc425 | ||
|
|
66d6e90ca2 | ||
|
|
37cf308b9f | ||
|
|
75e2ec1ea9 | ||
|
|
f0192d1695 | ||
|
|
aa72653b61 | ||
|
|
78b082a544 | ||
|
|
79ec20ac94 | ||
|
|
6bfcfb095a | ||
|
|
6c2da25b00 | ||
|
|
fcd0e1265e | ||
|
|
736952e5f2 | ||
|
|
40ddd432f6 | ||
|
|
d04b6b0317 | ||
|
|
27faf3de8b | ||
|
|
4d0c70d0ee | ||
|
|
2ff968535a | ||
|
|
4b1030cf24 | ||
|
|
a167a9f692 | ||
|
|
87c1e162de | ||
|
|
97a92653c9 | ||
|
|
8fe9db4a48 | ||
|
|
0024c147e3 | ||
|
|
6a4a4f096c | ||
|
|
7367990354 | ||
|
|
818f543c7d | ||
|
|
708e23dd68 | ||
|
|
c4f87d9686 | ||
|
|
de2a6a4bc1 | ||
|
|
c740834140 | ||
|
|
abd14e6940 | ||
|
|
9856518f92 | ||
|
|
2f2fa60101 | ||
|
|
b4facdd618 | ||
|
|
ae410788f5 | ||
|
|
fb9828c48c | ||
|
|
501371722c | ||
|
|
7138a2a06c | ||
|
|
a50d75d7fd | ||
|
|
1f9c0b2036 | ||
|
|
7abae75667 | ||
|
|
a3d34dfa49 | ||
|
|
9dc5c0889d | ||
|
|
9f642e0969 | ||
|
|
0453f62205 | ||
|
|
26f69dc5de | ||
|
|
1f58950fbc | ||
|
|
814848b1c0 | ||
|
|
45a860becf | ||
|
|
e2f469c9a9 | ||
|
|
fc487de6da | ||
|
|
4589af5e01 | ||
|
|
3737d47253 | ||
|
|
c778ce00aa | ||
|
|
5f740e2dcd | ||
|
|
6dc570b86f | ||
|
|
22ad3d1511 | ||
|
|
4129a0c81c | ||
|
|
7bce50f0f5 | ||
|
|
12d701ee87 | ||
|
|
05a8556980 | ||
|
|
3c8f1d5dc0 | ||
|
|
0838895885 | ||
|
|
f70252e467 | ||
|
|
010b2684ac | ||
|
|
03ed346436 | ||
|
|
7e7aab74e2 | ||
|
|
1c2ada628e | ||
|
|
a5120288c0 | ||
|
|
45b6f69b4e | ||
|
|
cc098b6857 | ||
|
|
fca5e5d52e | ||
|
|
0c4f7ae57f | ||
|
|
16ef47c7b2 | ||
|
|
fe2c84fc5e | ||
|
|
980200ab96 | ||
|
|
c5e79d395a | ||
|
|
f762f00161 | ||
|
|
4b6a4c21a0 | ||
|
|
abd51966e9 | ||
|
|
e8662ed39f | ||
|
|
ba525e8ef5 | ||
|
|
8c921ae845 | ||
|
|
248bf56cd4 | ||
|
|
5117070701 | ||
|
|
a85dc3d75f | ||
|
|
192d84d1b1 | ||
|
|
ec278a7270 | ||
|
|
e62f291d2c | ||
|
|
2281e5a099 | ||
|
|
417b28dce1 | ||
|
|
99ac96891f | ||
|
|
90bc4d48fd | ||
|
|
abf625fb0f | ||
|
|
44896ac204 | ||
|
|
337c87a4e4 | ||
|
|
f65549c8d2 | ||
|
|
9c31861d77 | ||
|
|
543f0c6193 | ||
|
|
e5ae905cee | ||
|
|
148e30c1e2 | ||
|
|
e55407fc4a | ||
|
|
da8b5adba8 | ||
|
|
966b027416 | ||
|
|
b08eba316f | ||
|
|
5c73156e94 | ||
|
|
efc7e439c5 | ||
|
|
92f6bb28d7 | ||
|
|
94f2ae9dc7 | ||
|
|
c4a85a3bc1 | ||
|
|
383056f5ed | ||
|
|
5c715dfbd3 | ||
|
|
2612b4b85d | ||
|
|
e94e07ae54 | ||
|
|
898879bdfd | ||
|
|
522f5d50a8 | ||
|
|
a233518e4c | ||
|
|
afea5e2c98 | ||
|
|
636ed4474e | ||
|
|
706ca304d2 | ||
|
|
f4d3b6e0eb | ||
|
|
67160e9e04 | ||
|
|
c1f68c40c8 | ||
|
|
53d10b0256 | ||
|
|
d093ee99ef | ||
|
|
9bd33003a2 | ||
|
|
25c03b80f7 | ||
|
|
e5f604cad4 | ||
|
|
ada386884c | ||
|
|
8ca8eda480 | ||
|
|
15d1b260bb | ||
|
|
1c9ed40f07 | ||
|
|
69257ea282 | ||
|
|
0fd61bf452 | ||
|
|
6ea698a101 | ||
|
|
1693b71e2e | ||
|
|
3e2945ec4f | ||
|
|
2a7f8d6b64 | ||
|
|
a4336bb2a9 | ||
|
|
845f847240 | ||
|
|
76690f1275 | ||
|
|
b8df37dddc | ||
|
|
356812745d | ||
|
|
d28ca0594c | ||
|
|
f83fc5a932 | ||
|
|
c3ab15a853 | ||
|
|
2681e6ae63 | ||
|
|
1e03eb833b | ||
|
|
0d776a6ce7 | ||
|
|
77404cb581 | ||
|
|
a13548f249 | ||
|
|
3cd3c656c0 | ||
|
|
9d1253d6d8 | ||
|
|
0c994df90a | ||
|
|
67f9b2666f | ||
|
|
d939832225 | ||
|
|
71286130ad | ||
|
|
9c21f848ff | ||
|
|
321f0ddaa2 | ||
|
|
eb5ef69fbd | ||
|
|
7f672c3ae3 |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# 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
@@ -93,4 +93,4 @@ bin/
|
||||
# fabric
|
||||
|
||||
run/
|
||||
.factorypath
|
||||
.nexuspath
|
||||
@@ -4,7 +4,7 @@
|
||||
<br>
|
||||
|
||||
# Nexia
|
||||
using **Factory API**
|
||||
using **Nexus API**
|
||||
|
||||
The mod for the Nexia CTS server.
|
||||
|
||||
@@ -15,9 +15,6 @@ 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`
|
||||
|
||||
+22
-27
@@ -50,51 +50,46 @@ 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}"
|
||||
|
||||
|
||||
modImplementation("com.combatreforged.factory:factory-api:${project.factory_version}-full")
|
||||
modImplementation("com.combatreforged.factory:factory-builder:${project.factory_version}-${project.minecraft_version}-full")
|
||||
|
||||
include(implementation("com.google.code.gson:gson:${project.gson_version}"))
|
||||
|
||||
include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_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 "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${project.mixin_extras_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") })
|
||||
// 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}"))
|
||||
|
||||
modImplementation("com.natamus:saveandloadinventories_fabric:${project.saveandloadinventories_version}")
|
||||
// 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") })
|
||||
modApi("com.natamus.collective:collective-fabric:${project.collective_version}")
|
||||
|
||||
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}"))
|
||||
// somewhat useful stuff
|
||||
modApi("me.lucko:fabric-permissions-api:${project.fabric_permissions_api_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:${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}")
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
+8
-9
@@ -14,27 +14,26 @@ maven_group = com.nexia
|
||||
archives_base_name = nexia
|
||||
|
||||
# Dependencies
|
||||
fabric_version= 0.42.0+1.16
|
||||
plasmid_version=0.4.0
|
||||
fabric_version=0.42.0+1.16
|
||||
mongodb_version=5.1.2
|
||||
jda_version=5.0.0-beta.20
|
||||
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
|
||||
mixin_extras_version=0.4.0
|
||||
nexus_version=0.1.15
|
||||
collective_version=1.16.5-5.50
|
||||
fantasy_version=0.4.2
|
||||
fantasy_version=0.4.3
|
||||
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
|
||||
codelib_version=1.0.4
|
||||
luckperms_api_version=5.4
|
||||
adventure_version=4.1.0-SNAPSHOT
|
||||
minedown_adventure_version=1.7.3-SNAPSHOT
|
||||
|
||||
# Useless dependencies
|
||||
json_simple_version=1.1.1
|
||||
discord_webhooks_version=0.8.4
|
||||
json_version=20230227
|
||||
gson_version=2.10.1
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
+90
-25
@@ -1,37 +1,44 @@
|
||||
package com.nexia.core.utilities.player;
|
||||
package com.nexia.base.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.effect.StatusEffectInstance;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.item.ItemStack;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.factory.builder.implementation.world.entity.player.WrappedPlayer;
|
||||
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.network.protocol.game.ClientboundStopSoundPacket;
|
||||
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.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class NexiaPlayer extends WrappedPlayer {
|
||||
|
||||
public NexiaPlayer(ServerPlayer wrappedPlayer) {
|
||||
@@ -52,44 +59,80 @@ public class NexiaPlayer extends WrappedPlayer {
|
||||
this.getInventory().setCursorStack(ItemStack.create(Minecraft.Item.AIR));
|
||||
|
||||
this.unwrap().getEnderChestInventory().clearContent();
|
||||
this.unwrap().setGlowing(false);
|
||||
this.unwrap().connection.send(new ClientboundStopSoundPacket());
|
||||
this.setGlowing(false);
|
||||
this.stopAllSounds();
|
||||
|
||||
this.setGameMode(gameMode);
|
||||
|
||||
if (heal) {
|
||||
this.setHealth(this.unwrap().getMaxHealth());
|
||||
this.setHealth(this.getMaxHealth());
|
||||
this.setFoodLevel(20);
|
||||
}
|
||||
|
||||
|
||||
this.setAbleToFly(false);
|
||||
|
||||
|
||||
Objects.requireNonNull(this.unwrap().getAttribute(Attributes.KNOCKBACK_RESISTANCE)).setBaseValue(0.0);
|
||||
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.unwrap().setGlowing(false);
|
||||
|
||||
this.setGameMode(gameMode);
|
||||
this.setGlowing(false);
|
||||
|
||||
if (heal) {
|
||||
this.setHealth(this.unwrap().getMaxHealth());
|
||||
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);
|
||||
}
|
||||
@@ -113,16 +156,20 @@ public class NexiaPlayer extends WrappedPlayer {
|
||||
BwPlayerEvents.leaveInBedWars(this);
|
||||
} else if (FfaUtil.isFfaPlayer(this)) {
|
||||
FfaUtil.leaveOrDie(this, this.unwrap().getLastDamageSource(), true);
|
||||
} else if (PlayerDataManager.get(this).gameMode == PlayerGameMode.LOBBY) {
|
||||
} else if (this.isInGameMode(PlayerGameMode.LOBBY)) {
|
||||
DuelGameHandler.leave(this, false);
|
||||
} else if (PlayerDataManager.get(this).gameMode == PlayerGameMode.OITC) {
|
||||
} else if (this.isInGameMode(PlayerGameMode.OITC)) {
|
||||
OitcGame.leave(this);
|
||||
} else if (PlayerDataManager.get(this).gameMode == PlayerGameMode.SKYWARS) {
|
||||
} else if (this.isInGameMode(PlayerGameMode.SKYWARS)) {
|
||||
SkywarsGame.leave(this);
|
||||
} else if (PlayerDataManager.get(this).gameMode == PlayerGameMode.FOOTBALL) {
|
||||
} 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);
|
||||
}
|
||||
@@ -167,6 +214,14 @@ public class NexiaPlayer extends WrappedPlayer {
|
||||
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;
|
||||
@@ -189,4 +244,14 @@ public class NexiaPlayer extends WrappedPlayer {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
package com.nexia.discord.utilities.player;
|
||||
package com.nexia.base.player;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
// Stuff saved into files
|
||||
@@ -0,0 +1,140 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
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.");
|
||||
|
||||
networkingHandler = new NetworkingHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("FutureReturnValueIgnored")
|
||||
public void onFactoryLoad(FactoryAPI api, FactoryServer server) {
|
||||
Main.logger.info("Loading Factory API...");
|
||||
|
||||
ServerTime.factoryServer = server;
|
||||
ServerTime.factoryAPI = api;
|
||||
ServerTime.scheduler = api.getScheduler();
|
||||
|
||||
Main.logger.info("Registering listeners...");
|
||||
ListenerHelper.registerListeners();
|
||||
Main.logger.info("Registered listeners.");
|
||||
Main.logger.info("Registering factory commands...");
|
||||
CommandLoader.registerFactoryCommands();
|
||||
Main.logger.info("Registered factory commands.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
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,12 +1,12 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.Main;
|
||||
import com.nexia.discord.NexiaDiscord;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
@@ -21,11 +21,13 @@ public class DiscordCommand {
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Link to discord: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(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)))
|
||||
));
|
||||
.append(Component.text("Link to discord: ", ChatFormat.normalColor))
|
||||
.append(Component.text(NexiaDiscord.config.discordLink, ChatFormat.brandColor2)
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.greenColor)))
|
||||
.clickEvent(ClickEvent.openUrl(NexiaDiscord.config.discordLink))
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -47,10 +47,10 @@ 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.bold, false).decoration(ChatFormat.strikeThrough, false))
|
||||
.append(Component.text(commandInfo[1]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.strikeThrough, false)));
|
||||
.append(Component.text(" | ").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, false))
|
||||
.append(Component.text(commandInfo[1], ChatFormat.brandColor2).decoration(ChatFormat.strikeThrough, false)));
|
||||
|
||||
//message += "\n" + ChatFormat.brandColor1 + "/" + commandInfo[0] + ChatFormat.lineColor + " | " + ChatFormat.brandColor2 + commandInfo[1];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
|
||||
public class LeaveCommand {
|
||||
|
||||
@@ -21,10 +21,8 @@ public class LeaveCommand {
|
||||
dispatcher.register(CommandUtils.literal(string).executes(LeaveCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.PlayerMutes;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
|
||||
|
||||
public class MessageCommand {
|
||||
@@ -49,10 +51,9 @@ public class MessageCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private static int msgCommand(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer sender = CommandUtil.getPlayer(context);
|
||||
NexiaPlayer receiver = new NexiaPlayer(context.getArgument("player", ServerPlayer.class));
|
||||
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)));
|
||||
String message = StringArgumentType.getString(context, "message");
|
||||
|
||||
sendMessage(sender, receiver, message);
|
||||
@@ -60,10 +61,9 @@ public class MessageCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int replyCommand(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer sender = CommandUtil.getPlayer(context);
|
||||
PlayerData senderData = PlayerDataManager.get(sender);
|
||||
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;
|
||||
|
||||
if (receiver == null) {
|
||||
@@ -81,20 +81,20 @@ public class MessageCommand {
|
||||
if (PlayerMutes.muted(sender) || sender.equals(receiver)) return;
|
||||
|
||||
sender.sendMessage(
|
||||
Component.text(String.format("To %s", receiver.getRawName())).color(ChatFormat.brandColor2)
|
||||
Component.text(String.format("To %s", receiver.getRawName()), ChatFormat.brandColor2)
|
||||
.append(Component.text(" » ").color(ChatFormat.arrowColor)
|
||||
.append(Component.text(message).color(ChatFormat.brandColor2))
|
||||
.append(Component.text(message, ChatFormat.brandColor2))
|
||||
|
||||
));
|
||||
|
||||
receiver.sendMessage(
|
||||
Component.text(String.format("From %s", sender.getRawName())).color(ChatFormat.brandColor2)
|
||||
Component.text(String.format("From %s", sender.getRawName()), ChatFormat.brandColor2)
|
||||
.append(Component.text(" » ").color(ChatFormat.arrowColor)
|
||||
.append(Component.text(message).color(ChatFormat.brandColor2))
|
||||
.append(Component.text(message, ChatFormat.brandColor2))
|
||||
|
||||
));
|
||||
|
||||
PlayerDataManager.get(receiver).lastMessageSender = sender;
|
||||
((CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(receiver)).lastMessageSender = sender;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -16,26 +17,25 @@ 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()))))
|
||||
.executes(context -> PingCommand.ping(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
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()))))
|
||||
.executes(context -> PingCommand.ping(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
int ping = CommandUtil.getPlayer(context).unwrap().latency;
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
int ping = new NexiaPlayer(context.getSource().getPlayerOrException()).getLatency();
|
||||
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your ping is ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(ping + "ms").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor))
|
||||
.append(Component.text(" (ping may not be accurate)").color(NamedTextColor.GRAY).decorate(ChatFormat.italic))
|
||||
.append(Component.text("Your ping is ", ChatFormat.normalColor)
|
||||
.append(Component.text(ping + "ms", ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
.append(Component.text(" (ping may not be accurate)", ChatFormat.Minecraft.dark_gray).decorate(ChatFormat.italic))
|
||||
));
|
||||
|
||||
return ping;
|
||||
@@ -46,12 +46,12 @@ public class PingCommand {
|
||||
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("The ping of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" is ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(ping + "ms").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" (ping may not be accurate)").color(NamedTextColor.GRAY).decorate(ChatFormat.italic).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("The ping of ", ChatFormat.normalColor))
|
||||
.append(Component.text(player.getScoreboardName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(" is ", ChatFormat.normalColor))
|
||||
.append(Component.text(ping + "ms", ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
.append(Component.text(" (ping may not be accurate)", ChatFormat.Minecraft.dark_gray).decorate(ChatFormat.italic))
|
||||
);
|
||||
|
||||
return ping;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.core.gui.PlayGUI;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
|
||||
public class PlayCommand {
|
||||
|
||||
@@ -16,94 +17,49 @@ public class PlayCommand {
|
||||
register(dispatcher, "join");
|
||||
|
||||
dispatcher.register(CommandUtils.literal("ffa").executes(PlayCommand::openFFAGui)
|
||||
.then(CommandUtils.literal("kits").executes(PlayCommand::playKitFFA))
|
||||
.then(CommandUtils.literal("sky").executes(PlayCommand::playSkyFFA))
|
||||
.then(CommandUtils.literal("uhc").executes(PlayCommand::playUhcFFA))
|
||||
.then(CommandUtils.literal("classic").executes(PlayCommand::playNormalFFA))
|
||||
.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")))
|
||||
);
|
||||
}
|
||||
|
||||
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(PlayCommand::playKitFFA))
|
||||
.then(CommandUtils.literal("sky").executes(PlayCommand::playSkyFFA))
|
||||
.then(CommandUtils.literal("uhc").executes(PlayCommand::playUhcFFA))
|
||||
.then(CommandUtils.literal("classic").executes(PlayCommand::playNormalFFA)))
|
||||
.then(CommandUtils.literal("bedwars").executes(PlayCommand::playBedWars))
|
||||
.then(CommandUtils.literal("duels").executes(PlayCommand::playDuels))
|
||||
.then(CommandUtils.literal("skywars").executes(PlayCommand::playSkywars))
|
||||
.then(CommandUtils.literal("sw").executes(PlayCommand::playSkywars))
|
||||
.then(CommandUtils.literal("football").executes(PlayCommand::playFootball))
|
||||
.then(CommandUtils.literal("oitc").executes(PlayCommand::playOITC))
|
||||
.then(CommandUtils.literal("bw").executes(PlayCommand::playBedWars)));
|
||||
.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 int openGUI(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
PlayGUI.openMainGUI(CommandUtil.getPlayer(context).unwrap());
|
||||
private static int openGUI(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
PlayGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int openFFAGui(CommandContext<CommandSourceInfo> context){
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
PlayGUI.openMainGUI(CommandUtil.getPlayer(context).unwrap()).setFFALayout();
|
||||
private static int openFFAGui(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
PlayGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap()).setFFALayout();
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playNormalFFA(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "classic ffa", true, true);
|
||||
return 1;
|
||||
private static int playGame(CommandContext<CommandSourceInfo> context, String game) throws CommandSyntaxException {
|
||||
return playGame(new NexiaPlayer(context.getSource().getPlayerOrException()), game);
|
||||
}
|
||||
|
||||
private static int playKitFFA(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "kits ffa", true, true);
|
||||
private static int playGame(NexiaPlayer player, String game) {
|
||||
LobbyUtil.sendGame(player, game, true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playUhcFFA(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "uhc ffa", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playSkyFFA(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "sky ffa", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playBedWars(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "bedwars", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playDuels(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "duels", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playOITC(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "oitc", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playFootball(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "football", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playSkywars(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
LobbyUtil.sendGame(CommandUtil.getPlayer(context), "skywars", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
|
||||
public class PrefixCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("prefix").executes(PrefixCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
PrefixGUI.openRankGUI(CommandUtil.getPlayer(context).unwrap());
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
PrefixGUI.openRankGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
|
||||
public class RanksCommand {
|
||||
|
||||
@@ -16,9 +17,8 @@ public class RanksCommand {
|
||||
dispatcher.register(CommandUtils.literal("role").executes(RanksCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
RanksGUI.openMainGUI(CommandUtil.getPlayer(context).unwrap());
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
RanksGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.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.http.DiscordWebhook;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.discord.Main;
|
||||
import com.nexia.discord.NexiaDiscord;
|
||||
import com.nexia.nexus.api.world.entity.player.Player;
|
||||
import com.nexia.nexus.builder.implementation.world.entity.player.WrappedPlayer;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -23,7 +28,7 @@ import java.awt.*;
|
||||
public class ReportCommand {
|
||||
|
||||
private static boolean sendWebhook(String reporter, String victim, String reason){
|
||||
DiscordWebhook webhook = new DiscordWebhook(Main.config.reportWebhook);
|
||||
DiscordWebhook webhook = new DiscordWebhook(NexiaDiscord.config.reportWebhook);
|
||||
webhook.addEmbed(new DiscordWebhook.EmbedObject()
|
||||
.setAuthor((reporter + " reported " + victim), null, null)
|
||||
.setColor(Color.RED)
|
||||
@@ -45,60 +50,46 @@ public class ReportCommand {
|
||||
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())), StringArgumentType.getString(context, "reason")))
|
||||
.executes(context -> ReportCommand.report(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "reason")))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static int report(CommandContext<CommandSourceInfo> context, ServerPlayer player, String reason) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = CommandUtil.getPlayer(context);
|
||||
public static int report(CommandContext<CommandSourceInfo> context, ServerPlayer player, String reason) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if(PlayerDataManager.get(executor).savedData.isReportBanned()) {
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You are report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)
|
||||
)
|
||||
|
||||
);
|
||||
if(((CoreSavedPlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(executor).savedData).isReportBanned()) {
|
||||
executor.sendNexiaMessage("You are report banned!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(executor.getUUID().equals(player.getUUID())){
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You cannot report yourself!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
|
||||
|
||||
);
|
||||
executor.sendNexiaMessage("You cannot report yourself!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have reported ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2))
|
||||
.append(Component.text(" for ").color(ChatFormat.normalColor))
|
||||
.append(Component.text(reason).color(ChatFormat.brandColor2))
|
||||
executor.sendNexiaMessage(
|
||||
Component.text("You have reported ", ChatFormat.normalColor)
|
||||
.append(Component.text(player.getScoreboardName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(" for ", ChatFormat.normalColor))
|
||||
.append(Component.text(reason, ChatFormat.brandColor2))
|
||||
);
|
||||
|
||||
if(!sendWebhook(executor.getRawName(), player.getScoreboardName(), reason)) {
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Failed to send webhook! Don't worry, staff who are currently online will see your report!").decoration(ChatFormat.bold, false).color(ChatFormat.normalColor))
|
||||
);
|
||||
executor.sendNexiaMessage("Failed to send webhook! Don't worry, staff who are currently online will see your report!");
|
||||
}
|
||||
|
||||
Component staffReportMessage = ChatFormat.nexiaMessage
|
||||
.append(Component.text(executor.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" has reported ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(reason).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false));
|
||||
.append(Component.text(executor.getRawName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(" has reported ", ChatFormat.normalColor))
|
||||
.append(Component.text(player.getScoreboardName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(" for ", ChatFormat.normalColor))
|
||||
.append(Component.text(reason, ChatFormat.brandColor2));
|
||||
|
||||
for (ServerPlayer staffPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()){
|
||||
if(Permissions.check(staffPlayer, "nexia.staff.report", 1)) ServerTime.factoryServer.getPlayer(staffPlayer.getUUID()).sendMessage(staffReportMessage);
|
||||
for (Player staffPlayer : ServerTime.nexusServer.getPlayers()){
|
||||
if(Permissions.check(((WrappedPlayer) staffPlayer).unwrap(), "nexia.staff.report", 1)) staffPlayer.sendMessage(staffReportMessage);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.Main;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -26,11 +26,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").color(ChatFormat.brandColor1).decoration(ChatFormat.strikeThrough, false))
|
||||
.append(Component.text("Rules", ChatFormat.brandColor1).decoration(ChatFormat.strikeThrough, false))
|
||||
.append(Component.text(" ]").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, false))
|
||||
.append(Component.text(" ").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, true)));
|
||||
|
||||
for (int i = 0; i < Main.config.rules.length; i++) {
|
||||
for (int i = 0; i < NexiaCore.config.rules.length; i++) {
|
||||
|
||||
message = message.append(Component.text("\n" + (i+1) + ". ")
|
||||
.color(ChatFormat.brandColor1)
|
||||
@@ -38,10 +38,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(Main.config.rules[i])
|
||||
.decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(NexiaCore.config.rules[i])
|
||||
|
||||
.decoration(ChatFormat.strikeThrough, false)
|
||||
.color(ChatFormat.normalColor)
|
||||
)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.combatreforged.factory.api.world.entity.player.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.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.PlayerMutes;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@@ -39,9 +40,8 @@ public class ShoutCommand {
|
||||
}
|
||||
|
||||
|
||||
public static int shout(CommandContext<CommandSourceInfo> context, String message) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = CommandUtil.getPlayer(context);
|
||||
public static int shout(CommandContext<CommandSourceInfo> context, String message) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if (PlayerMutes.muted(executor)) return 0;
|
||||
|
||||
@@ -50,19 +50,18 @@ public class ShoutCommand {
|
||||
|
||||
if(longTime - System.currentTimeMillis() > 0) {
|
||||
String time = ShoutCommand.timeToText(longTime - System.currentTimeMillis());
|
||||
executor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("You are still on cooldown, you have ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(time).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" left!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
));
|
||||
executor.sendNexiaMessage(
|
||||
Component.text("You are still on cooldown, you have ", ChatFormat.normalColor)
|
||||
.append(Component.text(time, ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" left!", ChatFormat.normalColor))
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Component cmessage = Component.text(executor.getRawName()).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true)
|
||||
.append(Component.text( " shouts: " + message).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
);
|
||||
Component cmessage = Component.text(executor.getRawName(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true)
|
||||
.append(Component.text( " shouts: " + message, ChatFormat.normalColor));
|
||||
|
||||
for(Player player : ServerTime.factoryServer.getPlayers()) {
|
||||
for(Player player : ServerTime.nexusServer.getPlayers()) {
|
||||
player.sendMessage(cmessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
@@ -28,51 +30,41 @@ public class SpectateCommand {
|
||||
dispatcher.register(CommandUtils.literal("spectate")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
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()))))
|
||||
.executes(context -> SpectateCommand.spectate(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int gameModeSpectate(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = CommandUtil.getPlayer(context);
|
||||
public static int gameModeSpectate(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if(PlayerDataManager.get(executor).gameMode != PlayerGameMode.FFA) {
|
||||
executor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
executor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("If you are in duels then you do /spectate <player>.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
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>.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!Permissions.check(executor.unwrap(), "nexia.prefix.supporter")) {
|
||||
executor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("This feature is only available for").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
if(!executor.hasPermission("nexia.prefix.supporter")) {
|
||||
executor.sendNexiaMessage(
|
||||
Component.text("This feature is only available for", ChatFormat.normalColor)
|
||||
.append(Component.text("Supporters")
|
||||
.color(ChatFormat.brandColor1)
|
||||
.decoration(ChatFormat.bold, true)
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click me").color(ChatFormat.brandColor1)))
|
||||
.clickEvent(ClickEvent.suggestCommand("/ranks")
|
||||
)
|
||||
.append(Component.text("!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.brandColor1)))
|
||||
.clickEvent(ClickEvent.suggestCommand("/ranks"))
|
||||
.append(Component.text("!", ChatFormat.normalColor))
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,9 +73,7 @@ public class SpectateCommand {
|
||||
}
|
||||
|
||||
if(Math.round(executor.getHealth()) < 20) {
|
||||
executor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
executor.sendNexiaMessage("You must be fully healed to go into spectator!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -92,29 +82,26 @@ public class SpectateCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int spectate(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer nexiaExecutor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int spectate(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer nexiaExecutor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(player);
|
||||
|
||||
if(PlayerDataManager.get(nexiaPlayer).gameMode == PlayerGameMode.LOBBY) {
|
||||
if(nexiaPlayer.isInGameMode(PlayerGameMode.LOBBY)) {
|
||||
GamemodeHandler.spectatePlayer(nexiaExecutor, nexiaPlayer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!Permissions.check(nexiaExecutor.unwrap(), "nexia.prefix.supporter")) {
|
||||
nexiaExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("This feature is only available for").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
if(!nexiaExecutor.hasPermission("nexia.prefix.supporter")) {
|
||||
nexiaExecutor.sendNexiaMessage(
|
||||
Component.text("This feature is only available for", ChatFormat.normalColor)
|
||||
.append(Component.text("Supporters")
|
||||
.color(ChatFormat.brandColor1)
|
||||
.decoration(ChatFormat.bold, true)
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click me").color(ChatFormat.brandColor1)))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click me", ChatFormat.brandColor1)))
|
||||
.clickEvent(ClickEvent.suggestCommand("/ranks")
|
||||
)
|
||||
.append(Component.text("!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("!", ChatFormat.normalColor))
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,28 +109,20 @@ public class SpectateCommand {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(PlayerDataManager.get(nexiaExecutor).gameMode != PlayerGameMode.FFA) {
|
||||
nexiaExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
nexiaExecutor.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(((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(!FfaUtil.isFfaPlayer(nexiaPlayer)) {
|
||||
nexiaExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("That player is not in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
nexiaExecutor.sendNexiaMessage("That player is not in FFA!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if player is in combat (or full health), then put them in spectator.
|
||||
|
||||
if(Math.round(nexiaExecutor.getHealth()) < 20) {
|
||||
nexiaExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
nexiaExecutor.sendNexiaMessage("You must be fully healed to go into spectator!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.SavedPlayerData;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
|
||||
public class SprintFixCommand {
|
||||
@@ -16,12 +17,11 @@ public class SprintFixCommand {
|
||||
dispatcher.register(CommandUtils.literal("sprintfix").executes(SprintFixCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(context);
|
||||
SavedPlayerData data = PlayerDataManager.get(player).savedData;
|
||||
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;
|
||||
|
||||
player.sendMessage(ChatFormat.nexiaMessage.append(Component.text((data.setSprintFix(!data.isSprintFix()) ? "Enabled" : "Disabled") + " Sprint Fix!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)));
|
||||
player.sendNexiaMessage(Component.text((data.setSprintFix(!data.isSprintFix()) ? "Enabled" : "Disabled") + " Sprint Fix!", ChatFormat.normalColor));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.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.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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.ffa.FfaGameMode;
|
||||
import com.nexia.ffa.classic.utilities.player.PlayerDataManager;
|
||||
import com.nexia.ffa.classic.utilities.player.SavedPlayerData;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
@@ -29,179 +30,165 @@ public class StatsCommand {
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.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())), StringArgumentType.getString(context, "gamemode")))))
|
||||
.executes(context -> StatsCommand.other(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "gamemode")))))
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(context);
|
||||
PlayerData playerData = com.nexia.core.utilities.player.PlayerDataManager.get(player);
|
||||
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);
|
||||
|
||||
|
||||
Component start = Component.text(" »").color(NamedTextColor.GRAY);
|
||||
Component start = Component.text(" »").color(ChatFormat.arrowColor);
|
||||
|
||||
Component user = start
|
||||
.append(Component.text(" User: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(player.getRawName()).color(ChatFormat.normalColor));
|
||||
.append(Component.text(" User: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(player.getRawName(), ChatFormat.normalColor));
|
||||
|
||||
|
||||
|
||||
Component message;
|
||||
|
||||
if(playerData.gameMode == PlayerGameMode.FFA){
|
||||
|
||||
if (playerData.gameMode == PlayerGameMode.FFA) {
|
||||
message = ChatFormat.separatorLine("FFA Classic Stats");
|
||||
SavedPlayerData data = PlayerDataManager.get(player).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FFA_CLASSIC_DATA_MANAGER).get(player).savedData;
|
||||
|
||||
int kills = data.kills;
|
||||
int deaths = data.deaths;
|
||||
int killstreak = data.killstreak;
|
||||
int bestKillstreak = data.bestKillstreak;
|
||||
|
||||
if(playerData.ffaGameMode == FfaGameMode.KITS) {
|
||||
if (playerData.ffaGameMode == FfaGameMode.KITS) {
|
||||
message = ChatFormat.separatorLine("Kit FFA Stats");
|
||||
com.nexia.ffa.kits.utilities.player.SavedPlayerData kData = com.nexia.ffa.kits.utilities.player.PlayerDataManager.get(player).savedData;
|
||||
kills = kData.kills;
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
data = PlayerDataManager.getDataManager(NexiaCore.FFA_KITS_DATA_MANAGER).get(player).savedData;
|
||||
}
|
||||
|
||||
if(playerData.ffaGameMode == FfaGameMode.UHC) {
|
||||
if (playerData.ffaGameMode == FfaGameMode.UHC) {
|
||||
message = ChatFormat.separatorLine("UHC FFA Stats");
|
||||
com.nexia.ffa.uhc.utilities.player.SavedPlayerData kData = com.nexia.ffa.uhc.utilities.player.PlayerDataManager.get(player).savedData;
|
||||
kills = kData.kills;
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
data = PlayerDataManager.getDataManager(NexiaCore.FFA_UHC_DATA_MANAGER).get(player).savedData;
|
||||
}
|
||||
|
||||
if(playerData.ffaGameMode == FfaGameMode.SKY) {
|
||||
if (playerData.ffaGameMode == FfaGameMode.SKY) {
|
||||
message = ChatFormat.separatorLine("Sky FFA Stats");
|
||||
com.nexia.ffa.sky.utilities.player.SavedPlayerData kData = com.nexia.ffa.sky.utilities.player.PlayerDataManager.get(player).savedData;
|
||||
kills = kData.kills;
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
data = PlayerDataManager.getDataManager(NexiaCore.FFA_SKY_DATA_MANAGER).get(player).savedData;
|
||||
}
|
||||
|
||||
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: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(kills).color(ChatFormat.greenColor))
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(kills).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Deaths: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(deaths).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Deaths: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(deaths, ChatFormat.failColor))
|
||||
);
|
||||
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" KDR: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor))
|
||||
.append(Component.text(" KDR: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor))
|
||||
);
|
||||
|
||||
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))
|
||||
.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))
|
||||
);
|
||||
}
|
||||
|
||||
if(playerData.gameMode == PlayerGameMode.LOBBY){
|
||||
message = ChatFormat.separatorLine("Duels Stats");
|
||||
com.nexia.minigames.games.duels.util.player.SavedPlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player).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))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(playerData.gameMode == PlayerGameMode.BEDWARS){
|
||||
message = ChatFormat.separatorLine("Bedwars Stats");
|
||||
com.nexia.minigames.games.bedwars.util.player.SavedPlayerData data = com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.get(player).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.BEDWARS_DATA_MANAGER).get(player).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))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Beds broken: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.bedsBroken).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Beds broken: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "bedsBroken"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
if(playerData.gameMode == PlayerGameMode.OITC){
|
||||
message = ChatFormat.separatorLine("OITC Stats");
|
||||
com.nexia.minigames.games.oitc.util.player.SavedPlayerData data = com.nexia.minigames.games.oitc.util.player.PlayerDataManager.get(player).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(player).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))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.kills).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
if(playerData.gameMode == PlayerGameMode.FOOTBALL){
|
||||
message = ChatFormat.separatorLine("Football Stats");
|
||||
com.nexia.minigames.games.football.util.player.SavedPlayerData data = com.nexia.minigames.games.football.util.player.PlayerDataManager.get(player).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FOOTBALL_DATA_MANAGER).get(player).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))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Goals: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.goals).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Goals: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "goals"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
if(playerData.gameMode == PlayerGameMode.SKYWARS){
|
||||
message = ChatFormat.separatorLine("SkyWars Stats");
|
||||
com.nexia.minigames.games.skywars.util.player.SavedPlayerData data = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(player).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player).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))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.losses).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.kills).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
player.sendMessage(ChatFormat.separatorLine(null));
|
||||
@@ -220,68 +207,56 @@ public class StatsCommand {
|
||||
Component start = Component.text(" »").color(ChatFormat.arrowColor);
|
||||
|
||||
Component user = start
|
||||
.append(Component.text(" User: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(otherPlayer.getScoreboardName()).color(ChatFormat.normalColor))
|
||||
.append(Component.text(" User: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(otherPlayer.getScoreboardName(), 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.get(otherPlayer.getUUID()).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FFA_CLASSIC_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
|
||||
int kills = data.kills;
|
||||
int deaths = data.deaths;
|
||||
int killstreak = data.killstreak;
|
||||
int bestKillstreak = data.bestKillstreak;
|
||||
|
||||
if(gamemode.equalsIgnoreCase("kit ffa")) {
|
||||
if (gamemode.equalsIgnoreCase("kit ffa")) {
|
||||
message = ChatFormat.separatorLine("Kit FFA Stats");
|
||||
com.nexia.ffa.kits.utilities.player.SavedPlayerData kData = com.nexia.ffa.kits.utilities.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
kills = kData.kills;
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
data = PlayerDataManager.getDataManager(NexiaCore.FFA_KITS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("sky ffa")) {
|
||||
if (gamemode.equalsIgnoreCase("sky ffa")) {
|
||||
message = ChatFormat.separatorLine("Sky FFA Stats");
|
||||
com.nexia.ffa.sky.utilities.player.SavedPlayerData kData = com.nexia.ffa.sky.utilities.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
kills = kData.kills;
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
data = PlayerDataManager.getDataManager(NexiaCore.FFA_SKY_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("uhc ffa")) {
|
||||
if (gamemode.equalsIgnoreCase("uhc ffa")) {
|
||||
message = ChatFormat.separatorLine("UHC FFA Stats");
|
||||
com.nexia.ffa.uhc.utilities.player.SavedPlayerData kData = com.nexia.ffa.uhc.utilities.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
kills = kData.kills;
|
||||
deaths = kData.deaths;
|
||||
killstreak = kData.killstreak;
|
||||
bestKillstreak = kData.bestKillstreak;
|
||||
data = PlayerDataManager.getDataManager(NexiaCore.FFA_UHC_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
}
|
||||
|
||||
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: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(kills).color(ChatFormat.greenColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Deaths: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(deaths).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Deaths: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(deaths, ChatFormat.failColor))
|
||||
);
|
||||
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" KDR: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(" KDR: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(calculateKDR(kills, deaths)).color(ChatFormat.greenColor))
|
||||
);
|
||||
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Killstreak: ").color(ChatFormat.brandColor2))
|
||||
.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))
|
||||
@@ -290,96 +265,96 @@ public class StatsCommand {
|
||||
|
||||
if(gamemode.equalsIgnoreCase("duels")){
|
||||
message = ChatFormat.separatorLine("Duels Stats");
|
||||
com.nexia.minigames.games.duels.util.player.SavedPlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
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: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(gamemode.equalsIgnoreCase("bedwars")){
|
||||
message = ChatFormat.separatorLine("Bedwars Stats");
|
||||
com.nexia.minigames.games.bedwars.util.player.SavedPlayerData data = com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
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: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Beds broken: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.bedsBroken).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Beds broken: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "bedsBroken"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("oitc")){
|
||||
message = ChatFormat.separatorLine("OITC Stats");
|
||||
com.nexia.minigames.games.oitc.util.player.SavedPlayerData data = com.nexia.minigames.games.oitc.util.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.kills).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("football")){
|
||||
message = ChatFormat.separatorLine("Football Stats");
|
||||
com.nexia.minigames.games.football.util.player.SavedPlayerData data = com.nexia.minigames.games.football.util.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FOOTBALL_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Goals: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.goals).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Goals: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "goals"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("skywars")){
|
||||
message = ChatFormat.separatorLine("SkyWars Stats");
|
||||
com.nexia.minigames.games.skywars.util.player.SavedPlayerData data = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(otherPlayer.getUUID()).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.losses).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.kills).color(ChatFormat.failColor))
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
source.sendMessage(ChatFormat.separatorLine(null));
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.nexia.core.commands.player.duels;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
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.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -25,26 +28,24 @@ public class AcceptDuelCommand {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
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()))))
|
||||
.executes(context -> AcceptDuelCommand.accept(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static int accept(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int accept(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.acceptDuel(executor, new NexiaPlayer(player));
|
||||
return 1;
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.nexia.core.commands.player.duels;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
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.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -25,26 +28,23 @@ public class DeclineDuelCommand {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
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()))))
|
||||
.executes(context -> DeclineDuelCommand.decline(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int decline(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int decline(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.declineDuel(executor, new NexiaPlayer(player));
|
||||
return 1;
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
package com.nexia.core.commands.player.duels;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.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.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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
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.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
@@ -31,12 +34,10 @@ public class DuelCommand {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
@@ -44,24 +45,22 @@ public class DuelCommand {
|
||||
})
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
DuelGUI.openDuelGui(player.unwrap(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource())));
|
||||
DuelGUI.openDuelGui(player.unwrap(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)));
|
||||
return 1;
|
||||
})
|
||||
.then(CommandUtils.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())), StringArgumentType.getString(context, "gamemode"), null))
|
||||
.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())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
|
||||
.executes(context -> DuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource())), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "map")))
|
||||
.executes(context -> DuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "map")))
|
||||
))));
|
||||
}
|
||||
|
||||
public static int challenge(CommandContext<CommandSourceInfo> context, ServerPlayer player, String gameMode, @Nullable String map) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
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));
|
||||
return 1;
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package com.nexia.core.commands.player.duels;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.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.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.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
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.commands.SharedSuggestionProvider;
|
||||
@@ -30,12 +32,10 @@ public class KitLayoutCommand {
|
||||
dispatcher.register((CommandUtils.literal("kitlayout")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
@@ -52,9 +52,8 @@ public class KitLayoutCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceInfo> context, @NotNull String argument, @NotNull String inventory) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
private static int run(CommandContext<CommandSourceInfo> context, @NotNull String argument, @NotNull String inventory) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if((inventory.trim().isEmpty() || !InventoryUtil.getListOfInventories("duels").contains(inventory.toLowerCase())) && !argument.equalsIgnoreCase("save")) {
|
||||
player.sendMessage(Component.text("Invalid gamemode!", ChatFormat.failColor));
|
||||
@@ -63,12 +62,12 @@ public class KitLayoutCommand {
|
||||
|
||||
if(argument.equalsIgnoreCase("save")) {
|
||||
|
||||
if(com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
|
||||
if(((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingLayout.isEmpty()) {
|
||||
player.sendMessage(Component.text("You aren't editing a layout!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
|
||||
inventory = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout;
|
||||
inventory = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingLayout;
|
||||
|
||||
String path = InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID() + File.separator + "layout";
|
||||
Path playerPath = Path.of(path);
|
||||
@@ -99,14 +98,14 @@ public class KitLayoutCommand {
|
||||
|
||||
if (argument.equalsIgnoreCase("edit")) {
|
||||
|
||||
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
|
||||
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));
|
||||
return 0;
|
||||
}
|
||||
|
||||
DuelGameHandler.loadInventory(player, inventory);
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout = inventory;
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingLayout = inventory;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package com.nexia.core.commands.player.duels;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
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.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
@@ -27,31 +30,29 @@ public class PartyCommand {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
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())))))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.invitePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.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())))))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.promotePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.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())))))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.joinTeam(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.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())))))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.kickPlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.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())))))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.declinePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.then(CommandUtils.literal("disband").executes(PartyCommand::disbandTeam))
|
||||
.then(CommandUtils.literal("create").executes(PartyCommand::createTeam))
|
||||
@@ -60,11 +61,10 @@ public class PartyCommand {
|
||||
);
|
||||
}
|
||||
|
||||
public static int invitePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer invitor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int invitePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer invitor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(invitor);
|
||||
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(invitor);
|
||||
|
||||
if(data.duelOptions.duelsTeam == null) {
|
||||
DuelsTeam.createTeam(invitor, false);
|
||||
@@ -73,22 +73,20 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int joinTeam(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int joinTeam(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player.getUUID()).duelOptions.duelsTeam.joinTeam(executor);
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player.getUUID())).duelOptions.duelsTeam.joinTeam(executor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int listTeam(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int listTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
|
||||
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(executor);
|
||||
|
||||
if(data.duelOptions.duelsTeam == null) {
|
||||
executor.sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
|
||||
executor.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -96,30 +94,27 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int declinePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int declinePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player.getUUID()).duelOptions.duelsTeam.declineTeam(executor);
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player.getUUID())).duelOptions.duelsTeam.declineTeam(executor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int createTeam(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int createTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
DuelsTeam.createTeam(player, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int promotePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int promotePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
|
||||
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(executor);
|
||||
|
||||
if(data.duelOptions.duelsTeam == null) {
|
||||
executor.sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
|
||||
executor.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -127,14 +122,13 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int kickPlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int kickPlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
|
||||
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(executor);
|
||||
|
||||
if(data.duelOptions.duelsTeam == null) {
|
||||
executor.sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
|
||||
executor.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -142,32 +136,30 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int disbandTeam(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int disbandTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
|
||||
if(data.duelOptions.duelsTeam == null) {
|
||||
player.sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
|
||||
player.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.disbandTeam(player, true);
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).duelOptions.duelsTeam.disbandTeam(player, true);
|
||||
return 1;
|
||||
}
|
||||
public static int leaveTeam(CommandContext<CommandSourceInfo> context) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
public static int leaveTeam(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
DuelsPlayerData data = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
|
||||
if(data.duelOptions.duelsTeam == null) {
|
||||
player.sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
|
||||
player.sendMessage(Component.text("You aren't in a team!", ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.leaveTeam(player, true);
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).duelOptions.duelsTeam.leaveTeam(player, true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,38 @@
|
||||
package com.nexia.core.commands.player.duels;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.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.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.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
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.SharedSuggestionProvider;
|
||||
|
||||
public class QueueCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("queue")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
})
|
||||
.executes(context -> {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
QueueGUI.openQueueGUI(player.unwrap());
|
||||
return 1;
|
||||
@@ -45,8 +44,7 @@ public class QueueCommand {
|
||||
}
|
||||
|
||||
public static int queue(CommandContext<CommandSourceInfo> context, String gameMode) throws CommandSyntaxException {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.joinQueue(player, gameMode, false);
|
||||
return 1;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.nexia.core.commands.player.duels.custom;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -9,9 +13,8 @@ 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.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
import com.nexia.minigames.games.duels.map.DuelsMap;
|
||||
@@ -31,12 +34,10 @@ public class CustomDuelCommand {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
@@ -44,24 +45,22 @@ public class CustomDuelCommand {
|
||||
})
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
CustomDuelGUI.openDuelGui(player.unwrap(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource())));
|
||||
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/" + CommandUtil.getPlayer(context).getUUID())), builder)))
|
||||
.executes(context -> CustomDuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource())), StringArgumentType.getString(context, "kit"), null))
|
||||
.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())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
|
||||
.executes(context -> CustomDuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource())), StringArgumentType.getString(context, "kit"), StringArgumentType.getString(context, "map")))
|
||||
.executes(context -> CustomDuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "kit"), StringArgumentType.getString(context, "map")))
|
||||
))));
|
||||
}
|
||||
|
||||
public static int challenge(CommandContext<CommandSourceInfo> context, ServerPlayer player, String kit, @Nullable String map) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer executor = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
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));
|
||||
return 1;
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
package com.nexia.core.commands.player.duels.custom;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.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.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.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
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.commands.SharedSuggestionProvider;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -39,12 +41,10 @@ public class KitEditorCommand {
|
||||
dispatcher.register((CommandUtils.literal("kiteditor")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
if(!CommandUtil.checkPlayerInCommand(commandSourceInfo)) return false;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(commandSourceInfo);
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
assert player != null;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
PlayerData playerData1 = PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
@@ -61,9 +61,8 @@ public class KitEditorCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceInfo> context, @NotNull String argument, String slot) {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
private static int run(CommandContext<CommandSourceInfo> context, @NotNull String argument, String slot) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if (!slots.contains(slot) && !argument.equalsIgnoreCase("save")) {
|
||||
player.sendMessage(Component.text("Invalid slot!", ChatFormat.failColor));
|
||||
@@ -76,14 +75,14 @@ public class KitEditorCommand {
|
||||
|
||||
if(argument.equalsIgnoreCase("save")) {
|
||||
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
|
||||
if(playerData.editingKit.isEmpty() || playerData.kitRoom == null) {
|
||||
player.sendMessage(Component.text("You aren't editing a kit!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
|
||||
inventory = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingKit;
|
||||
inventory = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).editingKit;
|
||||
|
||||
String gearstring = PlayerFunctions.getPlayerGearString(player.unwrap());
|
||||
|
||||
@@ -117,13 +116,13 @@ public class KitEditorCommand {
|
||||
|
||||
if (argument.equalsIgnoreCase("edit")) {
|
||||
|
||||
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingKit.isEmpty()) {
|
||||
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));
|
||||
return 0;
|
||||
}
|
||||
|
||||
KitRoom kitRoom;
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
|
||||
|
||||
switch (slot) {
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.nexia.core.commands.player.ffa;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
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.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
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.SharedSuggestionProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -20,9 +19,8 @@ public class KitCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("kit")
|
||||
.executes(context -> {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = CommandUtil.getPlayer(context);
|
||||
if(!FfaKitsUtil.canGoToSpawn(player)) {
|
||||
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;
|
||||
}
|
||||
@@ -33,10 +31,9 @@ public class KitCommand {
|
||||
.then(CommandUtils.argument("inventory", StringArgumentType.greedyString())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(FfaKit.stringFfaKits, builder)))
|
||||
.executes(context -> {
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
NexiaPlayer player = new NexiaPlayer(CommandUtil.getPlayer(context));
|
||||
if(!FfaKitsUtil.canGoToSpawn(player)) {
|
||||
player.sendMessage(Component.text("You must be fully healed to change kits!").color(ChatFormat.failColor));
|
||||
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 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.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.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
@@ -23,9 +24,9 @@ public class BanCommand {
|
||||
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())), "No reason specified."))
|
||||
.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())), StringArgumentType.getString(context, "reason"))))
|
||||
.executes(context -> BanCommand.ban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "reason"))))
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -45,10 +46,10 @@ public class BanCommand {
|
||||
++i;
|
||||
context.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))
|
||||
.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))
|
||||
);
|
||||
|
||||
|
||||
@@ -57,7 +58,7 @@ public class BanCommand {
|
||||
.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(com.nexia.discord.Main.config.discordLink, ChatFormat.brandColor2))
|
||||
.append(Component.text(NexiaDiscord.config.discordLink, ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +66,7 @@ public class BanCommand {
|
||||
|
||||
if (i == 0) {
|
||||
context.sendMessage(
|
||||
ChatFormat.nexiaMessage.append(Component.text("That player is already banned.").color(ChatFormat.failColor))
|
||||
ChatFormat.nexiaMessage.append(Component.text("That player is already banned.", ChatFormat.failColor))
|
||||
);
|
||||
} else {
|
||||
return i;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -28,9 +28,9 @@ public class DetectCommand {
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
if(!enabled || CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
if(!enabled) return 0;
|
||||
|
||||
detect(CommandUtil.getPlayer(context));
|
||||
detect(new NexiaPlayer(context.getSource().getPlayerOrException()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DetectCommand {
|
||||
});
|
||||
if(nearestPosition.get() != null) {
|
||||
Vec3 nearestPos = nearestPosition.get();
|
||||
ServerTime.factoryServer.runCommand("/player " + botName + " look at " + nearestPos.x + " " + nearestPos.y + " " + nearestPos.z, 4, false);
|
||||
ServerTime.nexusServer.runCommand("/player " + botName + " look at " + nearestPos.x + " " + nearestPos.y + " " + nearestPos.z, 4, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.nexia.core.games.util.PlayerGameMode;
|
||||
@@ -9,7 +9,7 @@ import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.BanHandler;
|
||||
import com.nexia.core.utilities.player.GamemodeBanHandler;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -25,7 +25,7 @@ public class GamemodeBanCommand {
|
||||
.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())), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
|
||||
.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"))))
|
||||
)
|
||||
)
|
||||
));
|
||||
@@ -39,7 +39,7 @@ public class GamemodeBanCommand {
|
||||
|
||||
sender.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("Invalid gamemode!", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
@@ -51,8 +51,8 @@ public class GamemodeBanCommand {
|
||||
} catch (Exception e) {
|
||||
sender.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))
|
||||
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
@@ -18,21 +18,18 @@ public class HealCommand {
|
||||
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()))))
|
||||
.executes(context -> HealCommand.heal(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
|
||||
if(CommandUtil.failIfNoPlayerInCommand(context)) return 0;
|
||||
|
||||
NexiaPlayer executor = CommandUtil.getPlayer(context);
|
||||
executor.setHealth(executor.unwrap().getMaxHealth());
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
executor.setHealth(executor.getMaxHealth());
|
||||
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have been healed.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("You have been healed.", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
@@ -44,17 +41,13 @@ public class HealCommand {
|
||||
|
||||
context.getSource().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))
|
||||
.append(Component.text("You have healed ", ChatFormat.normalColor))
|
||||
.append(Component.text(otherPlayer.getScoreboardName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
|
||||
new NexiaPlayer(otherPlayer).sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have been healed.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
new NexiaPlayer(otherPlayer).sendNexiaMessage("You have been healed.");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -33,7 +33,7 @@ public class ListInventoriesCommand {
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.getSource().sendMessage(Component.text("Saved Inventories:", ChatFormat.normalColor)
|
||||
context.getSource().sendMessage(Component.text("Saved Inventories: ", ChatFormat.normalColor)
|
||||
.append(Component.text(InventoryUtil.getListOfInventoriesString(type), ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.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.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
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.world.Difficulty;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
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")
|
||||
@@ -32,6 +29,7 @@ public class MapCommand {
|
||||
.then(CommandUtils.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)))
|
||||
.executes(MapCommand::run)
|
||||
)
|
||||
)
|
||||
@@ -39,20 +37,19 @@ public class MapCommand {
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceInfo> context) {
|
||||
NexiaPlayer player = CommandUtil.getPlayer(context);
|
||||
NexiaPlayer player = null;
|
||||
if(context.getSource().getExecutingEntity() instanceof Player nexusPlayer) {
|
||||
player = new NexiaPlayer(nexusPlayer);
|
||||
}
|
||||
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
String map = StringArgumentType.getString(context, "map");
|
||||
|
||||
if(map.trim().isEmpty() || type.trim().isEmpty()) {
|
||||
if(player != null) {
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid name!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid name!", ChatFormat.failColor))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -60,27 +57,14 @@ public class MapCommand {
|
||||
|
||||
if(type.equalsIgnoreCase("create")){
|
||||
|
||||
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())
|
||||
.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();
|
||||
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), (WorldUtil.defaultWorldConfig)).asWorld();
|
||||
|
||||
if (player != null) {
|
||||
player.unwrap().teleportTo(level, 0, 80, 0, 0, 0);
|
||||
player.teleport(new Location(0, 80, 0, 0, 0, WorldUtil.getWorld(level)));
|
||||
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Created map called: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(map).color(ChatFormat.brandColor2))
|
||||
player.sendNexiaMessage(
|
||||
Component.text("Created map called: ", ChatFormat.normalColor)
|
||||
.append(Component.text(map, ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,10 +75,9 @@ 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.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Deleted map called: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(map).color(ChatFormat.brandColor2))
|
||||
player.sendNexiaMessage(
|
||||
Component.text("Deleted map called: ", ChatFormat.normalColor)
|
||||
.append(Component.text(map, ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -108,12 +91,11 @@ public class MapCommand {
|
||||
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), null).asWorld();
|
||||
|
||||
if(player != null) {
|
||||
player.unwrap().teleportTo(level, 0, 80, 0, 0, 0);
|
||||
player.teleport(new Location(0, 80, 0, 0, 0, WorldUtil.getWorld(level)));
|
||||
|
||||
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))
|
||||
player.sendNexiaMessage(
|
||||
Component.text("Teleported to map called: ", ChatFormat.normalColor)
|
||||
.append(Component.text(map, ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -39,7 +39,7 @@ public class MuteCommand {
|
||||
public static int mute(CommandContext<CommandSourceInfo> context, String durationArg, String reason) throws CommandSyntaxException {
|
||||
|
||||
CommandSourceInfo sender = context.getSource();
|
||||
ServerPlayer muted = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource()));
|
||||
ServerPlayer muted = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
|
||||
int durationInSeconds;
|
||||
try {
|
||||
@@ -47,8 +47,8 @@ public class MuteCommand {
|
||||
} catch (Exception e) {
|
||||
|
||||
context.getSource().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))
|
||||
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -19,6 +18,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RankCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
|
||||
ArrayList<String> ranks = new ArrayList<>();
|
||||
@@ -29,43 +29,30 @@ public class RankCommand {
|
||||
.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())), StringArgumentType.getString(context, "rank")))))
|
||||
.executes(context -> RankCommand.give(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "rank")))))
|
||||
);
|
||||
}
|
||||
|
||||
public static int give(CommandContext<CommandSourceInfo> context, ServerPlayer player, String rank) {
|
||||
NexiaPlayer otherFactoryPlayer = new NexiaPlayer(player);
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(player);
|
||||
|
||||
for(NexiaRank tRank : NexiaRank.ranks){
|
||||
if(rank.equalsIgnoreCase(tRank.id)){
|
||||
|
||||
context.getSource().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(tRank.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))
|
||||
);
|
||||
|
||||
|
||||
otherFactoryPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your rank has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(tRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
for (NexiaRank tRank2 : NexiaRank.ranks) {
|
||||
otherFactoryPlayer.removeTag(tRank2.id);
|
||||
}
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s parent set %s", otherFactoryPlayer.getRawName(), tRank.id));
|
||||
|
||||
otherFactoryPlayer.addTag(tRank.id);
|
||||
}
|
||||
NexiaRank nexiaRank = NexiaRank.identifyRank(rank);
|
||||
if (nexiaRank == null) {
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid rank!", ChatFormat.normalColor))
|
||||
);
|
||||
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))
|
||||
);
|
||||
|
||||
NexiaRank.setRank(nexiaRank, nexiaPlayer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
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.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -34,74 +33,60 @@ public class StaffPrefixCommand {
|
||||
.executes(context -> {
|
||||
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource()));
|
||||
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
NexiaPlayer otherPlayer = new NexiaPlayer(mcOtherPlayer);
|
||||
String prefix = StringArgumentType.getString(context, "prefix");
|
||||
NexiaRank rank = NexiaRank.identifyRank(StringArgumentType.getString(context, "prefix"));
|
||||
|
||||
if(rank == null) {
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid rank!", ChatFormat.normalColor))
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("set")){
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
if(prefix.equalsIgnoreCase(rank.id)){
|
||||
context.getSource().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))
|
||||
);
|
||||
|
||||
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))
|
||||
);
|
||||
|
||||
context.getSource().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))
|
||||
);
|
||||
|
||||
otherPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.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))
|
||||
);
|
||||
|
||||
for (NexiaRank tRank : NexiaRank.ranks) {
|
||||
otherPlayer.removeTag(tRank.id);
|
||||
}
|
||||
|
||||
otherPlayer.addTag(rank.id);
|
||||
}
|
||||
}
|
||||
NexiaRank.setPrefix(rank, otherPlayer);
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("remove")){
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
if(prefix.equalsIgnoreCase(rank.id)){
|
||||
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))
|
||||
);
|
||||
|
||||
context.getSource().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))
|
||||
);
|
||||
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission unset %s", otherPlayer.getRawName(), rank.groupID));
|
||||
}
|
||||
}
|
||||
NexiaRank.removePrefix(rank, otherPlayer);
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("add")){
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
if(prefix.equalsIgnoreCase(rank.id)){
|
||||
context.getSource().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))
|
||||
);
|
||||
|
||||
ServerTime.factoryServer.runCommand(String.format("/lp user %s permission set %s true", otherPlayer.getRawName(), rank.groupID));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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.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.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -26,44 +28,43 @@ public class StaffReportCommand {
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> {
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource()));
|
||||
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
NexiaPlayer otherPlayer = new NexiaPlayer(mcOtherPlayer);
|
||||
|
||||
PlayerData data = PlayerDataManager.get(mcOtherPlayer.getUUID());
|
||||
CorePlayerData data = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(mcOtherPlayer.getUUID());
|
||||
|
||||
if(type.equalsIgnoreCase("ban")) {
|
||||
if(data.savedData.isReportBanned()) {
|
||||
context.getSource().sendMessage(Component.text("That player is already report banned!").color(ChatFormat.failColor));
|
||||
if(((CoreSavedPlayerData)data.savedData).isReportBanned()) {
|
||||
context.getSource().sendMessage(Component.text("That player is already report banned!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
data.savedData.setReportBanned(true);
|
||||
((CoreSavedPlayerData)data.savedData).setReportBanned(true);
|
||||
context.getSource().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)
|
||||
.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))
|
||||
)
|
||||
);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("unban") || type.equalsIgnoreCase("pardon")) {
|
||||
if(!data.savedData.isReportBanned()) {
|
||||
context.getSource().sendMessage(Component.text("That player is not report banned!").color(ChatFormat.failColor));
|
||||
if(!((CoreSavedPlayerData)data.savedData).isReportBanned()) {
|
||||
context.getSource().sendMessage(Component.text("That player is not report banned!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
data.savedData.setReportBanned(false);
|
||||
((CoreSavedPlayerData)data.savedData).setReportBanned(false);
|
||||
context.getSource().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)
|
||||
)
|
||||
.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))
|
||||
);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
context.getSource().sendMessage(Component.text("Invalid argument").color(ChatFormat.failColor));
|
||||
context.getSource().sendMessage(Component.text("Invalid argument", ChatFormat.failColor));
|
||||
|
||||
return 0;
|
||||
}))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -20,7 +20,7 @@ public class TempBanCommand {
|
||||
.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())), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
|
||||
.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"))))
|
||||
)
|
||||
));
|
||||
}
|
||||
@@ -32,8 +32,8 @@ public class TempBanCommand {
|
||||
durationInSeconds = BanHandler.parseTimeArg(durationArg);
|
||||
} catch (Exception e) {
|
||||
sender.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))
|
||||
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -20,14 +20,14 @@ public class UnBanCommand {
|
||||
.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()))))
|
||||
.executes(context -> UnBanCommand.unban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false))))
|
||||
)
|
||||
);
|
||||
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()))))
|
||||
.executes(context -> UnBanCommand.unban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false))))
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -43,9 +43,9 @@ public class UnBanCommand {
|
||||
|
||||
context.getSender().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))
|
||||
.append(Component.text("You have unbanned ", ChatFormat.normalColor))
|
||||
.append(Component.text(gameProfile.getName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class UnBanCommand {
|
||||
if (i == 0) {
|
||||
context.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("That player is not banned.").color(ChatFormat.failColor))
|
||||
.append(Component.text("That player is not banned.", ChatFormat.failColor))
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -10,7 +10,7 @@ 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.GamemodeBanHandler;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -37,13 +37,13 @@ public class UnGamemodeBanCommand {
|
||||
if(gameMode == null) {
|
||||
sender.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("Invalid gamemode!", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
GamemodeBanHandler.tryUnGamemodeBan(sender, new NexiaPlayer(context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource()))), gameMode);
|
||||
GamemodeBanHandler.tryUnGamemodeBan(sender, new NexiaPlayer(context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false))), gameMode);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -24,7 +24,7 @@ public class UnMuteCommand {
|
||||
|
||||
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()));
|
||||
ServerPlayer muted = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
|
||||
PlayerMutes.unMute(sender, muted);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
import com.combatreforged.factory.api.command.CommandUtils;
|
||||
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;
|
||||
@@ -23,7 +23,7 @@ public class UnTempBanCommand {
|
||||
public static int unBan(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
CommandSourceInfo sender = context.getSource();
|
||||
|
||||
BanHandler.tryUnBan(sender, context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource())));
|
||||
BanHandler.tryUnBan(sender, context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DeleteInventoryCommand {
|
||||
@@ -27,7 +28,15 @@ public class DeleteInventoryCommand {
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
|
||||
.then(Commands.argument("inventory", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type")), builder)))
|
||||
.suggests(((context, builder) -> {
|
||||
ArrayList<String> inventoryList = new ArrayList<>();
|
||||
try {
|
||||
inventoryList = InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type"));
|
||||
} catch (Exception ignored) {
|
||||
inventoryList.add("Unable to get inventories!");
|
||||
}
|
||||
return SharedSuggestionProvider.suggest(inventoryList, builder);
|
||||
}))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory")))
|
||||
)
|
||||
)
|
||||
|
||||
+4
-25
@@ -7,7 +7,8 @@ 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.uhc.utilities.FfaAreas;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.ffa.uhc.utilities.UhcFfaAreas;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import com.nexia.minigames.games.skywars.SkywarsMap;
|
||||
import io.github.blumbo.inventorymerger.saving.SavableInventory;
|
||||
@@ -23,15 +24,9 @@ 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.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")
|
||||
@@ -57,26 +52,10 @@ 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(), (
|
||||
new RuntimeWorldConfig()
|
||||
.setDimensionType(DimensionType.OVERWORLD_LOCATION)
|
||||
.setGenerator(getChunkGenerator())
|
||||
.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();
|
||||
|
||||
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("ffa", name)).location(), FfaUtil.ffaWorldConfig).asWorld();
|
||||
player.teleportTo(level, 0, 80, 0, 0, 0);
|
||||
} else if(argument.equalsIgnoreCase("rluhc")) {
|
||||
FfaAreas.resetMap(true);
|
||||
UhcFfaAreas.resetMap(true);
|
||||
player.sendMessage(LegacyChatFormat.format("Reloaded UHC Map."), Util.NIL_UUID);
|
||||
} else if(argument.contains("swmap")) {
|
||||
SkywarsMap map = SkywarsMap.identifyMap(name);
|
||||
|
||||
@@ -6,7 +6,7 @@ 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.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LoadInventoryCommand {
|
||||
@@ -32,7 +33,15 @@ public class LoadInventoryCommand {
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
|
||||
.then(Commands.argument("inventory", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type")), builder)))
|
||||
.suggests(((context, builder) -> {
|
||||
ArrayList<String> inventoryList = new ArrayList<>();
|
||||
try {
|
||||
inventoryList = InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type"));
|
||||
} catch (Exception ignored) {
|
||||
inventoryList.add("Unable to get inventories!");
|
||||
}
|
||||
return SharedSuggestionProvider.suggest(inventoryList, builder);
|
||||
}))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory"), context.getSource().getPlayerOrException()))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory"), EntityArgument.getPlayer(context, "player")))
|
||||
|
||||
@@ -3,6 +3,7 @@ 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;
|
||||
@@ -30,7 +31,7 @@ public class ProtectionMapCommand {
|
||||
|
||||
public static int ffa_sky(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
com.nexia.ffa.sky.utilities.FfaAreas.createProtectionMap(player);
|
||||
SkyFfaAreas.createProtectionMap(player);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@ 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.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.football.FootballGame;
|
||||
import com.nexia.minigames.games.oitc.OitcGame;
|
||||
@@ -32,7 +34,7 @@ public class SkipQueueCommand {
|
||||
|
||||
private static int currentGamemode(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
PlayerGameMode gameMode = PlayerDataManager.get(player.getUUID()).gameMode;
|
||||
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player.getUUID())).gameMode;
|
||||
|
||||
if(gameMode.equals(PlayerGameMode.SKYWARS)) return skywars(context);
|
||||
if(gameMode.equals(PlayerGameMode.BEDWARS)) return bedwars(context);
|
||||
|
||||
@@ -11,4 +11,10 @@ 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,41 +1,42 @@
|
||||
package com.nexia.core.games.util;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.ffa.FfaGameMode;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.world.WorldUtil;
|
||||
import com.nexia.ffa.base.BaseFfaUtil;
|
||||
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.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 me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.nexia.core.utilities.player.BanHandler.getBanTime;
|
||||
|
||||
@@ -44,18 +45,30 @@ 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 EntityPos lobbySpawn = new EntityPos(0, 65, 0, 0, 0);
|
||||
|
||||
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 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
|
||||
@@ -70,11 +83,6 @@ 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",
|
||||
@@ -97,65 +105,80 @@ public class LobbyUtil {
|
||||
DuelGameHandler.leave(player, false);
|
||||
|
||||
if (tp) {
|
||||
player.unwrap().setRespawnPosition(lobbyWorld.dimension(), lobbySpawn.toBlockPos(), lobbySpawn.yaw, true, false);
|
||||
player.unwrap().teleportTo(lobbyWorld, lobbySpawn.x, lobbySpawn.y, lobbySpawn.z, lobbySpawn.pitch, lobbySpawn.yaw);
|
||||
player.setRespawnPosition(nexusLobbyLocation, lobbySpawn.yaw, true, false);
|
||||
player.teleport(nexusLobbyLocation);
|
||||
|
||||
if(Permissions.check(player.unwrap(), "nexia.prefix.supporter")) {
|
||||
if(player.hasPrefix(NexiaRank.SUPPORTER)) {
|
||||
player.setAbleToFly(true);
|
||||
}
|
||||
|
||||
LobbyUtil.giveItems(player);
|
||||
}
|
||||
|
||||
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.LOBBY;
|
||||
|
||||
|
||||
PlayerDataManager.get(player).gameMode = PlayerGameMode.LOBBY;
|
||||
player.setBedrockBridging(true);
|
||||
}
|
||||
|
||||
public static void giveItems(NexiaPlayer player) {
|
||||
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);
|
||||
|
||||
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 hideAttrubtesNBTObject = NBTObject.create();
|
||||
hideAttrubtesNBTObject.set("HideFlags", NBTValue.of(39));
|
||||
|
||||
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);
|
||||
NBTObject unbreakableNBTObject = hideAttrubtesNBTObject.copy();
|
||||
unbreakableNBTObject.set("Unbreakable", NBTValue.of(1));
|
||||
|
||||
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);
|
||||
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 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);
|
||||
|
||||
if(Permissions.check(player.unwrap(), "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);
|
||||
player.unwrap().setItemSlot(EquipmentSlot.CHEST, elytra);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
player.unwrap().setSlot(0, customDuelSword); // 1st slot
|
||||
player.unwrap().setSlot(4, compass); //middle slot
|
||||
player.unwrap().setSlot(3, nameTag); //left
|
||||
player.unwrap().setSlot(5, queueSword); //right
|
||||
player.unwrap().setSlot(8, teamSword); // like right right not right
|
||||
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();
|
||||
}
|
||||
@@ -177,20 +200,16 @@ public class LobbyUtil {
|
||||
GamemodeBanHandler.removeBanFromList(player.getUUID(), gameMode);
|
||||
return false;
|
||||
} else {
|
||||
player.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))
|
||||
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))
|
||||
);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You are gamemode (" + gameMode.name + ") banned!"))
|
||||
);
|
||||
player.sendNexiaMessage("You are gamemode (%s) banned!", gameMode.name);
|
||||
}
|
||||
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
@@ -204,20 +223,20 @@ public class LobbyUtil {
|
||||
|
||||
public static void sendGame(NexiaPlayer player, String game, boolean message, boolean tp) {
|
||||
|
||||
if(checkGameModeBan(player, game)) {
|
||||
if (checkGameModeBan(player, game)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(player)) ||
|
||||
(game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(player) ||
|
||||
(game.equalsIgnoreCase("sky ffa") && !FfaSkyUtil.canGoToSpawn(player) ||
|
||||
(game.equalsIgnoreCase("uhc ffa") && !FfaUhcUtil.canGoToSpawn(player))))) {
|
||||
player.setBedrockBridging(true);
|
||||
|
||||
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
|
||||
return;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(player.hasTag("duels")) {
|
||||
if (player.hasTag("duels")) {
|
||||
player.removeTag("duels");
|
||||
DuelGameHandler.leave(player, true);
|
||||
}
|
||||
@@ -225,91 +244,53 @@ public class LobbyUtil {
|
||||
player.reset(true, Minecraft.GameMode.ADVENTURE);
|
||||
player.leaveAllGames();
|
||||
|
||||
if(game.equalsIgnoreCase("classic ffa") ||
|
||||
if (game.equalsIgnoreCase("classic ffa") ||
|
||||
game.equalsIgnoreCase("kits ffa") ||
|
||||
game.equalsIgnoreCase("pot ffa") ||
|
||||
game.equalsIgnoreCase("sky ffa") ||
|
||||
game.equalsIgnoreCase("uhc ffa")) {
|
||||
player.addTag(FfaUtil.FFA_TAG);
|
||||
PlayerDataManager.get(player).gameMode = PlayerGameMode.FFA;
|
||||
if(message){ player.sendActionBarMessage(Component.text("You have joined §8🗡 §7§lFFA §b🔱")); }
|
||||
((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🔱")); }
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("classic ffa")){
|
||||
player.addTag("ffa_classic");
|
||||
FfaClassicUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(player).ffaGameMode = FfaGameMode.CLASSIC;
|
||||
if(tp){
|
||||
player.unwrap().teleportTo(FfaAreas.ffaWorld, FfaAreas.spawn.x, FfaAreas.spawn.y, FfaAreas.spawn.z, FfaAreas.spawn.yaw, FfaAreas.spawn.pitch);
|
||||
player.unwrap().setRespawnPosition(FfaAreas.ffaWorld.dimension(), FfaAreas.spawn.toBlockPos(), FfaAreas.spawn.yaw, true, false);
|
||||
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);
|
||||
}
|
||||
|
||||
FfaClassicUtil.clearThrownTridents(player);
|
||||
FfaClassicUtil.setInventory(player);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("sky ffa")){
|
||||
player.unwrap().addTag("ffa_sky");
|
||||
FfaSkyUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(player).ffaGameMode = FfaGameMode.SKY;
|
||||
if(tp){
|
||||
FfaSkyUtil.sendToSpawn(player);
|
||||
player.unwrap().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(player);
|
||||
if (game.equalsIgnoreCase("classic ffa")) {
|
||||
FfaClassicUtil.INSTANCE.setInventory(player);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("uhc ffa")){
|
||||
player.addTag("ffa_uhc");
|
||||
FfaUhcUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(player).ffaGameMode = FfaGameMode.UHC;
|
||||
if(tp){
|
||||
FfaUhcUtil.sendToSpawn(player);
|
||||
player.unwrap().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(player);
|
||||
FfaUhcUtil.clearTrident(player);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("kits ffa")){
|
||||
player.addTag("ffa_kits");
|
||||
FfaKitsUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(player).ffaGameMode = FfaGameMode.KITS;
|
||||
if(tp){
|
||||
FfaKitsUtil.sendToSpawn(player);
|
||||
player.unwrap().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(player);
|
||||
FfaKitsUtil.clearArrows(player);
|
||||
FfaKitsUtil.clearSpectralArrows(player);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("bedwars")){
|
||||
if (game.equalsIgnoreCase("bedwars")) {
|
||||
if(message){ player.sendActionBarMessage(Component.text("You have joined §b\uD83E\uDE93 §c§lBedwars §e⚡"));}
|
||||
BwPlayerEvents.tryToJoin(player, false);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("duels")){
|
||||
if (game.equalsIgnoreCase("duels")) {
|
||||
LobbyUtil.returnToLobby(player, tp);
|
||||
|
||||
if(message){
|
||||
player.sendActionBarMessage(Component.text("You have joined §f☯ §c§lDuels §7\uD83E\uDE93"));
|
||||
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));
|
||||
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!"));
|
||||
}
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("oitc")){
|
||||
player.addTag(OitcGame.OITC_TAG);
|
||||
PlayerDataManager.get(player).gameMode = PlayerGameMode.OITC;
|
||||
OitcGame.death(player, player.unwrap().getLastDamageSource());
|
||||
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.OITC;
|
||||
OitcGame.death(player, null);
|
||||
|
||||
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.get(player).gameMode = OitcGameMode.LOBBY;
|
||||
((OITCPlayerData)PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(player)).gameMode = OitcGameMode.LOBBY;
|
||||
|
||||
OitcGame.joinQueue(player);
|
||||
|
||||
@@ -317,9 +298,9 @@ public class LobbyUtil {
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("football")){
|
||||
player.unwrap().addTag(FootballGame.FOOTBALL_TAG);
|
||||
PlayerDataManager.get(player).gameMode = PlayerGameMode.FOOTBALL;
|
||||
com.nexia.minigames.games.football.util.player.PlayerDataManager.get(player).gameMode = FootballGameMode.LOBBY;
|
||||
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;
|
||||
|
||||
FootballGame.joinQueue(player);
|
||||
|
||||
@@ -328,11 +309,11 @@ public class LobbyUtil {
|
||||
|
||||
|
||||
if(game.equalsIgnoreCase("skywars")){
|
||||
player.unwrap().addTag(PlayerGameMode.SKYWARS.tag);
|
||||
PlayerDataManager.get(player).gameMode = PlayerGameMode.SKYWARS;
|
||||
SkywarsGame.death(player, player.unwrap().getLastDamageSource());
|
||||
player.addTag(PlayerGameMode.SKYWARS.tag);
|
||||
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.SKYWARS;
|
||||
SkywarsGame.death(player, null);
|
||||
|
||||
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(player).gameMode = SkywarsGameMode.LOBBY;
|
||||
((SkywarsPlayerData)PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player)).gameMode = SkywarsGameMode.LOBBY;
|
||||
|
||||
SkywarsGame.joinQueue(player);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
@@ -26,7 +25,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", FfaUtil.FFA_TAG);
|
||||
public static final PlayerGameMode FFA = new PlayerGameMode("ffa", "FFA", "ffa");
|
||||
public static final PlayerGameMode FOOTBALL = new PlayerGameMode("football", "Football", FootballGame.FOOTBALL_TAG);
|
||||
|
||||
//public static final PlayerGameMode DUELS = new PlayerGameMode("duels");
|
||||
@@ -47,7 +46,10 @@ public class PlayerGameMode {
|
||||
if(playerGameMode.id.equalsIgnoreCase(gameMode)) return playerGameMode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,21 @@
|
||||
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.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.ffa.classic.utilities.ClassicFfaAreas;
|
||||
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;
|
||||
@@ -20,6 +28,8 @@ 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 {
|
||||
|
||||
@@ -34,68 +44,70 @@ public class PlayGUI extends SimpleGui {
|
||||
}
|
||||
}
|
||||
private void setMainLayout(){
|
||||
|
||||
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();
|
||||
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();
|
||||
|
||||
ItemStack ffa = new ItemStack(Items.NETHERITE_SWORD, 1);
|
||||
ffa.setHoverName(new TextComponent("§3FFA"));
|
||||
ffa.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("FFA", ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(ffa);
|
||||
ffa.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(ffa, "§5", 0);
|
||||
ItemDisplayUtil.addLore(ffa, "§7Fight players in a huge landscape", 1);
|
||||
ItemDisplayUtil.addLore(ffa, "§7be the best player.", 2);
|
||||
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, "§f", 3);
|
||||
ItemDisplayUtil.addLore(ffa, "§3◆ There are " + players + " people playing this gamemode.", 4);
|
||||
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);
|
||||
|
||||
|
||||
ItemStack other = new ItemStack(Items.DRAGON_BREATH, 1);
|
||||
other.setHoverName(new TextComponent("§5Other Games"));
|
||||
other.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Other Games", ChatFormat.Minecraft.dark_purple).decoration(ChatFormat.italic, false)));
|
||||
other.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
ItemDisplayUtil.addLore(other, "§7Discover other games.", 0);
|
||||
ItemDisplayUtil.addLore(other, net.kyori.adventure.text.Component.text("Discover other games.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 0);
|
||||
|
||||
ItemStack bedwars = new ItemStack(Items.RED_BED, 1);
|
||||
bedwars.setHoverName(new TextComponent("§cBedwars"));
|
||||
bedwars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Bedwars", ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(bedwars);
|
||||
bedwars.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(bedwars, "§5", 0);
|
||||
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, 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, "§f", 4);
|
||||
ItemDisplayUtil.addLore(bedwars, "§c◆ There are " + BwAreas.bedWarsWorld.players().size() + " people playing this gamemode.", 5);
|
||||
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);
|
||||
|
||||
|
||||
ItemStack skywars = new ItemStack(Items.GRASS_BLOCK, 1);
|
||||
skywars.setHoverName(new TextComponent("§aSkywars"));
|
||||
skywars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Skywars", ChatFormat.Minecraft.green).decoration(ChatFormat.italic, false)));
|
||||
skywars.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(skywars, "§5", 0);
|
||||
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, 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, "§f", 4);
|
||||
ItemDisplayUtil.addLore(skywars, "§a◆ There are " + SkywarsGame.world.players().size() + " people playing this gamemode.", 5);
|
||||
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);
|
||||
|
||||
ItemStack duels = new ItemStack(Items.NETHERITE_AXE, 1);
|
||||
duels.setHoverName(new TextComponent("§9Duels"));
|
||||
duels.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Duels", ChatFormat.Minecraft.blue).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(duels);
|
||||
duels.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
int duelsPlayers = 0;
|
||||
for(ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()) {
|
||||
DuelGameMode gameMode = PlayerDataManager.get(serverPlayer.getUUID()).gameMode;
|
||||
DuelGameMode gameMode = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(serverPlayer.getUUID())).gameMode;
|
||||
if(gameMode != null && (gameMode != DuelGameMode.LOBBY && gameMode != DuelGameMode.SPECTATING)) duelsPlayers++;
|
||||
}
|
||||
|
||||
ItemDisplayUtil.addLore(duels, "§5", 0);
|
||||
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, 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, "§f", 4);
|
||||
ItemDisplayUtil.addLore(duels, "§9◆ There are " + (LobbyUtil.lobbyWorld.players().size() + duelsPlayers) + " people playing this gamemode.", 5);
|
||||
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);
|
||||
|
||||
|
||||
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
|
||||
@@ -111,65 +123,71 @@ public class PlayGUI extends SimpleGui {
|
||||
|
||||
public void setFFALayout(){
|
||||
ItemStack classic = new ItemStack(Items.DIAMOND_SWORD, 1);
|
||||
classic.setHoverName(new TextComponent("§bClassic FFA"));
|
||||
classic.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Classic FFA", ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(classic);
|
||||
classic.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(classic, "§b", 0);
|
||||
ItemDisplayUtil.addLore(classic, "§7The classic snapshot", 1);
|
||||
ItemDisplayUtil.addLore(classic, "§7Free For All gamemode.", 2);
|
||||
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, "§f", 3);
|
||||
ItemDisplayUtil.addLore(classic, "§b◆ There are " + FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
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);
|
||||
|
||||
ItemStack kit = new ItemStack(Items.CROSSBOW, 1);
|
||||
kit.setHoverName(new TextComponent("§fKit FFA"));
|
||||
kit.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Kit FFA", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(kit);
|
||||
kit.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(kit, "§5", 0);
|
||||
ItemDisplayUtil.addLore(kit, "§7Fight against players", 1);
|
||||
ItemDisplayUtil.addLore(kit, "§7with various kits!", 2);
|
||||
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, "§f", 3);
|
||||
ItemDisplayUtil.addLore(kit, "§f◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
ItemStack pot = new ItemStack(Items.POTION, 1);
|
||||
pot.setHoverName(new TextComponent("§eSky FFA"));
|
||||
pot.getOrCreateTag().putInt("CustomPotionColor", 16771584);
|
||||
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)));
|
||||
ItemDisplayUtil.addGlint(pot);
|
||||
pot.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(pot, "§5", 0);
|
||||
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);
|
||||
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);
|
||||
|
||||
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(new TextComponent("§6UHC FFA"));
|
||||
uhc.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("UHC FFA", ChatFormat.goldColor).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(uhc);
|
||||
uhc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(uhc, "§5", 0);
|
||||
ItemDisplayUtil.addLore(uhc, "§7An FFA to practice pvp", 1);
|
||||
ItemDisplayUtil.addLore(uhc, "§7for the UHC gamemode.", 2);
|
||||
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, "§f", 3);
|
||||
ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
|
||||
emptySlot.setHoverName(new TextComponent(""));
|
||||
|
||||
fillEmptySlots(emptySlot);
|
||||
this.setSlot(1, classic);
|
||||
this.setSlot(3, uhc);
|
||||
this.setSlot(5, pot);
|
||||
this.setSlot(7, kit);
|
||||
this.setSlot(0, classic);
|
||||
this.setSlot(2, uhc);
|
||||
this.setSlot(4, pot);
|
||||
this.setSlot(6, skyffa);
|
||||
this.setSlot(8, kit);
|
||||
}
|
||||
|
||||
private void setOtherGamesLayout() {
|
||||
@@ -179,36 +197,37 @@ public class PlayGUI extends SimpleGui {
|
||||
unknown.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemStack back = new ItemStack(Items.DRAGON_BREATH, 1);
|
||||
back.setHoverName(new TextComponent("§5Back"));
|
||||
back.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Back", ChatFormat.Minecraft.dark_purple).decoration(ChatFormat.italic, false)));
|
||||
back.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
ItemDisplayUtil.addLore(back, "§7Go back to the main menu.", 0);
|
||||
ItemDisplayUtil.addLore(back, net.kyori.adventure.text.Component.text("Go back to the main menu.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 0);
|
||||
|
||||
ItemStack oitc = new ItemStack(Items.BOW, 1);
|
||||
oitc.setHoverName(new TextComponent("§eOITC"));
|
||||
oitc.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("OITC", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(oitc);
|
||||
oitc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(oitc, "§5", 0);
|
||||
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, 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, "§f", 4);
|
||||
ItemDisplayUtil.addLore(oitc, "§e◆ There are " + OitcGame.world.players().size() + " people playing this gamemode.", 5);
|
||||
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);
|
||||
|
||||
|
||||
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
|
||||
emptySlot.setHoverName(new TextComponent(""));
|
||||
|
||||
ItemStack football = new ItemStack(Items.ARMOR_STAND, 1);
|
||||
football.setHoverName(new TextComponent("§fFootball"));
|
||||
football.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Football", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
ItemDisplayUtil.addGlint(football);
|
||||
football.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(football, "§f", 0);
|
||||
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, 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, "§f", 4);
|
||||
ItemDisplayUtil.addLore(football, "§f◆ There are " + FootballGame.world.players().size() + " people playing this gamemode.", 5);
|
||||
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);
|
||||
|
||||
fillEmptySlots(emptySlot);
|
||||
|
||||
@@ -224,63 +243,67 @@ 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().equalsIgnoreCase("§bClassic FFA")){
|
||||
if(name.getString().contains("Classic FFA")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "classic ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§fKit FFA")){
|
||||
if(name.getString().contains("Kit FFA")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "kits ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§eSky FFA")){
|
||||
if(name.getString().contains("Pot FFA")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "pot ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Sky FFA")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "sky ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§6UHC FFA")){
|
||||
if(name.getString().contains("UHC FFA")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "uhc ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§3FFA")){
|
||||
if(name.getString().contains("FFA")){
|
||||
this.setFFALayout();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§cBedwars")){
|
||||
if(name.getString().contains("Bedwars")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "bedwars", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§aSkywars")){
|
||||
if(name.getString().contains("Skywars")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "skywars", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§eOITC")){
|
||||
if(name.getString().contains("OITC")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "oitc", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§fFootball")){
|
||||
if(name.getString().contains("Football")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "football", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§9Duels")){
|
||||
if(name.getString().contains("Duels")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "duels", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().toLowerCase().equalsIgnoreCase("§5Other Games")){
|
||||
if(name.getString().contains("Other Games")){
|
||||
this.setOtherGamesLayout();
|
||||
}
|
||||
|
||||
if(name.getString().toLowerCase().equalsIgnoreCase("§5Back")){
|
||||
if(name.getString().contains("Back")){
|
||||
this.setMainLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
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.minecraft.ChatFormatting;
|
||||
import net.kyori.adventure.text.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.item.enchantment.Enchantments;
|
||||
|
||||
public class PrefixGUI extends SimpleGui {
|
||||
static final TextComponent title = new TextComponent("Prefix Menu");
|
||||
@@ -46,7 +47,9 @@ public class PrefixGUI extends SimpleGui {
|
||||
this.setSlot(airSlots, new ItemStack(Items.AIR));
|
||||
airSlots++;
|
||||
}
|
||||
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
|
||||
if(slot == 17) {
|
||||
slot = 19;
|
||||
}
|
||||
@@ -55,21 +58,19 @@ public class PrefixGUI extends SimpleGui {
|
||||
|
||||
if(hasPermission && player.getTags().contains(rank.id)){
|
||||
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
enchantedItem.enchant(Enchantments.SHARPNESS, 1);
|
||||
enchantedItem.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS);
|
||||
enchantedItem.setHoverName(new TextComponent("§d§l" + rank.name));
|
||||
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){
|
||||
ItemStack changedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
changedItem.setHoverName(new TextComponent("§f" + rank.name));
|
||||
changedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
this.setSlot(slot, changedItem);
|
||||
slot++;
|
||||
} else if(player.getTags().contains(rank.id)) {
|
||||
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
enchantedItem.enchant(Enchantments.SHARPNESS, 1);
|
||||
enchantedItem.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS);
|
||||
enchantedItem.setHoverName(new TextComponent(rank.name).withStyle(ChatFormatting.BOLD, ChatFormatting.LIGHT_PURPLE));
|
||||
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++;
|
||||
}
|
||||
@@ -80,23 +81,25 @@ public class PrefixGUI extends SimpleGui {
|
||||
GuiElementInterface element = this.getSlot(index);
|
||||
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
String name = itemStack.getHoverName().getString().substring(2).replaceAll("§l", "");
|
||||
String name = itemStack.getHoverName().getString();
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
|
||||
|
||||
NexiaPlayer player = new NexiaPlayer(this.player);
|
||||
|
||||
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))
|
||||
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))
|
||||
);
|
||||
|
||||
for(NexiaRank rank : NexiaRank.ranks){
|
||||
player.removeTag(rank.id);
|
||||
}
|
||||
|
||||
if(name.equalsIgnoreCase("player")) name = "default";
|
||||
if(name.equalsIgnoreCase("nexia")) name = "supporter";
|
||||
|
||||
player.addTag(name.toLowerCase());
|
||||
this.setMainLayout(this.player);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.discord.Main;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.discord.NexiaDiscord;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
@@ -31,19 +32,20 @@ public class RanksGUI extends SimpleGui {
|
||||
}
|
||||
private void setMainLayout(){
|
||||
ItemStack supporter = new ItemStack(Items.DRAGON_BREATH, 1);
|
||||
supporter.setHoverName(new TextComponent("§5Supporter"));
|
||||
supporter.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Supporter", ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
ItemDisplayUtil.addGlint(supporter);
|
||||
supporter.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
|
||||
|
||||
ItemDisplayUtil.addLore(supporter, "§7How to get it:", 0);
|
||||
ItemDisplayUtil.addLore(supporter, net.kyori.adventure.text.Component.text("How to get it:", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 0);
|
||||
ItemDisplayUtil.addLore(supporter, "§1", 1);
|
||||
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, 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, "§3", 7);
|
||||
ItemDisplayUtil.addLore(supporter, "§dPrice: §5§l5.00$", 8);
|
||||
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);
|
||||
|
||||
ItemStack purple = new ItemStack(Items.PURPLE_STAINED_GLASS_PANE, 1);
|
||||
purple.setHoverName(new TextComponent(""));
|
||||
@@ -85,24 +87,23 @@ public class RanksGUI extends SimpleGui {
|
||||
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
|
||||
|
||||
if(name.getString().equalsIgnoreCase("§5Supporter")){
|
||||
nexiaPlayer.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))
|
||||
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))
|
||||
.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 ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(net.kyori.adventure.text.Component.text(" or ", ChatFormat.normalColor))
|
||||
.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(Main.config.discordLink)))
|
||||
.append(net.kyori.adventure.text.Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
)
|
||||
.clickEvent(ClickEvent.openUrl(NexiaDiscord.config.discordLink)))
|
||||
.append(net.kyori.adventure.text.Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
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.core.utilities.player.NexiaPlayer;
|
||||
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;
|
||||
@@ -55,7 +56,7 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
for(DuelsMap map : DuelsMap.duelsMaps){
|
||||
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
|
||||
this.setSlot(slot, map.item);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
@@ -80,10 +81,9 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
|
||||
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
|
||||
|
||||
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
|
||||
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
|
||||
playerHead.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(otherp.getScoreboardName(), ChatFormat.Minecraft.yellow).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)));
|
||||
|
||||
this.setSlot(4, playerHead);
|
||||
|
||||
@@ -97,10 +97,15 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
|
||||
ItemDisplayUtil.addLore(item, "§eUse §e§l/kiteditor edit §eto edit/create a custom kit!", 0);
|
||||
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.addGlint(item);
|
||||
|
||||
item.setHoverName(new TextComponent("§fNo kits!"));
|
||||
item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("No kits!", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
|
||||
this.setSlot(slot, item);
|
||||
return;
|
||||
@@ -120,20 +125,25 @@ 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, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
|
||||
ItemDisplayUtil.addLore(item, infoMsg, 0);
|
||||
}
|
||||
else if(inventory.equalsIgnoreCase("smp")) {
|
||||
item = new ItemStack(Items.DIAMOND_CHESTPLATE);
|
||||
|
||||
ItemDisplayUtil.addLore(item, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
|
||||
ItemDisplayUtil.addLore(item, infoMsg, 0);
|
||||
}
|
||||
|
||||
ItemDisplayUtil.addGlint(item);
|
||||
|
||||
item.setHoverName(new TextComponent("§f" + inventory.toUpperCase().replaceAll("_", " ")));
|
||||
item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(inventory.toUpperCase().replaceAll("_", " "), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
|
||||
this.setSlot(slot, item);
|
||||
slot++;
|
||||
@@ -147,11 +157,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().substring(2).replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().toLowerCase().substring(2).replaceAll(" ", "_");
|
||||
if(InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID()).contains(name.getString().toLowerCase().replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().toLowerCase().replaceAll(" ", "_");
|
||||
setMapLayout();
|
||||
} else {
|
||||
GamemodeHandler.customChallengePlayer(new NexiaPlayer(this.player), new NexiaPlayer(this.other), this.kit, DuelsMap.identifyMap(name.getString().substring(2)));
|
||||
GamemodeHandler.customChallengePlayer(new NexiaPlayer(this.player), new NexiaPlayer(this.other), this.kit, DuelsMap.identifyMap(name.getString()));
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.nexia.core.gui.duels;
|
||||
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
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.NexiaPlayer;
|
||||
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;
|
||||
@@ -54,8 +55,8 @@ public class DuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
for(DuelsMap map : DuelsMap.duelsMaps){
|
||||
if(gameMode.gameMode == Minecraft.GameMode.ADVENTURE && !map.isAdventureSupported) return;
|
||||
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
|
||||
if(gameMode.gameMode == Minecraft.GameMode.ADVENTURE && !map.isAdventureSupported) continue;
|
||||
this.setSlot(slot, map.item);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +84,7 @@ public class DuelGUI extends SimpleGui {
|
||||
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
|
||||
|
||||
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
|
||||
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
|
||||
playerHead.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(otherp.getScoreboardName(), ChatFormat.Minecraft.yellow).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)));
|
||||
|
||||
this.setSlot(4, playerHead);
|
||||
|
||||
@@ -96,7 +97,7 @@ public class DuelGUI extends SimpleGui {
|
||||
if(slot == 26) {
|
||||
slot = 28;
|
||||
}
|
||||
item = DuelGameMode.duelsItems.get(i1).setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " ")));
|
||||
item = DuelGameMode.duelsItems.get(i1);
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
|
||||
@@ -113,11 +114,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().substring(2).replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().substring(2).replaceAll(" ", "_");
|
||||
if(DuelGameMode.stringDuelGameModes.contains(name.getString().replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().replaceAll(" ", "_");
|
||||
setMapLayout(GamemodeHandler.identifyGamemode(this.kit));
|
||||
} else {
|
||||
GamemodeHandler.challengePlayer(new NexiaPlayer(this.player), new NexiaPlayer(this.other), this.kit, DuelsMap.identifyMap(name.getString().substring(2)));
|
||||
GamemodeHandler.challengePlayer(new NexiaPlayer(this.player), new NexiaPlayer(this.other), this.kit, DuelsMap.identifyMap(name.getString()));
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.nexia.core.gui.duels;
|
||||
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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;
|
||||
@@ -52,26 +54,27 @@ public class QueueGUI extends SimpleGui {
|
||||
slot = 28;
|
||||
}
|
||||
|
||||
|
||||
item = DuelGameMode.duelsItems.get(i1).setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " ")));
|
||||
item = DuelGameMode.duelsItems.get(i1);
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(duel);
|
||||
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
assert gameMode != null;
|
||||
ItemDisplayUtil.addLore(item, "§7There are §7§l" + gameMode.queue.size() + " §7people queued up.", 0);
|
||||
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.removeLore(item, 1);
|
||||
if(GamemodeHandler.isInQueue(new NexiaPlayer(this.player), gameMode)) {
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
ItemDisplayUtil.addLore(item, "§7Click to leave the queue.", 1);
|
||||
} else {
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
ItemDisplayUtil.addLore(item, net.kyori.adventure.text.Component.text("Click to leave the queue.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
}
|
||||
|
||||
this.setSlot(slot, item);
|
||||
slot++;
|
||||
i1++;
|
||||
}
|
||||
this.setSlot(40, new ItemStack(Items.BARRIER).setHoverName(new TextComponent("§c§lLeave ALL Queues")));
|
||||
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))));
|
||||
}
|
||||
|
||||
public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){
|
||||
@@ -83,24 +86,20 @@ public class QueueGUI extends SimpleGui {
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
|
||||
if(name.getString().substring(4).equalsIgnoreCase("Leave ALL Queues")) {
|
||||
//PlayerUtil.getFactoryPlayer(player).runCommand("/queue LEAVE", 0, false);
|
||||
if(name.getString().contains("Leave ALL Queues")) {
|
||||
GamemodeHandler.removeQueue(nexiaPlayer, null, false);
|
||||
|
||||
this.close();
|
||||
return super.click(index, clickType, action);
|
||||
}
|
||||
|
||||
String modifiedName = name.getString().substring(2).replaceAll(" ", "_");
|
||||
String modifiedName = name.getString().replaceAll(" ", "_");
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(modifiedName);
|
||||
|
||||
if(gameMode != null && GamemodeHandler.isInQueue(nexiaPlayer, gameMode)) {
|
||||
GamemodeHandler.removeQueue(nexiaPlayer, modifiedName, false);
|
||||
this.close();
|
||||
} else {
|
||||
GamemodeHandler.joinQueue(nexiaPlayer, modifiedName, false);
|
||||
this.close();
|
||||
}
|
||||
|
||||
this.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.nexia.core.gui.ffa;
|
||||
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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;
|
||||
@@ -16,6 +17,7 @@ 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);
|
||||
}
|
||||
@@ -47,7 +49,7 @@ public class KitGUI extends SimpleGui {
|
||||
|
||||
ItemStack item = ffaKits.item;
|
||||
|
||||
item.setHoverName(new TextComponent("§f" + StringUtil.capitalize(ffaKits.id.replaceAll("_", " "))));
|
||||
item.setHoverName(ObjectMappings.convertComponent(Component.text(StringUtil.capitalize(ffaKits.id.replaceAll("_", " ")), ChatFormat.Minecraft.white)));
|
||||
|
||||
this.setSlot(slot, item);
|
||||
|
||||
@@ -59,7 +61,7 @@ public class KitGUI extends SimpleGui {
|
||||
NexiaPlayer player = new NexiaPlayer(minecraftPlayer);
|
||||
FfaKit kit = FfaKit.identifyKit(name);
|
||||
if(kit != null) kit.giveKit(new NexiaPlayer(minecraftPlayer), false);
|
||||
else player.sendMessage(Component.text("Invalid kit!").color(ChatFormat.failColor));
|
||||
else player.sendMessage(Component.text("Invalid kit!", ChatFormat.failColor));
|
||||
}
|
||||
|
||||
public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){
|
||||
@@ -69,7 +71,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().substring(2).toLowerCase();
|
||||
String modifiedName = name.getString().toLowerCase();
|
||||
giveKit(this.player, modifiedName);
|
||||
this.close();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.nexia.core.gui.ffa;
|
||||
|
||||
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.NexiaPlayer;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.ffa.kits.utilities.KitFfaAreas;
|
||||
import com.nexia.nexus.api.world.util.Location;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
@@ -22,7 +23,7 @@ public class SpawnGUI extends SimpleGui {
|
||||
super(type, player, includePlayer);
|
||||
}
|
||||
|
||||
public static HashMap<String, int[]> mapLocations = new HashMap<>();
|
||||
public static HashMap<String, Location> mapLocations = new HashMap<>();
|
||||
|
||||
private void fillEmptySlots(ItemStack itemStack){
|
||||
for(int i = 0; i < 45; i++){
|
||||
@@ -108,18 +109,17 @@ public class SpawnGUI extends SimpleGui {
|
||||
}
|
||||
|
||||
public static void teleportPlayer(ServerPlayer minecraftPlayer, String name) {
|
||||
int[] pos = mapLocations.get(name);
|
||||
Location pos = mapLocations.get(name);
|
||||
NexiaPlayer player = new NexiaPlayer(minecraftPlayer);
|
||||
if(pos != null){
|
||||
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))
|
||||
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))
|
||||
);
|
||||
} else {
|
||||
player.sendMessage(Component.text("Invalid biome!").color(ChatFormat.failColor));
|
||||
player.sendMessage(Component.text("Invalid biome!", ChatFormat.failColor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,15 +157,15 @@ public class SpawnGUI extends SimpleGui {
|
||||
// 115 40 -151 | Mushrooms
|
||||
// 0 40 0 | Plains (Center)
|
||||
|
||||
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});
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.nexia.core.listeners;
|
||||
|
||||
import com.nexia.core.listeners.factory.*;
|
||||
import com.nexia.core.listeners.nexus.*;
|
||||
|
||||
public class ListenerHelper {
|
||||
public static void registerListeners() {
|
||||
// Factory Listeners
|
||||
// Nexus Listeners
|
||||
new PlayerJoinListener().registerListener();
|
||||
new PlayerDamageListener().registerListener();
|
||||
new PlayerDeathListener().registerListener();
|
||||
new PlayerHungerListener().registerListener();
|
||||
new PlayerLeaveListener().registerListener();
|
||||
new UseItemListener().registerListener();
|
||||
new PlayerSwapHandItemsListener().registerListener();
|
||||
new PlayerUseItemListener().registerListener();
|
||||
new PlayerDropItemListener().registerListener();
|
||||
new PlayerRespawnListener().registerListener();
|
||||
}
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.discord.Main;
|
||||
import com.nexia.discord.utilities.player.PlayerData;
|
||||
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 java.util.Objects;
|
||||
|
||||
import static com.nexia.discord.Main.jda;
|
||||
|
||||
public class PlayerJoinListener {
|
||||
public void registerListener() {
|
||||
PlayerJoinEvent.BACKEND.register(playerJoinEvent -> {
|
||||
|
||||
NexiaPlayer player = new NexiaPlayer(playerJoinEvent.getPlayer());
|
||||
processJoin(player);
|
||||
|
||||
/*
|
||||
if(minecraftPlayer.getStats().getValue(Stats.CUSTOM.get(Stats.LEAVE_GAME)) <= 1) {
|
||||
playerJoinEvent.setJoinMessage(
|
||||
Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(Component.text("!").color(TextColor.fromHexString("#ff9940")))
|
||||
.append(Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(Component.text(player.getRawName()).color(TextColor.fromHexString("#ff9940")))
|
||||
|
||||
|
||||
);
|
||||
} else {
|
||||
playerJoinEvent.setJoinMessage(
|
||||
Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(Component.text("+").color(ChatFormat.greenColor))
|
||||
.append(Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(Component.text(player.getRawName()).color(ChatFormat.greenColor))
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
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(NexiaPlayer 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(player.hasPermission("nexia.prefix.supporter")) {
|
||||
if(player.hasPermission("nexia.rank")) {
|
||||
ServerTime.factoryServer.runCommand("/staffprefix set " + player.getRawName() + " default");
|
||||
ServerTime.factoryServer.runCommand("/staffprefix remove " + player.getRawName() + " supporter");
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getRawName() + " default", 4, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Role supporterRole = jda.getRoleById("1107264322951979110");
|
||||
boolean hasRole = discordUser.getRoles().contains(supporterRole);
|
||||
boolean hasSupporterPrefix = player.hasPermission("nexia.prefix.supporter");
|
||||
|
||||
if(hasRole && !hasSupporterPrefix) {
|
||||
if(player.hasPermission("nexia.rank")) {
|
||||
ServerTime.factoryServer.runCommand("/staffprefix add " + player.getRawName() + " supporter", 4, false);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getRawName() + " supporter", 4, false);
|
||||
} else if(!hasRole && hasSupporterPrefix) {
|
||||
if(player.hasPermission("nexia.rank")) {
|
||||
ServerTime.factoryServer.runCommand("/staffprefix remove " + player.getRawName() + " supporter", 4, false);
|
||||
ServerTime.factoryServer.runCommand("/staffprefix set " + player.getRawName() + " default", 4, false);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getRawName() + " default", 4, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processJoin(NexiaPlayer player) {
|
||||
if(PlayerDataManager.get(player).clientType.equals(com.nexia.core.utilities.player.PlayerData.ClientType.VIAFABRICPLUS)) return;
|
||||
|
||||
com.nexia.ffa.classic.utilities.player.PlayerDataManager.addPlayerData(player);
|
||||
com.nexia.ffa.kits.utilities.player.PlayerDataManager.addPlayerData(player);
|
||||
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.addPlayerData(player);
|
||||
com.nexia.ffa.sky.utilities.player.PlayerDataManager.addPlayerData(player);
|
||||
|
||||
com.nexia.discord.utilities.player.PlayerDataManager.addPlayerData(player.getUUID());
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.addPlayerData(player);
|
||||
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.addPlayerData(player);
|
||||
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.addPlayerData(player);
|
||||
com.nexia.minigames.games.football.util.player.PlayerDataManager.addPlayerData(player);
|
||||
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.addPlayerData(player);
|
||||
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
|
||||
checkBooster(player);
|
||||
sendJoinMessage(player);
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerDisconnectEvent;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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 -> {
|
||||
|
||||
NexiaPlayer player = new NexiaPlayer(playerDisconnectEvent.getPlayer());
|
||||
processDisconnect(player);
|
||||
|
||||
/*
|
||||
if(Main.config.events.statusMessages){
|
||||
playerDisconnectEvent.setLeaveMessage(
|
||||
Component.text("[").color(ChatFormat.lineColor)
|
||||
.append(Component.text("-").color(ChatFormat.failColor)
|
||||
.append(Component.text("] ").color(ChatFormat.lineColor))
|
||||
.append(Component.text(player.getRawName()).color(ChatFormat.failColor)))
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void processDisconnect(NexiaPlayer player){
|
||||
if (BwUtil.isInBedWars(player)) BwPlayerEvents.leaveInBedWars(player);
|
||||
else if (FfaUtil.isFfaPlayer(player)) {
|
||||
FfaUtil.leaveOrDie(player, player.unwrap().getLastDamageSource(), true);
|
||||
}
|
||||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.LOBBY) DuelGameHandler.leave(player, true);
|
||||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.SKYWARS) SkywarsGame.leave(player);
|
||||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.OITC) OitcGame.leave(player);
|
||||
else if (PlayerDataManager.get(player).gameMode == PlayerGameMode.FOOTBALL) FootballGame.leave(player);
|
||||
|
||||
com.nexia.ffa.classic.utilities.player.PlayerDataManager.removePlayerData(player);
|
||||
com.nexia.ffa.kits.utilities.player.PlayerDataManager.removePlayerData(player);
|
||||
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.removePlayerData(player);
|
||||
com.nexia.ffa.sky.utilities.player.PlayerDataManager.removePlayerData(player);
|
||||
|
||||
com.nexia.discord.utilities.player.PlayerDataManager.removePlayerData(player.getUUID());
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.removePlayerData(player);
|
||||
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.removePlayerData(player);
|
||||
com.nexia.minigames.games.football.util.player.PlayerDataManager.removePlayerData(player);
|
||||
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.removePlayerData(player);
|
||||
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.removePlayerData(player);
|
||||
|
||||
|
||||
//LobbyUtil.leaveAllGames(minecraftPlayer, true);
|
||||
|
||||
PlayerDataManager.removePlayerData(player);
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerRespawnEvent;
|
||||
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.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.world.WorldUtil;
|
||||
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 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());
|
||||
|
||||
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.unwrap());
|
||||
if(serverPlayer != null && serverPlayer != player.unwrap() && 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) {
|
||||
player.getInventory().clear();
|
||||
LobbyUtil.giveItems(player);
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(duelsGame.winner.getLocation());
|
||||
} 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);
|
||||
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
|
||||
} else if(customDuelsGame != null && customDuelsGame.isEnding && customDuelsGame.winner != null) {
|
||||
player.getInventory().clear();
|
||||
LobbyUtil.giveItems(player);
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(customDuelsGame.winner.getLocation());
|
||||
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
|
||||
} else if(customTeamDuelsGame != 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(customTeamDuelsGame.level));
|
||||
|
||||
NexiaPlayer 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()));
|
||||
}
|
||||
} else {
|
||||
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
|
||||
}
|
||||
|
||||
if(player1 != null) {
|
||||
respawn = player1.getLocation();
|
||||
}
|
||||
|
||||
respawnEvent.setSpawnpoint(respawn);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,8 +1,8 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
package com.nexia.core.listeners.nexus;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerHotbarDropItemEvent;
|
||||
import com.nexia.nexus.api.event.player.PlayerHotbarDropItemEvent;
|
||||
import com.nexia.core.utilities.misc.EventUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
|
||||
public class PlayerDropItemListener {
|
||||
public void registerListener(){
|
||||
@@ -13,7 +13,6 @@ public class PlayerDropItemListener {
|
||||
if (!EventUtil.dropItem(player, playerDropItemEvent.getItemStack())) {
|
||||
playerDropItemEvent.setCancelled(true);
|
||||
player.refreshInventory();
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+9
-7
@@ -1,13 +1,15 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
package com.nexia.core.listeners.nexus;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerUseItemEvent;
|
||||
import com.combatreforged.factory.api.world.item.ItemStack;
|
||||
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.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class UseItemListener {
|
||||
public class PlayerUseItemListener {
|
||||
public void registerListener() {
|
||||
PlayerUseItemEvent.BACKEND.register(playerUseItemEvent -> {
|
||||
|
||||
@@ -17,7 +19,7 @@ public class UseItemListener {
|
||||
|
||||
Component name = itemStack.getDisplayName();
|
||||
|
||||
PlayerGameMode gameMode = PlayerDataManager.get(player).gameMode;
|
||||
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode;
|
||||
String sName = name.toString().toLowerCase();
|
||||
|
||||
if(gameMode == PlayerGameMode.LOBBY) {
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.loader;
|
||||
|
||||
import com.combatreforged.factory.api.command.CommandSourceInfo;
|
||||
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.*;
|
||||
@@ -17,10 +17,10 @@ import net.fabricmc.fabric.api.event.Event;
|
||||
|
||||
public class CommandLoader {
|
||||
|
||||
public static void registerFactoryCommands() {
|
||||
CommandDispatcher<CommandSourceInfo> commandDispatcher = ServerTime.factoryServer.getCommandDispatcher();
|
||||
public static void registerNexusCommands() {
|
||||
CommandDispatcher<CommandSourceInfo> commandDispatcher = ServerTime.nexusServer.getCommandDispatcher();
|
||||
|
||||
SprintFixCommand.register(commandDispatcher);
|
||||
HelpCommand.register(commandDispatcher);
|
||||
DiscordCommand.register(commandDispatcher);
|
||||
LeaveCommand.register(commandDispatcher);
|
||||
PrefixCommand.register(commandDispatcher);
|
||||
@@ -54,15 +54,14 @@ public class CommandLoader {
|
||||
BanCommand.register(commandDispatcher);
|
||||
UnBanCommand.register(commandDispatcher);
|
||||
StatsCommand.register(commandDispatcher);
|
||||
SprintFixCommand.register(commandDispatcher);
|
||||
RulesCommand.register(commandDispatcher);
|
||||
ReportCommand.register(commandDispatcher);
|
||||
SprintFixCommand.register(commandDispatcher);
|
||||
SprintFixCommand.register(commandDispatcher);
|
||||
MessageCommand.registerMsg(commandDispatcher);
|
||||
MessageCommand.registerReply(commandDispatcher);
|
||||
HealCommand.register(commandDispatcher);
|
||||
DetectCommand.register(commandDispatcher);
|
||||
SudoCommand.register(commandDispatcher);
|
||||
}
|
||||
|
||||
public static void registerCommands() {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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;
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
|
||||
PlayerData playerData = PlayerDataManager.get(nexiaPlayer);
|
||||
|
||||
if (BwUtil.isInBedWars(nexiaPlayer) || (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(nexiaPlayer) && !serverPlayer.isCreative())) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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 serverPlayer)) return;
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
|
||||
|
||||
if((FfaUtil.isFfaPlayer(nexiaPlayer) || 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.FfaAreas;
|
||||
import com.nexia.ffa.sky.utilities.FfaSkyUtil;
|
||||
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))) || FfaAreas.isFfaWorld(serverLevel)) {
|
||||
if ((BwAreas.isBedWarsWorld(serverLevel) && !(BwUtil.dropResources(blockState))) || FfaSkyUtil.INSTANCE.isFfaWorld(serverLevel)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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 serverPlayer)) return;
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
|
||||
|
||||
if((FfaUtil.isFfaPlayer(nexiaPlayer) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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 serverPlayer)) return;
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
|
||||
|
||||
if((FfaUtil.isFfaPlayer(nexiaPlayer) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); }
|
||||
}
|
||||
}
|
||||
+13
-11
@@ -1,19 +1,20 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
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.NexiaPlayer;
|
||||
import com.nexia.ffa.classic.utilities.FfaAreas;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerData;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
|
||||
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
|
||||
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.FlowerPotBlock;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -21,17 +22,18 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FlowerPotBlock.class)
|
||||
public class PotBlockMixin {
|
||||
@Mixin(value = {GrindstoneBlock.class, DispenserBlock.class, CraftingTableBlock.class, BeaconBlock.class, AnvilBlock.class, HopperBlock.class, FlowerPotBlock.class})
|
||||
public class MultipleBlockMixins {
|
||||
|
||||
@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(nexiaPlayer);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(nexiaPlayer);
|
||||
|
||||
if (BwUtil.isInBedWars(nexiaPlayer) || KitRoom.isInKitRoom(nexiaPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null || playerData.gameOptions.customTeamDuelsGame != null || playerData.gameOptions.customDuelsGame != null)) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaAreas.isFfaWorld(serverPlayer.getLevel()) || com.nexia.ffa.kits.utilities.FfaAreas.isFfaWorld(serverPlayer.getLevel())) && !serverPlayer.isCreative()) {
|
||||
if ((FfaUtil.isFfaPlayer(nexiaPlayer) || KitRoom.isInKitRoom(nexiaPlayer) || BwUtil.isInBedWars(nexiaPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null)) || LobbyUtil.isLobbyWorld(nexiaPlayer.getWorld())) && !player.isCreative()) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+9
-14
@@ -1,17 +1,16 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
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 com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
|
||||
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.GrindstoneBlock;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -19,19 +18,15 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(GrindstoneBlock.class)
|
||||
public class GrindstoneBlockMixin {
|
||||
|
||||
@Mixin(TrapDoorBlock.class)
|
||||
public class TrapDoorBlockMixin {
|
||||
@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(nexiaPlayer);
|
||||
|
||||
if (BwUtil.isInBedWars(nexiaPlayer) || (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;
|
||||
if ((FfaUtil.isFfaPlayer(nexiaPlayer) || KitRoom.isInKitRoom(nexiaPlayer) || LobbyUtil.isLobbyWorld(nexiaPlayer.getWorld())) && !player.isCreative()) {
|
||||
cir.setReturnValue(InteractionResult.PASS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.mixin.entity;
|
||||
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
|
||||
import com.nexia.minigames.games.football.FootballGame;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.nexia.core.mixin.entity;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.ffa.sky.utilities.FfaAreas;
|
||||
import com.nexia.ffa.sky.utilities.FfaSkyUtil;
|
||||
import com.nexia.ffa.sky.utilities.SkyFfaAreas;
|
||||
import com.nexia.minigames.games.football.FootballGame;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -42,7 +43,7 @@ public abstract class EntityMixin implements Nameable, CommandSource {
|
||||
@Inject(method = "isInvulnerableTo", at = @At("HEAD"), cancellable = true)
|
||||
private void hurt(DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
|
||||
if ((damageSource == DamageSource.FALL && getTags().contains(LobbyUtil.NO_FALL_DAMAGE_TAG)) ||
|
||||
(damageSource == DamageSource.FALL && getTags().contains("ffa"))
|
||||
(damageSource == DamageSource.FALL && getTags().contains("oitc"))
|
||||
) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
@@ -54,8 +55,8 @@ public abstract class EntityMixin implements Nameable, CommandSource {
|
||||
|
||||
if (instance.level instanceof ServerLevel serverLevel) {
|
||||
|
||||
if (FfaAreas.isFfaWorld(serverLevel)) {
|
||||
voidY = FfaAreas.getVoidY();
|
||||
if (FfaSkyUtil.INSTANCE.isFfaWorld(serverLevel)) {
|
||||
voidY = SkyFfaAreas.getVoidY();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public abstract class EntityMixin implements Nameable, CommandSource {
|
||||
double e = entity.getZ() - this.getZ();
|
||||
double f = Mth.absMax(d, e);
|
||||
if (f >= 0.009999999776482582) {
|
||||
f = (double)Mth.sqrt(f);
|
||||
f = Mth.sqrt(f);
|
||||
d /= f;
|
||||
e /= f;
|
||||
double g = 1.0 / f;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.mixin.entity;
|
||||
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -31,7 +31,6 @@ public abstract class ItemFrameMixin extends Entity {
|
||||
// Disable interacting with item frames
|
||||
if ((FfaUtil.isFfaPlayer(nexiaPlayer) || KitRoom.isInKitRoom(nexiaPlayer)) && !player.isCreative()) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,70 +1,21 @@
|
||||
package com.nexia.core.mixin.entity;
|
||||
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.minigames.games.bedwars.areas.BwAreas;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.CombatRules;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ShieldItem;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntityMixin {
|
||||
|
||||
|
||||
@Shadow public abstract double getAttributeValue(Attribute attribute);
|
||||
|
||||
@Shadow public abstract ItemStack getBlockingItem();
|
||||
|
||||
// Make void death instant
|
||||
@ModifyArg(method = "hurt", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;actuallyHurt(Lnet/minecraft/world/damagesource/DamageSource;F)V"))
|
||||
protected float hurt(DamageSource damageSource, float value) {
|
||||
if((Object) this instanceof ServerPlayer player) {
|
||||
if(PlayerDataManager.get(player.getUUID()).gameMode == PlayerGameMode.LOBBY) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
if (damageSource == DamageSource.OUT_OF_WORLD) return 1000000.0F;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author NotCoded
|
||||
* @reason Fix Shield Knockback
|
||||
*/
|
||||
@Overwrite
|
||||
public void knockback(float f, double d, double e) {
|
||||
LivingEntity instance = (LivingEntity) (Object) this;
|
||||
double g = this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
|
||||
ItemStack itemStack = this.getBlockingItem();
|
||||
if (!itemStack.isEmpty()) {
|
||||
if(instance instanceof Player) {
|
||||
g = Math.min(1.0, 1-(1-g)*(1-(double) ShieldItem.getShieldKnockbackResistanceValue(itemStack)));
|
||||
} else {
|
||||
g = Math.min(1.0, g + (double) ShieldItem.getShieldKnockbackResistanceValue(itemStack));
|
||||
}
|
||||
}
|
||||
|
||||
f = (float)((double)f * (1.0 - g));
|
||||
if (!(f <= 0.0F)) {
|
||||
instance.hasImpulse = true;
|
||||
Vec3 vec3 = instance.getDeltaMovement();
|
||||
Vec3 vec32 = (new Vec3(d, 0.0, e)).normalize().scale(f);
|
||||
instance.setDeltaMovement(vec3.x / 2.0 - vec32.x, instance.isOnGround() ? Math.min(0.4, (double)f * 0.75) : Math.min(0.4, vec3.y + (double)f * 0.5), vec3.z / 2.0 - vec32.z);
|
||||
}
|
||||
public abstract class LivingEntityMixin extends Entity {
|
||||
public LivingEntityMixin(EntityType<?> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
@Redirect(method = "getDamageAfterMagicAbsorb", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/CombatRules;getDamageAfterMagicAbsorb(FF)F"))
|
||||
|
||||
Loaded 100 of 270 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user