Skip to content

Commit

Permalink
battle royale
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Jan 3, 2024
1 parent 08fdd92 commit 041463f
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo
"queue" + commandSeparator + "queue for a gamemode in duels",
"spectate" + commandSeparator + "spectate a player which is in duels (or ffa if you have supporter rank)",
"buy" + commandSeparator + "buy our ranks to support the server",
"shout" + commandSeparator + "shout a message to the whole server (supporter++)"
"shout" + commandSeparator + "shout a message to the whole server (supporter)"
};

public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/com/nexia/core/commands/player/PlayCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PlayCommand {

public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("play").executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").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))
Expand All @@ -25,7 +25,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo
.then(Commands.literal("oitc").executes(PlayCommand::playOITC))
.then(Commands.literal("bw").executes(PlayCommand::playBedWars)));
dispatcher.register(Commands.literal("join").executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").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))
Expand All @@ -37,14 +37,23 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo
.then(Commands.literal("bw").executes(PlayCommand::playBedWars))
.then(Commands.literal("oitc").executes(PlayCommand::playOITC))
);
dispatcher.register(Commands.literal("ffa").executes(PlayCommand::playNormalFFA));
dispatcher.register(Commands.literal("ffa").executes(PlayCommand::openFFAGui)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("sky").executes(PlayCommand::playSkyFFA))
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA)));
}

private static int openGUI(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
PlayGUI.openMainGUI(context.getSource().getPlayerOrException());
return 1;
}

private static int openFFAGui(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
PlayGUI.openMainGUI(context.getSource().getPlayerOrException()).setFFALayout();
return 1;
}

