Skip to content

Commit

Permalink
fortnite basba j
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Dec 28, 2023
1 parent 053524d commit 92c68a6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/nexia/core/commands/player/PlayCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo
dispatcher.register(Commands.literal("play").executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").executes(PlayCommand::openGUI)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("pot").executes(PlayCommand::playPotFFA))
.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))
Expand All @@ -27,7 +27,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo
dispatcher.register(Commands.literal("join").executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").executes(PlayCommand::openGUI)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("pot").executes(PlayCommand::playPotFFA))
.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))
Expand Down Expand Up @@ -63,9 +63,9 @@ private static int playUhcFFA(CommandContext<CommandSourceStack> context) throws
return 1;
}

private static int playPotFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
private static int playSkyFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "pot ffa", true, true);
LobbyUtil.sendGame(player, "sky ffa", true, true);
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private void setPlayer(Level level, Player player, InteractionHand interactionHa
if (player instanceof ServerPlayer serverPlayer) {
thrower = serverPlayer;

if (FfaAreas.isFfaWorld(serverPlayer.getLevel()) && !FfaSkyUtil.wasInSpawn.contains(serverPlayer.getUUID())) {
if (FfaAreas.isFfaWorld(serverPlayer.getLevel()) && FfaSkyUtil.wasInSpawn.contains(serverPlayer.getUUID())) {
cir.setReturnValue(InteractionResultHolder.pass(serverPlayer.getItemInHand(interactionHand)));
InventoryUtil.sendHandItemPacket(serverPlayer, interactionHand);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.nexia.core.utilities.player.BanHandler;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.sky.utilities.FfaSkyUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
Expand Down Expand Up @@ -65,6 +66,11 @@ private void respawned(ServerPlayer oldPlayer, boolean bl, CallbackInfoReturnabl

ServerLevel respawn = ServerTime.minecraftServer.getLevel(player.getRespawnDimension());

if(FfaSkyUtil.isFfaPlayer(player)) {
FfaSkyUtil.joinOrRespawn(player);
return;
}

if(respawn != null && LobbyUtil.isLobbyWorld(respawn)) {
player.inventory.clearContent();
LobbyUtil.giveItems(player);
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/nexia/ffa/sky/utilities/FfaAreas.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.nexia.ffa.sky.utilities;

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.pos.*;
import com.nexia.ffa.Main;
import net.kyori.adventure.text.Component;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.server.MinecraftServer;
Expand All @@ -20,11 +23,15 @@
public class FfaAreas {
public static ServerLevel ffaWorld = null;
public static EntityPos spawn = new EntityPos(Main.sky.spawnCoordinates[0], Main.sky.spawnCoordinates[1], Main.sky.spawnCoordinates[2], 0, 0);

private static final int mapRadius = 30;

public static final int buildLimitY = 80;
public static BlockPos spawnCorner1 = spawn.toBlockPos().offset(-6, -5, -6);
public static BlockPos spawnCorner2 = spawn.toBlockPos().offset(6, 5, 6);

public static BlockPos ffaCorner1 = spawn.toBlockPos().offset(25, -spawn.y, 25);
public static BlockPos ffaCorner2 = spawn.toBlockPos().offset(-25, spawn.y + 255, -25);
public static BlockPos ffaCorner1 = spawn.toBlockPos().offset(-mapRadius, -spawn.y, -mapRadius);
public static BlockPos ffaCorner2 = spawn.toBlockPos().offset(mapRadius, spawn.y + 255, mapRadius);

public FfaAreas() {
}
Expand Down Expand Up @@ -59,7 +66,7 @@ public static float getVoidY() {

public static boolean canBuild(ServerPlayer player, BlockPos blockPos) {
if (protectionMap == null) {
player.sendMessage(LegacyChatFormat.formatFail("Something went wrong, please inform the developers."), Util.NIL_UUID);
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("Something went wrong, please inform the admins").color(ChatFormat.failColor));
return false;
}

Expand All @@ -69,10 +76,11 @@ public static boolean canBuild(ServerPlayer player, BlockPos blockPos) {
private static final String protMapPath = FfaSkyUtil.ffaSkyDir + "/protectionMap.json";

private static final ProtectionBlock[] protMapBlocks = {
new ProtectionBlock(Blocks.AIR, true, null)
new ProtectionBlock(Blocks.AIR, true, null),
new ProtectionBlock(Blocks.VOID_AIR, true, null)
};
private static final ProtectionBlock notListedBlock =
new ProtectionBlock(null, false, "You can't build here.");
new ProtectionBlock(null, false, "You can only break blocks placed by players.");
private static final String outsideMessage = "You can't build here.";

public static ProtectionMap protectionMap = ProtectionMap.importMap(
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.nexia.ffa.sky.utilities;

import com.combatreforged.factory.api.world.entity.player.Player;
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.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.item.ItemStackUtil;
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;
Expand All @@ -21,7 +20,6 @@
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
Expand All @@ -31,11 +29,9 @@
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
import net.minecraft.world.entity.projectile.ThrownExperienceBottle;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -457,6 +453,10 @@ private static ItemStack gApplePotion() {

public static boolean beforeBuild(ServerPlayer player, BlockPos blockPos) {
if (player.isCreative()) return true;
if (wasInSpawn.contains(player.getUUID()) || blockPos.getY() >= buildLimitY) {
InventoryUtil.sendHandItemPacket(player, player.getUsedItemHand());
return false;
}
return FfaAreas.canBuild(player, blockPos);
}

Expand Down

0 comments on commit 92c68a6

Please sign in to comment.