Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59e3fcb70c | ||
|
|
56fad0a9da | ||
|
|
e6719c619f | ||
|
|
35e76fc8b4 | ||
|
|
d99d8f4699 | ||
|
|
ba328585bf | ||
|
|
3a121afd81 | ||
|
|
30ac6076f2 | ||
|
|
96980fdcea | ||
|
|
7977015d80 | ||
|
|
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 | ||
|
|
73015ad263 | ||
|
|
25af9ac960 | ||
|
|
5c8e7b5b8a | ||
|
|
b68519e563 | ||
|
|
b3df7a1119 | ||
|
|
14e02313ab | ||
|
|
21043eb96b | ||
|
|
d1de6ab2e8 | ||
|
|
d7205debc9 | ||
|
|
3ff03632ff | ||
|
|
f7381e359f | ||
|
|
0ec5ef70dc | ||
|
|
9add587313 | ||
|
|
f01863c5bd | ||
|
|
15abe8bda7 | ||
|
|
ef1758f2e1 | ||
|
|
987bd54c25 | ||
|
|
cc2137766d | ||
|
|
045ed107ab | ||
|
|
161d71fdf7 | ||
|
|
e229a432e4 | ||
|
|
84845640c9 | ||
|
|
6bdb81e124 | ||
|
|
7754d9a326 | ||
|
|
67b5d1af47 | ||
|
|
8e64062cf3 | ||
|
|
ba4a7ff9c5 | ||
|
|
b024e4be52 | ||
|
|
547e4a17c8 | ||
|
|
77c3dca42e | ||
|
|
6dd22598ba | ||
|
|
504284a47a | ||
|
|
e2aa919c7a | ||
|
|
02e94954ed | ||
|
|
1450a9d6b8 | ||
|
|
a3c24a7f7e | ||
|
|
f8f93041c7 | ||
|
|
a593178ad3 | ||
|
|
f09559145b | ||
|
|
f441aa11bb | ||
|
|
1e1e98b91a | ||
|
|
aea96fc1a1 | ||
|
|
58c37704c9 | ||
|
|
56220efc6d | ||
|
|
4c2c0b9d3d | ||
|
|
5d65615685 | ||
|
|
c6067291a9 | ||
|
|
05ee2b6724 | ||
|
|
e8e3ad4e45 | ||
|
|
122c973762 | ||
|
|
44a16a5af7 | ||
|
|
77636f83fe | ||
|
|
ec3b244baa | ||
|
|
23c644c3db | ||
|
|
16db949c7d | ||
|
|
480553f088 | ||
|
|
8bd539dcce | ||
|
|
f6c57c3f3e | ||
|
|
2b6ed2675a | ||
|
|
94075c084f | ||
|
|
6e3324f57c | ||
|
|
28dbdbc90e | ||
|
|
83c9907e01 | ||
|
|
b40e8defa4 | ||
|
|
8365817799 | ||
|
|
92680cb79c | ||
|
|
11fe172fec | ||
|
|
ae515ae773 | ||
|
|
70b13d82f8 | ||
|
|
752e22e224 | ||
|
|
710f7ced46 | ||
|
|
4a7e00e410 | ||
|
|
db338bb99d | ||
|
|
d0ebddb12b | ||
|
|
f2b526e7b7 | ||
|
|
d831220cce | ||
|
|
4fe41dbc6c | ||
|
|
cc5f0a4c34 | ||
|
|
0794f418e0 | ||
|
|
9e8bdfcecd | ||
|
|
d2c10c8037 | ||
|
|
27f20c1a43 | ||
|
|
7d0ecae692 | ||
|
|
755c47a864 | ||
|
|
24ee9ec6b3 | ||
|
|
2802474172 | ||
|
|
01828d2045 | ||
|
|
d195ed08b0 | ||
|
|
4e5c9f2567 | ||
|
|
f1b1d5c739 | ||
|
|
4629b20ef2 | ||
|
|
457d138343 | ||
|
|
06104f542f | ||
|
|
afa363b885 | ||
|
|
02d8b3cf93 | ||
|
|
648a9f7062 | ||
|
|
94e7934a7c | ||
|
|
4b8709fad2 | ||
|
|
4d20fcdd36 | ||
|
|
c32e0193f9 | ||
|
|
d824efd6ae | ||
|
|
599e5dc9ac | ||
|
|
d0714e9e8f | ||
|
|
ff79aee63d | ||
|
|
c6c5cd3f79 | ||
|
|
597b5ceee3 | ||
|
|
d1481d0a57 | ||
|
|
9008efba05 | ||
|
|
347d8a0701 | ||
|
|
f5d2bd22a0 | ||
|
|
97ae66848b | ||
|
|
eb1c0a07fa | ||
|
|
1b66d78bf9 | ||
|
|
e5b28e09eb | ||
|
|
cf9590ffe4 | ||
|
|
3dfb694772 | ||
|
|
89cade32b5 | ||
|
|
cf89ee2aad | ||
|
|
9c997d001e | ||
|
|
9e27a0600f | ||
|
|
48ff57d761 | ||
|
|
f815d89480 |
No files matched your search
@@ -36,4 +36,4 @@ jobs:
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/${{ github.ref_name }}/libs
|
||||
path: build/${{ github.ref_name }}/libs
|
||||
+1
-1
@@ -93,4 +93,4 @@ bin/
|
||||
# fabric
|
||||
|
||||
run/
|
||||
.factorypath
|
||||
.nexuspath
|
||||
@@ -4,6 +4,7 @@
|
||||
<br>
|
||||
|
||||
# Nexia
|
||||
using **Nexus API**
|
||||
|
||||
The mod for the Nexia CTS server.
|
||||
|
||||
@@ -14,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`
|
||||
|
||||
+24
-30
@@ -50,52 +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}-1.16_combat-6")
|
||||
|
||||
include(implementation("com.google.code.gson:gson:${project.gson_version}"))
|
||||
|
||||
include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}")))
|
||||
// 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}")
|
||||
|
||||
|
||||
modApi("com.nexia:gato-anticheat:${project.gato_anticheat_version}+${project.minecraft_version}")
|
||||
|
||||
include(modApi("net.blumbo:blfscheduler:${project.blfscheduler_version}"))
|
||||
include(modApi("io.github.blumbo:inventory-merger:${project.inventory_merger_version}"))
|
||||
include(modApi("net.notcoded:codelib:${project.codelib_version}+${project.minecraft_version}"))
|
||||
|
||||
include(implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT"))
|
||||
include(implementation("net.kyori:adventure-text-serializer-gson:4.1.0-SNAPSHOT"))
|
||||
include(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}"))
|
||||
|
||||
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
|
||||
// You may need to force-disable transitiveness on them.
|
||||
// useless libraries
|
||||
include(implementation("com.google.code.gson:gson:${project.gson_version}"))
|
||||
include(implementation("com.googlecode.json-simple:json-simple:${project.json_simple_version}"))
|
||||
|
||||
}
|
||||
|
||||
// Custom Manifest and Intermediary mappings declaration
|
||||
|
||||
+10
-11
@@ -9,32 +9,31 @@ yarn_mappings=1.16_combat-6+build.2
|
||||
loader_version=0.14.21
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.2.1
|
||||
mod_version = 2.0.0
|
||||
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.3
|
||||
gato_anticheat_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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,259 @@
|
||||
package com.nexia.base.player;
|
||||
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
|
||||
import com.nexia.minigames.games.bedwars.util.BwScoreboard;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
import com.nexia.minigames.games.football.FootballGame;
|
||||
import com.nexia.minigames.games.oitc.OitcGame;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import com.nexia.nexus.api.world.effect.StatusEffectInstance;
|
||||
import com.nexia.nexus.api.world.entity.player.Player;
|
||||
import com.nexia.nexus.api.world.item.ItemStack;
|
||||
import com.nexia.nexus.api.world.types.Minecraft;
|
||||
import com.nexia.nexus.builder.implementation.world.entity.player.WrappedPlayer;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NexiaPlayer extends WrappedPlayer {
|
||||
|
||||
public NexiaPlayer(ServerPlayer wrappedPlayer) {
|
||||
super(wrappedPlayer);
|
||||
}
|
||||
|
||||
public NexiaPlayer(Player player) {
|
||||
super(PlayerUtil.getMinecraftPlayer(player.getUUID()));
|
||||
}
|
||||
|
||||
public void reset(boolean heal, Minecraft.GameMode gameMode) {
|
||||
this.setInvulnerabilityTime(0);
|
||||
this.clearEffects();
|
||||
this.unwrap().setAbsorptionAmount(0);
|
||||
this.getInventory().clear();
|
||||
this.setRemainingFireTicks(0);
|
||||
this.setExperienceLevel(0);
|
||||
this.setExperiencePoints(0);
|
||||
this.getInventory().setCursorStack(ItemStack.create(Minecraft.Item.AIR));
|
||||
|
||||
this.unwrap().getEnderChestInventory().clearContent();
|
||||
this.setGlowing(false);
|
||||
this.stopAllSounds();
|
||||
|
||||
this.setGameMode(gameMode);
|
||||
|
||||
if (heal) {
|
||||
this.setHealth(this.getMaxHealth());
|
||||
this.setFoodLevel(20);
|
||||
}
|
||||
|
||||
this.setAbleToFly(false);
|
||||
this.unwrap().onUpdateAbilities();
|
||||
|
||||
ServerTime.minecraftServer.getPlayerList().sendPlayerPermissionLevel(this.unwrap());
|
||||
}
|
||||
|
||||
public PlayerGameMode getCurrentGameMode() {
|
||||
return ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(this)).gameMode;
|
||||
}
|
||||
|
||||
public NexiaPlayer refreshPlayer() {
|
||||
return new NexiaPlayer(PlayerUtil.getMinecraftPlayer(this.getUUID()));
|
||||
}
|
||||
|
||||
public boolean isInGameMode(PlayerGameMode gameMode) {
|
||||
return this.getCurrentGameMode().equals(gameMode);
|
||||
}
|
||||
|
||||
public void safeReset(boolean heal, Minecraft.GameMode gameMode) {
|
||||
this.setGameMode(gameMode);
|
||||
|
||||
this.setInvulnerabilityTime(0);
|
||||
this.clearEffects();
|
||||
this.unwrap().setAbsorptionAmount(0);
|
||||
this.setRemainingFireTicks(0);
|
||||
this.setGlowing(false);
|
||||
|
||||
if (heal) {
|
||||
this.setHealth(this.getMaxHealth());
|
||||
this.setFoodLevel(20);
|
||||
}
|
||||
|
||||
this.setAbleToFly(false);
|
||||
this.unwrap().onUpdateAbilities();
|
||||
|
||||
ServerTime.minecraftServer.getPlayerList().sendPlayerPermissionLevel(this.unwrap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a parsed <a href="https://docs.advntr.dev/minimessage/index.html">MiniMessage</a> message to the player.
|
||||
* @param message The message that's going to get parsed
|
||||
* @apiNote Check out the <a href="https://docs.advntr.dev/minimessage/format.html">MiniMessage docs</a>.
|
||||
*/
|
||||
|
||||
public void sendMiniMessage(String message, Object... args) {
|
||||
this.sendMessage(MiniMessage.get().parse(String.format(message, args)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message with the prefix <code>Nexia » </code> to the player.
|
||||
* @apiNote The message is going to get sent in white ({@link ChatFormat.Minecraft}).
|
||||
*/
|
||||
|
||||
public void sendNexiaMessage(String message, Object... args) {
|
||||
this.sendMessage(ChatFormat.nexiaMessage.append(Component.text(String.format(message, args), ChatFormat.Minecraft.white)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a Component with the prefix <code>Nexia » </code> to the player.
|
||||
*/
|
||||
|
||||
public void sendNexiaMessage(Component component) {
|
||||
this.sendMessage(ChatFormat.nexiaMessage.append(component));
|
||||
}
|
||||
|
||||
public boolean hasPermission(@NotNull String permission) {
|
||||
return Permissions.check(this.unwrap(), permission);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPermission(@NotNull String permission, int defaultRequiredLevel) {
|
||||
return Permissions.check(this.unwrap(), permission, defaultRequiredLevel);
|
||||
}
|
||||
|
||||
public boolean hasEffect(Minecraft.Effect effect) {
|
||||
for(StatusEffectInstance effectInstance : this.getActiveEffects()) {
|
||||
if(effectInstance.getStatusEffect().getType().equals(effect.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void leaveAllGames() {
|
||||
if (BwUtil.isInBedWars(this)) {
|
||||
BwPlayerEvents.leaveInBedWars(this);
|
||||
} else if (FfaUtil.isFfaPlayer(this)) {
|
||||
FfaUtil.leaveOrDie(this, this.unwrap().getLastDamageSource(), true);
|
||||
} else if (this.isInGameMode(PlayerGameMode.LOBBY)) {
|
||||
DuelGameHandler.leave(this, false);
|
||||
} else if (this.isInGameMode(PlayerGameMode.OITC)) {
|
||||
OitcGame.leave(this);
|
||||
} else if (this.isInGameMode(PlayerGameMode.SKYWARS)) {
|
||||
SkywarsGame.leave(this);
|
||||
} else if (this.isInGameMode(PlayerGameMode.FOOTBALL)) {
|
||||
FootballGame.leave(this);
|
||||
}
|
||||
|
||||
// sometimes those do not get removed
|
||||
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, this, true);
|
||||
BwScoreboard.removeScoreboardFor(this);
|
||||
|
||||
for (String tag : LobbyUtil.removedTags) {
|
||||
if (this.hasTag(tag)) this.removeTag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshInventory() {
|
||||
NonNullList<net.minecraft.world.item.ItemStack> i = NonNullList.create();
|
||||
for (int j = 0; j < this.unwrap().containerMenu.slots.size(); ++j) {
|
||||
net.minecraft.world.item.ItemStack itemStack = this.unwrap().containerMenu.slots.get(j).getItem();
|
||||
i.add(itemStack.isEmpty() ? net.minecraft.world.item.ItemStack.EMPTY : itemStack);
|
||||
}
|
||||
this.unwrap().refreshContainer(this.unwrap().containerMenu, i);
|
||||
}
|
||||
|
||||
public void sendHandItemPacket(InteractionHand hand) {
|
||||
if (hand == InteractionHand.MAIN_HAND) {
|
||||
sendInvSlotPacket(this.unwrap().inventory.selected);
|
||||
} else if (hand == InteractionHand.OFF_HAND) {
|
||||
sendInvSlotPacket(40);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendHandItemPacket() {
|
||||
this.sendHandItemPacket(this.unwrap().getUsedItemHand());
|
||||
}
|
||||
|
||||
public void sendInvSlotPacket(int slot) {
|
||||
int packetSlot;
|
||||
|
||||
if (slot < 9) {
|
||||
packetSlot = 36 + slot;
|
||||
} else if (slot < 36) {
|
||||
packetSlot = slot;
|
||||
} else if (slot < 40) {
|
||||
packetSlot = 44 - slot;
|
||||
} else if (slot == 40) {
|
||||
packetSlot = 45;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
this.unwrap().connection.send(new ClientboundContainerSetSlotPacket(0, packetSlot, this.unwrap().inventory.getItem(slot)));
|
||||
}
|
||||
|
||||
public boolean hasRank(NexiaRank rank) {
|
||||
return this.hasPermission(rank.groupID);
|
||||
}
|
||||
|
||||
public boolean hasPrefix(NexiaRank rank) {
|
||||
return this.hasPermission("nexia.prefix." + rank.id);
|
||||
}
|
||||
|
||||
public void removeItem(Item item, int count) {
|
||||
for (net.minecraft.world.item.ItemStack itemStack : ItemStackUtil.getInvItems(this.unwrap())) {
|
||||
if (itemStack.getItem() != item) continue;
|
||||
|
||||
if (itemStack.getCount() >= count) {
|
||||
itemStack.shrink(count);
|
||||
break;
|
||||
} else {
|
||||
count -= itemStack.getCount();
|
||||
itemStack.shrink(itemStack.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSound(SoundEvent soundEvent, SoundSource soundSource, float volume, float pitch) {
|
||||
sendSound(new EntityPos(this), soundEvent, soundSource, volume, pitch);
|
||||
}
|
||||
|
||||
public void sendSound(EntityPos position, SoundEvent soundEvent, SoundSource soundSource, float volume, float pitch) {
|
||||
this.unwrap().connection.send(new ClientboundSoundPacket(soundEvent, soundSource,
|
||||
position.x, position.y, position.z, 16f * volume, pitch));
|
||||
}
|
||||
|
||||
public boolean setBedrockBridging(boolean allowed) {
|
||||
if (ServerPlayNetworking.canSend(this.unwrap(), NexiaCore.CONVENTIONAL_BRIDGING_UPDATE_ID)) {
|
||||
FriendlyByteBuf buf = PacketByteBufs.create();
|
||||
buf.writeBoolean(allowed);
|
||||
ServerPlayNetworking.send(this.unwrap(), NexiaCore.CONVENTIONAL_BRIDGING_UPDATE_ID, buf);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+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,70 +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.");
|
||||
|
||||
// annoying ahh
|
||||
/*
|
||||
PlayerDetectionEvent.REACH.register((player, entity) -> {
|
||||
Punishment punishment = PlayerDataManager.get(player).punishment;
|
||||
punishment.reachOffences++;
|
||||
punishment.check((ServerPlayer) player);
|
||||
});
|
||||
|
||||
PlayerDetectionEvent.NO_SWING.register((player, entity) -> {
|
||||
Punishment punishment = PlayerDataManager.get(player).punishment;
|
||||
punishment.noSwingOffences++;
|
||||
punishment.check((ServerPlayer) player);
|
||||
});
|
||||
*/
|
||||
|
||||
networkingHandler = new NetworkingHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("FutureReturnValueIgnored")
|
||||
public void onFactoryLoad(FactoryAPI api, FactoryServer server) {
|
||||
Main.logger.info("Loading factory version...");
|
||||
|
||||
ServerTime.factoryServer = server;
|
||||
ServerTime.factoryAPI = api;
|
||||
ServerTime.scheduler = api.getScheduler();
|
||||
|
||||
Main.logger.info("Registering listeners....");
|
||||
ListenerHelper.registerListeners();
|
||||
Main.logger.info("Registered listeners.");
|
||||
}
|
||||
}
|
||||
@@ -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,32 +1,33 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import 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;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class DiscordCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("discord").executes(DiscordCommand::run));
|
||||
dispatcher.register(Commands.literal("dc").executes(DiscordCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("discord").executes(DiscordCommand::run));
|
||||
dispatcher.register(CommandUtils.literal("dc").executes(DiscordCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(
|
||||
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,18 +1,17 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class HelpCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("help").executes(HelpCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("help").executes(HelpCommand::run));
|
||||
}
|
||||
|
||||
static String commandSeparator = ": ";
|
||||
@@ -38,7 +37,7 @@ public class HelpCommand {
|
||||
"sprintfix" + commandSeparator + "toggle the sprint fix"
|
||||
};
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
|
||||
Component message = ChatFormat.separatorLine("Commands");
|
||||
|
||||
@@ -48,17 +47,17 @@ public class HelpCommand {
|
||||
|
||||
message = message.append(Component.text("\n/" + commandInfo[0])
|
||||
.color(ChatFormat.brandColor1)
|
||||
.decoration(ChatFormat.bold, false)
|
||||
|
||||
.decoration(ChatFormat.strikeThrough, false)
|
||||
.append(Component.text(" | ").color(ChatFormat.lineColor).decoration(ChatFormat.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];
|
||||
}
|
||||
|
||||
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
|
||||
|
||||
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
|
||||
context.getSource().sendMessage(message);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
|
||||
public class LeaveCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
register(dispatcher, "leave");
|
||||
register(dispatcher, "lobby");
|
||||
register(dispatcher, "l");
|
||||
register(dispatcher, "hub");
|
||||
}
|
||||
|
||||
private static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
|
||||
dispatcher.register(Commands.literal(string).executes(LeaveCommand::run));
|
||||
private static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
|
||||
dispatcher.register(CommandUtils.literal(string).executes(LeaveCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
LobbyUtil.leaveAllGames(context.getSource().getPlayerOrException(), true);
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.chat.PlayerMutes;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
|
||||
|
||||
public class MessageCommand {
|
||||
|
||||
public static void registerMsg(CommandDispatcher<CommandSourceStack> commandDispatcher, boolean bl) {
|
||||
public static void registerMsg(CommandDispatcher<CommandSourceInfo> commandDispatcher) {
|
||||
registerMsg(commandDispatcher, "msg");
|
||||
registerMsg(commandDispatcher, "message");
|
||||
registerMsg(commandDispatcher, "tell");
|
||||
registerMsg(commandDispatcher, "whisper");
|
||||
}
|
||||
|
||||
public static void registerMsg(CommandDispatcher<CommandSourceStack> commandDispatcher, String string) {
|
||||
commandDispatcher.register(Commands.literal(string)
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
public static void registerMsg(CommandDispatcher<CommandSourceInfo> commandDispatcher, String string) {
|
||||
commandDispatcher.register(CommandUtils.literal(string)
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::msgCommand)
|
||||
)
|
||||
)
|
||||
@@ -39,21 +39,21 @@ public class MessageCommand {
|
||||
|
||||
|
||||
|
||||
public static void registerReply(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("r")
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
public static void registerReply(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("r")
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::replyCommand)
|
||||
));
|
||||
dispatcher.register(Commands.literal("reply")
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
dispatcher.register(CommandUtils.literal("reply")
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(MessageCommand::replyCommand)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static int msgCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer sender = context.getSource().getPlayerOrException();
|
||||
ServerPlayer receiver = EntityArgument.getPlayer(context, "player");
|
||||
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);
|
||||
@@ -61,13 +61,13 @@ public class MessageCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int replyCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer sender = context.getSource().getPlayerOrException();
|
||||
PlayerData senderData = PlayerDataManager.get(sender);
|
||||
ServerPlayer receiver = PlayerUtil.getFixedPlayer(senderData.lastMessageSender);
|
||||
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) {
|
||||
sender.sendMessage(LegacyChatFormat.format("{s}Nobody to reply to"), Util.NIL_UUID);
|
||||
sender.sendMessage(Component.text("Nobody to reply to.", ChatFormat.systemColor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -77,24 +77,24 @@ public class MessageCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static void sendMessage(ServerPlayer sender, ServerPlayer receiver, String message) {
|
||||
if (PlayerMutes.muted(sender) || sender == receiver) return;
|
||||
private static void sendMessage(NexiaPlayer sender, NexiaPlayer receiver, String message) {
|
||||
if (PlayerMutes.muted(sender) || sender.equals(receiver)) return;
|
||||
|
||||
PlayerUtil.getFactoryPlayer(sender).sendMessage(
|
||||
Component.text(String.format("To %s", receiver.getScoreboardName())).color(ChatFormat.brandColor2)
|
||||
sender.sendMessage(
|
||||
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))
|
||||
|
||||
));
|
||||
|
||||
PlayerUtil.getFactoryPlayer(receiver).sendMessage(
|
||||
Component.text(String.format("From %s", sender.getScoreboardName())).color(ChatFormat.brandColor2)
|
||||
receiver.sendMessage(
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,65 +3,55 @@ package com.nexia.core.commands.player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
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.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class PingCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("ping").executes(PingCommand::run)
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("ping").executes(PingCommand::run)
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
dispatcher.register(Commands.literal("latency").executes(PingCommand::run)
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
|
||||
dispatcher.register(CommandUtils.literal("latency").executes(PingCommand::run)
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> PingCommand.ping(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer executer = context.getSource().getPlayerOrException();
|
||||
int ping = executer.latency;
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
int ping = new NexiaPlayer(context.getSource().getPlayerOrException()).getLatency();
|
||||
|
||||
PlayerUtil.getFactoryPlayer(executer).sendMessage(
|
||||
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;
|
||||
}
|
||||
|
||||
public static int ping(CommandContext<CommandSourceStack> context, ServerPlayer player) {
|
||||
CommandSourceStack cmdExecutor = context.getSource();
|
||||
ServerPlayer executor;
|
||||
public static int ping(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
|
||||
int ping = player.latency;
|
||||
|
||||
try {
|
||||
executor = cmdExecutor.getPlayerOrException();
|
||||
} catch(Exception ignored){
|
||||
cmdExecutor.sendSuccess(LegacyChatFormat.format("{b1}The ping of {} is {b2}{}ms{b1}.", player.getScoreboardName(), ping), false);
|
||||
return ping;
|
||||
}
|
||||
|
||||
PlayerUtil.getFactoryPlayer(executor).sendMessage(
|
||||
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;
|
||||
|
||||
@@ -5,104 +5,61 @@ 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 net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
|
||||
public class PlayCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
|
||||
register(dispatcher, "play");
|
||||
register(dispatcher, "join");
|
||||
|
||||
dispatcher.register(Commands.literal("ffa").executes(PlayCommand::openFFAGui)
|
||||
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
|
||||
.then(Commands.literal("sky").executes(PlayCommand::playSkyFFA))
|
||||
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
|
||||
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA))
|
||||
dispatcher.register(CommandUtils.literal("ffa").executes(PlayCommand::openFFAGui)
|
||||
.then(CommandUtils.literal("kits").executes(context -> playGame(context, "kits ffa")))
|
||||
.then(CommandUtils.literal("pot").executes(context -> playGame(context, "pot ffa")))
|
||||
.then(CommandUtils.literal("sky").executes(context -> playGame(context, "sky ffa")))
|
||||
.then(CommandUtils.literal("uhc").executes(context -> playGame(context, "uhc ffa")))
|
||||
.then(CommandUtils.literal("classic").executes(context -> playGame(context, "classic ffa")))
|
||||
);
|
||||
}
|
||||
|
||||
private static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
|
||||
dispatcher.register(Commands.literal(string).executes(PlayCommand::openGUI)
|
||||
.then(Commands.literal("ffa").executes(PlayCommand::openFFAGui)
|
||||
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
|
||||
.then(Commands.literal("sky").executes(PlayCommand::playSkyFFA))
|
||||
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
|
||||
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA)))
|
||||
.then(Commands.literal("bedwars").executes(PlayCommand::playBedWars))
|
||||
.then(Commands.literal("duels").executes(PlayCommand::playDuels))
|
||||
.then(Commands.literal("skywars").executes(PlayCommand::playSkywars))
|
||||
.then(Commands.literal("sw").executes(PlayCommand::playSkywars))
|
||||
.then(Commands.literal("football").executes(PlayCommand::playFootball))
|
||||
.then(Commands.literal("oitc").executes(PlayCommand::playOITC))
|
||||
.then(Commands.literal("bw").executes(PlayCommand::playBedWars)));
|
||||
private static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
|
||||
dispatcher.register(CommandUtils.literal(string).executes(PlayCommand::openGUI)
|
||||
.then(CommandUtils.literal("ffa").executes(PlayCommand::openFFAGui)
|
||||
.then(CommandUtils.literal("kits").executes(context -> playGame(context, "kits ffa")))
|
||||
.then(CommandUtils.literal("pot").executes(context -> playGame(context, "pot ffa")))
|
||||
.then(CommandUtils.literal("sky").executes(context -> playGame(context, "sky ffa")))
|
||||
.then(CommandUtils.literal("uhc").executes(context -> playGame(context, "uhc ffa")))
|
||||
.then(CommandUtils.literal("classic").executes(context -> playGame(context, "classic ffa")))
|
||||
)
|
||||
.then(CommandUtils.literal("bedwars").executes(context -> playGame(context, "bedwars")))
|
||||
.then(CommandUtils.literal("duels").executes(context -> playGame(context, "duels")))
|
||||
.then(CommandUtils.literal("skywars").executes(context -> playGame(context, "skywars")))
|
||||
.then(CommandUtils.literal("sw").executes(context -> playGame(context, "skywars")))
|
||||
.then(CommandUtils.literal("football").executes(context -> playGame(context, "football")))
|
||||
.then(CommandUtils.literal("oitc").executes(context -> playGame(context, "oitc")))
|
||||
.then(CommandUtils.literal("bw").executes(context -> playGame(context, "bedwars")))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private static int openGUI(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
|
||||
PlayGUI.openMainGUI(context.getSource().getPlayerOrException());
|
||||
private static int openGUI(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
PlayGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int openFFAGui(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
|
||||
PlayGUI.openMainGUI(context.getSource().getPlayerOrException()).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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "uhc ffa", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playSkyFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "sky ffa", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playBedWars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "bedwars", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playDuels(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "duels", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playOITC(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "oitc", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playFootball(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "football", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int playSkywars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
LobbyUtil.sendGame(player, "skywars", true, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,18 +4,17 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.gui.PrefixGUI;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
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<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("prefix").executes(PrefixCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("prefix").executes(PrefixCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer executer = context.getSource().getPlayerOrException();
|
||||
PrefixGUI.openRankGUI(executer);
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
PrefixGUI.openRankGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -4,20 +4,21 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.gui.RanksGUI;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
|
||||
public class RanksCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("buy").executes(RanksCommand::run));
|
||||
dispatcher.register(Commands.literal("store").executes(RanksCommand::run));
|
||||
dispatcher.register(Commands.literal("ranks").executes(RanksCommand::run));
|
||||
dispatcher.register(Commands.literal("role").executes(RanksCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("buy").executes(RanksCommand::run));
|
||||
dispatcher.register(CommandUtils.literal("store").executes(RanksCommand::run));
|
||||
dispatcher.register(CommandUtils.literal("ranks").executes(RanksCommand::run));
|
||||
dispatcher.register(CommandUtils.literal("role").executes(RanksCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
RanksGUI.openMainGUI(context.getSource().getPlayerOrException());
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
RanksGUI.openMainGUI(new NexiaPlayer(context.getSource().getPlayerOrException()).unwrap());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.utilities.player.CoreSavedPlayerData;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.http.DiscordWebhook;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
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.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -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)
|
||||
@@ -41,64 +46,50 @@ public class ReportCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("report")
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> ReportCommand.report(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "reason")))
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("report")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> ReportCommand.report(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "reason")))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static int report(CommandContext<CommandSourceStack> context, ServerPlayer player, String reason) throws CommandSyntaxException {
|
||||
ServerPlayer mcExecutor = context.getSource().getPlayerOrException();
|
||||
Player executor = PlayerUtil.getFactoryPlayer(mcExecutor);
|
||||
public static int report(CommandContext<CommandSourceInfo> context, ServerPlayer player, String reason) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if(PlayerDataManager.get(mcExecutor).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(mcExecutor.equals(player)){
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You cannot report yourself!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
|
||||
|
||||
);
|
||||
if(executor.getUUID().equals(player.getUUID())){
|
||||
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)) PlayerUtil.getFactoryPlayer(staffPlayer).sendMessage(staffReportMessage);
|
||||
for (Player staffPlayer : ServerTime.nexusServer.getPlayers()){
|
||||
if(Permissions.check(((WrappedPlayer) staffPlayer).unwrap(), "nexia.staff.report", 1)) staffPlayer.sendMessage(staffReportMessage);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.Main;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
||||
public class RulesCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("rules").executes(RulesCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("rules").executes(RulesCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
public static int run(CommandContext<CommandSourceInfo> context) {
|
||||
|
||||
/*
|
||||
Apparently this just doesn't work.....
|
||||
@@ -28,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)
|
||||
@@ -40,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)
|
||||
)
|
||||
@@ -52,7 +50,7 @@ public class RulesCommand {
|
||||
|
||||
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
|
||||
|
||||
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
|
||||
context.getSource().sendMessage(message);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,35 +1,30 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
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.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.PlayerMutes;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ShoutCommand {
|
||||
|
||||
private static HashMap<UUID, Long> cooldownTime = new HashMap<>();
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("shout")
|
||||
.requires(context -> {
|
||||
try {
|
||||
return Permissions.check(context.getPlayerOrException(), "nexia.prefix.supporter");
|
||||
} catch (Exception ignored) { }
|
||||
return false;
|
||||
})
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
private static final HashMap<UUID, Long> cooldownTime = new HashMap<>();
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("shout")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.prefix.supporter"))
|
||||
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
|
||||
.executes(context -> ShoutCommand.shout(context, StringArgumentType.getString(context, "message")))
|
||||
)
|
||||
);
|
||||
@@ -45,30 +40,28 @@ public class ShoutCommand {
|
||||
}
|
||||
|
||||
|
||||
public static int shout(CommandContext<CommandSourceStack> context, String message) throws CommandSyntaxException {
|
||||
ServerPlayer executor = context.getSource().getPlayerOrException();
|
||||
public static int shout(CommandContext<CommandSourceInfo> context, String message) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if (PlayerMutes.muted(executor)) return 0;
|
||||
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
if(ShoutCommand.cooldownTime.get(executor.getUUID()) == null) ShoutCommand.cooldownTime.put(executor.getUUID(), System.currentTimeMillis());
|
||||
long longTime = ShoutCommand.cooldownTime.get(executor.getUUID());
|
||||
|
||||
if(longTime - System.currentTimeMillis() > 0) {
|
||||
String time = ShoutCommand.timeToText(longTime - System.currentTimeMillis());
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("You are still on cooldown, you have ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(time).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" left!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
));
|
||||
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(factoryExecutor.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,115 +1,107 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
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;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
|
||||
public class SpectateCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("spectate")
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("spectate")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return (playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY) || (playerData1.gameMode == PlayerGameMode.FFA);
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.executes(SpectateCommand::gameModeSpectate)
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> SpectateCommand.spectate(context, EntityArgument.getPlayer(context, "player")))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> SpectateCommand.spectate(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int gameModeSpectate(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer executor = context.getSource().getPlayerOrException();
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
public static int gameModeSpectate(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
if(PlayerDataManager.get(executor).gameMode != PlayerGameMode.FFA) {
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("If you are in duels then you do /spectate <player>.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
));
|
||||
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, "nexia.prefix.supporter")) {
|
||||
factoryExecutor.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))
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
if(LobbyUtil.checkGameModeBan(factoryExecutor, executor, "ffa")) {
|
||||
if(LobbyUtil.checkGameModeBan(executor, "ffa")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(Math.round(factoryExecutor.getHealth()) < 20) {
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
if(Math.round(executor.getHealth()) < 20) {
|
||||
executor.sendNexiaMessage("You must be fully healed to go into spectator!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
factoryExecutor.setGameMode(Minecraft.GameMode.SPECTATOR);
|
||||
executor.setGameMode(Minecraft.GameMode.SPECTATOR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int spectate(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
ServerPlayer executor = context.getSource().getPlayerOrException();
|
||||
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
|
||||
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(player).gameMode == PlayerGameMode.LOBBY) {
|
||||
GamemodeHandler.spectatePlayer(AccuratePlayer.create(executor), AccuratePlayer.create(player));
|
||||
if(nexiaPlayer.isInGameMode(PlayerGameMode.LOBBY)) {
|
||||
GamemodeHandler.spectatePlayer(nexiaExecutor, nexiaPlayer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!Permissions.check(executor, "nexia.prefix.supporter")) {
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("This feature is only available for").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
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))
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,33 +109,25 @@ 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(factoryExecutor.getHealth()) < 20) {
|
||||
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
if(Math.round(nexiaExecutor.getHealth()) < 20) {
|
||||
nexiaExecutor.sendNexiaMessage("You must be fully healed to go into spectator!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
factoryExecutor.setGameMode(Minecraft.GameMode.SPECTATOR);
|
||||
executor.teleportTo(player.getLevel(), player.getX(), player.getY(), player.getZ(), 0, 0);
|
||||
nexiaExecutor.setGameMode(Minecraft.GameMode.SPECTATOR);
|
||||
nexiaExecutor.teleport(nexiaPlayer.getLocation());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3,25 +3,25 @@ package com.nexia.core.commands.player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
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;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class SprintFixCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("sprintfix").executes(SprintFixCommand::run));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("sprintfix").executes(SprintFixCommand::run));
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
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;
|
||||
|
||||
PlayerUtil.getFactoryPlayer(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,215 +1,194 @@
|
||||
package com.nexia.core.commands.player;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.base.player.SavedPlayerData;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
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.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class StatsCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("stats").executes(StatsCommand::run)
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("gamemode", StringArgumentType.greedyString())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("stats").executes(StatsCommand::run)
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("gamemode", StringArgumentType.greedyString())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((LobbyUtil.statsGameModes), builder)))
|
||||
.executes(context -> StatsCommand.other(context, EntityArgument.getPlayer(context, "player"), 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<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
|
||||
ServerPlayer mcPlayer = context.getSource().getPlayerOrException();
|
||||
PlayerData executerData = com.nexia.core.utilities.player.PlayerDataManager.get(mcPlayer);
|
||||
Player player = PlayerUtil.getFactoryPlayer(mcPlayer);
|
||||
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(executerData.gameMode == PlayerGameMode.FFA){
|
||||
|
||||
if (playerData.gameMode == PlayerGameMode.FFA) {
|
||||
message = ChatFormat.separatorLine("FFA Classic Stats");
|
||||
SavedPlayerData data = PlayerDataManager.get(mcPlayer).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;
|
||||
double rating = Math.round(data.rating * 100);
|
||||
|
||||
if(executerData.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(mcPlayer).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(executerData.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(mcPlayer).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(executerData.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(mcPlayer).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))
|
||||
);
|
||||
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).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(executerData.gameMode == PlayerGameMode.LOBBY){
|
||||
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(mcPlayer).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(executerData.gameMode == PlayerGameMode.BEDWARS){
|
||||
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(mcPlayer).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(executerData.gameMode == PlayerGameMode.OITC){
|
||||
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(mcPlayer).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(executerData.gameMode == PlayerGameMode.FOOTBALL){
|
||||
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(mcPlayer).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(executerData.gameMode == PlayerGameMode.SKYWARS){
|
||||
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(mcPlayer).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));
|
||||
@@ -222,182 +201,163 @@ public class StatsCommand {
|
||||
return Float.parseFloat(new DecimalFormat("#.##").format((float) kills / deaths));
|
||||
}
|
||||
|
||||
public static int other(CommandContext<CommandSourceStack> context, ServerPlayer otherPlayer, String gamemode) throws CommandSyntaxException {
|
||||
ServerPlayer mcPlayer = context.getSource().getPlayerOrException();
|
||||
Player player = PlayerUtil.getFactoryPlayer(mcPlayer);
|
||||
public static int other(CommandContext<CommandSourceInfo> context, ServerPlayer otherPlayer, String gamemode) {
|
||||
CommandSourceInfo source = context.getSource();
|
||||
|
||||
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(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).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;
|
||||
double rating = Math.round(data.rating * 100);
|
||||
|
||||
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).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).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).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;
|
||||
}
|
||||
|
||||
player.sendMessage(message);
|
||||
player.sendMessage(user);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
|
||||
int kills = data.get(Integer.class, "kills");
|
||||
int deaths = data.get(Integer.class, "deaths");
|
||||
int killstreak = data.get(Integer.class, "killstreak");
|
||||
int bestKillstreak = data.get(Integer.class, "bestKillstreak");
|
||||
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(kills).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Deaths: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(deaths).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Deaths: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(deaths, ChatFormat.failColor))
|
||||
);
|
||||
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" KDR: ").color(ChatFormat.brandColor2))
|
||||
source.sendMessage(start
|
||||
.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))
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Killstreak: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(killstreak).color(ChatFormat.goldColor))
|
||||
.append(Component.text("/").color(ChatFormat.arrowColor))
|
||||
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
|
||||
);
|
||||
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(rating).color(ChatFormat.goldColor))
|
||||
);
|
||||
}
|
||||
|
||||
if(gamemode.equalsIgnoreCase("duels")){
|
||||
message = ChatFormat.separatorLine("Duels Stats");
|
||||
com.nexia.minigames.games.duels.util.player.SavedPlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(otherPlayer).savedData;
|
||||
player.sendMessage(message);
|
||||
player.sendMessage(user);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.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).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))
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.BEDWARS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Beds broken: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.bedsBroken).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.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).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
|
||||
player.sendMessage(message);
|
||||
player.sendMessage(user);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.kills).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.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).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.FOOTBALL_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
|
||||
player.sendMessage(message);
|
||||
player.sendMessage(user);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.loss).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Goals: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.goals).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.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).savedData;
|
||||
SavedPlayerData data = PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(otherPlayer.getUUID()).savedData;
|
||||
|
||||
player.sendMessage(message);
|
||||
player.sendMessage(user);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.wins).color(ChatFormat.greenColor))
|
||||
source.sendMessage(message);
|
||||
source.sendMessage(user);
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Wins: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "wins")).color(ChatFormat.greenColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.losses).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Losses: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "losses"), ChatFormat.failColor))
|
||||
);
|
||||
player.sendMessage(start
|
||||
.append(Component.text(" Kills: ").color(ChatFormat.brandColor2))
|
||||
.append(Component.text(data.kills).color(ChatFormat.failColor))
|
||||
source.sendMessage(start
|
||||
.append(Component.text(" Kills: ", ChatFormat.brandColor2))
|
||||
.append(Component.text(data.get(Integer.class, "kills"), ChatFormat.failColor))
|
||||
);
|
||||
}
|
||||
player.sendMessage(ChatFormat.separatorLine(null));
|
||||
source.sendMessage(ChatFormat.separatorLine(null));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3,42 +3,51 @@ package com.nexia.core.commands.player.duels;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
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;
|
||||
|
||||
public class AcceptDuelCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
register(dispatcher, "acceptduel");
|
||||
register(dispatcher, "acceptchallenge");
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
|
||||
dispatcher.register(Commands.literal(string)
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> AcceptDuelCommand.accept(context, EntityArgument.getPlayer(context, "player")))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> AcceptDuelCommand.accept(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static int accept(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
GamemodeHandler.acceptDuel(context.getSource().getPlayerOrException(), player);
|
||||
public static int accept(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.acceptDuel(executor, new NexiaPlayer(player));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -3,41 +3,50 @@ package com.nexia.core.commands.player.duels;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
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;
|
||||
|
||||
public class DeclineDuelCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
register(dispatcher, "declineduel");
|
||||
register(dispatcher, "declinechallenge");
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
|
||||
dispatcher.register(Commands.literal(string)
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> DeclineDuelCommand.decline(context, EntityArgument.getPlayer(context, "player")))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> DeclineDuelCommand.decline(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int decline(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
GamemodeHandler.declineDuel(context.getSource().getPlayerOrException(), player);
|
||||
public static int decline(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.declineDuel(executor, new NexiaPlayer(player));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -4,52 +4,65 @@ 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.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
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 net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
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;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DuelCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
register(dispatcher, "duel");
|
||||
register(dispatcher, "challenge");
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
|
||||
dispatcher.register(Commands.literal(string)
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> DuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player")))
|
||||
.then(Commands.argument("gamemode", StringArgumentType.string())
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
DuelGUI.openDuelGui(player.unwrap(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)));
|
||||
return 1;
|
||||
})
|
||||
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder)))
|
||||
.executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), null))
|
||||
.then(Commands.argument("map", StringArgumentType.string())
|
||||
.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, EntityArgument.getPlayer(context, "player"), 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<CommandSourceStack> context, ServerPlayer player, String gameMode, @Nullable String map) throws CommandSyntaxException {
|
||||
ServerPlayer executer = context.getSource().getPlayerOrException();
|
||||
GamemodeHandler.challengePlayer(executer, player, gameMode, DuelsMap.identifyMap(map));
|
||||
public static int challenge(CommandContext<CommandSourceInfo> context, ServerPlayer player, String gameMode, @Nullable String map) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.challengePlayer(executor, new NexiaPlayer(player), gameMode, DuelsMap.identifyMap(map));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,21 @@ 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.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
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.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -26,20 +28,22 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class KitLayoutCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register((Commands.literal("kitlayout")
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register((CommandUtils.literal("kitlayout")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
})
|
||||
.then(Commands.argument("argument", StringArgumentType.string())
|
||||
.then(CommandUtils.argument("argument", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"save", "edit", "reset"}), builder)))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), ""))
|
||||
.then(Commands.argument("inventory", StringArgumentType.string())
|
||||
.then(CommandUtils.argument("inventory", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(InventoryUtil.getListOfInventories("duels"), builder)))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), StringArgumentType.getString(context, "inventory")))
|
||||
)
|
||||
@@ -48,25 +52,24 @@ public class KitLayoutCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceStack> context, @NotNull String argument, @NotNull String inventory) throws CommandSyntaxException {
|
||||
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
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")) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Invalid gamemode!"));
|
||||
player.sendMessage(Component.text("Invalid gamemode!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(argument.equalsIgnoreCase("save")) {
|
||||
|
||||
if(com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("You aren't editing a layout!"));
|
||||
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.getStringUUID() + File.separator + "layout";
|
||||
String path = InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID() + File.separator + "layout";
|
||||
Path playerPath = Path.of(path);
|
||||
|
||||
File playerDir = playerPath.toFile();
|
||||
@@ -74,7 +77,7 @@ public class KitLayoutCommand {
|
||||
if(!playerDir.exists()) Files.createDirectory(playerPath);
|
||||
} catch (IOException ignored) { }
|
||||
|
||||
SavableInventory savableInventory = new SavableInventory(player.inventory);
|
||||
SavableInventory savableInventory = new SavableInventory(player.unwrap().inventory);
|
||||
String stringInventory = savableInventory.toSave();
|
||||
|
||||
try {
|
||||
@@ -83,43 +86,43 @@ public class KitLayoutCommand {
|
||||
fileWriter.write(stringInventory);
|
||||
fileWriter.close();
|
||||
} catch (Exception var6) {
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.sendMessage(LegacyChatFormat.format("{f}Failed to save your inventory as '{}'. Please try again or contact a developer.", inventory), Util.NIL_UUID);
|
||||
player.runCommand("/hub", 0, false);
|
||||
player.sendMessage(Component.text(String.format("Failed to save your inventory as '%s'. Please try again or contact a developer.", inventory), ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully saved your inventory as '{}'.", inventory), false);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.sendMessage(Component.text(String.format("Successfully saved your inventory as '%s'.", inventory), ChatFormat.brandColor1));
|
||||
player.runCommand("/hub", 0, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argument.equalsIgnoreCase("edit")) {
|
||||
|
||||
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("You are still editing a layout! Save it or run /hub!"));
|
||||
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;
|
||||
}
|
||||
|
||||
if(argument.equalsIgnoreCase("reset")) {
|
||||
|
||||
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID() + File.separator + "layout" + File.separator + inventory + ".json");
|
||||
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID() + File.separator + "layout" + File.separator + inventory + ".json");
|
||||
if(playerFile.exists() && playerFile.delete()) {
|
||||
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully reset saved layout '{}'!", inventory), false);
|
||||
player.sendMessage(Component.text(String.format("Successfully reset saved layout '%s'!", inventory), ChatFormat.brandColor1));
|
||||
} else {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Saved Layout does not exist!"));
|
||||
player.sendMessage(Component.text("Saved Layout does not exist!", ChatFormat.failColor));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Invalid argument!"));
|
||||
player.sendMessage(Component.text("Invalid argument!", ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -3,82 +3,90 @@ package com.nexia.core.commands.player.duels;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
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.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
|
||||
public class PartyCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
register(dispatcher, "party");
|
||||
register(dispatcher, "duelsteam");
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
|
||||
dispatcher.register(Commands.literal(string)
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.then(Commands.literal("invite")
|
||||
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.invitePlayer(context, EntityArgument.getPlayer(context, "player"))))
|
||||
.then(CommandUtils.literal("invite")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.invitePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.then(Commands.literal("promote")
|
||||
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.promotePlayer(context, EntityArgument.getPlayer(context, "player"))))
|
||||
.then(CommandUtils.literal("promote")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.promotePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.then(Commands.literal("join")
|
||||
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.joinTeam(context, EntityArgument.getPlayer(context, "player"))))
|
||||
.then(CommandUtils.literal("join")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.joinTeam(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.then(Commands.literal("kick")
|
||||
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.kickPlayer(context, EntityArgument.getPlayer(context, "player"))))
|
||||
.then(CommandUtils.literal("kick")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.kickPlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.then(Commands.literal("decline")
|
||||
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.declinePlayer(context, EntityArgument.getPlayer(context, "player"))))
|
||||
.then(CommandUtils.literal("decline")
|
||||
.then(CommandUtils.argument("player", EntityArgument.player()).executes(context -> PartyCommand.declinePlayer(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)))))
|
||||
)
|
||||
.then(Commands.literal("disband").executes(PartyCommand::disbandTeam))
|
||||
.then(Commands.literal("create").executes(PartyCommand::createTeam))
|
||||
.then(Commands.literal("list").executes(PartyCommand::listTeam))
|
||||
.then(Commands.literal("leave").executes(PartyCommand::leaveTeam))
|
||||
.then(CommandUtils.literal("disband").executes(PartyCommand::disbandTeam))
|
||||
.then(CommandUtils.literal("create").executes(PartyCommand::createTeam))
|
||||
.then(CommandUtils.literal("list").executes(PartyCommand::listTeam))
|
||||
.then(CommandUtils.literal("leave").executes(PartyCommand::leaveTeam))
|
||||
);
|
||||
}
|
||||
|
||||
public static int invitePlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
ServerPlayer invitor = context.getSource().getPlayerOrException();
|
||||
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);
|
||||
}
|
||||
data.duelOptions.duelsTeam.invitePlayer(invitor, player);
|
||||
data.duelOptions.duelsTeam.invitePlayer(invitor, new NexiaPlayer(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int joinTeam(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.joinTeam(context.getSource().getPlayerOrException());
|
||||
public static int joinTeam(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player.getUUID())).duelOptions.duelsTeam.joinTeam(executor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int listTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer executor = context.getSource().getPlayerOrException();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -86,68 +94,72 @@ public class PartyCommand {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int declinePlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.declineTeam(context.getSource().getPlayerOrException());
|
||||
public static int declinePlayer(CommandContext<CommandSourceInfo> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player.getUUID())).duelOptions.duelsTeam.declineTeam(executor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int createTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
DuelsTeam.createTeam(context.getSource().getPlayerOrException(), true);
|
||||
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<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
ServerPlayer executor = context.getSource().getPlayerOrException();
|
||||
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) {
|
||||
PlayerUtil.getFactoryPlayer(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;
|
||||
}
|
||||
|
||||
data.duelOptions.duelsTeam.replaceLeader(AccuratePlayer.create(executor), AccuratePlayer.create(player), true);
|
||||
data.duelOptions.duelsTeam.replaceLeader(executor, new NexiaPlayer(player), true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int kickPlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
|
||||
ServerPlayer executor = context.getSource().getPlayerOrException();
|
||||
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) {
|
||||
PlayerUtil.getFactoryPlayer(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;
|
||||
}
|
||||
|
||||
data.duelOptions.duelsTeam.kickPlayer(executor, player);
|
||||
data.duelOptions.duelsTeam.kickPlayer(executor, new NexiaPlayer(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int disbandTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
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) {
|
||||
PlayerUtil.getFactoryPlayer(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(AccuratePlayer.create(player), true);
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).duelOptions.duelsTeam.disbandTeam(player, true);
|
||||
return 1;
|
||||
}
|
||||
public static int leaveTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
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) {
|
||||
PlayerUtil.getFactoryPlayer(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(AccuratePlayer.create(player), true);
|
||||
((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player)).duelOptions.duelsTeam.leaveTeam(player, true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -4,38 +4,49 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.gui.duels.QueueGUI;
|
||||
import com.nexia.core.utilities.player.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 net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
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.server.level.ServerPlayer;
|
||||
|
||||
public class QueueCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("queue")
|
||||
.requires(commandSourceStack -> {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("queue")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
})
|
||||
.executes(context -> QueueGUI.openQueueGUI(context.getSource().getPlayerOrException()))
|
||||
.then(Commands.argument("gamemode", StringArgumentType.string())
|
||||
.executes(context -> {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
QueueGUI.openQueueGUI(player.unwrap());
|
||||
return 1;
|
||||
})
|
||||
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder)))
|
||||
.executes(context -> QueueCommand.queue(context, StringArgumentType.getString(context, "gamemode"))))
|
||||
);
|
||||
}
|
||||
|
||||
public static int queue(CommandContext<CommandSourceStack> context, String gameMode) throws CommandSyntaxException {
|
||||
ServerPlayer executer = context.getSource().getPlayerOrException();
|
||||
GamemodeHandler.joinQueue(executer, gameMode, false);
|
||||
public static int queue(CommandContext<CommandSourceInfo> context, String gameMode) throws CommandSyntaxException {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.joinQueue(player, gameMode, false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,68 @@
|
||||
package com.nexia.core.commands.player.duels.custom;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.gui.duels.CustomDuelGUI;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.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;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CustomDuelCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
register(dispatcher, "customduel");
|
||||
register(dispatcher, "customchallenge");
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
|
||||
dispatcher.register(Commands.literal(string)
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher, String string) {
|
||||
dispatcher.register(CommandUtils.literal(string)
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> CustomDuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player")))
|
||||
.then(Commands.argument("kit", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((InventoryUtil.getListOfInventories("duels/custom/" + context.getSource().getPlayerOrException().getStringUUID())), builder)))
|
||||
.executes(context -> CustomDuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "kit"), null))
|
||||
.then(Commands.argument("map", StringArgumentType.string())
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> {
|
||||
NexiaPlayer player = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
CustomDuelGUI.openDuelGui(player.unwrap(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)));
|
||||
return 1;
|
||||
})
|
||||
.then(CommandUtils.argument("kit", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((InventoryUtil.getListOfInventories("duels/custom/" + context.getSource().getPlayerOrException().getUUID())), builder)))
|
||||
.executes(context -> CustomDuelCommand.challenge(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), true)), StringArgumentType.getString(context, "kit"), null))
|
||||
.then(CommandUtils.argument("map", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
|
||||
.executes(context -> CustomDuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), 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<CommandSourceStack> context, ServerPlayer player, String kit, @Nullable String map) throws CommandSyntaxException {
|
||||
ServerPlayer executor = context.getSource().getPlayerOrException();
|
||||
GamemodeHandler.customChallengePlayer(executor, player, kit, DuelsMap.identifyMap(map));
|
||||
public static int challenge(CommandContext<CommandSourceInfo> context, ServerPlayer player, String kit, @Nullable String map) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
|
||||
GamemodeHandler.customChallengePlayer(executor, new NexiaPlayer(player), kit, DuelsMap.identifyMap(map));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,23 @@ 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.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
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 net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
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 net.minecraft.server.level.ServerPlayer;
|
||||
import net.notcoded.codelib.players.AccuratePlayer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -37,20 +37,22 @@ public class KitEditorCommand {
|
||||
|
||||
private static final List<String> slots = Arrays.asList("1", "2", "3", "smp", "vanilla");
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register((Commands.literal("kiteditor")
|
||||
.requires(commandSourceStack -> {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register((CommandUtils.literal("kiteditor")
|
||||
.requires(commandSourceInfo -> {
|
||||
try {
|
||||
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
|
||||
NexiaPlayer player = new NexiaPlayer(commandSourceInfo.getPlayerOrException());
|
||||
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
CorePlayerData playerData1 = (CorePlayerData) PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player);
|
||||
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
})
|
||||
.then(Commands.argument("argument", StringArgumentType.string())
|
||||
.then(CommandUtils.argument("argument", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"save", "edit", "delete"}), builder)))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), ""))
|
||||
.then(Commands.argument("slot", StringArgumentType.string())
|
||||
.then(CommandUtils.argument("slot", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(slots, builder)))
|
||||
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), StringArgumentType.getString(context, "slot")))
|
||||
)
|
||||
@@ -59,11 +61,11 @@ public class KitEditorCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceStack> context, @NotNull String argument, String slot) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
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")) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Invalid slot!"));
|
||||
player.sendMessage(Component.text("Invalid slot!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,18 +75,18 @@ 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) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("You aren't editing a kit!"));
|
||||
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);
|
||||
String gearstring = PlayerFunctions.getPlayerGearString(player.unwrap());
|
||||
|
||||
Path playerPath = Path.of(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID());
|
||||
Path playerPath = Path.of(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID());
|
||||
File playerDir = playerPath.toFile();
|
||||
try {
|
||||
if(!playerDir.exists()) Files.createDirectory(playerPath);
|
||||
@@ -93,45 +95,43 @@ public class KitEditorCommand {
|
||||
KitRoom kitRoom = playerData.kitRoom;
|
||||
|
||||
if (StringFunctions.sequenceCount(gearstring, "\n") < 40 || !playerDir.exists()) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while generating the save file content for your inventory."));
|
||||
|
||||
player.sendMessage(Component.text("Something went wrong while generating the save file content for your inventory.", ChatFormat.failColor));
|
||||
kitRoom.leave();
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.runCommand("/hub", 0, false);
|
||||
return 0;
|
||||
} else if (!InventoryUtil.writeGearStringToFile("duels/custom/" + player.getStringUUID(), inventory, gearstring)) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while saving the content of your inventory as '{}'.", inventory));
|
||||
} else if (!InventoryUtil.writeGearStringToFile("duels/custom/" + player.getUUID(), inventory, gearstring)) {
|
||||
player.sendMessage(Component.text(String.format("Something went wrong while saving the content of your inventory as '%s'.", inventory), ChatFormat.failColor));
|
||||
|
||||
kitRoom.leave();
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.runCommand("/hub", 0, false);
|
||||
return 0;
|
||||
} else {
|
||||
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully saved your inventory as '{}'.", inventory),false);
|
||||
player.sendMessage(Component.text(String.format("Successfully saved your inventory as '%s'.", inventory), ChatFormat.failColor));
|
||||
|
||||
kitRoom.leave();
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.runCommand("/hub", 0, false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (argument.equalsIgnoreCase("edit")) {
|
||||
|
||||
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingKit.isEmpty()) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("You are still editing a kit! Save it or run /hub!"));
|
||||
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);
|
||||
AccuratePlayer accuratePlayer = AccuratePlayer.create(player);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(player);
|
||||
|
||||
|
||||
switch (slot) {
|
||||
case "1", "2", "3" -> kitRoom = new CustomKitRoom(accuratePlayer);
|
||||
case "vanilla" -> kitRoom = new VanillaKitRoom(accuratePlayer);
|
||||
case "smp" -> kitRoom = new SmpKitRoom(accuratePlayer);
|
||||
case "1", "2", "3" -> kitRoom = new CustomKitRoom(player);
|
||||
case "vanilla" -> kitRoom = new VanillaKitRoom(player);
|
||||
case "smp" -> kitRoom = new SmpKitRoom(player);
|
||||
default -> {
|
||||
player.sendMessage(LegacyChatFormat.formatFail("Something went wrong whilst creating your kit room."), Util.NIL_UUID);
|
||||
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
|
||||
player.sendMessage(Component.text("Something went wrong whilst creating your kit room.", ChatFormat.failColor));
|
||||
player.runCommand("/hub", 0, false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -141,9 +141,9 @@ public class KitEditorCommand {
|
||||
|
||||
if(kitRoom.generate()) kitRoom.teleport();
|
||||
|
||||
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID(), inventory + ".txt");
|
||||
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID(), inventory + ".txt");
|
||||
if(playerFile.exists()) {
|
||||
InventoryUtil.loadInventory(player, "duels/custom/" + player.getStringUUID(), inventory.toLowerCase());
|
||||
InventoryUtil.loadInventory(player, "duels/custom/" + player.getUUID(), inventory.toLowerCase());
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -151,17 +151,17 @@ public class KitEditorCommand {
|
||||
|
||||
if(argument.equalsIgnoreCase("delete")) {
|
||||
|
||||
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID(), inventory + ".txt");
|
||||
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getUUID(), inventory + ".txt");
|
||||
if(playerFile.exists() && playerFile.delete()) {
|
||||
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully deleted slot '{}'!", slot), false);
|
||||
player.sendMessage(Component.text(String.format("Successfully deleted slot '%s’!", slot), ChatFormat.brandColor1));
|
||||
} else {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("The saved kit for that slot ({}) does not exist!", slot));
|
||||
player.sendMessage(Component.text(String.format("The saved kit for that slot (%s) does not exist!", slot), ChatFormat.failColor));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Invalid argument!"));
|
||||
player.sendMessage(Component.text("Invalid argument!", ChatFormat.failColor));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -2,55 +2,54 @@ package com.nexia.core.commands.player.ffa;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.gui.ffa.KitGUI;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
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.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class KitCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("kit")
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("kit")
|
||||
.executes(context -> {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
if(!FfaKitsUtil.canGoToSpawn(player)) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change kits!").color(ChatFormat.failColor));
|
||||
return 1;
|
||||
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;
|
||||
}
|
||||
LobbyUtil.sendGame(player, "kits ffa", false, true);
|
||||
run(context);
|
||||
run(player.unwrap());
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("inventory", StringArgumentType.greedyString())
|
||||
.then(CommandUtils.argument("inventory", StringArgumentType.greedyString())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(FfaKit.stringFfaKits, builder)))
|
||||
.executes(context -> {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
if(!FfaKitsUtil.canGoToSpawn(player)) {
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change kits!").color(ChatFormat.failColor));
|
||||
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;
|
||||
}
|
||||
|
||||
LobbyUtil.sendGame(player, "kits ffa", false, true);
|
||||
selectedMap(context);
|
||||
selectedMap(player.unwrap(), StringArgumentType.getString(context, "inventory"));
|
||||
return 1;
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static void run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
KitGUI.openKitGUI(context.getSource().getPlayerOrException());
|
||||
public static void run(ServerPlayer player) throws CommandSyntaxException {
|
||||
KitGUI.openKitGUI(player);
|
||||
}
|
||||
|
||||
public static void selectedMap(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
KitGUI.giveKit(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "inventory"));
|
||||
public static void selectedMap(ServerPlayer player, String inventory) {
|
||||
KitGUI.giveKit(player, inventory);
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,15 @@ 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.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import 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.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.UserBanList;
|
||||
import net.minecraft.server.players.UserBanListEntry;
|
||||
@@ -21,62 +20,54 @@ import net.minecraft.server.players.UserBanListEntry;
|
||||
import java.util.Collection;
|
||||
|
||||
public class BanCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("ban")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
|
||||
.then(Commands.argument("player", GameProfileArgument.gameProfile())
|
||||
.executes(context -> BanCommand.ban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player"), "No reason specified."))
|
||||
.then(Commands.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> BanCommand.ban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player"), StringArgumentType.getString(context, "reason"))))
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("ban")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
|
||||
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
|
||||
.executes(context -> BanCommand.ban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)), "No reason specified."))
|
||||
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> BanCommand.ban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "reason"))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int ban(CommandSourceStack context, Collection<GameProfile> collection, String reason) {
|
||||
public static int ban(CommandSourceInfo context, Collection<GameProfile> collection, String reason) {
|
||||
UserBanList userBanList = ServerTime.minecraftServer.getPlayerList().getBans();
|
||||
int i = 0;
|
||||
|
||||
ServerPlayer player = null;
|
||||
|
||||
try {
|
||||
player = context.getPlayerOrException();
|
||||
} catch (Exception ignored){ }
|
||||
|
||||
for (GameProfile gameProfile : collection) {
|
||||
if (!userBanList.isBanned(gameProfile)) {
|
||||
ServerPlayer serverPlayer = ServerTime.minecraftServer.getPlayerList().getPlayer(gameProfile.getId());
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
|
||||
|
||||
UserBanListEntry userBanListEntry = new UserBanListEntry(gameProfile, null, context.getTextName(), null, reason);
|
||||
UserBanListEntry userBanListEntry = new UserBanListEntry(gameProfile, null, null, null, reason);
|
||||
userBanList.add(userBanListEntry);
|
||||
++i;
|
||||
if(player != null){
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have banned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(ComponentUtils.getDisplayName(gameProfile).getString()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(reason).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
context.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have banned ", ChatFormat.normalColor))
|
||||
.append(Component.text(ComponentUtils.getDisplayName(gameProfile).getString(), ChatFormat.brandColor2))
|
||||
.append(Component.text(" for ", ChatFormat.normalColor))
|
||||
.append(Component.text(reason, ChatFormat.brandColor2))
|
||||
);
|
||||
|
||||
} else {
|
||||
context.sendSuccess(LegacyChatFormat.format("{b1}You have banned {b2}{} {b1}for {b2}{}", ComponentUtils.getDisplayName(gameProfile).getString(), reason), true);
|
||||
}
|
||||
|
||||
if (serverPlayer != null) {
|
||||
serverPlayer.connection.disconnect(new TextComponent("§c§lYou have been banned.\n§7Reason: §d" + reason + "\n§7You can appeal your ban at §d" + com.nexia.discord.Main.config.discordLink));
|
||||
nexiaPlayer.disconnect(Component.text("You have been banned.", ChatFormat.failColor)
|
||||
.append(Component.text("\nReason: ", ChatFormat.systemColor))
|
||||
.append(Component.text(reason, ChatFormat.brandColor2))
|
||||
.append(Component.text("\nYou can appeal your ban at ", ChatFormat.systemColor))
|
||||
.append(Component.text(NexiaDiscord.config.discordLink, ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
if(player != null){
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(
|
||||
ChatFormat.nexiaMessage.append(Component.text("That player is already banned.").color(ChatFormat.failColor))
|
||||
);
|
||||
} else {
|
||||
context.sendFailure(LegacyChatFormat.formatFail("That player is already banned."));
|
||||
}
|
||||
|
||||
context.sendMessage(
|
||||
ChatFormat.nexiaMessage.append(Component.text("That player is already banned.", ChatFormat.failColor))
|
||||
);
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -18,26 +19,27 @@ public class DetectCommand {
|
||||
|
||||
public static final boolean enabled = false;
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
if(!enabled) return;
|
||||
dispatcher.register(Commands.literal("detect")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.detect", 4))
|
||||
dispatcher.register(CommandUtils.literal("detect")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.dev.detect", 4))
|
||||
.executes(DetectCommand::run)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
if(!enabled) return 0;
|
||||
detect(context.getSource().getPlayerOrException());
|
||||
|
||||
detect(new NexiaPlayer(context.getSource().getPlayerOrException()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static void detect(ServerPlayer attacker) {
|
||||
public static void detect(NexiaPlayer attacker) {
|
||||
|
||||
String botName = ".bot";
|
||||
|
||||
List<Player> playersNearby = attacker.level.getEntitiesOfClass(ServerPlayer.class, attacker.getBoundingBox().inflate(12, 0.25, 12));
|
||||
Vec3 eyePos = attacker.getEyePosition(1);
|
||||
List<Player> playersNearby = attacker.unwrap().level.getEntitiesOfClass(ServerPlayer.class, attacker.unwrap().getBoundingBox().inflate(12, 0.25, 12));
|
||||
Vec3 eyePos = attacker.unwrap().getEyePosition(1);
|
||||
AtomicReference<Vec3> nearestPosition = new AtomicReference<>();
|
||||
playersNearby.forEach(player -> {
|
||||
Vec3 currentPos = player.getBoundingBox().getNearestPointTo(eyePos);
|
||||
@@ -46,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,61 +1,46 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
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;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
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.PlayerUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class GamemodeBanCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("gamemodeban")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("gamemode", StringArgumentType.string())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("gamemodeban")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((PlayerGameMode.stringPlayerGameModes), builder)))
|
||||
.then(Commands.argument("duration", StringArgumentType.word())
|
||||
.then(Commands.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> GamemodeBanCommand.ban(context.getSource(), EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
|
||||
.then(CommandUtils.argument("duration", StringArgumentType.word())
|
||||
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> GamemodeBanCommand.ban(context.getSource(), context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public static int ban(CommandSourceStack sender, ServerPlayer player, String stringGameMode, String reason, String durationArg) {
|
||||
ServerPlayer mcExecutor = null;
|
||||
Player executor = null;
|
||||
|
||||
try {
|
||||
mcExecutor = sender.getPlayerOrException();
|
||||
} catch (Exception ignored){ }
|
||||
|
||||
if(mcExecutor != null) {
|
||||
executor = PlayerUtil.getFactoryPlayer(mcExecutor);
|
||||
}
|
||||
public static int ban(CommandSourceInfo sender, ServerPlayer player, String stringGameMode, String reason, String durationArg) {
|
||||
|
||||
PlayerGameMode gameMode = PlayerGameMode.identifyGamemode(stringGameMode);
|
||||
if(gameMode == null) {
|
||||
|
||||
if(executor != null) {
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
sender.sendFailure(LegacyChatFormat.format("{f}Invalid gamemode!"));
|
||||
}
|
||||
sender.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid gamemode!", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -64,19 +49,15 @@ public class GamemodeBanCommand {
|
||||
try {
|
||||
durationInSeconds = BanHandler.parseTimeArg(durationArg);
|
||||
} catch (Exception e) {
|
||||
if (executor != null) {
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
sender.sendFailure(LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"));
|
||||
}
|
||||
sender.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
GamemodeBanHandler.tryGamemodeBan(sender, player, gameMode, durationInSeconds, reason);
|
||||
GamemodeBanHandler.tryGamemodeBan(sender, new NexiaPlayer(player), gameMode, durationInSeconds, reason);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,69 +1,53 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class HealCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("heal").executes(HealCommand::run)
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.heal", 1))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.executes(context -> HealCommand.heal(context, EntityArgument.getPlayer(context, "player")))
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("heal").executes(HealCommand::run)
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.heal", 1))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> HealCommand.heal(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer executer = context.getSource().getPlayerOrException();
|
||||
executer.heal(executer.getMaxHealth());
|
||||
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
NexiaPlayer executor = new NexiaPlayer(context.getSource().getPlayerOrException());
|
||||
executor.setHealth(executor.getMaxHealth());
|
||||
|
||||
|
||||
PlayerUtil.getFactoryPlayer(executer).sendMessage(
|
||||
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;
|
||||
}
|
||||
|
||||
public static int heal(CommandContext<CommandSourceStack> context, ServerPlayer otherPlayer) {
|
||||
CommandSourceStack executer = context.getSource();
|
||||
public static int heal(CommandContext<CommandSourceInfo> context, ServerPlayer otherPlayer) {
|
||||
otherPlayer.heal(otherPlayer.getMaxHealth());
|
||||
|
||||
ServerPlayer player = null;
|
||||
try {
|
||||
player = executer.getPlayerOrException();
|
||||
|
||||
} catch(Exception ignored) { }
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have healed ", ChatFormat.normalColor))
|
||||
.append(Component.text(otherPlayer.getScoreboardName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
|
||||
if(player != null){
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have healed ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executer.sendSuccess(LegacyChatFormat.format("{b1}You have healed {b2}{}{b1}.", otherPlayer.getScoreboardName()), false);
|
||||
}
|
||||
|
||||
|
||||
PlayerUtil.getFactoryPlayer(otherPlayer).sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have been healed.").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
|
||||
new NexiaPlayer(otherPlayer).sendNexiaMessage("You have been healed.");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,42 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ListInventoriesCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register((Commands.literal("listinventories")
|
||||
.requires(commandSourceStack -> {
|
||||
try {
|
||||
return Permissions.check(commandSourceStack, "nexia.inventory.list", 4);
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register((CommandUtils.literal("listinventories")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.inventory.list", 4))
|
||||
.then(CommandUtils.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
|
||||
.executes(ListInventoriesCommand::run)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceStack> context){
|
||||
private static int run(CommandContext<CommandSourceInfo> context){
|
||||
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
if(type.trim().isEmpty()) {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Empty type!"));
|
||||
context.getSource().sendMessage(Component.text("Empty type!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Saved inventories: {b2}{}{b1}.", InventoryUtil.getListOfInventoriesString(type)), false);
|
||||
context.getSource().sendMessage(Component.text("Saved Inventories: ", ChatFormat.normalColor)
|
||||
.append(Component.text(InventoryUtil.getListOfInventoriesString(type), ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,102 +1,81 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
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.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.io.File;
|
||||
|
||||
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
|
||||
import static net.minecraft.server.commands.LocateBiomeCommand.ERROR_INVALID_BIOME;
|
||||
|
||||
public class MapCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register((Commands.literal("map")
|
||||
.requires(commandSourceStack -> {
|
||||
try {
|
||||
return Permissions.check(commandSourceStack, "nexia.staff.map", 2);
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register((CommandUtils.literal("map")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.map", 2))
|
||||
.then(CommandUtils.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"delete", "create", "tp"}), builder)))
|
||||
.then(Commands.argument("map", StringArgumentType.greedyString())
|
||||
.executes(MapCommand::run)
|
||||
.then(CommandUtils.argument("map", ResourceLocationArgument.id())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((WorldUtil.getAllWorldsId()), builder)))
|
||||
.executes((context -> run(context, StringArgumentType.getString(context, "type"), context.getArgument("map", ResourceLocation.class), Biomes.THE_VOID)))
|
||||
.then(CommandUtils.argument("biome", ResourceLocationArgument.id())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggestResource((ServerTime.minecraftServer.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).keySet()), builder)))
|
||||
.executes((context -> run(context, StringArgumentType.getString(context, "type"), context.getArgument("map", ResourceLocation.class), context.getArgument("biome", ResourceLocation.class))))
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceStack> context) {
|
||||
ServerPlayer mcPlayer = null;
|
||||
Player player = null;
|
||||
private static int run(CommandContext<CommandSourceInfo> context, String type, ResourceLocation map, ResourceLocation biomeLocation) throws CommandSyntaxException {
|
||||
// check if biome is valid
|
||||
ServerTime.minecraftServer.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOptional(biomeLocation).orElseThrow(() -> ERROR_INVALID_BIOME.create(biomeLocation));
|
||||
|
||||
try {
|
||||
mcPlayer = context.getSource().getPlayerOrException();
|
||||
player = PlayerUtil.getFactoryPlayer(mcPlayer);
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
String map = StringArgumentType.getString(context, "map");
|
||||
|
||||
if(map.trim().isEmpty() || type.trim().isEmpty()) {
|
||||
if(player != null) {
|
||||
player.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid name!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
}
|
||||
return run(context, type, map, ResourceKey.create(Registry.BIOME_REGISTRY, biomeLocation));
|
||||
}
|
||||
|
||||
private static int run(CommandContext<CommandSourceInfo> context, String type, ResourceLocation map, @NotNull ResourceKey<Biome> biome) {
|
||||
NexiaPlayer player = null;
|
||||
if(context.getSource().getExecutingEntity() instanceof Player nexusPlayer) {
|
||||
player = new NexiaPlayer(nexusPlayer);
|
||||
}
|
||||
|
||||
if(map == null || map.toString().trim().isEmpty() || type.trim().isEmpty()) {
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid name!", ChatFormat.failColor))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
String[] mapname = map.split(":");
|
||||
|
||||
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(Biomes.THE_VOID))
|
||||
.setDifficulty(Difficulty.HARD)
|
||||
.setGameRule(GameRules.RULE_KEEPINVENTORY, false)
|
||||
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
|
||||
.setGameRule(GameRules.RULE_WEATHER_CYCLE, false)
|
||||
.setGameRule(GameRules.RULE_DAYLIGHT, false)
|
||||
.setGameRule(GameRules.RULE_DO_IMMEDIATE_RESPAWN, false)
|
||||
.setGameRule(GameRules.RULE_DOMOBSPAWNING, false)
|
||||
.setGameRule(GameRules.RULE_SHOWDEATHMESSAGES, false)
|
||||
.setGameRule(GameRules.RULE_SPAWN_RADIUS, 0))).asWorld();
|
||||
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, map).location(), (WorldUtil.defaultWorldConfig.setGenerator(WorldUtil.getChunkGenerator(biome)))).asWorld();
|
||||
|
||||
if (mcPlayer != null && player != null) {
|
||||
mcPlayer.teleportTo(level, 0, 80, 0, 0, 0);
|
||||
if (player != null) {
|
||||
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.toString(), ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,31 +84,29 @@ public class MapCommand {
|
||||
}
|
||||
|
||||
if (type.equalsIgnoreCase("delete")) {
|
||||
ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), null).delete();
|
||||
ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, map).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.toString(), ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
FileUtils.forceDeleteOnExit(new File("/world/dimensions/" + mapname[0], mapname[1]));
|
||||
FileUtils.forceDeleteOnExit(new File("/world/dimensions/" + map.getNamespace(), map.getPath()));
|
||||
} catch (Exception ignored) { }
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("tp")) {
|
||||
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), null).asWorld();
|
||||
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, map).location(), null).asWorld();
|
||||
|
||||
if(mcPlayer != null && player != null) {
|
||||
mcPlayer.teleportTo(level, 0, 80, 0, 0, 0);
|
||||
if(player != null) {
|
||||
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.toString(), ChatFormat.brandColor2))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.chat.PlayerMutes;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MuteCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("mute")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.mute", 1))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("duration", StringArgumentType.word())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("mute")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.mute", 1))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("duration", StringArgumentType.word())
|
||||
.executes(context -> MuteCommand.mute(context, StringArgumentType.getString(context, "duration"), "No reason specified."))
|
||||
.then(Commands.argument("reason", StringArgumentType.greedyString())
|
||||
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> MuteCommand.mute(context,
|
||||
StringArgumentType.getString(context, "duration"),
|
||||
StringArgumentType.getString(context, "reason"))
|
||||
@@ -37,20 +36,20 @@ public class MuteCommand {
|
||||
);
|
||||
}
|
||||
|
||||
public static int mute(CommandContext<CommandSourceStack> context, String durationArg, String reason) throws CommandSyntaxException {
|
||||
public static int mute(CommandContext<CommandSourceInfo> context, String durationArg, String reason) throws CommandSyntaxException {
|
||||
|
||||
CommandSourceStack sender = context.getSource();
|
||||
ServerPlayer muted = EntityArgument.getPlayer(context, "player");
|
||||
CommandSourceInfo sender = context.getSource();
|
||||
ServerPlayer muted = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
|
||||
int durationInSeconds;
|
||||
try {
|
||||
durationInSeconds = parseTimeArg(durationArg);
|
||||
} catch (Exception e) {
|
||||
|
||||
PlayerUtil.safeSendMessage(sender, LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"),
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)),false);
|
||||
context.getSource().sendMessage(ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,82 +1,57 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RankCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
|
||||
ArrayList<String> arrayListRank = new ArrayList<>();
|
||||
NexiaRank.ranks.forEach(rank -> arrayListRank.add(rank.id));
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
|
||||
dispatcher.register(Commands.literal("rank")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.rank"))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("rank", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((arrayListRank), builder)))
|
||||
.executes(context -> RankCommand.give(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "rank")))))
|
||||
ArrayList<String> ranks = new ArrayList<>();
|
||||
NexiaRank.ranks.forEach(rank -> ranks.add(rank.id));
|
||||
|
||||
dispatcher.register(CommandUtils.literal("rank")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.rank"))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("rank", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ranks), builder)))
|
||||
.executes(context -> RankCommand.give(context, context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "rank")))))
|
||||
);
|
||||
}
|
||||
|
||||
public static int give(CommandContext<CommandSourceStack> context, ServerPlayer player, String rank) {
|
||||
CommandSourceStack executor = context.getSource();
|
||||
Player factoryExecutor = null;
|
||||
Player otherFactoryPlayer = PlayerUtil.getFactoryPlayer(player);
|
||||
|
||||
try {
|
||||
factoryExecutor = PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException());
|
||||
} catch(Exception ignored) { }
|
||||
public static int give(CommandContext<CommandSourceInfo> context, ServerPlayer player, String rank) {
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(player);
|
||||
|
||||
NexiaRank nexiaRank = NexiaRank.identifyRank(rank);
|
||||
if(nexiaRank == null) {
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
|
||||
}
|
||||
if (nexiaRank == null) {
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid rank!", ChatFormat.normalColor))
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have set the rank of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherFactoryPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" to ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the rank of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherFactoryPlayer.getRawName(), nexiaRank.name), false);
|
||||
}
|
||||
|
||||
|
||||
otherFactoryPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Your rank has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
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, player);
|
||||
NexiaRank.setRank(nexiaRank, nexiaPlayer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,122 +1,92 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
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.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StaffPrefixCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
|
||||
ArrayList<String> ranks = new ArrayList<>();
|
||||
NexiaRank.ranks.forEach(rank -> ranks.add(rank.id));
|
||||
|
||||
dispatcher.register(Commands.literal("staffprefix")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.prefix"))
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
dispatcher.register(CommandUtils.literal("staffprefix")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.prefix"))
|
||||
.then(CommandUtils.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"set", "add", "remove"}), builder)))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("prefix", StringArgumentType.string())
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("prefix", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ranks), builder)))
|
||||
.executes(context -> {
|
||||
|
||||
CommandSourceStack executor = context.getSource();
|
||||
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
ServerPlayer mcOtherPlayer = EntityArgument.getPlayer(context, "player");
|
||||
Player otherPlayer = PlayerUtil.getFactoryPlayer(mcOtherPlayer);
|
||||
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
NexiaPlayer otherPlayer = new NexiaPlayer(mcOtherPlayer);
|
||||
NexiaRank rank = NexiaRank.identifyRank(StringArgumentType.getString(context, "prefix"));
|
||||
|
||||
ServerPlayer mcExecutor;
|
||||
Player factoryExecutor = null;
|
||||
|
||||
try {
|
||||
mcExecutor = executor.getPlayerOrException();
|
||||
factoryExecutor = PlayerUtil.getFactoryPlayer(mcExecutor);
|
||||
} catch(Exception ignored){ }
|
||||
|
||||
|
||||
if(rank == null) {
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
|
||||
}
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid rank!", ChatFormat.normalColor))
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("set")){
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have set the prefix of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2))
|
||||
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the prefix of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherPlayer.getRawName(), rank.name), false);
|
||||
}
|
||||
|
||||
otherPlayer.sendMessage(
|
||||
context.getSource().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))
|
||||
.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))
|
||||
);
|
||||
|
||||
NexiaRank.setPrefix(rank, mcOtherPlayer);
|
||||
otherPlayer.sendNexiaMessage(
|
||||
Component.text("Your prefix has been set to: ", ChatFormat.normalColor)
|
||||
.append(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
NexiaRank.setPrefix(rank, otherPlayer);
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("remove")){
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have removed the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(" from: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have removed the prefix {b2}{b}{} {b1}from {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
|
||||
}
|
||||
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))
|
||||
);
|
||||
|
||||
NexiaRank.removePrefix(rank, mcOtherPlayer);
|
||||
NexiaRank.removePrefix(rank, otherPlayer);
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("add")){
|
||||
if(factoryExecutor != null){
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have added the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("{b1}You have added the prefix {b2}{b}{} {b1}to {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
|
||||
}
|
||||
|
||||
NexiaRank.addPrefix(rank, mcOtherPlayer, false);
|
||||
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,103 +1,72 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
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.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerData;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class StaffReportCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
|
||||
dispatcher.register(Commands.literal("staffreport")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.report", 1))
|
||||
.then(Commands.argument("type", StringArgumentType.string())
|
||||
dispatcher.register(CommandUtils.literal("staffreport")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.report", 3))
|
||||
.then(CommandUtils.argument("type", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"ban", "unban"}), builder)))
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(context -> {
|
||||
|
||||
CommandSourceStack executor = context.getSource();
|
||||
|
||||
String type = StringArgumentType.getString(context, "type");
|
||||
ServerPlayer mcOtherPlayer = EntityArgument.getPlayer(context, "player");
|
||||
Player otherPlayer = PlayerUtil.getFactoryPlayer(mcOtherPlayer);
|
||||
ServerPlayer mcOtherPlayer = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
NexiaPlayer otherPlayer = new NexiaPlayer(mcOtherPlayer);
|
||||
|
||||
Player factoryExecutor = null;
|
||||
|
||||
try {
|
||||
factoryExecutor = PlayerUtil.getFactoryPlayer(executor.getPlayerOrException());
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
|
||||
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()) {
|
||||
if(factoryExecutor != null) {
|
||||
factoryExecutor.sendMessage(Component.text("That player is already report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
|
||||
} else {
|
||||
executor.sendFailure(new TextComponent("That player is already report banned!"));
|
||||
}
|
||||
if(((CoreSavedPlayerData)data.savedData).isReportBanned()) {
|
||||
context.getSource().sendMessage(Component.text("That player is already report banned!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
data.savedData.setReportBanned(true);
|
||||
if(factoryExecutor != null) {
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have report banned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".")).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("You have report banned {}.", otherPlayer.getRawName()), true);
|
||||
}
|
||||
((CoreSavedPlayerData)data.savedData).setReportBanned(true);
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have report banned ", ChatFormat.normalColor)
|
||||
.append(Component.text(otherPlayer.getRawName(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
)
|
||||
);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
if(type.equalsIgnoreCase("unban") || type.equalsIgnoreCase("pardon")) {
|
||||
if(!data.savedData.isReportBanned()) {
|
||||
if(factoryExecutor != null) {
|
||||
factoryExecutor.sendMessage(Component.text("That player is not report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
|
||||
} else {
|
||||
executor.sendFailure(new TextComponent("That player is not report banned!"));
|
||||
}
|
||||
if(!((CoreSavedPlayerData)data.savedData).isReportBanned()) {
|
||||
context.getSource().sendMessage(Component.text("That player is not report banned!", ChatFormat.failColor));
|
||||
return 0;
|
||||
}
|
||||
data.savedData.setReportBanned(false);
|
||||
if(factoryExecutor != null) {
|
||||
factoryExecutor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have report unbanned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".")).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
executor.sendSuccess(LegacyChatFormat.format("You have report unbanned {}.", otherPlayer.getRawName()), true);
|
||||
}
|
||||
((CoreSavedPlayerData)data.savedData).setReportBanned(false);
|
||||
context.getSource().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have report unbanned ", ChatFormat.normalColor))
|
||||
.append(Component.text(otherPlayer.getRawName(), ChatFormat.brandColor1).decoration(ChatFormat.bold, true))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
if(factoryExecutor != null) {
|
||||
factoryExecutor.sendMessage(Component.text("Invalid argument").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
|
||||
} else {
|
||||
executor.sendFailure(new TextComponent("Invalid argument!"));
|
||||
}
|
||||
context.getSource().sendMessage(Component.text("Invalid argument", ChatFormat.failColor));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
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,42 +1,40 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.BanHandler;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class TempBanCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("tempban")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
|
||||
.then(Commands.argument("player", GameProfileArgument.gameProfile())
|
||||
.then(Commands.argument("duration", StringArgumentType.word())
|
||||
.then(Commands.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> TempBanCommand.ban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("tempban")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
|
||||
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
|
||||
.then(CommandUtils.argument("duration", StringArgumentType.word())
|
||||
.then(CommandUtils.argument("reason", StringArgumentType.greedyString())
|
||||
.executes(context -> TempBanCommand.ban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public static int ban(CommandSourceStack sender, Collection<GameProfile> collection, String reason, String durationArg) {
|
||||
public static int ban(CommandSourceInfo sender, Collection<GameProfile> collection, String reason, String durationArg) {
|
||||
int durationInSeconds;
|
||||
try {
|
||||
durationInSeconds = BanHandler.parseTimeArg(durationArg);
|
||||
} catch (Exception e) {
|
||||
PlayerUtil.safeSendMessage(sender, LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"), ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)), false);
|
||||
|
||||
sender.sendMessage(ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid duration. Examples: ", ChatFormat.normalColor))
|
||||
.append(Component.text("1s / 2m / 3h / 4d / 5w", ChatFormat.failColor))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,79 +1,61 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.UserBanList;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class UnBanCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("unban")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
|
||||
.then(Commands.argument("player", GameProfileArgument.gameProfile())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((context.getSource()).getServer().getPlayerList().getBans().getUserList(), builder)))
|
||||
.executes(context -> UnBanCommand.unban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player")))
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("unban")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
|
||||
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ServerTime.minecraftServer.getPlayerList().getBans().getUserList()), builder)))
|
||||
.executes(context -> UnBanCommand.unban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false))))
|
||||
)
|
||||
);
|
||||
dispatcher.register(Commands.literal("pardon")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
|
||||
.then(Commands.argument("player", GameProfileArgument.gameProfile())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((context.getSource()).getServer().getPlayerList().getBans().getUserList(), builder)))
|
||||
.executes(context -> UnBanCommand.unban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player")))
|
||||
dispatcher.register(CommandUtils.literal("pardon")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
|
||||
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ServerTime.minecraftServer.getPlayerList().getBans().getUserList()), builder)))
|
||||
.executes(context -> UnBanCommand.unban(context.getSource(), context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false))))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int unban(CommandSourceStack context, Collection<GameProfile> collection) {
|
||||
public static int unban(CommandSourceInfo context, Collection<GameProfile> collection) {
|
||||
UserBanList userBanList = ServerTime.minecraftServer.getPlayerList().getBans();
|
||||
int i = 0;
|
||||
|
||||
ServerPlayer player = null;
|
||||
|
||||
try {
|
||||
player = context.getPlayerOrException();
|
||||
} catch (Exception ignored){ }
|
||||
|
||||
for (GameProfile gameProfile : collection) {
|
||||
if (userBanList.isBanned(gameProfile)) {
|
||||
userBanList.remove(gameProfile);
|
||||
++i;
|
||||
if(player != null){
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have unbanned ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(gameProfile.getName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
|
||||
|
||||
);
|
||||
} else {
|
||||
context.sendSuccess(LegacyChatFormat.format("{b1}You have unbanned {b2}{}{b1}.", gameProfile.getName()), true);
|
||||
}
|
||||
context.getSender().sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You have unbanned ", ChatFormat.normalColor))
|
||||
.append(Component.text(gameProfile.getName(), ChatFormat.brandColor2))
|
||||
.append(Component.text(".", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
if(player != null){
|
||||
PlayerUtil.getFactoryPlayer(player).sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("That player is not banned.").color(ChatFormat.failColor))
|
||||
);
|
||||
} else {
|
||||
context.sendSuccess(LegacyChatFormat.formatFail("That player is not banned."), false);
|
||||
}
|
||||
context.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("That player is not banned.", ChatFormat.failColor))
|
||||
);
|
||||
|
||||
} else {
|
||||
return i;
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.chat.LegacyChatFormat;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.GamemodeBanHandler;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
|
||||
public class UnGamemodeBanCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("ungamemodeban")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
|
||||
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
.then(Commands.argument("gamemode", StringArgumentType.string())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("ungamemodeban")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.then(CommandUtils.argument("gamemode", StringArgumentType.string())
|
||||
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((PlayerGameMode.stringPlayerGameModes), builder)))
|
||||
.executes(UnGamemodeBanCommand::unBan)
|
||||
)
|
||||
@@ -33,34 +30,20 @@ public class UnGamemodeBanCommand {
|
||||
);
|
||||
}
|
||||
|
||||
public static int unBan(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
CommandSourceStack sender = context.getSource();
|
||||
ServerPlayer mcExecutor = null;
|
||||
Player executor = null;
|
||||
|
||||
try {
|
||||
mcExecutor = sender.getPlayerOrException();
|
||||
} catch (Exception ignored){ }
|
||||
|
||||
if(mcExecutor != null) {
|
||||
executor = PlayerUtil.getFactoryPlayer(mcExecutor);
|
||||
}
|
||||
public static int unBan(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
CommandSourceInfo sender = context.getSource();
|
||||
|
||||
PlayerGameMode gameMode = PlayerGameMode.identifyGamemode(StringArgumentType.getString(context, "gamemode"));
|
||||
if(gameMode == null) {
|
||||
if(executor != null) {
|
||||
executor.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
);
|
||||
} else {
|
||||
sender.sendFailure(LegacyChatFormat.format("{f}Invalid gamemode!"));
|
||||
}
|
||||
sender.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("Invalid gamemode!", ChatFormat.normalColor))
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
GamemodeBanHandler.tryUnGamemodeBan(sender, EntityArgument.getPlayer(context, "player"), gameMode);
|
||||
GamemodeBanHandler.tryUnGamemodeBan(sender, new NexiaPlayer(context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false))), gameMode);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.chat.PlayerMutes;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class UnMuteCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("unmute")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.mute", 1))
|
||||
|
||||
.then(Commands.argument("player", EntityArgument.player())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("unmute")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.mute", 1))
|
||||
.then(CommandUtils.argument("player", EntityArgument.player())
|
||||
.executes(UnMuteCommand::unMute)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int unMute(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
CommandSourceStack sender = context.getSource();
|
||||
ServerPlayer muted = EntityArgument.getPlayer(context, "player");
|
||||
public static int unMute(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
CommandSourceInfo sender = context.getSource();
|
||||
ServerPlayer muted = context.getArgument("player", EntitySelector.class).findSinglePlayer(CommandUtil.getCommandSourceStack(context.getSource(), false));
|
||||
|
||||
PlayerMutes.unMute(sender, muted);
|
||||
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
package com.nexia.core.commands.staff;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.nexia.nexus.api.command.CommandUtils;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.nexia.core.utilities.commands.CommandUtil;
|
||||
import com.nexia.core.utilities.player.BanHandler;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
|
||||
public class UnTempBanCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("untempban")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
|
||||
|
||||
.then(Commands.argument("player", GameProfileArgument.gameProfile())
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(CommandUtils.literal("untempban")
|
||||
.requires(commandSourceInfo -> CommandUtil.hasPermission(commandSourceInfo, "nexia.staff.ban", 3))
|
||||
.then(CommandUtils.argument("player", GameProfileArgument.gameProfile())
|
||||
.executes(UnTempBanCommand::unBan)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int unBan(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
CommandSourceStack sender = context.getSource();
|
||||
public static int unBan(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
|
||||
CommandSourceInfo sender = context.getSource();
|
||||
|
||||
BanHandler.tryUnBan(sender, GameProfileArgument.getGameProfiles(context, "player"));
|
||||
BanHandler.tryUnBan(sender, context.getArgument("player", GameProfileArgument.Result.class).getNames(CommandUtil.getCommandSourceStack(context.getSource(), false)));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -7,20 +7,18 @@ import com.nexia.minigames.games.bedwars.players.BwTeam;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class BwReloadTeamColorsCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register(Commands.literal("bwreloadteamcolors").executes(BwReloadTeamColorsCommand::run)
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.bwreloadteamcolors", 3)));
|
||||
dispatcher.register(Commands.literal("bwreloadteamcolors")
|
||||
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.bwreloadteamcolors", 3))
|
||||
.executes(BwReloadTeamColorsCommand::run)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerPlayer player = context.getSource().getPlayerOrException();
|
||||
|
||||
BwTeam.reloadPlayerTeamColors(player);
|
||||
|
||||
BwTeam.reloadPlayerTeamColors();
|
||||
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
-26
@@ -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,16 +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.biome.Biomes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
|
||||
|
||||
import java.io.FileWriter;
|
||||
|
||||
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
|
||||
|
||||
public class DevExperimentalCommandsCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
|
||||
dispatcher.register((Commands.literal("devexperimentalcmds")
|
||||
@@ -58,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(Biomes.PLAINS))
|
||||
.setDifficulty(Difficulty.HARD)
|
||||
.setGameRule(GameRules.RULE_KEEPINVENTORY, true)
|
||||
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
|
||||
.setGameRule(GameRules.RULE_WEATHER_CYCLE, false)
|
||||
.setGameRule(GameRules.RULE_DAYLIGHT, true)
|
||||
.setGameRule(GameRules.RULE_DO_IMMEDIATE_RESPAWN, true)
|
||||
.setGameRule(GameRules.RULE_DOMOBSPAWNING, false)
|
||||
.setGameRule(GameRules.RULE_SHOWDEATHMESSAGES, false)
|
||||
.setGameRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS, false)
|
||||
.setGameRule(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK, true)
|
||||
.setGameRule(GameRules.RULE_DROWNING_DAMAGE, true)
|
||||
.setGameRule(GameRules.RULE_SPAWN_RADIUS, 0))).asWorld();
|
||||
|
||||
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);
|
||||
|
||||
@@ -39,7 +39,10 @@ public class ForceGameEndCommand {
|
||||
case "oitc" -> OitcGame.endGame(null);
|
||||
case "skywars" -> SkywarsGame.winNearestCenter();
|
||||
case "bedwars" -> BwGame.endBedwars();
|
||||
default -> context.getSource().sendFailure(new TextComponent("Invalid game!"));
|
||||
default -> {
|
||||
context.getSource().sendFailure(new TextComponent("Invalid game!"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(new TextComponent("Game ended (if valid)."), false);
|
||||
|
||||
@@ -6,6 +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.base.player.NexiaPlayer;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
@@ -16,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 {
|
||||
@@ -31,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")))
|
||||
@@ -65,7 +75,7 @@ public class LoadInventoryCommand {
|
||||
context.getSource().sendFailure(LegacyChatFormat.format("Unable to load the content of the inventory with the name '{}' in '{}'.", inventory, type));
|
||||
return 0;
|
||||
} else {
|
||||
InventoryUtil.loadInventory(player, type, inventory);
|
||||
InventoryUtil.loadInventory(new NexiaPlayer(player), type, inventory);
|
||||
|
||||
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully loaded '{}' in '{}' to " + ((isContextPlayer) ? "your inventory" : "the inventory of " + player.getScoreboardName()) + ".", inventory, type), false);
|
||||
|
||||
|
||||
@@ -3,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).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,50 +1,42 @@
|
||||
package com.nexia.core.games.util;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.nbt.NBTObject;
|
||||
import com.combatreforged.factory.api.world.nbt.NBTValue;
|
||||
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.ItemStackUtil;
|
||||
import com.nexia.core.utilities.player.BanHandler;
|
||||
import com.nexia.core.utilities.player.CorePlayerData;
|
||||
import com.nexia.core.utilities.player.GamemodeBanHandler;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.pos.EntityPos;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
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.bedwars.util.BwScoreboard;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
import com.nexia.minigames.games.football.FootballGame;
|
||||
import com.nexia.minigames.games.football.FootballGameMode;
|
||||
import com.nexia.minigames.games.football.util.player.FootballPlayerData;
|
||||
import com.nexia.minigames.games.oitc.OitcGame;
|
||||
import com.nexia.minigames.games.oitc.OitcGameMode;
|
||||
import com.nexia.minigames.games.oitc.util.player.OITCPlayerData;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGameMode;
|
||||
import 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.protocol.game.ClientboundStopSoundPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.nexia.core.utilities.player.BanHandler.getBanTime;
|
||||
|
||||
@@ -53,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
|
||||
@@ -79,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",
|
||||
@@ -93,134 +92,56 @@ public class LobbyUtil {
|
||||
"in_kitroom",
|
||||
NO_RANK_DISPLAY_TAG,
|
||||
NO_SATURATION_TAG,
|
||||
NO_FALL_DAMAGE_TAG
|
||||
NO_FALL_DAMAGE_TAG,
|
||||
NO_DAMAGE_TAG
|
||||
};
|
||||
|
||||
public static void leaveAllGames(ServerPlayer minecraftPlayer, boolean tp) {
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
if (BwUtil.isInBedWars(minecraftPlayer)) {
|
||||
BwPlayerEvents.leaveInBedWars(minecraftPlayer);
|
||||
}
|
||||
else if (FfaUtil.isFfaPlayer(minecraftPlayer)) {
|
||||
if((FfaClassicUtil.isFfaPlayer(minecraftPlayer) && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
|
||||
(FfaKitsUtil.isFfaPlayer(minecraftPlayer)) && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaSkyUtil.isFfaPlayer(minecraftPlayer) && !FfaSkyUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaUhcUtil.isFfaPlayer(minecraftPlayer) && !FfaUhcUtil.canGoToSpawn(minecraftPlayer)))) {
|
||||
|
||||
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
FfaUtil.leaveOrDie(minecraftPlayer, minecraftPlayer.getLastDamageSource(), true);
|
||||
}
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.LOBBY) {
|
||||
DuelGameHandler.leave(minecraftPlayer, false);
|
||||
}
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.OITC) {
|
||||
OitcGame.leave(minecraftPlayer);
|
||||
}
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) {
|
||||
SkywarsGame.leave(minecraftPlayer);
|
||||
}
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.FOOTBALL) {
|
||||
FootballGame.leave(minecraftPlayer);
|
||||
}
|
||||
|
||||
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, minecraftPlayer, true);
|
||||
BwScoreboard.removeScoreboardFor(minecraftPlayer);
|
||||
minecraftPlayer.setGlowing(false);
|
||||
minecraftPlayer.setGameMode(GameType.ADVENTURE);
|
||||
|
||||
for(String tag : LobbyUtil.removedTags) {
|
||||
if(player.hasTag(tag)) player.removeTag(tag);
|
||||
}
|
||||
|
||||
returnToLobby(minecraftPlayer, tp);
|
||||
}
|
||||
|
||||
public static void returnToLobby(ServerPlayer minecraftPlayer, boolean tp) {
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
|
||||
if((FfaClassicUtil.isFfaPlayer(minecraftPlayer) && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
|
||||
(FfaKitsUtil.isFfaPlayer(minecraftPlayer)) && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaSkyUtil.isFfaPlayer(minecraftPlayer) && !FfaSkyUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(FfaUhcUtil.isFfaPlayer(minecraftPlayer) && !FfaUhcUtil.canGoToSpawn(minecraftPlayer)))) {
|
||||
|
||||
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
|
||||
return;
|
||||
}
|
||||
|
||||
for(String tag : LobbyUtil.removedTags) {
|
||||
if(player.hasTag(tag)) player.removeTag(tag);
|
||||
}
|
||||
|
||||
minecraftPlayer.setInvulnerable(false);
|
||||
|
||||
minecraftPlayer.abilities.mayfly = false;
|
||||
minecraftPlayer.abilities.flying = false;
|
||||
Objects.requireNonNull(minecraftPlayer.getAttribute(Attributes.KNOCKBACK_RESISTANCE)).setBaseValue(0.0);
|
||||
minecraftPlayer.onUpdateAbilities();
|
||||
minecraftPlayer.setGlowing(false);
|
||||
|
||||
PlayerUtil.resetHealthStatus(player);
|
||||
minecraftPlayer.setGameMode(GameType.ADVENTURE);
|
||||
|
||||
player.getInventory().clear();
|
||||
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
|
||||
minecraftPlayer.getEnderChestInventory().clearContent();
|
||||
minecraftPlayer.setExperiencePoints(0);
|
||||
minecraftPlayer.setExperienceLevels(0);
|
||||
public static void returnToLobby(NexiaPlayer player, boolean tp) {
|
||||
player.leaveAllGames();
|
||||
player.reset(true, Minecraft.GameMode.ADVENTURE);
|
||||
|
||||
// Duels shit
|
||||
player.addTag("duels");
|
||||
DuelGameHandler.leave(minecraftPlayer, false);
|
||||
DuelGameHandler.leave(player, false);
|
||||
|
||||
if (tp) {
|
||||
minecraftPlayer.setRespawnPosition(lobbyWorld.dimension(), lobbySpawn.toBlockPos(), lobbySpawn.yaw, true, false);
|
||||
minecraftPlayer.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(minecraftPlayer, "nexia.prefix.supporter")) {
|
||||
minecraftPlayer.abilities.mayfly = true;
|
||||
minecraftPlayer.onUpdateAbilities();
|
||||
if(player.hasPrefix(NexiaRank.SUPPORTER)) {
|
||||
player.setAbleToFly(true);
|
||||
}
|
||||
|
||||
LobbyUtil.giveItems(minecraftPlayer);
|
||||
LobbyUtil.giveItems(player);
|
||||
}
|
||||
|
||||
minecraftPlayer.connection.send(new ClientboundStopSoundPacket());
|
||||
((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode = PlayerGameMode.LOBBY;
|
||||
|
||||
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.LOBBY;
|
||||
player.removeTag(LobbyUtil.NO_RANK_DISPLAY_TAG);
|
||||
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
ServerTime.minecraftServer.getPlayerList().sendPlayerPermissionLevel(minecraftPlayer);
|
||||
player.setBedrockBridging(true);
|
||||
}
|
||||
|
||||
public static void giveItems(ServerPlayer minecraftPlayer) {
|
||||
public static void giveItems(NexiaPlayer player) {
|
||||
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
NBTObject hideAttributesNBTObject = NBTObject.create();
|
||||
hideAttributesNBTObject.set("HideFlags", NBTValue.of(39));
|
||||
|
||||
NBTObject hideAttrubtesNBTObject = NBTObject.create();
|
||||
hideAttrubtesNBTObject.set("HideFlags", NBTValue.of(39));
|
||||
|
||||
NBTObject unbreakableNBTObject = hideAttrubtesNBTObject.copy();
|
||||
NBTObject unbreakableNBTObject = hideAttributesNBTObject.copy();
|
||||
unbreakableNBTObject.set("Unbreakable", NBTValue.of(1));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack compass = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.COMPASS);
|
||||
compass.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
com.nexia.nexus.api.world.item.ItemStack compass = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.COMPASS);
|
||||
compass.setItemNBT(hideAttributesNBTObject.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));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack nameTag = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.NAME_TAG);
|
||||
nameTag.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
com.nexia.nexus.api.world.item.ItemStack nameTag = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.NAME_TAG);
|
||||
nameTag.setItemNBT(hideAttributesNBTObject.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.combatreforged.factory.api.world.item.ItemStack queueSword = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.IRON_SWORD);
|
||||
queueSword.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
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)
|
||||
@@ -228,8 +149,8 @@ public class LobbyUtil {
|
||||
queueSword.setDisplayName(Component.text("Duel Sword", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack teamSword = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.IRON_AXE);
|
||||
teamSword.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
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)
|
||||
@@ -237,32 +158,32 @@ public class LobbyUtil {
|
||||
teamSword.setDisplayName(Component.text("Team Axe", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false));
|
||||
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack customDuelSword = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.DIAMOND_SWORD);
|
||||
customDuelSword.setItemNBT(hideAttrubtesNBTObject.copy());
|
||||
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(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
|
||||
if(player.hasPrefix(NexiaRank.SUPPORTER)) {
|
||||
|
||||
com.combatreforged.factory.api.world.item.ItemStack elytra = com.combatreforged.factory.api.world.item.ItemStack.create(Minecraft.Item.ELYTRA);
|
||||
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));
|
||||
|
||||
factoryPlayer.getInventory().setItemStack(38, elytra);
|
||||
player.getInventory().setItemStack(38, elytra);
|
||||
}
|
||||
|
||||
|
||||
factoryPlayer.getInventory().setItemStack(0, customDuelSword); // 1st slot
|
||||
factoryPlayer.getInventory().setItemStack(4, compass); // middle slot
|
||||
factoryPlayer.getInventory().setItemStack(3, nameTag); // left
|
||||
factoryPlayer.getInventory().setItemStack(5, queueSword); // right
|
||||
factoryPlayer.getInventory().setItemStack(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
|
||||
|
||||
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
|
||||
player.refreshInventory();
|
||||
}
|
||||
|
||||
public static boolean checkGameModeBan(Player factoryPlayer, ServerPlayer player, String game) {
|
||||
public static boolean checkGameModeBan(NexiaPlayer player, String game) {
|
||||
ArrayList<PlayerGameMode> bannedGameModes = GamemodeBanHandler.getBannedGameModes(player);
|
||||
if(bannedGameModes.isEmpty()) {
|
||||
return false;
|
||||
@@ -271,31 +192,27 @@ public class LobbyUtil {
|
||||
for(PlayerGameMode gameMode : bannedGameModes) {
|
||||
if(game.toLowerCase().contains(gameMode.id.toLowerCase())) {
|
||||
|
||||
JSONObject banJSON = GamemodeBanHandler.getBanList(player.getStringUUID(), gameMode);
|
||||
JSONObject banJSON = GamemodeBanHandler.getBanList(player.getUUID(), gameMode);
|
||||
|
||||
if (banJSON != null) {
|
||||
LocalDateTime banTime = getBanTime((String) banJSON.get("duration"));
|
||||
if(LocalDateTime.now().isAfter(banTime)) {
|
||||
GamemodeBanHandler.removeBanFromList(player.getStringUUID(), gameMode);
|
||||
GamemodeBanHandler.removeBanFromList(player.getUUID(), gameMode);
|
||||
return false;
|
||||
} else {
|
||||
factoryPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You are gamemode (" + gameMode.name + ") banned for ").decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(BanHandler.banTimeToText(banTime)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
.append(Component.text(".\nReason: ").decoration(ChatFormat.bold, false))
|
||||
.append(Component.text((String) banJSON.get("reason")).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
|
||||
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 {
|
||||
factoryPlayer.sendMessage(
|
||||
ChatFormat.nexiaMessage
|
||||
.append(Component.text("You are gamemode (" + gameMode.name + ") banned!"))
|
||||
);
|
||||
player.sendNexiaMessage("You are gamemode (%s) banned!", gameMode.name);
|
||||
}
|
||||
|
||||
factoryPlayer.runCommand("/hub");
|
||||
LobbyUtil.returnToLobby(player, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -304,146 +221,88 @@ public class LobbyUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void sendGame(ServerPlayer minecraftPlayer, String game, boolean message, boolean tp){
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
public static void sendGame(NexiaPlayer player, String game, boolean message, boolean tp) {
|
||||
|
||||
if(checkGameModeBan(player, minecraftPlayer, game)) {
|
||||
if (checkGameModeBan(player, game)) {
|
||||
return;
|
||||
}
|
||||
|
||||
minecraftPlayer.setInvulnerable(false);
|
||||
player.setBedrockBridging(true);
|
||||
|
||||
minecraftPlayer.abilities.mayfly = false;
|
||||
minecraftPlayer.onUpdateAbilities();
|
||||
|
||||
if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
|
||||
(game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(game.equalsIgnoreCase("sky ffa") && !FfaSkyUtil.canGoToSpawn(minecraftPlayer) ||
|
||||
(game.equalsIgnoreCase("uhc ffa") && !FfaUhcUtil.canGoToSpawn(minecraftPlayer))))) {
|
||||
|
||||
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
|
||||
return;
|
||||
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(minecraftPlayer, true);
|
||||
DuelGameHandler.leave(player, true);
|
||||
}
|
||||
|
||||
if (!LobbyUtil.isLobbyWorld(minecraftPlayer.getLevel())) {
|
||||
LobbyUtil.leaveAllGames(minecraftPlayer, false);
|
||||
} else{
|
||||
PlayerUtil.resetHealthStatus(player);
|
||||
minecraftPlayer.setGameMode(GameType.ADVENTURE);
|
||||
player.reset(true, Minecraft.GameMode.ADVENTURE);
|
||||
player.leaveAllGames();
|
||||
|
||||
player.getInventory().clear();
|
||||
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
|
||||
minecraftPlayer.getEnderChestInventory().clearContent();
|
||||
|
||||
minecraftPlayer.connection.send(new ClientboundStopSoundPacket());
|
||||
|
||||
player.removeTag(LobbyUtil.NO_FALL_DAMAGE_TAG);
|
||||
player.removeTag(LobbyUtil.NO_DAMAGE_TAG);
|
||||
player.removeTag("duels");
|
||||
player.removeTag(LobbyUtil.NO_SATURATION_TAG);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("classic ffa") ||
|
||||
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(minecraftPlayer).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(minecraftPlayer).ffaGameMode = FfaGameMode.CLASSIC;
|
||||
if(tp){
|
||||
minecraftPlayer.teleportTo(FfaAreas.ffaWorld, FfaAreas.spawn.x, FfaAreas.spawn.y, FfaAreas.spawn.z, FfaAreas.spawn.yaw, FfaAreas.spawn.pitch);
|
||||
minecraftPlayer.setRespawnPosition(FfaAreas.ffaWorld.dimension(), FfaAreas.spawn.toBlockPos(), FfaAreas.spawn.yaw, true, false);
|
||||
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(minecraftPlayer);
|
||||
FfaClassicUtil.setInventory(minecraftPlayer);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("sky ffa")){
|
||||
player.addTag("ffa_sky");
|
||||
FfaSkyUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.SKY;
|
||||
if(tp){
|
||||
FfaSkyUtil.sendToSpawn(minecraftPlayer);
|
||||
minecraftPlayer.setRespawnPosition(com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.sky.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.sky.utilities.FfaAreas.spawn.yaw, true, false);
|
||||
}
|
||||
|
||||
FfaSkyUtil.joinOrRespawn(minecraftPlayer);
|
||||
if (game.equalsIgnoreCase("classic ffa")) {
|
||||
FfaClassicUtil.INSTANCE.setInventory(player);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("uhc ffa")){
|
||||
player.addTag("ffa_uhc");
|
||||
FfaUhcUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.UHC;
|
||||
if(tp){
|
||||
FfaUhcUtil.sendToSpawn(minecraftPlayer);
|
||||
minecraftPlayer.setRespawnPosition(com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.yaw, true, false);
|
||||
}
|
||||
|
||||
FfaUhcUtil.clearArrows(minecraftPlayer);
|
||||
FfaUhcUtil.clearTrident(minecraftPlayer);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("kits ffa")){
|
||||
player.addTag("ffa_kits");
|
||||
FfaKitsUtil.wasInSpawn.add(player.getUUID());
|
||||
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.KITS;
|
||||
if(tp){
|
||||
FfaKitsUtil.sendToSpawn(minecraftPlayer);
|
||||
minecraftPlayer.setRespawnPosition(com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.kits.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.kits.utilities.FfaAreas.spawn.yaw, true, false);
|
||||
}
|
||||
|
||||
FfaKitsUtil.clearThrownTridents(minecraftPlayer);
|
||||
FfaKitsUtil.clearArrows(minecraftPlayer);
|
||||
FfaKitsUtil.clearSpectralArrows(minecraftPlayer);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("bedwars")){
|
||||
if (game.equalsIgnoreCase("bedwars")) {
|
||||
if(message){ player.sendActionBarMessage(Component.text("You have joined §b\uD83E\uDE93 §c§lBedwars §e⚡"));}
|
||||
BwPlayerEvents.tryToJoin(minecraftPlayer, false);
|
||||
BwPlayerEvents.tryToJoin(player, false);
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("duels")){
|
||||
LobbyUtil.leaveAllGames(minecraftPlayer, tp);
|
||||
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(minecraftPlayer).gameMode = PlayerGameMode.OITC;
|
||||
OitcGame.death(minecraftPlayer, minecraftPlayer.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(minecraftPlayer).gameMode = OitcGameMode.LOBBY;
|
||||
((OITCPlayerData)PlayerDataManager.getDataManager(NexiaCore.OITC_DATA_MANAGER).get(player)).gameMode = OitcGameMode.LOBBY;
|
||||
|
||||
OitcGame.joinQueue(minecraftPlayer);
|
||||
OitcGame.joinQueue(player);
|
||||
|
||||
if(message){player.sendActionBarMessage(Component.text("You have joined §7\uD83D\uDDE1 §f§lOITC §7\uD83C\uDFF9"));}
|
||||
}
|
||||
|
||||
if(game.equalsIgnoreCase("football")){
|
||||
player.addTag(FootballGame.FOOTBALL_TAG);
|
||||
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.FOOTBALL;
|
||||
com.nexia.minigames.games.football.util.player.PlayerDataManager.get(minecraftPlayer).gameMode = FootballGameMode.LOBBY;
|
||||
((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(minecraftPlayer);
|
||||
FootballGame.joinQueue(player);
|
||||
|
||||
if(message){player.sendActionBarMessage(Component.text("You have joined §7○ §7§lFootball §7\uD83D\uDDE1"));}
|
||||
}
|
||||
@@ -451,12 +310,12 @@ public class LobbyUtil {
|
||||
|
||||
if(game.equalsIgnoreCase("skywars")){
|
||||
player.addTag(PlayerGameMode.SKYWARS.tag);
|
||||
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.SKYWARS;
|
||||
SkywarsGame.death(minecraftPlayer, minecraftPlayer.getLastDamageSource());
|
||||
((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(minecraftPlayer).gameMode = SkywarsGameMode.LOBBY;
|
||||
((SkywarsPlayerData)PlayerDataManager.getDataManager(NexiaCore.SKYWARS_DATA_MANAGER).get(player)).gameMode = SkywarsGameMode.LOBBY;
|
||||
|
||||
SkywarsGame.joinQueue(minecraftPlayer);
|
||||
SkywarsGame.joinQueue(player);
|
||||
|
||||
if(message){player.sendActionBarMessage(Component.text("You have joined §7☐ §aSkywars §7\uD83D\uDDE1"));}
|
||||
}
|
||||
|
||||
@@ -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,14 +1,21 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.base.player.PlayerDataManager;
|
||||
import com.nexia.core.NexiaCore;
|
||||
import com.nexia.ffa.kits.utilities.KitFfaAreas;
|
||||
import com.nexia.ffa.pot.utilities.PotFfaAreas;
|
||||
import com.nexia.ffa.sky.utilities.SkyFfaAreas;
|
||||
import com.nexia.ffa.uhc.utilities.UhcFfaAreas;
|
||||
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
|
||||
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.ffa.classic.utilities.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;
|
||||
@@ -21,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 {
|
||||
|
||||
@@ -35,11 +44,11 @@ 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(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("FFA", ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false)));
|
||||
@@ -59,7 +68,7 @@ public class PlayGUI extends SimpleGui {
|
||||
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(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("BedWars", ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false)));
|
||||
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);
|
||||
|
||||
@@ -72,7 +81,7 @@ public class PlayGUI extends SimpleGui {
|
||||
|
||||
|
||||
ItemStack skywars = new ItemStack(Items.GRASS_BLOCK, 1);
|
||||
skywars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("SkyWars", ChatFormat.Minecraft.green).decoration(ChatFormat.italic, false)));
|
||||
skywars.setHoverName(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);
|
||||
@@ -89,7 +98,7 @@ public class PlayGUI extends SimpleGui {
|
||||
|
||||
int duelsPlayers = 0;
|
||||
for(ServerPlayer serverPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()) {
|
||||
DuelGameMode gameMode = PlayerDataManager.get(serverPlayer).gameMode;
|
||||
DuelGameMode gameMode = ((DuelsPlayerData)PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(serverPlayer.getUUID())).gameMode;
|
||||
if(gameMode != null && (gameMode != DuelGameMode.LOBBY && gameMode != DuelGameMode.SPECTATING)) duelsPlayers++;
|
||||
}
|
||||
|
||||
@@ -122,7 +131,7 @@ public class PlayGUI extends SimpleGui {
|
||||
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, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", FfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.aqua).decoration(ChatFormat.italic, false), 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(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("Kit FFA", ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
@@ -133,7 +142,19 @@ public class PlayGUI extends SimpleGui {
|
||||
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, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false), 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);
|
||||
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, 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)));
|
||||
@@ -145,7 +166,7 @@ public class PlayGUI extends SimpleGui {
|
||||
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.", com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false), 4);
|
||||
ItemDisplayUtil.addLore(skyffa, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", SkyFfaAreas.ffaWorld.players().size()), ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false), 4);
|
||||
|
||||
ItemStack uhc = new ItemStack(Items.GOLDEN_APPLE, 1);
|
||||
uhc.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("UHC FFA", ChatFormat.goldColor).decoration(ChatFormat.italic, false)));
|
||||
@@ -156,16 +177,17 @@ public class PlayGUI extends SimpleGui {
|
||||
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, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size()), ChatFormat.goldColor).decoration(ChatFormat.italic, false), 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, skyffa);
|
||||
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() {
|
||||
@@ -221,23 +243,30 @@ public class PlayGUI extends SimpleGui {
|
||||
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
Component name = itemStack.getHoverName();
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
|
||||
|
||||
if(name.getString().contains("Classic FFA")){
|
||||
LobbyUtil.sendGame(this.player, "classic ffa", true, true);
|
||||
LobbyUtil.sendGame(nexiaPlayer, "classic ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Kit FFA")){
|
||||
LobbyUtil.sendGame(this.player, "kits ffa", true, true);
|
||||
LobbyUtil.sendGame(nexiaPlayer, "kits ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Pot FFA")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "pot ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Sky FFA")){
|
||||
LobbyUtil.sendGame(this.player, "sky ffa", true, true);
|
||||
LobbyUtil.sendGame(nexiaPlayer, "sky ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("UHC FFA")){
|
||||
LobbyUtil.sendGame(this.player, "uhc ffa", true, true);
|
||||
LobbyUtil.sendGame(nexiaPlayer, "uhc ffa", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
@@ -245,28 +274,28 @@ public class PlayGUI extends SimpleGui {
|
||||
this.setFFALayout();
|
||||
}
|
||||
|
||||
if(name.getString().contains("BedWars")){
|
||||
LobbyUtil.sendGame(this.player, "bedwars", true, true);
|
||||
if(name.getString().contains("Bedwars")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "bedwars", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("SkyWars")){
|
||||
LobbyUtil.sendGame(this.player, "skywars", true, true);
|
||||
if(name.getString().contains("Skywars")){
|
||||
LobbyUtil.sendGame(nexiaPlayer, "skywars", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("OITC")){
|
||||
LobbyUtil.sendGame(this.player, "oitc", true, true);
|
||||
LobbyUtil.sendGame(nexiaPlayer, "oitc", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Football")){
|
||||
LobbyUtil.sendGame(this.player, "football", true, true);
|
||||
LobbyUtil.sendGame(nexiaPlayer, "football", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
if(name.getString().contains("Duels")){
|
||||
LobbyUtil.sendGame(this.player, "duels", true, true);
|
||||
LobbyUtil.sendGame(nexiaPlayer, "duels", true, true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
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.PlayerUtil;
|
||||
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;
|
||||
@@ -55,13 +54,15 @@ public class PrefixGUI extends SimpleGui {
|
||||
slot = 19;
|
||||
}
|
||||
|
||||
if(Permissions.check(player, "nexia.prefix." + rank.id) && player.getTags().contains(rank.id)){
|
||||
boolean hasPermission = Permissions.check(player, rank.groupID);
|
||||
|
||||
if(hasPermission && player.getTags().contains(rank.id)){
|
||||
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
ItemDisplayUtil.addGlint(enchantedItem);
|
||||
enchantedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
this.setSlot(slot, enchantedItem);
|
||||
slot++;
|
||||
} else if(Permissions.check(player, "nexia.prefix." + rank.id)){
|
||||
} else if(hasPermission){
|
||||
ItemStack changedItem = new ItemStack(Items.NAME_TAG, 1);
|
||||
changedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
|
||||
this.setSlot(slot, changedItem);
|
||||
@@ -84,13 +85,12 @@ public class PrefixGUI extends SimpleGui {
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
|
||||
|
||||
Player player = PlayerUtil.getFactoryPlayer(this.player);
|
||||
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){
|
||||
@@ -98,6 +98,7 @@ public class PrefixGUI extends SimpleGui {
|
||||
}
|
||||
|
||||
if(name.equalsIgnoreCase("player")) name = "default";
|
||||
if(name.equalsIgnoreCase("nexia")) name = "supporter";
|
||||
|
||||
player.addTag(name.toLowerCase());
|
||||
this.setMainLayout(this.player);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.nexia.core.gui;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
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.PlayerUtil;
|
||||
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;
|
||||
@@ -43,7 +42,7 @@ public class RanksGUI extends SimpleGui {
|
||||
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(Main.config.discordLink, TextColor.fromHexString("#8c00ff")).decoration(ChatFormat.italic, false), 6);
|
||||
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, 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);
|
||||
@@ -86,27 +85,25 @@ public class RanksGUI extends SimpleGui {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
Component name = itemStack.getHoverName();
|
||||
|
||||
Player factoryPlayer = PlayerUtil.getFactoryPlayer(this.player);
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
|
||||
|
||||
if(name.getString().contains("Supporter")){
|
||||
// Insert supporter thing here (link to discord and patreon)
|
||||
factoryPlayer.sendMessage(ChatFormat.nexiaMessage.append(
|
||||
net.kyori.adventure.text.Component.text("In order to get the ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
|
||||
.append(net.kyori.adventure.text.Component.text("Supporter").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
|
||||
.append(net.kyori.adventure.text.Component.text(" rank, you need to either ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
|
||||
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,9 +1,10 @@
|
||||
package com.nexia.core.gui.duels;
|
||||
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.InventoryUtil;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
import com.nexia.minigames.games.duels.map.DuelsMap;
|
||||
@@ -55,7 +56,7 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
for(DuelsMap map : DuelsMap.duelsMaps){
|
||||
this.setSlot(slot, map.item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(map.id, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false))));
|
||||
this.setSlot(slot, map.item);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +81,6 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
|
||||
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
|
||||
|
||||
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
|
||||
playerHead.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(otherp.getScoreboardName(), ChatFormat.Minecraft.yellow).decoration(ChatFormat.bold, true).decoration(ChatFormat.italic, false)));
|
||||
@@ -99,7 +99,7 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
|
||||
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", ChatFormat.Minecraft.yellow).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true))
|
||||
.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);
|
||||
|
||||
@@ -126,9 +126,9 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
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).decoration(ChatFormat.bold, false)
|
||||
.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).decoration(ChatFormat.bold, false);
|
||||
.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);
|
||||
@@ -156,14 +156,12 @@ public class CustomDuelGUI extends SimpleGui {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
Component name = itemStack.getHoverName();
|
||||
|
||||
System.out.println(name.getString());
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR && itemStack.getItem() != Items.PLAYER_HEAD && itemStack.getItem() != Items.COMMAND_BLOCK){
|
||||
if(InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID()).contains(name.getString().toLowerCase().replaceAll(" ", "_"))){
|
||||
this.kit = name.getString().toLowerCase().replaceAll(" ", "_");
|
||||
setMapLayout();
|
||||
} else {
|
||||
GamemodeHandler.customChallengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString()));
|
||||
GamemodeHandler.customChallengePlayer(new NexiaPlayer(this.player), new NexiaPlayer(this.other), this.kit, DuelsMap.identifyMap(name.getString()));
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.nexia.core.gui.duels;
|
||||
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameMode;
|
||||
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
|
||||
import com.nexia.minigames.games.duels.map.DuelsMap;
|
||||
import com.nexia.nexus.api.world.types.Minecraft;
|
||||
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
@@ -16,7 +18,6 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.GameType;
|
||||
|
||||
public class DuelGUI extends SimpleGui {
|
||||
static final TextComponent title = new TextComponent("Duel Menu");
|
||||
@@ -54,10 +55,9 @@ public class DuelGUI extends SimpleGui {
|
||||
airSlots++;
|
||||
}
|
||||
for(DuelsMap map : DuelsMap.duelsMaps){
|
||||
if(gameMode.gameMode == GameType.ADVENTURE && map.isAdventureSupported) {
|
||||
this.setSlot(slot, map.item.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(map.id, ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false))));
|
||||
slot++;
|
||||
}
|
||||
if(gameMode.gameMode == Minecraft.GameMode.ADVENTURE && !map.isAdventureSupported) continue;
|
||||
this.setSlot(slot, map.item);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class DuelGUI extends SimpleGui {
|
||||
if(slot == 26) {
|
||||
slot = 28;
|
||||
}
|
||||
item = DuelGameMode.duelsItems.get(i1).setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text(duel.toUpperCase().replaceAll("_", " "), ChatFormat.Minecraft.white).decoration(ChatFormat.italic, false)));
|
||||
item = DuelGameMode.duelsItems.get(i1);
|
||||
ItemDisplayUtil.removeLore(item, 0);
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class DuelGUI extends SimpleGui {
|
||||
this.kit = name.getString().replaceAll(" ", "_");
|
||||
setMapLayout(GamemodeHandler.identifyGamemode(this.kit));
|
||||
} else {
|
||||
GamemodeHandler.challengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString()));
|
||||
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.games.util.LobbyUtil;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.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);
|
||||
|
||||
if(GamemodeHandler.isInQueue(player, gameMode)) {
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
ItemDisplayUtil.addLore(item, "§7Click to leave the queue.", 1);
|
||||
} else {
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
ItemDisplayUtil.removeLore(item, 1);
|
||||
if(GamemodeHandler.isInQueue(new NexiaPlayer(this.player), gameMode)) {
|
||||
ItemDisplayUtil.addLore(item, net.kyori.adventure.text.Component.text("Click to leave the queue.", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 1);
|
||||
}
|
||||
|
||||
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){
|
||||
@@ -80,24 +83,23 @@ public class QueueGUI extends SimpleGui {
|
||||
ItemStack itemStack = element.getItemStack();
|
||||
Component name = itemStack.getHoverName();
|
||||
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(this.player);
|
||||
|
||||
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
|
||||
if(name.getString().substring(4).equalsIgnoreCase("Leave ALL Queues")) {
|
||||
//PlayerUtil.getFactoryPlayer(player).runCommand("/queue LEAVE", 0, false);
|
||||
LobbyUtil.leaveAllGames(this.player, true);
|
||||
this.close();
|
||||
return super.click(index, clickType, action);
|
||||
if(name.getString().contains("Leave ALL Queues")) {
|
||||
GamemodeHandler.removeQueue(nexiaPlayer, null, false);
|
||||
}
|
||||
|
||||
String modifiedName = name.getString().substring(2).replaceAll(" ", "_");
|
||||
String modifiedName = name.getString().replaceAll(" ", "_");
|
||||
DuelGameMode gameMode = GamemodeHandler.identifyGamemode(modifiedName);
|
||||
|
||||
if(gameMode != null && GamemodeHandler.isInQueue(player, gameMode)) {
|
||||
GamemodeHandler.removeQueue(this.player, modifiedName, false);
|
||||
this.close();
|
||||
if(gameMode != null && GamemodeHandler.isInQueue(nexiaPlayer, gameMode)) {
|
||||
GamemodeHandler.removeQueue(nexiaPlayer, modifiedName, false);
|
||||
} else {
|
||||
GamemodeHandler.joinQueue(this.player, modifiedName, false);
|
||||
this.close();
|
||||
GamemodeHandler.joinQueue(nexiaPlayer, modifiedName, false);
|
||||
}
|
||||
|
||||
this.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.nexia.core.gui.ffa;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.kits.FfaKit;
|
||||
import com.nexia.nexus.builder.implementation.util.ObjectMappings;
|
||||
import eu.pb4.sgui.api.ClickType;
|
||||
import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
@@ -59,10 +58,10 @@ public class KitGUI extends SimpleGui {
|
||||
}
|
||||
|
||||
public static void giveKit(ServerPlayer minecraftPlayer, String name) {
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
NexiaPlayer player = new NexiaPlayer(minecraftPlayer);
|
||||
FfaKit kit = FfaKit.identifyKit(name);
|
||||
if(kit != null) kit.giveKit(minecraftPlayer, false);
|
||||
else player.sendMessage(Component.text("Invalid kit!").color(ChatFormat.failColor));
|
||||
if(kit != null) kit.giveKit(new NexiaPlayer(minecraftPlayer), false);
|
||||
else player.sendMessage(Component.text("Invalid kit!", ChatFormat.failColor));
|
||||
}
|
||||
|
||||
public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.nexia.core.gui.ffa;
|
||||
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.chat.ChatFormat;
|
||||
import com.nexia.core.utilities.item.ItemDisplayUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.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;
|
||||
@@ -23,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++){
|
||||
@@ -109,18 +109,17 @@ public class SpawnGUI extends SimpleGui {
|
||||
}
|
||||
|
||||
public static void teleportPlayer(ServerPlayer minecraftPlayer, String name) {
|
||||
int[] pos = mapLocations.get(name);
|
||||
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,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,14 +1,18 @@
|
||||
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
|
||||
PlayerJoinListener.registerListener();
|
||||
PlayerLeaveListener.registerListener();
|
||||
UseItemListener.registerListener();
|
||||
PlayerDropItemListener.registerListener();
|
||||
PlayerRespawnListener.registerListener();
|
||||
// Nexus Listeners
|
||||
new PlayerJoinListener().registerListener();
|
||||
new PlayerDamageListener().registerListener();
|
||||
new PlayerDeathListener().registerListener();
|
||||
new PlayerHungerListener().registerListener();
|
||||
new PlayerLeaveListener().registerListener();
|
||||
new PlayerSwapHandItemsListener().registerListener();
|
||||
new PlayerUseItemListener().registerListener();
|
||||
new PlayerDropItemListener().registerListener();
|
||||
new PlayerRespawnListener().registerListener();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerHotbarDropItemEvent;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.utilities.item.ItemStackUtil;
|
||||
import com.nexia.core.utilities.misc.EventUtil;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class PlayerDropItemListener {
|
||||
public static void registerListener(){
|
||||
PlayerHotbarDropItemEvent.BACKEND.register(playerDropItemEvent -> {
|
||||
|
||||
Player player = playerDropItemEvent.getPlayer();
|
||||
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
|
||||
|
||||
if (!EventUtil.dropItem(minecraftPlayer, playerDropItemEvent.getItemStack())) {
|
||||
playerDropItemEvent.setCancelled(true);
|
||||
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,158 +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.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.ranks.NexiaRank;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.discord.Main;
|
||||
import com.nexia.discord.utilities.player.PlayerData;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.nexia.discord.Main.jda;
|
||||
import static com.nexia.ffa.classic.utilities.RatingUtil.checkRatingRank;
|
||||
|
||||
public class PlayerJoinListener {
|
||||
public static void registerListener() {
|
||||
PlayerJoinEvent.BACKEND.register(playerJoinEvent -> {
|
||||
|
||||
Player player = playerJoinEvent.getPlayer();
|
||||
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
|
||||
|
||||
processJoin(player, minecraftPlayer);
|
||||
|
||||
/*
|
||||
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(ServerPlayer player) {
|
||||
PlayerData playerData = com.nexia.discord.utilities.player.PlayerDataManager.get(player.getUUID());
|
||||
if(!playerData.savedData.isLinked) { return; }
|
||||
Member discordUser = null;
|
||||
|
||||
try {
|
||||
discordUser = Objects.requireNonNull(jda.getGuildById(Main.config.guildID)).retrieveMemberById(playerData.savedData.discordID).complete(true);
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
if(discordUser == null) {
|
||||
if(Permissions.check(player, "nexia.prefix.supporter")) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
NexiaRank.setPrefix(NexiaRank.DEFAULT, player);
|
||||
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
|
||||
return;
|
||||
}
|
||||
NexiaRank.setRank(NexiaRank.DEFAULT, player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Role supporterRole = jda.getRoleById("1107264322951979110");
|
||||
boolean hasRole = discordUser.getRoles().contains(supporterRole);
|
||||
boolean hasSupporterPrefix = Permissions.check(player, "nexia.prefix.supporter");
|
||||
|
||||
if(hasRole && !hasSupporterPrefix) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
NexiaRank.addPrefix(NexiaRank.SUPPORTER, player, true);
|
||||
return;
|
||||
}
|
||||
ServerTime.factoryServer.runCommand("/rank " + player.getScoreboardName() + " supporter", 4, false);
|
||||
} else if(!hasRole && hasSupporterPrefix) {
|
||||
if(Permissions.check(player, "nexia.rank")) {
|
||||
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
|
||||
NexiaRank.setPrefix(NexiaRank.DEFAULT, player);
|
||||
return;
|
||||
}
|
||||
NexiaRank.setRank(NexiaRank.DEFAULT, player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void processJoin(Player player, ServerPlayer minecraftPlayer) {
|
||||
if(PlayerDataManager.get(player).clientType.equals(com.nexia.core.utilities.player.PlayerData.ClientType.VIAFABRICPLUS)) return;
|
||||
|
||||
|
||||
com.nexia.ffa.classic.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
com.nexia.ffa.kits.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
com.nexia.ffa.sky.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
|
||||
com.nexia.discord.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer.getUUID());
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.football.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
|
||||
LobbyUtil.leaveAllGames(minecraftPlayer, true);
|
||||
checkBooster(minecraftPlayer);
|
||||
//checkRatingRank(minecraftPlayer);
|
||||
sendJoinMessage(player);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerDisconnectEvent;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.PlayerDataManager;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.duels.DuelGameHandler;
|
||||
import com.nexia.minigames.games.football.FootballGame;
|
||||
import com.nexia.minigames.games.oitc.OitcGame;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class PlayerLeaveListener {
|
||||
public static void registerListener() {
|
||||
PlayerDisconnectEvent.BACKEND.register(playerDisconnectEvent -> {
|
||||
|
||||
Player player = playerDisconnectEvent.getPlayer();
|
||||
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
|
||||
|
||||
processDisconnect(player, minecraftPlayer);
|
||||
|
||||
/*
|
||||
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(Player player, ServerPlayer minecraftPlayer){
|
||||
|
||||
if (BwUtil.isInBedWars(minecraftPlayer)) BwPlayerEvents.leaveInBedWars(minecraftPlayer);
|
||||
else if (FfaUtil.isFfaPlayer(minecraftPlayer)) {
|
||||
FfaUtil.leaveOrDie(minecraftPlayer, minecraftPlayer.getLastDamageSource(), true);
|
||||
}
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.LOBBY) DuelGameHandler.leave(minecraftPlayer, true);
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) SkywarsGame.leave(minecraftPlayer);
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.OITC) OitcGame.leave(minecraftPlayer);
|
||||
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.FOOTBALL) FootballGame.leave(minecraftPlayer);
|
||||
else if (minecraftPlayer.getTags().contains("duels")) DuelGameHandler.leave(minecraftPlayer, true);
|
||||
|
||||
com.nexia.ffa.classic.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.ffa.kits.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.ffa.sky.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
|
||||
com.nexia.discord.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer.getUUID());
|
||||
com.nexia.minigames.games.duels.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.football.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
|
||||
|
||||
//LobbyUtil.leaveAllGames(minecraftPlayer, true);
|
||||
|
||||
PlayerDataManager.removePlayerData(minecraftPlayer);
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package com.nexia.core.listeners.factory;
|
||||
|
||||
import com.combatreforged.factory.api.event.player.PlayerRespawnEvent;
|
||||
import com.combatreforged.factory.api.util.Identifier;
|
||||
import com.combatreforged.factory.api.world.entity.player.Player;
|
||||
import com.combatreforged.factory.api.world.types.Minecraft;
|
||||
import com.combatreforged.factory.api.world.util.Location;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.core.games.util.PlayerGameMode;
|
||||
import com.nexia.core.utilities.player.NexiaPlayer;
|
||||
import com.nexia.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.minigames.games.duels.DuelsGame;
|
||||
import com.nexia.minigames.games.duels.custom.CustomDuelsGame;
|
||||
import com.nexia.minigames.games.duels.custom.team.CustomTeamDuelsGame;
|
||||
import com.nexia.minigames.games.duels.team.TeamDuelsGame;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerData;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGame;
|
||||
import com.nexia.minigames.games.skywars.SkywarsGameMode;
|
||||
import com.nexia.core.utilities.world.WorldUtil;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PlayerRespawnListener {
|
||||
public static void registerListener(){
|
||||
PlayerRespawnEvent.BACKEND.register((respawnEvent) -> {
|
||||
Player factoryPlayer = respawnEvent.getPlayer();
|
||||
if(factoryPlayer == null && respawnEvent.getEntity() instanceof Player) {
|
||||
factoryPlayer = (Player) respawnEvent.getEntity();
|
||||
}
|
||||
|
||||
if(factoryPlayer == null) return;
|
||||
|
||||
ServerPlayer player = ServerTime.minecraftServer.getPlayerList().getPlayer(factoryPlayer.getUUID());
|
||||
if(player == null) return;
|
||||
|
||||
PlayerData duelsData = PlayerDataManager.get(player);
|
||||
com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player);
|
||||
|
||||
if(duelsData.gameOptions == null) return;
|
||||
|
||||
DuelsGame duelsGame = duelsData.gameOptions.duelsGame;
|
||||
TeamDuelsGame teamDuelsGame = duelsData.gameOptions.teamDuelsGame;
|
||||
|
||||
CustomDuelsGame customDuelsGame = duelsData.gameOptions.customDuelsGame;
|
||||
CustomTeamDuelsGame customTeamDuelsGame = duelsData.gameOptions.customTeamDuelsGame;
|
||||
|
||||
|
||||
if(data.gameMode == PlayerGameMode.SKYWARS) {
|
||||
Location respawn = new Location(0,100, 0, WorldUtil.getWorld(SkywarsGame.world));
|
||||
|
||||
boolean isPlaying = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(player).gameMode == SkywarsGameMode.PLAYING;
|
||||
ServerPlayer serverPlayer = PlayerUtil.getPlayerAttacker(player);
|
||||
if(serverPlayer != null && serverPlayer != player && isPlaying) {
|
||||
respawn.setX(serverPlayer.getX());
|
||||
respawn.setY(serverPlayer.getY());
|
||||
respawn.setZ(serverPlayer.getZ());
|
||||
}
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(respawn);
|
||||
return;
|
||||
}
|
||||
|
||||
if(duelsGame != null && duelsGame.isEnding && duelsGame.winner != null) {
|
||||
factoryPlayer.getInventory().clear();
|
||||
LobbyUtil.giveItems(player);
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.get().getX(), duelsGame.winner.get().getY(), duelsGame.winner.get().getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(duelsGame.level).getId()))));
|
||||
} else if(teamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
|
||||
factoryPlayer.getInventory().clear();
|
||||
LobbyUtil.giveItems(player);
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
|
||||
Location respawn = new Location(0,80, 0, ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(teamDuelsGame.level).getId())));
|
||||
|
||||
ServerPlayer player1 = null;
|
||||
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
|
||||
if(teamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team2.alive.isEmpty()) {
|
||||
player1 = teamDuelsGame.team2.alive.get(new Random().nextInt(teamDuelsGame.team2.alive.size())).get();
|
||||
} else if(teamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team1.alive.isEmpty()){
|
||||
player1 = teamDuelsGame.team1.alive.get(new Random().nextInt(teamDuelsGame.team1.alive.size())).get();
|
||||
}
|
||||
|
||||
if(player1 != null) {
|
||||
respawn.setX(player1.getX());
|
||||
respawn.setY(player1.getY());
|
||||
respawn.setZ(player1.getZ());
|
||||
}
|
||||
|
||||
} else {
|
||||
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size())).get();
|
||||
}
|
||||
|
||||
|
||||
respawnEvent.setSpawnpoint(respawn);
|
||||
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
|
||||
} else if(customDuelsGame != null && customDuelsGame.isEnding && customDuelsGame.winner != null) {
|
||||
factoryPlayer.getInventory().clear();
|
||||
LobbyUtil.giveItems(player);
|
||||
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
respawnEvent.setSpawnpoint(new Location(customDuelsGame.winner.get().getX(), customDuelsGame.winner.get().getY(), customDuelsGame.winner.get().getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customDuelsGame.level).getId()))));
|
||||
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
|
||||
} else if(customTeamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
|
||||
factoryPlayer.getInventory().clear();
|
||||
LobbyUtil.giveItems(player);
|
||||
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
|
||||
|
||||
Location respawn = new Location(0,80, 0, ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customTeamDuelsGame.level).getId())));
|
||||
|
||||
ServerPlayer player1 = null;
|
||||
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
|
||||
if(customTeamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team2.alive.isEmpty()) {
|
||||
player1 = customTeamDuelsGame.team2.alive.get(new Random().nextInt(customTeamDuelsGame.team2.alive.size())).get();
|
||||
} else if (customTeamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team1.alive.isEmpty()) {
|
||||
player1 = customTeamDuelsGame.team1.alive.get(new Random().nextInt(customTeamDuelsGame.team1.alive.size())).get();
|
||||
}
|
||||
|
||||
if(player1 != null) {
|
||||
respawn.setX(player1.getX());
|
||||
respawn.setY(player1.getY());
|
||||
respawn.setZ(player1.getZ());
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size())).get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
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,56 @@
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.nexia.core.listeners.nexus;
|
||||
|
||||
import com.nexia.nexus.api.event.player.PlayerHotbarDropItemEvent;
|
||||
import com.nexia.core.utilities.misc.EventUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
|
||||
public class PlayerDropItemListener {
|
||||
public void registerListener(){
|
||||
PlayerHotbarDropItemEvent.BACKEND.register(playerDropItemEvent -> {
|
||||
NexiaPlayer player = new NexiaPlayer(playerDropItemEvent.getPlayer());
|
||||
|
||||
if (!EventUtil.dropItem(player, playerDropItemEvent.getItemStack())) {
|
||||
playerDropItemEvent.setCancelled(true);
|
||||
player.refreshInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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,141 @@
|
||||
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 java.util.concurrent.CompletableFuture;
|
||||
|
||||
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);
|
||||
|
||||
if (!player.getTags().contains("bot"))
|
||||
CompletableFuture.runAsync(() -> 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,34 @@
|
||||
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;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class PlayerLeaveListener {
|
||||
public void registerListener() {
|
||||
PlayerDisconnectEvent.BACKEND.register(playerDisconnectEvent -> {
|
||||
NexiaPlayer player = new NexiaPlayer(playerDisconnectEvent.getPlayer());
|
||||
player.leaveAllGames();
|
||||
|
||||
//setLeaveMessage(player, playerDisconnectEvent);
|
||||
|
||||
if (!player.getTags().contains("bot"))
|
||||
CompletableFuture.runAsync(() -> 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+11
-14
@@ -1,28 +1,25 @@
|
||||
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.entity.player.Player;
|
||||
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.core.utilities.player.PlayerUtil;
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class UseItemListener {
|
||||
public static void registerListener() {
|
||||
public class PlayerUseItemListener {
|
||||
public void registerListener() {
|
||||
PlayerUseItemEvent.BACKEND.register(playerUseItemEvent -> {
|
||||
|
||||
Player player = playerUseItemEvent.getPlayer();
|
||||
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
|
||||
NexiaPlayer player = new NexiaPlayer(playerUseItemEvent.getPlayer());
|
||||
|
||||
ItemStack itemStack = playerUseItemEvent.getItemStack();
|
||||
|
||||
Component name = itemStack.getDisplayName();
|
||||
|
||||
PlayerGameMode gameMode = PlayerDataManager.get(minecraftPlayer).gameMode;
|
||||
|
||||
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode;
|
||||
String sName = name.toString().toLowerCase();
|
||||
|
||||
if(gameMode == PlayerGameMode.LOBBY) {
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.nexia.core.loader;
|
||||
|
||||
import com.nexia.nexus.api.command.CommandSourceInfo;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.nexia.core.commands.player.*;
|
||||
import com.nexia.core.commands.player.duels.*;
|
||||
import com.nexia.core.commands.player.duels.custom.CustomDuelCommand;
|
||||
@@ -7,6 +9,7 @@ import com.nexia.core.commands.player.duels.custom.KitEditorCommand;
|
||||
import com.nexia.core.commands.player.ffa.KitCommand;
|
||||
import com.nexia.core.commands.staff.*;
|
||||
import com.nexia.core.commands.staff.dev.*;
|
||||
import com.nexia.core.utilities.time.ServerTime;
|
||||
import com.nexia.discord.commands.minecraft.LinkCommand;
|
||||
import com.nexia.discord.commands.minecraft.UnLinkCommand;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
@@ -14,57 +17,64 @@ import net.fabricmc.fabric.api.event.Event;
|
||||
|
||||
public class CommandLoader {
|
||||
|
||||
public static void registerNexusCommands() {
|
||||
CommandDispatcher<CommandSourceInfo> commandDispatcher = ServerTime.nexusServer.getCommandDispatcher();
|
||||
|
||||
HelpCommand.register(commandDispatcher);
|
||||
DiscordCommand.register(commandDispatcher);
|
||||
LeaveCommand.register(commandDispatcher);
|
||||
PrefixCommand.register(commandDispatcher);
|
||||
RankCommand.register(commandDispatcher);
|
||||
LinkCommand.register(commandDispatcher);
|
||||
PingCommand.register(commandDispatcher);
|
||||
SpectateCommand.register(commandDispatcher);
|
||||
PartyCommand.register(commandDispatcher);
|
||||
TempBanCommand.register(commandDispatcher);
|
||||
ShoutCommand.register(commandDispatcher);
|
||||
RanksCommand.register(commandDispatcher);
|
||||
UnTempBanCommand.register(commandDispatcher);
|
||||
UnLinkCommand.register(commandDispatcher);
|
||||
GamemodeBanCommand.register(commandDispatcher);
|
||||
UnGamemodeBanCommand.register(commandDispatcher);
|
||||
DeclineDuelCommand.register(commandDispatcher);
|
||||
AcceptDuelCommand.register(commandDispatcher);
|
||||
StaffPrefixCommand.register(commandDispatcher);
|
||||
KitEditorCommand.register(commandDispatcher);
|
||||
KitLayoutCommand.register(commandDispatcher);
|
||||
CustomDuelCommand.register(commandDispatcher);
|
||||
StaffReportCommand.register(commandDispatcher);
|
||||
ListInventoriesCommand.register(commandDispatcher);
|
||||
DuelCommand.register(commandDispatcher);
|
||||
QueueCommand.register(commandDispatcher);
|
||||
MapCommand.register(commandDispatcher);
|
||||
MuteCommand.register(commandDispatcher);
|
||||
UnMuteCommand.register(commandDispatcher);
|
||||
PlayCommand.register(commandDispatcher);
|
||||
KitCommand.register(commandDispatcher);
|
||||
BanCommand.register(commandDispatcher);
|
||||
UnBanCommand.register(commandDispatcher);
|
||||
StatsCommand.register(commandDispatcher);
|
||||
RulesCommand.register(commandDispatcher);
|
||||
ReportCommand.register(commandDispatcher);
|
||||
SprintFixCommand.register(commandDispatcher);
|
||||
MessageCommand.registerMsg(commandDispatcher);
|
||||
MessageCommand.registerReply(commandDispatcher);
|
||||
HealCommand.register(commandDispatcher);
|
||||
DetectCommand.register(commandDispatcher);
|
||||
SudoCommand.register(commandDispatcher);
|
||||
}
|
||||
|
||||
public static void registerCommands() {
|
||||
Event<CommandRegistrationCallback> callbackEvent = CommandRegistrationCallback.EVENT;
|
||||
|
||||
callbackEvent.register(SprintFixCommand::register);
|
||||
callbackEvent.register(DiscordCommand::register);
|
||||
callbackEvent.register(LeaveCommand::register);
|
||||
callbackEvent.register(ProtectionMapCommand::register);
|
||||
callbackEvent.register(PrefixCommand::register);
|
||||
callbackEvent.register(RankCommand::register);
|
||||
callbackEvent.register(LinkCommand::register);
|
||||
callbackEvent.register(PingCommand::register);
|
||||
callbackEvent.register(ForceGameEndCommand::register);
|
||||
callbackEvent.register(SpectateCommand::register);
|
||||
callbackEvent.register(PartyCommand::register);
|
||||
callbackEvent.register(TempBanCommand::register);
|
||||
callbackEvent.register(ShoutCommand::register);
|
||||
callbackEvent.register(RanksCommand::register);
|
||||
callbackEvent.register(UnTempBanCommand::register);
|
||||
callbackEvent.register(UnLinkCommand::register);
|
||||
callbackEvent.register(GamemodeBanCommand::register);
|
||||
callbackEvent.register(UnGamemodeBanCommand::register);
|
||||
callbackEvent.register(AcceptDuelCommand::register);
|
||||
callbackEvent.register(DeclineDuelCommand::register);
|
||||
callbackEvent.register(StaffPrefixCommand::register);
|
||||
callbackEvent.register(ProtectionMapCommand::register);
|
||||
callbackEvent.register(DevExperimentalCommandsCommand::register);
|
||||
callbackEvent.register(LoadInventoryCommand::register);
|
||||
callbackEvent.register(SaveInventoryCommand::register);
|
||||
callbackEvent.register(ListInventoriesCommand::register);
|
||||
callbackEvent.register(DeleteInventoryCommand::register);
|
||||
callbackEvent.register(KitEditorCommand::register);
|
||||
callbackEvent.register(KitLayoutCommand::register);
|
||||
callbackEvent.register(CustomDuelCommand::register);
|
||||
callbackEvent.register(StaffReportCommand::register);
|
||||
callbackEvent.register(DuelCommand::register);
|
||||
callbackEvent.register(QueueCommand::register);
|
||||
callbackEvent.register(MapCommand::register);
|
||||
callbackEvent.register(MuteCommand::register);
|
||||
callbackEvent.register(UnMuteCommand::register);
|
||||
callbackEvent.register(PlayCommand::register);
|
||||
callbackEvent.register(KitCommand::register);
|
||||
callbackEvent.register(BanCommand::register);
|
||||
callbackEvent.register(UnBanCommand::register);
|
||||
callbackEvent.register(StatsCommand::register);
|
||||
callbackEvent.register(RulesCommand::register);
|
||||
callbackEvent.register(HelpCommand::register);
|
||||
callbackEvent.register(ReportCommand::register);
|
||||
callbackEvent.register(MessageCommand::registerMsg);
|
||||
callbackEvent.register(MessageCommand::registerReply);
|
||||
callbackEvent.register(RandomCommand::register);
|
||||
callbackEvent.register(HealCommand::register);
|
||||
callbackEvent.register(BwReloadShopCommand::register);
|
||||
callbackEvent.register(RandomCommand::register);
|
||||
callbackEvent.register(BwReloadTeamColorsCommand::register);
|
||||
callbackEvent.register(SkipQueueCommand::register);
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import com.nexia.minigames.games.bedwars.util.BwUtil;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerData;
|
||||
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.AnvilBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AnvilBlock.class)
|
||||
public class AnvilBlockMixin {
|
||||
|
||||
@Inject(method = "use", cancellable = true, at = @At("HEAD"))
|
||||
private void use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
if (!(player instanceof ServerPlayer serverPlayer)) return;
|
||||
PlayerData playerData = PlayerDataManager.get(serverPlayer);
|
||||
|
||||
if (BwUtil.isInBedWars(serverPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null || playerData.gameOptions.customDuelsGame != null || playerData.gameOptions.customTeamDuelsGame != null)) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaUtil.isFfaPlayer(player) && !serverPlayer.isCreative())) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BeaconBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BeaconBlock.class)
|
||||
public class BeaconBlockMixin {
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
if(!(player instanceof ServerPlayer))
|
||||
return;
|
||||
|
||||
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.ffa.sky.utilities.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,7 +1,9 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
@@ -33,7 +35,7 @@ public abstract class ChestBlockEntityMixin extends BlockEntity {
|
||||
|
||||
@Inject(method = "startOpen", at = @At("HEAD"))
|
||||
public void onOpen(Player player, CallbackInfo ci) {
|
||||
if (KitRoom.isInKitRoom(player)) {
|
||||
if (KitRoom.isInKitRoom(new NexiaPlayer((ServerPlayer) player))) {
|
||||
nbtList.put(player.getUUID(), new CompoundTag());
|
||||
this.save(nbtList.get(player.getUUID()));
|
||||
}
|
||||
@@ -41,7 +43,7 @@ public abstract class ChestBlockEntityMixin extends BlockEntity {
|
||||
|
||||
@Inject(method = "stopOpen", at = @At("HEAD"))
|
||||
public void onClose(Player player, CallbackInfo ci) {
|
||||
if (KitRoom.isInKitRoom(player)) {
|
||||
if (KitRoom.isInKitRoom(new NexiaPlayer((ServerPlayer) player))) {
|
||||
BlockState blockState = this.getBlockState();
|
||||
if(blockState.getBlock() instanceof ChestBlock) {
|
||||
this.load(blockState, nbtList.get(player.getUUID()));
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.CraftingTableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(CraftingTableBlock.class)
|
||||
public class CraftingTableMixin {
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
if(!(player instanceof ServerPlayer))
|
||||
return;
|
||||
|
||||
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.ffa.FfaUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(DispenserBlock.class)
|
||||
public class DispenserBlockMixin {
|
||||
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||
public void onUse(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
if(!(player instanceof ServerPlayer))
|
||||
return;
|
||||
|
||||
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); }
|
||||
}
|
||||
}
|
||||
+14
-10
@@ -1,18 +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.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;
|
||||
@@ -20,16 +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;
|
||||
PlayerData playerData = PlayerDataManager.get(serverPlayer);
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
|
||||
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(nexiaPlayer);
|
||||
|
||||
if (BwUtil.isInBedWars(serverPlayer) || KitRoom.isInKitRoom(player) || (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+10
-13
@@ -1,16 +1,16 @@
|
||||
package com.nexia.core.mixin.block;
|
||||
|
||||
import com.nexia.base.player.NexiaPlayer;
|
||||
import com.nexia.core.games.util.LobbyUtil;
|
||||
import com.nexia.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;
|
||||
@@ -18,18 +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;
|
||||
PlayerData playerData = PlayerDataManager.get(serverPlayer);
|
||||
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
|
||||
|
||||
if (BwUtil.isInBedWars(serverPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null || playerData.gameOptions.customTeamDuelsGame != null || playerData.gameOptions.customDuelsGame != null)) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel())) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
return;
|
||||
if ((FfaUtil.isFfaPlayer(nexiaPlayer) || KitRoom.isInKitRoom(nexiaPlayer) || LobbyUtil.isLobbyWorld(nexiaPlayer.getWorld())) && !player.isCreative()) {
|
||||
cir.setReturnValue(InteractionResult.PASS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loaded 100 of 282 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user