updated pvp, refactored some old code, removed transfer instance

This commit is contained in:
Elias Müller 2024-11-03 14:57:53 +01:00
parent 4de66d65a2
commit dc24f28b8f
8 changed files with 29 additions and 76 deletions

View File

@ -28,7 +28,7 @@ public class AddEntityToInstanceEventListener implements EventListener<AddEntity
PacketUtil.resendPlayerList(p);
p.addEffect(new Potion(PotionEffect.BLINDNESS, (byte) 1, 20)); //TODO Uncomment, currently buggy causes disconnect see https://github.com/Minestom/Minestom/discussions/1302
p.addEffect(new Potion(PotionEffect.BLINDNESS, (byte) 1, 20));
}
return Result.SUCCESS;

View File

@ -3,16 +3,13 @@ package eu.mhsl.minenet.minigames.handler.global;
import eu.mhsl.minenet.minigames.Main;
import eu.mhsl.minenet.minigames.api.QueuedPlayerRooms;
import eu.mhsl.minenet.minigames.instance.room.Room;
import eu.mhsl.minenet.minigames.instance.transfer.Transfer;
import eu.mhsl.minenet.minigames.skin.SkinCache;
import eu.mhsl.minenet.minigames.util.MoveInstance;
import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Player;
import eu.mhsl.minenet.minigames.instance.hub.Hub;
import net.minestom.server.event.EventListener;
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
import net.minestom.server.permission.Permission;
import net.minestom.server.timer.TaskSchedule;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.serialize.SerializationException;
@ -30,22 +27,17 @@ public class PlayerLoginHandler implements EventListener<AsyncPlayerConfiguratio
public @NotNull Result run(@NotNull AsyncPlayerConfigurationEvent event) {
Player p = event.getPlayer();
Transfer transferInstance = new Transfer();
p.setRespawnPoint(transferInstance.getSpawn());
event.setSpawningInstance(transferInstance);
event.setSpawningInstance(Hub.INSTANCE);
p.setRespawnPoint(Hub.INSTANCE.getSpawn());
UUID pushQueue = QueuedPlayerRooms.pullQueue(event.getPlayer().getUuid());
MinecraftServer.getSchedulerManager().scheduleTask(
() -> {
if(pushQueue != null) {
Room.setRoom(p, Room.getRoom(pushQueue).orElseThrow());
} else {
MoveInstance.move(p, Hub.INSTANCE);
}
},
TaskSchedule.seconds(5),
TaskSchedule.stop()
MinecraftServer.getSchedulerManager().scheduleNextTick(
() -> {
if(pushQueue != null) {
Room.setRoom(p, Room.getRoom(pushQueue).orElseThrow());
}
}
);
SkinCache.applySkin(p);

View File

@ -6,6 +6,7 @@ import eu.mhsl.minenet.minigames.util.BatchUtil;
import eu.mhsl.minenet.minigames.instance.Dimension;
import eu.mhsl.minenet.minigames.world.BlockPallet;
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
import io.github.togar2.pvp.feature.CombatFeatures;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.event.player.PlayerMoveEvent;
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
@ -26,12 +27,13 @@ class Deathcube extends StatelessGame {
this.percentage = percentage;
this.setGenerator(new CircularPlateTerrainGenerator(radius+10).setPlateHeight(50));
// if(pvpEnabled == 1) eventNode().addChild( // TODO update
// PvPConfig.emptyBuilder()
// .damage(DamageConfig.LEGACY.fallDamage(false))
// .attack(AttackConfig.DEFAULT.attackCooldown(true))
// .build().createNode()
// );
if(pvpEnabled == 1) eventNode().addChild(
CombatFeatures.empty()
.add(CombatFeatures.VANILLA_ATTACK)
.add(CombatFeatures.VANILLA_DAMAGE)
.add(CombatFeatures.VANILLA_KNOCKBACK)
.build().createNode()
);
System.out.println(radius);
}

View File

@ -28,7 +28,7 @@ public class DeathcubeFactory implements GameFactory {
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 10, 20, 30))
.addOption(new NumericOption("height", Material.SCAFFOLDING, TranslatedComponent.byId("optionCommon#height"), 10, 30, 50))
.addOption(new NumericOption("percentage", Material.COBWEB, TranslatedComponent.byId("game_Deathcube#optionPercentageBlocks"), 5, 7, 9, 11, 13))
.addOption(new NumericOption("pvpEnabled", Material.STICK, TranslatedComponent.byId("game_Deathcube#optionPvpEnabled"), 1, 0));
.addOption(new NumericOption("pvpEnabled", Material.STICK, TranslatedComponent.byId("game_Deathcube#optionPvpEnabled"), 0, 1));
}

View File

@ -5,8 +5,8 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
import eu.mhsl.minenet.minigames.score.LastWinsScore;
import eu.mhsl.minenet.minigames.util.BatchUtil;
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
import io.github.togar2.pvp.config.PvPConfig;
import io.github.togar2.pvp.events.FinalAttackEvent;
import io.github.togar2.pvp.feature.CombatFeatures;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.Player;
import net.minestom.server.event.player.PlayerMoveEvent;
@ -20,12 +20,13 @@ public class Stickfight extends StatelessGame {
public Stickfight() {
super(Dimension.OVERWORLD.key, "Stickfight", new LastWinsScore());
// eventNode().addChild( // TODO update
// PvPConfig.emptyBuilder()
// .damage(DamageConfig.legacyBuilder().fallDamage(false))
// .attack(AttackConfig.legacyBuilder().attackCooldown(true))
// .build().createNode()
// );
eventNode().addChild(
CombatFeatures.empty()
.add(CombatFeatures.VANILLA_ATTACK)
.add(CombatFeatures.VANILLA_DAMAGE)
.add(CombatFeatures.VANILLA_KNOCKBACK)
.build().createNode()
);
eventNode().addListener(FinalAttackEvent.class, finalAttackEvent -> {
finalAttackEvent.setBaseDamage(0);

View File

@ -1,22 +0,0 @@
package eu.mhsl.minenet.minigames.instance.transfer;
import eu.mhsl.minenet.minigames.instance.Dimension;
import eu.mhsl.minenet.minigames.instance.MineNetInstance;
import eu.mhsl.minenet.minigames.instance.Spawnable;
import eu.mhsl.minenet.minigames.util.CommonEventHandles;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.event.player.PlayerMoveEvent;
import net.minestom.server.instance.block.Block;
public class Transfer extends MineNetInstance implements Spawnable {
public Transfer() {
super(Dimension.THE_END.key);
eventNode().addListener(PlayerMoveEvent.class, CommonEventHandles::cancel);
setBlock(0, 0, 0, Block.BARRIER);
}
@Override
public Pos getSpawn() {
return new Pos(0.5, 1, 0.5);
}
}

View File

@ -130,25 +130,10 @@ public class InventoryItemAlignment {
}.get(count);
}
public static class ItemOffset {
private final int x;
private final int z;
public ItemOffset(int x, int z) {
this.x = x;
this.z = z;
}
public int getX() {
return x;
}
public int getZ() {
return z;
}
public record ItemOffset(int x, int z) {
public int get() {
return x + (z * 9);
return x + (z * 9);
}
}
}
}

View File

@ -1,5 +0,0 @@
package eu.mhsl.minenet.minigames.util;
public abstract class Static {
public abstract void load(); //TODO REMOVE
}