private static int playNormalFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "classic ffa", true, true);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/nexia/core/games/util/LobbyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static void setLobbyWorld(MinecraftServer server) {

public static String[] removedTags = {
"in_bedwars",
"bedwars",
"ffa",
"ffa_classic",
"ffa_kits",
Expand Down Expand Up @@ -218,6 +219,7 @@ public static void sendGame(ServerPlayer minecraftPlayer, String game, boolean m
return;
}

player.removeTag("duels");
DuelGameHandler.leave(minecraftPlayer, true);

if (!LobbyUtil.isLobbyWorld(minecraftPlayer.getLevel())) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/nexia/core/gui/PlayGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void setMainLayout(){
this.setSlot(8, bedwars);
}

private void setFFALayout(){
public void setFFALayout(){
ItemStack classic = new ItemStack(Items.NETHERITE_SWORD, 1);
classic.setHoverName(new TextComponent("§cClassic FFA"));
ItemDisplayUtil.addGlint(classic);
Expand Down Expand Up @@ -267,10 +267,12 @@ public boolean click(int index, ClickType clickType, net.minecraft.world.invento
}
return super.click(index, clickType, action);
}
public static void openMainGUI(ServerPlayer player) {
public static PlayGUI openMainGUI(ServerPlayer player) {
PlayGUI shop = new PlayGUI(MenuType.GENERIC_9x1, player, false);
shop.setTitle(title);
shop.setMainLayout();
shop.open();

return shop;
}
}
1 change: 0 additions & 1 deletion src/main/java/com/nexia/core/mixin/player/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.nexia.core.utilities.pos.EntityPos;
import com.nexia.ffa.FfaUtil;
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.BwUtil;
import com.nexia.minigames.games.duels.team.DuelsTeam;
Expand Down
30 changes: 6 additions & 24 deletions src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public static boolean isFfaPlayer(net.minecraft.world.entity.player.Player playe
com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player);
return player.getTags().contains("ffa_sky") && data.gameMode == PlayerGameMode.FFA && data.ffaGameMode == FfaGameMode.SKY;
}

public static void ffaSecond() {
/*
Iterator<UUID> it = fallInvulnerable.keySet().iterator();
while (it.hasNext()) {
UUID uuid = it.next();
Expand All @@ -81,29 +83,8 @@ public static void ffaSecond() {
fallInvulnerable.put(player.getUUID(), 4);
}
}
}
public static void calculateKill(ServerPlayer player){
SavedPlayerData data = PlayerDataManager.get(player).savedData;
data.killstreak++;
if(data.killstreak > data.bestKillstreak){
data.bestKillstreak = data.killstreak;
}
data.kills++;

if(data.killstreak % 5 == 0) {
for (ServerPlayer serverPlayer : FfaAreas.ffaWorld.players()) {
PlayerUtil.getFactoryPlayer(serverPlayer).sendMessage(
Component.text("[").color(ChatFormat.lineColor)
.append(Component.text("☠").color(ChatFormat.failColor))
.append(Component.text("] ").color(ChatFormat.lineColor))
.append(Component.text(player.getScoreboardName()).color(ChatFormat.normalColor))
.append(Component.text(" now has a killstreak of ").color(ChatFormat.chatColor2))
.append(Component.text(data.killstreak).color(ChatFormat.failColor).decoration(ChatFormat.bold, true))
.append(Component.text("!").color(ChatFormat.chatColor2))
);
}
}
*/
}

public static void fiveTick() {
Expand Down Expand Up @@ -171,7 +152,7 @@ public static void setInventory(ServerPlayer player){

public static void joinOrRespawn(ServerPlayer player) {
PlayerUtil.resetHealthStatus(player);
fallInvulnerable.put(player.getUUID(), 4);
//fallInvulnerable.put(player.getUUID(), 4);
wasInSpawn.add(player.getUUID());
player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1000000, 0, true, false, false));
player.setGameMode(GameType.SURVIVAL);
Expand Down Expand Up @@ -365,7 +346,8 @@ public static boolean beforeDamage(ServerPlayer player, DamageSource damageSourc
return false;
}

return damageSource != DamageSource.FALL || !FfaSkyUtil.fallInvulnerable.containsKey(player.getUUID());
return true;
//return damageSource != DamageSource.FALL || !FfaSkyUtil.fallInvulnerable.containsKey(player.getUUID());
}

public static void afterPlace(ServerPlayer player, BlockPos blockPos, InteractionHand hand) {
Expand Down
33 changes: 20 additions & 13 deletions src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ public static void sendToSpawn(ServerPlayer player) {
invItems = new HashMap<>();

ItemStack sword = new ItemStack(Items.DIAMOND_SWORD);
sword.enchant(Enchantments.SHARPNESS, 2);
sword.enchant(Enchantments.SHARPNESS, 4);

ItemStack trident = new ItemStack(Items.TRIDENT);
trident.enchant(Enchantments.IMPALING, 1);
trident.enchant(Enchantments.IMPALING, 2);

ItemStack axe = new ItemStack(Items.DIAMOND_AXE);
axe.enchant(Enchantments.CLEAVING, 1);
axe.enchant(Enchantments.CLEAVING, 2);

ItemStack lava_bucket = new ItemStack(Items.LAVA_BUCKET);
ItemStack water_bucket = new ItemStack(Items.WATER_BUCKET);
Expand All @@ -349,33 +349,36 @@ public static void sendToSpawn(ServerPlayer player) {

ItemStack crossbow = new ItemStack(Items.CROSSBOW);
crossbow.enchant(Enchantments.PIERCING, 1);
crossbow.enchant(Enchantments.QUICK_CHARGE, 1);

ItemStack shield = new ItemStack(Items.SHIELD);

ItemStack golden_apples = new ItemStack(Items.GOLDEN_APPLE);
golden_apples.setCount(8);
golden_apples.setCount(13);

ItemStack cobwebs = new ItemStack(Items.COBWEB);
cobwebs.setCount(10);

ItemStack bow = new ItemStack(Items.BOW);
bow.enchant(Enchantments.POWER_ARROWS, 1);
bow.enchant(Enchantments.POWER_ARROWS, 2);

ItemStack pickaxe = new ItemStack(Items.DIAMOND_PICKAXE);
pickaxe.enchant(Enchantments.DIGGING_EFFICIENCY, 1);
pickaxe.enchant(Enchantments.DIGGING_EFFICIENCY, 2);

ItemStack arrows = new ItemStack(Items.ARROW);
arrows.setCount(8);
arrows.setCount(6);

ItemStack helmet = new ItemStack(Items.DIAMOND_HELMET);
helmet.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 1);
helmet.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2);

ItemStack chestplate = new ItemStack(Items.DIAMOND_CHESTPLATE);
chestplate.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2);
chestplate.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 3);

ItemStack leggings = new ItemStack(Items.DIAMOND_LEGGINGS);
leggings.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2);
leggings.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 3);

ItemStack boots = new ItemStack(Items.DIAMOND_BOOTS);
boots.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 1);
boots.enchant(Enchantments.ALL_DAMAGE_PROTECTION, 2);

