Skip to content

Commit

Permalink
Refactoring is crazy work
Browse files Browse the repository at this point in the history
  • Loading branch information
Stunf committed Jul 31, 2024
1 parent 952118f commit 79f2802
Show file tree
Hide file tree
Showing 61 changed files with 576 additions and 583 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/nexia/base/player/NexiaPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
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.bedwars.players.BedwarsPlayerEvents;
import com.nexia.minigames.games.bedwars.util.BedwarsScoreboard;
import com.nexia.minigames.games.bedwars.util.BedwarsUtil;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
Expand Down Expand Up @@ -150,8 +150,8 @@ public boolean hasEffect(Minecraft.Effect effect) {
}

public void leaveAllGames() {
if (BwUtil.isInBedWars(this)) {
BwPlayerEvents.leaveInBedWars(this);
if (BedwarsUtil.isInBedWars(this)) {
BedwarsPlayerEvents.leaveInBedWars(this);
} else if (FfaUtil.isFfaPlayer(this)) {
FfaUtil.leaveOrDie(this, this.unwrap().getLastDamageSource(), true);
} else if (this.isInGameMode(PlayerGameMode.LOBBY)) {
Expand All @@ -166,7 +166,7 @@ public void leaveAllGames() {

// sometimes those do not get removed
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, this, true);
BwScoreboard.removeScoreboardFor(this);
BedwarsScoreboard.removeScoreboardFor(this);

for (String tag : LobbyUtil.removedTags) {
if (this.hasTag(tag)) this.removeTag(tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.minigames.games.bedwars.shop.BwLoadShop;
import com.nexia.minigames.games.bedwars.shop.BedwarsLoadShop;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
Expand All @@ -19,7 +19,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo

public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {

boolean success = BwLoadShop.loadBedWarsShop(false);
boolean success = BedwarsLoadShop.loadBedWarsShop(false);

if (success) {
String message = LegacyChatFormat.brandColor1 + "Reloaded Bedwars shop successfully!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.minigames.games.bedwars.players.BwTeam;
import com.nexia.minigames.games.bedwars.players.BedwarsTeam;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
Expand All @@ -18,7 +18,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo
}

public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
BwTeam.reloadPlayerTeamColors();
BedwarsTeam.reloadPlayerTeamColors();
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.minigames.games.bedwars.BwGame;
import com.nexia.minigames.games.bedwars.BedwarsGame;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
Expand Down Expand Up @@ -38,7 +38,7 @@ private static int run(CommandContext<CommandSourceStack> context) {
case "football" -> FootballGame.endGame(null);
case "oitc" -> OitcGame.endGame(null);
case "skywars" -> SkywarsGame.winNearestCenter();
case "bedwars" -> BwGame.endBedwars();
case "bedwars" -> BedwarsGame.endBedwars();
default -> {
context.getSource().sendFailure(new TextComponent("Invalid game!"));
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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 com.nexia.minigames.games.bedwars.areas.BedwarsAreas;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
Expand All @@ -25,7 +25,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo

public static int bedwars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
BwAreas.createProtectionMap(player);
BedwarsAreas.createProtectionMap(player);
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.CorePlayerData;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.bedwars.util.BedwarsUtil;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
Expand Down Expand Up @@ -88,7 +88,7 @@ private static int oitc(CommandContext<CommandSourceStack> context) throws Comma
private static int bedwars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();

if (BwUtil.skipQueue()) {
if (BedwarsUtil.skipQueue()) {
player.sendMessage(new TextComponent("Skipped queue"), Util.NIL_UUID);
} else {
player.sendMessage(new TextComponent("Epic queue skip failure"), Util.NIL_UUID);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/nexia/core/games/util/LobbyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.nexia.core.utilities.world.WorldUtil;
import com.nexia.ffa.base.BaseFfaUtil;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.bedwars.players.BedwarsPlayerEvents;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.football.FootballGameMode;
Expand Down Expand Up @@ -142,6 +142,7 @@ public static void giveItems(NexiaPlayer player) {

com.nexia.nexus.api.world.item.ItemStack queueSword = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.IRON_SWORD);
queueSword.setItemNBT(hideAttrubtesNBTObject.copy());
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)
Expand All @@ -151,6 +152,7 @@ public static void giveItems(NexiaPlayer player) {

com.nexia.nexus.api.world.item.ItemStack teamSword = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.IRON_AXE);
teamSword.setItemNBT(hideAttrubtesNBTObject.copy());
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)
Expand All @@ -160,6 +162,7 @@ public static void giveItems(NexiaPlayer player) {

com.nexia.nexus.api.world.item.ItemStack customDuelSword = com.nexia.nexus.api.world.item.ItemStack.create(Minecraft.Item.DIAMOND_SWORD);
customDuelSword.setItemNBT(hideAttrubtesNBTObject.copy());
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));

Expand Down Expand Up @@ -276,7 +279,7 @@ public static void sendGame(NexiaPlayer player, String game, boolean message, bo

if (game.equalsIgnoreCase("bedwars")) {
if(message){ player.sendActionBarMessage(Component.text("You have joined §b\uD83E\uDE93 §c§lBedwars §e⚡"));}
BwPlayerEvents.tryToJoin(player, false);
BedwarsPlayerEvents.tryToJoin(player, false);
}

if (game.equalsIgnoreCase("duels")) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/nexia/core/games/util/PlayerGameMode.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.nexia.core.games.util;

import com.nexia.minigames.games.bedwars.players.BwPlayers;
import com.nexia.minigames.games.bedwars.players.BedwarsPlayers;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
Expand All @@ -21,15 +21,13 @@ public class PlayerGameMode {
public String tag;

public static final PlayerGameMode LOBBY = new PlayerGameMode("lobby", "Hub", LobbyUtil.NO_DAMAGE_TAG);
public static final PlayerGameMode BEDWARS = new PlayerGameMode("bedwars", "Bedwars", BwPlayers.BED_WARS_IN_GAME_TAG);
public static final PlayerGameMode BEDWARS = new PlayerGameMode("bedwars", "Bedwars", BedwarsPlayers.BED_WARS_IN_GAME_TAG);

public static final PlayerGameMode SKYWARS = new PlayerGameMode("skywars", "Skywars", SkywarsGame.SKYWARS_TAG);
public static final PlayerGameMode OITC = new PlayerGameMode("oitc", "OITC", OitcGame.OITC_TAG);
public static final PlayerGameMode FFA = new PlayerGameMode("ffa", "FFA", "ffa");
public static final PlayerGameMode FOOTBALL = new PlayerGameMode("football", "Football", FootballGame.FOOTBALL_TAG);

//public static final PlayerGameMode DUELS = new PlayerGameMode("duels");

PlayerGameMode(String id, String name, String tag) {
this.id = id;
this.name = name;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/nexia/core/gui/PlayGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.nexia.base.player.NexiaPlayer;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.classic.utilities.ClassicFfaAreas;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.areas.BedwarsAreas;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
Expand Down Expand Up @@ -68,7 +68,7 @@ private void setMainLayout(){
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);

Expand All @@ -77,11 +77,11 @@ private void setMainLayout(){
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("destroy other opponent's beds, and", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 2);
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text("kill your opponents to win!", ChatFormat.Minecraft.gray).decoration(ChatFormat.italic, false), 3);
ItemDisplayUtil.addLore(bedwars, "§f", 4);
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", BwAreas.bedWarsWorld.players().size()), ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false), 5);
ItemDisplayUtil.addLore(bedwars, net.kyori.adventure.text.Component.text(String.format("There are %s people playing this gamemode.", BedwarsAreas.bedWarsWorld.players().size()), ChatFormat.Minecraft.red).decoration(ChatFormat.italic, false), 5);


ItemStack skywars = new ItemStack(Items.GRASS_BLOCK, 1);
skywars.setHoverName(ObjectMappings.convertComponent(net.kyori.adventure.text.Component.text("SkyWars", ChatFormat.Minecraft.green).decoration(ChatFormat.italic, false)));
skywars.setHoverName(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void registerListener() {

private static void processDisconnect(NexiaPlayer player){
/*
if (BwUtil.isInBedWars(player)) BwPlayerEvents.leaveInBedWars(player);
if (BedwarsUtil.isInBedWars(player)) BedwarsPlayerEvents.leaveInBedWars(player);
else if (FfaUtil.isFfaPlayer(player)) {
FfaUtil.leaveOrDie(player, player.getLastDamageSource(), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ public void registerListener() {
return;
}

if(data.gameMode == PlayerGameMode.BEDWARS)
respawnEvent.setRespawnMode(Minecraft.GameMode.SURVIVAL);

if(data.gameMode == PlayerGameMode.OITC)
respawnEvent.setRespawnMode(Minecraft.GameMode.ADVENTURE);

if(duelsGame != null && duelsGame.isEnding && duelsGame.winner != null) {
player.getInventory().clear();
LobbyUtil.giveItems(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@ public void registerListener() {

if(gameMode == PlayerGameMode.LOBBY) {
if(sName.contains("gamemode selector")){
//PlayGUI.openMainGUI(minecraftPlayer);
player.runCommand("/play", 0, false);
return;
}

if(sName.contains("prefix selector")){
//PrefixGUI.openRankGUI(minecraftPlayer);
player.runCommand("/prefix", 0, false);
return;
}

if(sName.contains("duel sword") && !sName.contains("custom duel sword")) {
//QueueGUI.openQueueGUI(minecraftPlayer);
player.runCommand("/queue", 0, false);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/nexia/core/mixin/block/BlockMixin.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.nexia.core.mixin.block;

import com.nexia.ffa.sky.utilities.FfaSkyUtil;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.bedwars.areas.BedwarsAreas;
import com.nexia.minigames.games.bedwars.util.BedwarsUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
Expand All @@ -25,7 +25,7 @@ public class BlockMixin {
private static void dropResources(BlockState blockState, Level level, BlockPos blockPos, BlockEntity blockEntity, Entity breakerEntity, ItemStack tool, CallbackInfo ci) {
if (!(level instanceof ServerLevel serverLevel)) return;

if ((BwAreas.isBedWarsWorld(serverLevel) && !(BwUtil.dropResources(blockState))) || FfaSkyUtil.INSTANCE.isFfaWorld(serverLevel)) {
if ((BedwarsAreas.isBedWarsWorld(serverLevel) && !(BedwarsUtil.dropResources(blockState))) || FfaSkyUtil.INSTANCE.isFfaWorld(serverLevel)) {
ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.nexia.core.NexiaCore;
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.bedwars.util.BedwarsUtil;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
import com.nexia.minigames.games.duels.util.player.DuelsPlayerData;
import net.minecraft.core.BlockPos;
Expand All @@ -31,7 +31,7 @@ private void use(BlockState blockState, Level level, BlockPos blockPos, Player p
NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer);
DuelsPlayerData playerData = (DuelsPlayerData) PlayerDataManager.getDataManager(NexiaCore.DUELS_DATA_MANAGER).get(nexiaPlayer);

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()) {
if ((FfaUtil.isFfaPlayer(nexiaPlayer) || KitRoom.isInKitRoom(nexiaPlayer) || BedwarsUtil.isInBedWars(nexiaPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null)) || LobbyUtil.isLobbyWorld(nexiaPlayer.getWorld())) && !player.isCreative()) {
cir.setReturnValue(InteractionResult.FAIL);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.nexia.core.mixin.entity;

import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.areas.BedwarsAreas;
import com.nexia.minigames.games.oitc.OitcGame;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.projectile.AbstractArrow;
Expand All @@ -20,7 +20,7 @@ private int modifyArrowDamage(double vanillaCalculated) {

ServerLevel level = (ServerLevel) ((AbstractArrow)(Object)this).level;

if (BwAreas.isBedWarsWorld(level)) {
if (BedwarsAreas.isBedWarsWorld(level)) {
vanillaCalculated *= 0.625;
}

Expand All @@ -38,7 +38,7 @@ private long modifyCritDamage(long vanillaCalculated, long intMaxValue) {

ServerLevel level = (ServerLevel) ((AbstractArrow)(Object)this).level;

if (BwAreas.isBedWarsWorld(level)) {
if (BedwarsAreas.isBedWarsWorld(level)) {
long critBoost = arrowDamage / 4 + 1;
arrowDamage = (int)Math.min(arrowDamage + critBoost, Integer.MAX_VALUE);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nexia.core.mixin.entity;

import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.bedwars.areas.BedwarsAreas;
import com.nexia.minigames.games.bedwars.util.BedwarsUtil;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.projectile.AbstractHurtingProjectile;
Expand All @@ -22,8 +22,8 @@ public AbstractHurtingProjectileMixin(EntityType<?> entityType, Level level) {
// Slow down fireballs
@Inject(method = "getInertia", cancellable = true, at = @At("HEAD"))
private void getInertia(CallbackInfoReturnable<Float> cir) {
if (BwAreas.isBedWarsWorld(level) && (Object)this instanceof LargeFireball) {
cir.setReturnValue(BwUtil.getFireballInertia());
if (BedwarsAreas.isBedWarsWorld(level) && (Object)this instanceof LargeFireball) {
cir.setReturnValue(BedwarsUtil.getFireballInertia());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/nexia/core/mixin/entity/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public void push(Entity entity) {

d *= 0.05000000074505806;
e *= 0.05000000074505806;
d *= (double)(1.0F - this.pushthrough);
e *= (double)(1.0F - this.pushthrough);
d *= 1.0F - this.pushthrough;
e *= 1.0F - this.pushthrough;

/* if (!this.isVehicle()) {
this.push(-d, 0.0, -e);
Expand Down
Loading

0 comments on commit 79f2802

Please sign in to comment.