invItems.put(0, sword);
invItems.put(1, trident);
Expand All @@ -385,24 +388,28 @@ public static void sendToSpawn(ServerPlayer player) {
invItems.put(5, cobblestone);
invItems.put(6, crossbow);
invItems.put(7, cobwebs);
invItems.put(8, bow);
invItems.put(8, golden_apples);

invItems.put(30, lava_bucket);
invItems.put(13, water_bucket);
invItems.put(32, cobblestone);
invItems.put(35, pickaxe);
invItems.put(34, bow);

invItems.put(21, lava_bucket);
invItems.put(22, water_bucket);
invItems.put(23, oak_log);

invItems.put(31, water_bucket);
invItems.put(17, arrows);
invItems.put(16, shield);
invItems.put(14, water_bucket);

invItems.put(36, boots);
invItems.put(37, leggings);
invItems.put(38, chestplate);
invItems.put(39, helmet);

invItems.put(40, golden_apples);
invItems.put(40, shield);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class SkywarsGame {
.setGenerator(FfaAreas.ffaWorld.getChunkSource().getGenerator())
.setDifficulty(Difficulty.EASY)
.setGameRule(GameRules.RULE_KEEPINVENTORY, false)
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
.setGameRule(GameRules.RULE_MOBGRIEFING, true)
.setGameRule(GameRules.RULE_WEATHER_CYCLE, false)
.setGameRule(GameRules.RULE_FALL_DAMAGE, true)
.setGameRule(GameRules.RULE_DAYLIGHT, false)
Expand Down Expand Up @@ -225,7 +225,7 @@ public static void resetMap() {
new ResourceLocation("skywars", SkywarsGame.id)).asWorld();

SkywarsGame.map.structureMap.pasteMap(level);
ServerTime.factoryServer.runCommand(String.format("execute in skywars:%s run worldborder set 200", SkywarsGame.id));
ServerTime.factoryServer.runCommand(String.format("execute in skywars:%s run worldborder set 200", SkywarsGame.id), 4, false);
SkywarsMap.spawnQueueBuild(level);
SkywarsGame.world = level;
}
Expand All @@ -241,6 +241,8 @@ public static void startGame() {

ArrayList<EntityPos> positions = new ArrayList<>(SkywarsGame.map.positions);

ServerTime.factoryServer.runCommand(String.format("execute in skywars:%s run worldborder set 30 60", SkywarsGame.id), 4, false);

for (AccuratePlayer player : SkywarsGame.alive) {
EntityPos pos = positions.get(RandomUtil.randomInt(positions.size()));
ServerPlayer serverPlayer = player.get();
Expand Down
51 changes: 31 additions & 20 deletions src/main/java/com/nexia/minigames/games/skywars/SkywarsMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,42 @@ public class SkywarsMap {
public StructureMap structureMap;

public static SkywarsMap RELIC = new SkywarsMap("relic", 8, new ArrayList<>(Arrays.asList(
new EntityPos(59,92,-14),
new EntityPos(59,92,14),
new EntityPos(14,92,59),
new EntityPos(-14,92,59),
new EntityPos(-59,92,14),
new EntityPos(-59,92,-14),
new EntityPos(-14,92,-59),
new EntityPos(14,92,-59))
new EntityPos(59.5,91.0,-14.5),
new EntityPos(59.5,91.0,14.5),
new EntityPos(14.5,91.0,59.5),
new EntityPos(-14.5,91.0,59.5),
new EntityPos(-59.5,91.0,14.5),
new EntityPos(-59.5,91.0,-14.5),
new EntityPos(-14.5,91.0,-59.5),
new EntityPos(14.5,91.0,-59.5))
), new StructureMap(new ResourceLocation("skywars", "relic"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-63,-7,-63), true));

public static SkywarsMap SKYHENGE = new SkywarsMap("skyhenge", 12, new ArrayList<>(Arrays.asList(
new EntityPos(72, 82, 0),
new EntityPos(49,82,-23),
new EntityPos(23,82,-49),
new EntityPos(0,82,-72),
new EntityPos(-23,82,-49),
new EntityPos(-49,82,-23),
new EntityPos(-72,82,0),
new EntityPos(-49,82,23),
new EntityPos(-23,82,49),
new EntityPos(0,82,72),
new EntityPos(23,82,49),
new EntityPos(49,82,23))
new EntityPos(72.5, 88.0, 0.5),
new EntityPos(49.5,88.0,-23.5),
new EntityPos(23.5,88.0,-49.5),
new EntityPos(0.5,88.0,-72.5),
new EntityPos(-23.5,88.0,-49.5),
new EntityPos(-49.5,88.0,-23.5),
new EntityPos(-72.5,88.0,0.5),
new EntityPos(-49.5,88.0,23.5),
new EntityPos(-23.5,88.0,49.5),
new EntityPos(0.5,88.0,72.5),
new EntityPos(23.5,88.0,49.5),
new EntityPos(49.5,88.0,23.5))
), new StructureMap(new ResourceLocation("skywars", "skyhenge"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-77, -7, -77), true));

public static SkywarsMap BELOW = new SkywarsMap("below", 8, new ArrayList<>(Arrays.asList(
new EntityPos(-29.5, 81.0, 69.5),
new EntityPos(29.5,81.0,69.5),
new EntityPos(69.5,81.0,28.5),
new EntityPos(69.5,81.0,-28.5),
new EntityPos(29.5,81.0,-68.5),
new EntityPos(-28.5,81.0,-68.5),
new EntityPos(-68.5,81.0,-28.5),
new EntityPos(-68.5,81.0,29.5))
), new StructureMap(new ResourceLocation("skywars", "below"), Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-76, -9, -76), true));


public static SkywarsMap identifyMap(String name) {
for(SkywarsMap map : SkywarsMap.skywarsMaps) {
Expand Down

0 comments on commit 041463f

Please sign in to comment.