Compare commits
16 Commits
10b392-cus
...
8451463b73
Author | SHA1 | Date | |
---|---|---|---|
8451463b73 | |||
7e27a05596 | |||
ba260519e0 | |||
dc24f28b8f | |||
4de66d65a2 | |||
bdb7c85ceb | |||
21ab8c4bd3 | |||
3f247bfc90 | |||
843fa26c08 | |||
cfbb2688d2 | |||
350cf108dd | |||
c9ef7197cc | |||
40f02449d9 | |||
e71dccb98d | |||
a3f2a06f6a | |||
a321d243ba |
23
build.gradle
23
build.gradle
@ -28,9 +28,16 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,13 +46,7 @@ dependencies {
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
|
||||
|
||||
//https://jitpack.io/#Minestom/Minestom
|
||||
// implementation 'com.github.Minestom:Minestom:c496ee357'
|
||||
// implementation 'com.github.waxeria:Minestom:e0427a36f3'
|
||||
|
||||
// implementation 'dev.hollowcube:minestom-ce:5bcc72b911'
|
||||
implementation 'dev.hollowcube:minestom-ce:8715f4305d'
|
||||
implementation 'dev.hollowcube:minestom-ce-extensions:1.2.0'
|
||||
|
||||
implementation 'net.minestom:minestom-snapshots:d707b0674f'
|
||||
|
||||
//Tools
|
||||
implementation 'de.articdive:jnoise:3.0.2'
|
||||
@ -54,13 +55,11 @@ dependencies {
|
||||
implementation 'org.spongepowered:configurate-yaml:4.1.2'
|
||||
implementation 'com.sparkjava:spark-core:2.9.4'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'com.google.guava:guava:31.0.1-jre'
|
||||
implementation 'com.google.guava:guava:32.0.0-android'
|
||||
|
||||
|
||||
//PvP
|
||||
implementation 'com.github.TogAr2:MinestomPvP:35e5661'
|
||||
//implementation 'com.github.TogAr2:MinestomPvP:135ec9e2b7'
|
||||
|
||||
implementation 'com.github.TogAr2:MinestomPvP:04180ddf9a'
|
||||
|
||||
// Hephaestus engine
|
||||
implementation("team.unnamed:hephaestus-api:0.2.1-SNAPSHOT")
|
||||
|
@ -5,8 +5,6 @@ import eu.mhsl.minenet.minigames.command.Commands;
|
||||
import eu.mhsl.minenet.minigames.handler.Listeners;
|
||||
import eu.mhsl.minenet.minigames.lang.Languages;
|
||||
import eu.mhsl.minenet.minigames.server.tasks.TablistUpdateTask;
|
||||
import eu.mhsl.minenet.minigames.server.provider.ByPlayerNameUuidProvider;
|
||||
import io.github.bloepiloepi.pvp.PvpExtension;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.extras.bungee.BungeeCordProxy;
|
||||
import net.minestom.server.extras.lan.OpenToLAN;
|
||||
@ -42,14 +40,12 @@ public class Main {
|
||||
logger.info("Initialize Minecraft server...");
|
||||
|
||||
MinecraftServer server = MinecraftServer.init();
|
||||
PvpExtension.init();
|
||||
// MinestomPvP.init();
|
||||
|
||||
MinecraftServer.setBrandName("mhsl.eu - minenet - credits to minestom");
|
||||
MinecraftServer.setCompressionThreshold(serverConfig.node("compression-threshold").getInt(0));
|
||||
System.setProperty("minestom.chunk-view-distance", String.valueOf(serverConfig.node("view-distance").getInt()));
|
||||
|
||||
MinecraftServer.getConnectionManager().setUuidProvider(new ByPlayerNameUuidProvider());
|
||||
|
||||
Commands.values();
|
||||
Listeners.values();
|
||||
new HttpServer();
|
||||
|
@ -2,6 +2,7 @@ package eu.mhsl.minenet.minigames.command;
|
||||
|
||||
import net.minestom.server.command.builder.Command;
|
||||
import net.minestom.server.command.builder.condition.CommandCondition;
|
||||
import net.minestom.server.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -27,7 +28,7 @@ public class PrivilegedCommand extends Command {
|
||||
}
|
||||
|
||||
protected CommandCondition isPrivileged() {
|
||||
return (sender, commandString) -> sender.hasPermission("admin");
|
||||
return (sender, commandString) -> ((Player) sender).getPermissionLevel() == 4;
|
||||
}
|
||||
|
||||
protected void addCondition(CommandCondition condition) {
|
||||
|
@ -5,7 +5,6 @@ import eu.mhsl.minenet.minigames.message.Icon;
|
||||
import eu.mhsl.minenet.minigames.message.type.ActionBarMessage;
|
||||
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
||||
import eu.mhsl.minenet.minigames.message.type.TitleMessage;
|
||||
import eu.mhsl.minenet.minigames.util.PacketUtil;
|
||||
import net.minestom.server.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -36,8 +35,6 @@ public class DebugCommand extends PrivilegedCommand {
|
||||
.appendTranslated("score#thanks")
|
||||
.send(sender);
|
||||
|
||||
PacketUtil.resendPlayerList(((Player) sender));
|
||||
|
||||
new ChatMessage(Icon.SCIENCE).appendStatic(((Player) sender).getUuid().toString()).send(sender);
|
||||
});
|
||||
|
||||
|
@ -6,8 +6,6 @@ import eu.mhsl.minenet.minigames.message.Icon;
|
||||
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
||||
import net.minestom.server.command.builder.arguments.ArgumentType;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.entity.fakeplayer.FakePlayer;
|
||||
import net.minestom.server.entity.fakeplayer.FakePlayerOption;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -18,12 +16,12 @@ public class FakeplayerCommand extends PrivilegedCommand {
|
||||
addSyntax((sender, context) -> {
|
||||
if(sender instanceof Player p) {
|
||||
if(p.getInstance() instanceof Room room) {
|
||||
FakePlayer.initPlayer(
|
||||
UUID.randomUUID(),
|
||||
context.getRaw("name"),
|
||||
new FakePlayerOption().setInTabList(true).setRegistered(true),
|
||||
fakePlayer -> Room.setRoom(fakePlayer, room)
|
||||
);
|
||||
// FakePlayer.initPlayer( // TODO FakePlayer does no longer exists
|
||||
// UUID.randomUUID(),
|
||||
// context.getRaw("name"),
|
||||
// new FakePlayerOption().setInTabList(true).setRegistered(true),
|
||||
// fakePlayer -> Room.setRoom(fakePlayer, room)
|
||||
// );
|
||||
} else {
|
||||
new ChatMessage(Icon.ERROR).appendStatic("Du musst dich in einer Raumlobby befinden!").send(sender);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class KickCommand extends PrivilegedCommand {
|
||||
}
|
||||
|
||||
private void kick(String playername, String reason) {
|
||||
Player playerToKick = MinecraftServer.getConnectionManager().findPlayer(playername);
|
||||
Player playerToKick = MinecraftServer.getConnectionManager().findOnlinePlayer(playername);
|
||||
Objects.requireNonNull(playerToKick).kick(reason);
|
||||
}
|
||||
}
|
||||
|
@ -6,16 +6,15 @@ import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.command.builder.arguments.ArgumentType;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.permission.Permission;
|
||||
|
||||
public class OpCommand extends PrivilegedCommand {
|
||||
public OpCommand() {
|
||||
super("op");
|
||||
|
||||
addSyntax((sender, context) -> {
|
||||
Player target = MinecraftServer.getConnectionManager().getPlayer(context.getRaw("target"));
|
||||
Player target = MinecraftServer.getConnectionManager().getOnlinePlayerByUsername(context.getRaw("target"));
|
||||
if(target != null) {
|
||||
target.addPermission(new Permission("admin"));
|
||||
target.setPermissionLevel(4);
|
||||
target.refreshCommands();
|
||||
} else new ChatMessage(Icon.ERROR).appendStatic("Spieler nicht gefunden").send(sender);
|
||||
}, ArgumentType.Entity("target").onlyPlayers(true));
|
||||
|
@ -27,7 +27,7 @@ public class SetRoomOwnerCommand extends PrivilegedCommand {
|
||||
addSyntax((sender, context) -> {
|
||||
System.out.println("Test");
|
||||
if(sender instanceof Player p) {
|
||||
Player newOwner = MinecraftServer.getConnectionManager().getPlayer(context.getRaw("player"));
|
||||
Player newOwner = MinecraftServer.getConnectionManager().getOnlinePlayerByUsername(context.getRaw("player"));
|
||||
Room.getRoom(p).orElseThrow().setOwner(Objects.requireNonNull(newOwner));
|
||||
new ChatMessage(Icon.SUCCESS).appendStatic("The new owner has been set!").send(sender);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import net.minestom.server.event.EventListener;
|
||||
|
||||
public enum Listeners {
|
||||
SPAWN(new AddEntityToInstanceEventListener()),
|
||||
CHAT(new PlayerChatHandler()),
|
||||
LOGIN(new PlayerLoginHandler()),
|
||||
LEAVE(new PlayerLeaveHandler());
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package eu.mhsl.minenet.minigames.handler.global;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.Spawnable;
|
||||
import eu.mhsl.minenet.minigames.util.PacketUtil;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.EventListener;
|
||||
@ -20,15 +19,13 @@ public class AddEntityToInstanceEventListener implements EventListener<AddEntity
|
||||
@Override
|
||||
public @NotNull Result run(@NotNull AddEntityToInstanceEvent event) {
|
||||
if(event.getEntity() instanceof Player p) {
|
||||
MinecraftServer.getSchedulerManager().scheduleNextTick(p::refreshCommands, ExecutionType.ASYNC);
|
||||
MinecraftServer.getSchedulerManager().scheduleNextTick(p::refreshCommands, ExecutionType.TICK_END);
|
||||
|
||||
if(event.getInstance() instanceof Spawnable instance) {
|
||||
p.setRespawnPoint(instance.getSpawn());
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1,26 +0,0 @@
|
||||
package eu.mhsl.minenet.minigames.handler.global;
|
||||
|
||||
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
||||
import net.minestom.server.event.EventListener;
|
||||
import net.minestom.server.event.player.PlayerChatEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerChatHandler implements EventListener<PlayerChatEvent> {
|
||||
@Override
|
||||
public @NotNull Class<PlayerChatEvent> eventType() {
|
||||
return PlayerChatEvent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Result run(@NotNull PlayerChatEvent event) {
|
||||
event.setChatFormat(
|
||||
(messages) -> new ChatMessage()
|
||||
.appendStatic(event.getPlayer().getUsername())
|
||||
.pipe()
|
||||
.appendStatic(messages.getMessage())
|
||||
.build(event.getPlayer())
|
||||
);
|
||||
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
}
|
@ -3,16 +3,12 @@ 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 net.minestom.server.event.EventListener;
|
||||
import net.minestom.server.event.player.PlayerLoginEvent;
|
||||
import eu.mhsl.minenet.minigames.instance.hub.Hub;
|
||||
import net.minestom.server.permission.Permission;
|
||||
import net.minestom.server.timer.TaskSchedule;
|
||||
import net.minestom.server.event.EventListener;
|
||||
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
@ -20,39 +16,34 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PlayerLoginHandler implements EventListener<PlayerLoginEvent> {
|
||||
public class PlayerLoginHandler implements EventListener<AsyncPlayerConfigurationEvent> {
|
||||
@Override
|
||||
public @NotNull Class<PlayerLoginEvent> eventType() {
|
||||
return PlayerLoginEvent.class;
|
||||
public @NotNull Class<AsyncPlayerConfigurationEvent> eventType() {
|
||||
return AsyncPlayerConfigurationEvent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Result run(@NotNull PlayerLoginEvent event) {
|
||||
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);
|
||||
|
||||
try {
|
||||
if(Objects.requireNonNull(Main.globalConfig.node("admins").getList(String.class)).stream().anyMatch(s -> s.equalsIgnoreCase(p.getUsername()))) {
|
||||
p.addPermission(new Permission("admin"));
|
||||
p.setPermissionLevel(4);
|
||||
}
|
||||
} catch (SerializationException | NullPointerException ignored) {}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.mhsl.minenet.minigames.instance;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
|
||||
@ -9,33 +10,39 @@ import net.minestom.server.world.DimensionType;
|
||||
*/
|
||||
public enum Dimension {
|
||||
OVERWORLD(
|
||||
NamespaceID.from("minenet:fullbright_overworld"),
|
||||
DimensionType
|
||||
.builder(NamespaceID.from("minenet:fullbright_overworld"))
|
||||
.builder()
|
||||
.ambientLight(2.0f)
|
||||
.build()
|
||||
),
|
||||
|
||||
NETHER(
|
||||
NamespaceID.from("minenet:fullbright_nether"),
|
||||
DimensionType
|
||||
.builder(NamespaceID.from("minenet:fullbright_nether"))
|
||||
.builder()
|
||||
.ambientLight(2.0f)
|
||||
.effects("minecraft:the_nether")
|
||||
.build()
|
||||
),
|
||||
|
||||
THE_END(
|
||||
NamespaceID.from("minenet:fullbright_end"),
|
||||
DimensionType
|
||||
.builder(NamespaceID.from("minenet:fullbright_end"))
|
||||
.builder()
|
||||
.ambientLight(2.0f)
|
||||
.effects("minecraft:the_end")
|
||||
.build()
|
||||
);
|
||||
|
||||
public final DimensionType DIMENSION;
|
||||
Dimension(DimensionType dimType) {
|
||||
public final NamespaceID namespaceID;
|
||||
public final DynamicRegistry.Key<DimensionType> key;
|
||||
Dimension(NamespaceID namespaceID, DimensionType dimType) {
|
||||
this.DIMENSION = dimType;
|
||||
this.namespaceID = namespaceID;
|
||||
|
||||
MinecraftServer.getDimensionTypeManager().addDimension(this.DIMENSION);
|
||||
this.key = MinecraftServer.getDimensionTypeRegistry().register(namespaceID, DIMENSION);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,13 +7,15 @@ import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
||||
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.InstanceContainer;
|
||||
import net.minestom.server.instance.InstanceManager;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.timer.TaskSchedule;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MineNetInstance extends InstanceContainer {
|
||||
public MineNetInstance(DimensionType type) {
|
||||
public MineNetInstance(DynamicRegistry.Key<DimensionType> type) {
|
||||
super(UUID.randomUUID(), type);
|
||||
MinecraftServer.getInstanceManager().registerInstance(this);
|
||||
|
||||
|
@ -16,6 +16,7 @@ import net.minestom.server.event.item.ItemDropEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.timer.ExecutionType;
|
||||
import net.minestom.server.timer.TaskSchedule;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
@ -36,7 +37,7 @@ public abstract class Game extends MineNetInstance implements Spawnable {
|
||||
|
||||
protected final Logger logger;
|
||||
|
||||
public Game(DimensionType dimensionType) {
|
||||
public Game(DynamicRegistry.Key<DimensionType> dimensionType) {
|
||||
super(dimensionType);
|
||||
|
||||
MinecraftServer.getInstanceManager().registerInstance(this);
|
||||
@ -78,7 +79,7 @@ public abstract class Game extends MineNetInstance implements Spawnable {
|
||||
this.onLoad(callback);
|
||||
// callback.whenComplete((unused, throwable) -> this.start());
|
||||
return TaskSchedule.stop();
|
||||
}, ExecutionType.ASYNC);
|
||||
}, ExecutionType.TICK_END);
|
||||
|
||||
}
|
||||
|
||||
@ -117,7 +118,6 @@ public abstract class Game extends MineNetInstance implements Spawnable {
|
||||
protected void onStop() {}
|
||||
protected void onUnload() {}
|
||||
|
||||
|
||||
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.anvilRun.AnvilRunFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.bowSpleef.BowSpleefFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.elytraRace.ElytraRaceFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms.BackroomsFactory;
|
||||
@ -24,6 +25,7 @@ public enum GameList {
|
||||
BACKROOMS(new BackroomsFactory(), GameType.PROTOTYPE),
|
||||
TNTRUN(new TntRunFactory(), GameType.OTHER),
|
||||
ACIDRAIN(new AcidRainFactory(), GameType.PVE),
|
||||
ANVILRUN(new AnvilRunFactory(), GameType.PVE),
|
||||
ELYTRARACE(new ElytraRaceFactory(), GameType.PVP),
|
||||
SPLEEF(new SpleefFactory(), GameType.PVP),
|
||||
BOWSPLEEF(new BowSpleefFactory(), GameType.PVP);
|
||||
|
@ -9,6 +9,7 @@ import eu.mhsl.minenet.minigames.score.Score;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.timer.ExecutionType;
|
||||
import net.minestom.server.timer.TaskSchedule;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
@ -22,7 +23,8 @@ public class StatelessGame extends Game {
|
||||
|
||||
private int timeLimit = 0;
|
||||
private int timePlayed = 0;
|
||||
public StatelessGame(DimensionType dimensionType, String gameName, Score score) {
|
||||
|
||||
public StatelessGame(DynamicRegistry.Key<DimensionType> dimensionType, String gameName, Score score) {
|
||||
super(dimensionType);
|
||||
this.score = score;
|
||||
this.name = gameName;
|
||||
@ -55,7 +57,7 @@ public class StatelessGame extends Game {
|
||||
timePlayed++;
|
||||
|
||||
return TaskSchedule.seconds(1);
|
||||
}, ExecutionType.SYNC);
|
||||
}, ExecutionType.TICK_START);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class GameConfigurationInventory extends InteractableInventory {
|
||||
|
||||
setClickableItem(
|
||||
ItemStack.builder(Material.RED_WOOL)
|
||||
.displayName(
|
||||
.customName(
|
||||
TranslatedComponent.byId("common#back")
|
||||
.setColor(NamedTextColor.RED)
|
||||
.getAssembled(p)
|
||||
@ -62,7 +62,7 @@ public class GameConfigurationInventory extends InteractableInventory {
|
||||
|
||||
setDummyItem(
|
||||
ItemStack.builder(Material.NAME_TAG)
|
||||
.displayName(
|
||||
.customName(
|
||||
factory.name().setColor(NamedTextColor.GOLD).getAssembled(p)
|
||||
)
|
||||
.build(),
|
||||
@ -80,7 +80,7 @@ public class GameConfigurationInventory extends InteractableInventory {
|
||||
if(config == null) {
|
||||
setDummyItem(
|
||||
ItemStack.builder(Material.BARRIER)
|
||||
.displayName(
|
||||
.customName(
|
||||
TranslatedComponent.byId("room#noOption").setColor(NamedTextColor.RED).getAssembled(p)
|
||||
)
|
||||
.lore(
|
||||
@ -130,7 +130,7 @@ public class GameConfigurationInventory extends InteractableInventory {
|
||||
|
||||
setClickableItem(
|
||||
ItemStack.builder(restrictionHandler.getWarnings(restrictionData).size() > 0 ? Material.YELLOW_WOOL : Material.GREEN_WOOL)
|
||||
.displayName(TranslatedComponent.byId("restriction#success").setColor(NamedTextColor.GREEN).getAssembled(p))
|
||||
.customName(TranslatedComponent.byId("restriction#success").setColor(NamedTextColor.GREEN).getAssembled(p))
|
||||
.lore(restrictionHandler.getWarnings(restrictionData).stream().map(translatedComponent -> translatedComponent.getAssembled(p)).collect(Collectors.toList()))
|
||||
.build(),
|
||||
8,
|
||||
@ -142,7 +142,7 @@ public class GameConfigurationInventory extends InteractableInventory {
|
||||
|
||||
setClickableItem(
|
||||
ItemStack.builder(Material.RED_WOOL)
|
||||
.displayName(TranslatedComponent.byId("restriction#fail").setColor(NamedTextColor.RED).getAssembled(p))
|
||||
.customName(TranslatedComponent.byId("restriction#fail").setColor(NamedTextColor.RED).getAssembled(p))
|
||||
.lore(
|
||||
restrictionHandler.getRestrictions()
|
||||
.stream()
|
||||
|
@ -46,7 +46,7 @@ public abstract class Option<T> {
|
||||
public ItemStack getCurrent(Player p) {
|
||||
int amount = Integer.parseInt(options.get(pointer).toString());
|
||||
return ItemStack.builder(item)
|
||||
.displayName(name.getAssembled(p))
|
||||
.customName(name.getAssembled(p))
|
||||
.lore(TranslatedComponent.byId("optionCommon#value").setColor(NamedTextColor.GOLD).getAssembled(p)
|
||||
.append(Component.text(": ")).append(Component.text(amount)))
|
||||
.build();
|
||||
|
@ -17,8 +17,8 @@ import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.event.player.PlayerTickEvent;
|
||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.network.packet.server.play.ParticlePacket;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.particle.ParticleCreator;
|
||||
import net.minestom.server.timer.ExecutionType;
|
||||
import net.minestom.server.timer.TaskSchedule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -38,7 +38,7 @@ public class AcidRain extends StatelessGame {
|
||||
.setFrequency(0.09)
|
||||
.build();
|
||||
public AcidRain() {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "acidRain", new LastWinsScore());
|
||||
super(Dimension.OVERWORLD.key, "acidRain", new LastWinsScore());
|
||||
setGenerator(
|
||||
new CircularPlateTerrainGenerator(radius)
|
||||
.setPlateHeight(50)
|
||||
@ -62,13 +62,13 @@ public class AcidRain extends StatelessGame {
|
||||
MinecraftServer.getSchedulerManager().submitTask(() -> {
|
||||
|
||||
getPlayers().forEach(player -> {
|
||||
player.sendPacket(ParticleCreator.createParticlePacket(Particle.SNEEZE, 0, 60, 0, radius, radius, radius, 500));
|
||||
player.sendPacket(ParticleCreator.createParticlePacket(Particle.ITEM_SLIME, 0, 60, 0, radius, radius, radius, 500));
|
||||
player.sendPacket(new ParticlePacket(Particle.SNEEZE, 0, 60, 0, radius, radius, radius, 1f, 500));
|
||||
player.sendPacket(new ParticlePacket(Particle.ITEM_SLIME, 0, 60, 0, radius, radius, radius, 1f, 500));
|
||||
});
|
||||
|
||||
if(!isRunning) return TaskSchedule.stop();
|
||||
return TaskSchedule.millis(100);
|
||||
}, ExecutionType.ASYNC);
|
||||
}, ExecutionType.TICK_END);
|
||||
|
||||
MinecraftServer.getSchedulerManager().submitTask(() -> {
|
||||
generationOffset++;
|
||||
@ -76,7 +76,7 @@ public class AcidRain extends StatelessGame {
|
||||
|
||||
if(!isRunning) return TaskSchedule.stop();
|
||||
return TaskSchedule.millis((long) NumberUtil.map(50 - difficulty, 0, 50, 100, 1000));
|
||||
}, ExecutionType.ASYNC);
|
||||
}, ExecutionType.TICK_END);
|
||||
|
||||
MinecraftServer.getSchedulerManager().submitTask(() -> {
|
||||
difficulty++;
|
||||
|
@ -0,0 +1,111 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.anvilRun;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||
import eu.mhsl.minenet.minigames.score.LastWinsScore;
|
||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
||||
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.metadata.other.FallingBlockMeta;
|
||||
import net.minestom.server.event.entity.EntityTickEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.timer.Scheduler;
|
||||
import net.minestom.server.timer.TaskSchedule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
class AnvilRun extends StatelessGame {
|
||||
|
||||
final int spawnHeight = 30;
|
||||
final int radius;
|
||||
int anvilsPerSecond;
|
||||
final int seconds;
|
||||
final int anvilHeight = 200;
|
||||
final List<Pos> anvilSpawnPositions = new ArrayList<>();
|
||||
|
||||
public AnvilRun(int radius, int seconds) {
|
||||
super(Dimension.OVERWORLD.key, "Anvil Run", new LastWinsScore());
|
||||
this.radius = radius;
|
||||
this.seconds = seconds;
|
||||
this.setGenerator(new CircularPlateTerrainGenerator(radius));
|
||||
|
||||
eventNode().addListener(EntityTickEvent.class, this::onEntityTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
|
||||
|
||||
for(int x = -radius; x <= radius; x++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
if(new Pos(x, 0, z).distance(new Pos(0, 0, 0)) > radius) continue;
|
||||
|
||||
anvilSpawnPositions.add(new Pos(x+0.5, anvilHeight, z+0.5));
|
||||
|
||||
batch.setBlock(x, spawnHeight-1, z, Block.SNOW_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
this.anvilsPerSecond = anvilSpawnPositions.size() / this.seconds;
|
||||
Collections.shuffle(anvilSpawnPositions);
|
||||
|
||||
BatchUtil.loadAndApplyBatch(batch, this, () -> callback.complete(null));
|
||||
}
|
||||
|
||||
protected void spawnAnvil(Pos spawnPosition) {
|
||||
Entity anvil = new Entity(EntityType.FALLING_BLOCK);
|
||||
((FallingBlockMeta) anvil.getEntityMeta()).setBlock(Block.ANVIL);
|
||||
anvil.setInstance(this, spawnPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
Scheduler scheduler = MinecraftServer.getSchedulerManager();
|
||||
for(int i=0; i<this.anvilSpawnPositions.size(); i++) {
|
||||
final int j = i;
|
||||
scheduler.scheduleTask(
|
||||
() -> spawnAnvil(this.anvilSpawnPositions.get(j)),
|
||||
TaskSchedule.millis(
|
||||
(long) Math.floor((double) i/this.anvilsPerSecond * 1000)
|
||||
),
|
||||
TaskSchedule.stop()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||
super.onPlayerMove(playerMoveEvent);
|
||||
if(isBeforeBeginning && playerMoveEvent.getNewPosition().y() < spawnHeight - 2) {
|
||||
playerMoveEvent.setCancelled(true);
|
||||
playerMoveEvent.getPlayer().teleport(getSpawn());
|
||||
return;
|
||||
}
|
||||
if(playerMoveEvent.getNewPosition().y() < spawnHeight - 2) getScore().insertResult(playerMoveEvent.getPlayer());
|
||||
}
|
||||
|
||||
protected void onEntityTick(@NotNull EntityTickEvent entityTickEvent) {
|
||||
if(!entityTickEvent.getEntity().getEntityType().equals(EntityType.FALLING_BLOCK)) return;
|
||||
Pos anvilPosition = entityTickEvent.getEntity().getPosition();
|
||||
if(anvilPosition.y() > spawnHeight + 0.5) return;
|
||||
if(anvilPosition.y() < spawnHeight - 3) entityTickEvent.getEntity().remove();
|
||||
if(this.getBlock(anvilPosition.withY(spawnHeight-1)).isAir()) return;
|
||||
this.setBlock(anvilPosition.withY(spawnHeight-1), Block.AIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
return new Pos(0, spawnHeight, 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package eu.mhsl.minenet.minigames.instance.game.stateless.types.anvilRun;
|
||||
|
||||
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption;
|
||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
import net.minestom.server.item.Material;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AnvilRunFactory implements GameFactory {
|
||||
@Override
|
||||
public TranslatedComponent name() {
|
||||
return TranslatedComponent.byId("game_AnvilRun#name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatedComponent description() {
|
||||
return TranslatedComponent.byId("game_AnvilRun#description");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigManager configuration() {
|
||||
return new ConfigManager()
|
||||
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 5, 10, 15, 20, 25, 30))
|
||||
.addOption(new NumericOption("seconds", Material.STICK, TranslatedComponent.byId("optionCommon#seconds"), 10, 30, 60, 90, 120));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game manufacture(Room parent, Map<String, Option<?>> configuration) {
|
||||
return new AnvilRun(configuration.get("radius").getAsInt(), configuration.get("seconds").getAsInt()).setParent(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material symbol() {
|
||||
return Material.ANVIL;
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Backrooms extends StatelessGame {
|
||||
public Backrooms() {
|
||||
super(Dimension.NETHER.DIMENSION, "Backrooms", new NoScore());
|
||||
super(Dimension.NETHER.key, "Backrooms", new NoScore());
|
||||
BackroomsGenerator generator = new BackroomsGenerator();
|
||||
setGenerator(unit -> generator.generateRoom(unit, 50));
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import net.minestom.server.event.item.PickupItemEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.instance.AnvilLoader;
|
||||
import net.minestom.server.instance.anvil.AnvilLoader;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.timer.ExecutionType;
|
||||
@ -38,7 +38,7 @@ public class Bedwars extends StatelessGame {
|
||||
|
||||
|
||||
public Bedwars() throws IOException {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "Bedwars", new LastWinsScore());
|
||||
super(Dimension.OVERWORLD.key, "Bedwars", new LastWinsScore());
|
||||
setChunkLoader(new AnvilLoader(Resource.GAME_MAP.getPath().resolve("bedwars/test")));
|
||||
|
||||
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(Resource.GAME_MAP.getPath().resolve("bedwars/test/config.yml").toFile());
|
||||
@ -78,7 +78,7 @@ public class Bedwars extends StatelessGame {
|
||||
});
|
||||
|
||||
return TaskSchedule.stop();
|
||||
}, ExecutionType.SYNC);
|
||||
}, ExecutionType.TICK_END);
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,31 +6,22 @@ import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
import eu.mhsl.minenet.minigames.score.LastWinsScore;
|
||||
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
||||
import eu.mhsl.minenet.minigames.util.GeneratorUtils;
|
||||
import io.github.bloepiloepi.pvp.events.ProjectileHitEvent;
|
||||
import io.github.bloepiloepi.pvp.projectile.CustomEntityProjectile;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.*;
|
||||
import net.minestom.server.entity.metadata.arrow.ArrowMeta;
|
||||
import net.minestom.server.entity.metadata.other.PrimedTntMeta;
|
||||
import net.minestom.server.event.EventListener;
|
||||
import net.minestom.server.event.item.ItemUpdateStateEvent;
|
||||
import net.minestom.server.event.player.PlayerItemAnimationEvent;
|
||||
import net.minestom.server.event.entity.projectile.ProjectileCollideWithBlockEvent;
|
||||
import net.minestom.server.event.entity.projectile.ProjectileCollideWithEntityEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.Enchantment;
|
||||
import net.minestom.server.item.ItemHideFlag;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.tag.Tag;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class BowSpleef extends StatelessGame {
|
||||
@ -39,48 +30,48 @@ public class BowSpleef extends StatelessGame {
|
||||
private final int radius = 30;
|
||||
private final int totalElevation = 50;
|
||||
public BowSpleef() {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "bowSpleef", new LastWinsScore());
|
||||
super(Dimension.OVERWORLD.key, "bowSpleef", new LastWinsScore());
|
||||
|
||||
// eventNode().addListener( TODO implement bow mechanism
|
||||
// EventListener
|
||||
// .builder(PlayerItemAnimationEvent.class)
|
||||
// .handler(playerItemAnimationEvent -> playerItemAnimationEvent.getPlayer().setTag(CHARGE_BOW_SINCE, System.currentTimeMillis()))
|
||||
// .filter(playerItemAnimationEvent -> playerItemAnimationEvent.getItemAnimationType() == PlayerItemAnimationEvent.ItemAnimationType.BOW)
|
||||
// .build()
|
||||
// );
|
||||
//
|
||||
// eventNode().addListener(
|
||||
// EventListener
|
||||
// .builder(ItemUpdateStateEvent.class)
|
||||
// .handler(event -> {
|
||||
// final Player player = event.getPlayer();
|
||||
// final double chargedFor = (System.currentTimeMillis() - player.getTag(CHARGE_BOW_SINCE)) / 1000D;
|
||||
// final double power = MathUtils.clamp((chargedFor * chargedFor + 2 * chargedFor) / 2D, 0, 1);
|
||||
//
|
||||
// if (power > 0.2) {
|
||||
// final CustomEntityProjectile projectile = new CustomEntityProjectile(player, EntityType.ARROW);
|
||||
// final ArrowMeta meta = (ArrowMeta) projectile.getEntityMeta();
|
||||
// meta.setCritical(power >= 0.9);
|
||||
// projectile.scheduleRemove(Duration.of(100, TimeUnit.SERVER_TICK));
|
||||
// meta.setOnFire(true);
|
||||
//
|
||||
// final Pos position = player.getPosition().add(0, player.getEyeHeight(), 0);
|
||||
// projectile.setInstance(Objects.requireNonNull(player.getInstance()), position);
|
||||
//
|
||||
// final Vec direction = projectile.getPosition().direction();
|
||||
// projectile.shootFrom(position.add(direction).sub(0, 0.2, 0), power * 3, 1.0);
|
||||
// projectile.setTag(ARROW_FIRST_HIT, true);
|
||||
// }
|
||||
// })
|
||||
// .filter(itemUpdateStateEvent -> itemUpdateStateEvent.getItemStack().material() == Material.BOW)
|
||||
// .build()
|
||||
// );
|
||||
|
||||
eventNode().addListener(
|
||||
EventListener
|
||||
.builder(PlayerItemAnimationEvent.class)
|
||||
.handler(playerItemAnimationEvent -> playerItemAnimationEvent.getPlayer().setTag(CHARGE_BOW_SINCE, System.currentTimeMillis()))
|
||||
.filter(playerItemAnimationEvent -> playerItemAnimationEvent.getItemAnimationType() == PlayerItemAnimationEvent.ItemAnimationType.BOW)
|
||||
.build()
|
||||
);
|
||||
|
||||
eventNode().addListener(
|
||||
EventListener
|
||||
.builder(ItemUpdateStateEvent.class)
|
||||
.handler(event -> {
|
||||
final Player player = event.getPlayer();
|
||||
final double chargedFor = (System.currentTimeMillis() - player.getTag(CHARGE_BOW_SINCE)) / 1000D;
|
||||
final double power = MathUtils.clamp((chargedFor * chargedFor + 2 * chargedFor) / 2D, 0, 1);
|
||||
|
||||
if (power > 0.2) {
|
||||
final CustomEntityProjectile projectile = new CustomEntityProjectile(player, EntityType.ARROW, true);
|
||||
final ArrowMeta meta = (ArrowMeta) projectile.getEntityMeta();
|
||||
meta.setCritical(power >= 0.9);
|
||||
projectile.scheduleRemove(Duration.of(100, TimeUnit.SERVER_TICK));
|
||||
projectile.setOnFire(true);
|
||||
|
||||
final Pos position = player.getPosition().add(0, player.getEyeHeight(), 0);
|
||||
projectile.setInstance(Objects.requireNonNull(player.getInstance()), position);
|
||||
|
||||
final Vec direction = projectile.getPosition().direction();
|
||||
projectile.shoot(position.add(direction).sub(0, 0.2, 0), power * 3, 1.0);
|
||||
projectile.setTag(ARROW_FIRST_HIT, true);
|
||||
}
|
||||
})
|
||||
.filter(itemUpdateStateEvent -> itemUpdateStateEvent.getItemStack().material() == Material.BOW)
|
||||
.build()
|
||||
);
|
||||
|
||||
eventNode().addListener(
|
||||
EventListener
|
||||
.builder(ProjectileHitEvent.ProjectileBlockHitEvent.class)
|
||||
.builder(ProjectileCollideWithBlockEvent.class)
|
||||
.handler(projectileBlockHitEvent -> {
|
||||
CustomEntityProjectile projectile = projectileBlockHitEvent.getEntity();
|
||||
Entity projectile = projectileBlockHitEvent.getEntity();
|
||||
if(!projectile.getTag(ARROW_FIRST_HIT)) {
|
||||
projectile.remove();
|
||||
return;
|
||||
@ -108,7 +99,7 @@ public class BowSpleef extends StatelessGame {
|
||||
|
||||
eventNode().addListener(
|
||||
EventListener
|
||||
.builder(ProjectileHitEvent.ProjectileEntityHitEvent.class)
|
||||
.builder(ProjectileCollideWithEntityEvent.class)
|
||||
.handler(projectileEntityHitEvent -> projectileEntityHitEvent.setCancelled(true))
|
||||
.build()
|
||||
);
|
||||
@ -135,9 +126,8 @@ public class BowSpleef extends StatelessGame {
|
||||
0,
|
||||
ItemStack
|
||||
.builder(Material.BOW)
|
||||
.displayName(TranslatedComponent.byId("bow").getAssembled(player))
|
||||
.meta(builder -> builder.enchantment(Enchantment.FLAME, (short) 1).build())
|
||||
.meta(builder -> builder.hideFlag(ItemHideFlag.HIDE_ENCHANTS))
|
||||
.customName(TranslatedComponent.byId("bow").getAssembled(player))
|
||||
.glowing(true)
|
||||
.build()
|
||||
);
|
||||
});
|
||||
|
@ -6,9 +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.bloepiloepi.pvp.config.AttackConfig;
|
||||
import io.github.bloepiloepi.pvp.config.DamageConfig;
|
||||
import io.github.bloepiloepi.pvp.config.PvPConfig;
|
||||
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;
|
||||
@ -23,17 +21,18 @@ class Deathcube extends StatelessGame {
|
||||
final int percentage;
|
||||
|
||||
public Deathcube(int radius, int height, int percentage, int pvpEnabled) {
|
||||
super(Dimension.THE_END.DIMENSION, "Deathcube", new FirstWinsScore());
|
||||
super(Dimension.THE_END.key, "Deathcube", new FirstWinsScore());
|
||||
this.radius = radius;
|
||||
this.height = height + 49;
|
||||
this.percentage = percentage;
|
||||
this.setGenerator(new CircularPlateTerrainGenerator(radius+10).setPlateHeight(50));
|
||||
|
||||
if(pvpEnabled == 1) eventNode().addChild(
|
||||
PvPConfig.emptyBuilder()
|
||||
.damage(DamageConfig.legacyBuilder().fallDamage(false))
|
||||
.attack(AttackConfig.legacyBuilder().attackCooldown(true))
|
||||
.build().createNode()
|
||||
CombatFeatures.empty()
|
||||
.add(CombatFeatures.VANILLA_ATTACK)
|
||||
.add(CombatFeatures.VANILLA_DAMAGE)
|
||||
.add(CombatFeatures.VANILLA_KNOCKBACK)
|
||||
.build().createNode()
|
||||
);
|
||||
System.out.println(radius);
|
||||
}
|
||||
@ -60,12 +59,20 @@ class Deathcube extends StatelessGame {
|
||||
@Override
|
||||
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||
super.onPlayerMove(playerMoveEvent);
|
||||
if(isBeforeBeginning) if(playerMoveEvent.getNewPosition().y() > 51.5) playerMoveEvent.setCancelled(true);
|
||||
if(playerMoveEvent.getNewPosition().y() < 48) {
|
||||
playerMoveEvent.setCancelled(true);
|
||||
playerMoveEvent.getPlayer().teleport(getSpawn());
|
||||
return;
|
||||
}
|
||||
if(isBeforeBeginning && playerMoveEvent.getNewPosition().y() > 51.5) {
|
||||
playerMoveEvent.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(playerMoveEvent.getNewPosition().y() > height) getScore().insertResult(playerMoveEvent.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
return new Pos(0, 50, 30);
|
||||
return new Pos(0, 50, -(radius+5));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.EquipmentSlot;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.player.*;
|
||||
@ -26,7 +27,6 @@ import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.network.packet.server.play.ParticlePacket;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.particle.ParticleCreator;
|
||||
import net.minestom.server.sound.SoundEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -57,7 +57,7 @@ public class ElytraRace extends StatelessGame {
|
||||
private final Map<Player, CheckPointData> playerCheckpoints = new HashMap<>();
|
||||
|
||||
public ElytraRace(int ringCount) {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "ElytraRace", new FirstWinsScore());
|
||||
super(Dimension.OVERWORLD.key, "ElytraRace", new FirstWinsScore());
|
||||
|
||||
this.ringCount = ringCount;
|
||||
|
||||
@ -106,7 +106,7 @@ public class ElytraRace extends StatelessGame {
|
||||
@Override
|
||||
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
|
||||
Point spawnpoint = new Pos(vale.getXShiftAtZ(0), -46, 0);
|
||||
GeneratorUtils.iterateArea(spawnpoint.sub(2, 0, 2), spawnpoint.add(2, 0, 2), point -> {
|
||||
GeneratorUtils.iterateArea(spawnpoint.sub(5, 0, 5), spawnpoint.add(5, 0, 5), point -> {
|
||||
setBlock(point, BlockPallet.STREET.rnd());
|
||||
});
|
||||
|
||||
@ -118,9 +118,9 @@ public class ElytraRace extends StatelessGame {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
getPlayers().forEach(player -> {
|
||||
player.getInventory().setChestplate(ItemStack.of(Material.ELYTRA));
|
||||
player.getInventory().setEquipment(EquipmentSlot.CHESTPLATE, (byte) 0, ItemStack.of(Material.ELYTRA));
|
||||
for(int i = 0; i < 3; i++) {
|
||||
player.getInventory().setItemStack(i, ItemStack.builder(boostMaterial).displayName(TranslatedComponent.byId("boost").getAssembled(player)).build());
|
||||
player.getInventory().setItemStack(i, ItemStack.builder(boostMaterial).customName(TranslatedComponent.byId("boost").getAssembled(player)).build());
|
||||
}
|
||||
addResetItemToPlayer(player);
|
||||
});
|
||||
@ -131,6 +131,11 @@ public class ElytraRace extends StatelessGame {
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
Point newPos = playerMoveEvent.getNewPosition();
|
||||
|
||||
if(isBeforeBeginning && playerMoveEvent.getNewPosition().y() < getSpawn().y()) {
|
||||
player.teleport(getSpawn());
|
||||
return;
|
||||
}
|
||||
|
||||
playerCheckpoints.putIfAbsent(player, new CheckPointData(ringSpacing, ringSpacing * 2));
|
||||
|
||||
if(newPos.z() > generatedUntil - ringSpacing) {
|
||||
@ -144,7 +149,7 @@ public class ElytraRace extends StatelessGame {
|
||||
|
||||
if(newPos.y() > gameHeight - 5) {
|
||||
Point particlePoint = newPos.withY(gameHeight);
|
||||
ParticlePacket particle = ParticleCreator.createParticlePacket(
|
||||
ParticlePacket particle = new ParticlePacket(
|
||||
Particle.WAX_ON,
|
||||
particlePoint.blockX(),
|
||||
particlePoint.blockY(),
|
||||
@ -152,6 +157,7 @@ public class ElytraRace extends StatelessGame {
|
||||
20,
|
||||
0,
|
||||
30,
|
||||
1f,
|
||||
Math.toIntExact((long) NumberUtil.map(newPos.y(), gameHeight - 5, gameHeight, 50, 500))
|
||||
);
|
||||
player.sendPacket(particle);
|
||||
@ -173,7 +179,7 @@ public class ElytraRace extends StatelessGame {
|
||||
}
|
||||
|
||||
private void addResetItemToPlayer(Player p) {
|
||||
p.getInventory().setItemStack(8, ItemStack.builder(resetMaterial).displayName(TranslatedComponent.byId("reset").getAssembled(p)).build());
|
||||
p.getInventory().setItemStack(8, ItemStack.builder(resetMaterial).customName(TranslatedComponent.byId("reset").getAssembled(p)).build());
|
||||
}
|
||||
|
||||
private Point getRingPositionAtZ(int z) {
|
||||
@ -189,7 +195,7 @@ public class ElytraRace extends StatelessGame {
|
||||
|
||||
Point ringPos = getRingPositionAtZ(zPos);
|
||||
GeneratorUtils.iterateArea(
|
||||
ringPos.sub(100, 0, 0).withY(getDimensionType().getMinY()),
|
||||
ringPos.sub(100, 0, 0).withY(0), // TODO 0 was before update getDimensionType().getMinY, might not work correctly
|
||||
ringPos.add(100, 0, 0).withY(gameHeight),
|
||||
point -> batch.setBlock(point, Block.BARRIER)
|
||||
);
|
||||
|
@ -10,7 +10,6 @@ import eu.mhsl.minenet.minigames.world.BlockPallet;
|
||||
import eu.mhsl.minenet.minigames.world.generator.terrain.SquarePlateTerrainGenerator;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
@ -33,7 +32,7 @@ class Minerun extends StatelessGame {
|
||||
private final int afterFinishLine = 10;
|
||||
|
||||
public Minerun(int width, int length, int minePercentage) {
|
||||
super(Dimension.THE_END.DIMENSION, "Minerun", new FirstWinsScore());
|
||||
super(Dimension.THE_END.key, "Minerun", new FirstWinsScore());
|
||||
setGenerator(new SquarePlateTerrainGenerator(width, length + preRun + afterFinishLine).setPlateHeight(50).setGenerateBorders(true));
|
||||
|
||||
this.width = width;
|
||||
@ -87,7 +86,6 @@ class Minerun extends StatelessGame {
|
||||
|
||||
if(Intersect.withPressurePlate(this, BlockPallet.PRESSURE_PLATES, middle)) { //Player died
|
||||
p.playSound(Sound.sound(SoundEvent.ENTITY_GENERIC_EXPLODE, Sound.Source.PLAYER, 1f, 1f));
|
||||
p.setPose(Entity.Pose.DYING);
|
||||
p.teleport(new Pos(p.getPosition().x(), getSpawn().y(), getSpawn().z()));
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class Spleef extends StatelessGame {
|
||||
final int totalElevation = 50;
|
||||
|
||||
public Spleef(int radius, int stackCount) {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "Spleef", new LastWinsScore());
|
||||
super(Dimension.OVERWORLD.key, "Spleef", new LastWinsScore());
|
||||
getScore().setIgnoreLastPlayers(1);
|
||||
|
||||
this.radius = radius;
|
||||
@ -61,13 +61,7 @@ public class Spleef extends StatelessGame {
|
||||
player.getInventory().addItemStack(
|
||||
ItemStack
|
||||
.builder(Material.DIAMOND_SHOVEL)
|
||||
.displayName(TranslatedComponent.byId("game_Spleef#shovelName").getAssembled(player))
|
||||
.meta(
|
||||
builder -> builder
|
||||
.enchantment(Enchantment.EFFICIENCY, (short) 99)
|
||||
.hideFlag(ItemHideFlag.HIDE_ENCHANTS)
|
||||
.build()
|
||||
)
|
||||
.customName(TranslatedComponent.byId("game_Spleef#shovelName").getAssembled(player))
|
||||
.build()
|
||||
);
|
||||
player.setHeldItemSlot((byte) 0);
|
||||
|
@ -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.bloepiloepi.pvp.config.*;
|
||||
import io.github.bloepiloepi.pvp.events.FinalAttackEvent;
|
||||
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;
|
||||
@ -18,13 +18,14 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class Stickfight extends StatelessGame {
|
||||
public Stickfight() {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "Stickfight", new LastWinsScore());
|
||||
super(Dimension.OVERWORLD.key, "Stickfight", new LastWinsScore());
|
||||
|
||||
eventNode().addChild(
|
||||
PvPConfig.emptyBuilder()
|
||||
.damage(DamageConfig.legacyBuilder().fallDamage(false))
|
||||
.attack(AttackConfig.legacyBuilder().attackCooldown(true))
|
||||
.build().createNode()
|
||||
CombatFeatures.empty()
|
||||
.add(CombatFeatures.VANILLA_ATTACK)
|
||||
.add(CombatFeatures.VANILLA_DAMAGE)
|
||||
.add(CombatFeatures.VANILLA_KNOCKBACK)
|
||||
.build().createNode()
|
||||
);
|
||||
|
||||
eventNode().addListener(FinalAttackEvent.class, finalAttackEvent -> {
|
||||
|
@ -27,7 +27,7 @@ public class TntRun extends StatelessGame {
|
||||
final int radius;
|
||||
final int stackCount;
|
||||
public TntRun(int radius, int stackCount) {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "tntRun", new LastWinsScore());
|
||||
super(Dimension.OVERWORLD.key, "tntRun", new LastWinsScore());
|
||||
this.radius = radius;
|
||||
this.stackCount = stackCount;
|
||||
setGenerator(new CircularPlateTerrainGenerator(radius));
|
||||
@ -74,7 +74,7 @@ public class TntRun extends StatelessGame {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, TaskSchedule.millis(500), TaskSchedule.stop(), ExecutionType.ASYNC);
|
||||
}, TaskSchedule.millis(500), TaskSchedule.stop(), ExecutionType.TICK_END);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import net.minestom.server.item.Material;
|
||||
|
||||
public class Towerdefense extends StatelessGame {
|
||||
public Towerdefense() {
|
||||
super(Dimension.NETHER.DIMENSION, "Towerdefense", new NoScore());
|
||||
super(Dimension.NETHER.key, "Towerdefense", new NoScore());
|
||||
|
||||
setGenerator(new MazeGenerator());
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class TrafficLightRace extends StatelessGame {
|
||||
private final List<Pos> trafficLights = new ArrayList<>();
|
||||
|
||||
public TrafficLightRace(int width, int length) {
|
||||
super(Dimension.THE_END.DIMENSION, "Ampelrennen", new FirstWinsScore());
|
||||
super(Dimension.THE_END.key, "Ampelrennen", new FirstWinsScore());
|
||||
this.width = width;
|
||||
this.length = length;
|
||||
|
||||
@ -150,7 +150,7 @@ class TrafficLightRace extends StatelessGame {
|
||||
BatchUtil.loadAndApplyBatch(changeLightsBatch, this, () -> {});
|
||||
|
||||
return phase.taskScheduleRandomDuration();
|
||||
}, ExecutionType.SYNC);
|
||||
}, ExecutionType.TICK_END);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,7 +9,7 @@ import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.event.player.*;
|
||||
import net.minestom.server.instance.AnvilLoader;
|
||||
import net.minestom.server.instance.anvil.AnvilLoader;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
@ -30,7 +30,7 @@ public class Hub extends MineNetInstance implements Spawnable {
|
||||
}
|
||||
|
||||
private Hub() {
|
||||
super(Dimension.THE_END.DIMENSION);
|
||||
super(Dimension.THE_END.key);
|
||||
setChunkLoader(new AnvilLoader(Path.of("maps/hub")));
|
||||
|
||||
setTime(18000);
|
||||
|
@ -5,7 +5,6 @@ import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.inventory.InventoryType;
|
||||
import net.minestom.server.item.ItemHideFlag;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
|
||||
@ -16,9 +15,8 @@ public class HubInventory extends InteractableInventory {
|
||||
setClickableItem(
|
||||
ItemStack
|
||||
.builder(Material.WRITABLE_BOOK)
|
||||
.displayName(TranslatedComponent.assemble("hub#create", p))
|
||||
.customName(TranslatedComponent.assemble("hub#create", p))
|
||||
.lore(TranslatedComponent.assemble("hub#create_description", p))
|
||||
.meta(metaBuilder -> metaBuilder.hideFlag(ItemHideFlag.HIDE_ATTRIBUTES))
|
||||
.build(),
|
||||
12,
|
||||
itemClick -> Room.createRoom(itemClick.getPlayer()),
|
||||
@ -28,7 +26,7 @@ public class HubInventory extends InteractableInventory {
|
||||
setClickableItem(
|
||||
ItemStack
|
||||
.builder(Material.KNOWLEDGE_BOOK)
|
||||
.displayName(TranslatedComponent.assemble("hub#join", p))
|
||||
.customName(TranslatedComponent.assemble("hub#join", p))
|
||||
.lore(TranslatedComponent.assemble("hub#join_description", p))
|
||||
.build(),
|
||||
14,
|
||||
|
@ -29,7 +29,7 @@ public class JoinInventory extends InteractableInventory {
|
||||
|
||||
setClickableItem(
|
||||
ItemStack.builder(Material.GREEN_STAINED_GLASS_PANE)
|
||||
.displayName(Component.text(prefix))
|
||||
.customName(Component.text(prefix))
|
||||
.build(),
|
||||
0,
|
||||
itemClick -> {}
|
||||
@ -51,7 +51,7 @@ public class JoinInventory extends InteractableInventory {
|
||||
|
||||
typedText = formatInput(typedText);
|
||||
|
||||
Optional<Room> target = Room.getRoom(MinecraftServer.getConnectionManager().findPlayer(typedText));
|
||||
Optional<Room> target = Room.getRoom(MinecraftServer.getConnectionManager().findOnlinePlayer(typedText));
|
||||
if(target.isPresent())
|
||||
Room.setRoom(player, target.get());
|
||||
else
|
||||
|
@ -17,7 +17,7 @@ import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||
import net.minestom.server.event.player.PlayerDisconnectEvent;
|
||||
import net.minestom.server.instance.AnvilLoader;
|
||||
import net.minestom.server.instance.anvil.AnvilLoader;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
@ -85,14 +85,14 @@ public class Room extends MineNetInstance implements Spawnable {
|
||||
private GameSelector gameSelector;
|
||||
private final Tournament tournament = new Tournament();
|
||||
private Room(Player owner) {
|
||||
super(Dimension.THE_END.DIMENSION);
|
||||
super(Dimension.THE_END.key);
|
||||
this.apiDriven = false;
|
||||
construct();
|
||||
setOwner(owner);
|
||||
}
|
||||
|
||||
protected Room() {
|
||||
super(Dimension.THE_END.DIMENSION);
|
||||
super(Dimension.THE_END.key);
|
||||
this.apiDriven = true;
|
||||
construct();
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
||||
import eu.mhsl.minenet.minigames.util.InventoryItemAlignment;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.inventory.InventoryType;
|
||||
import net.minestom.server.item.ItemHideFlag;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
|
||||
@ -29,7 +28,7 @@ public class MinigameSelectInventory extends InteractableInventory {
|
||||
for (GameType type : GameType.values()) {
|
||||
setClickableItem(
|
||||
ItemStack.builder(type.getIcon())
|
||||
.displayName(type.getTitle().getAssembled(p))
|
||||
.customName(type.getTitle().getAssembled(p))
|
||||
.lore(type.getDescription().addWrap().getWrappedAssembled(p))
|
||||
.build(),
|
||||
itemAlignment.next().get(),
|
||||
@ -58,9 +57,8 @@ public class MinigameSelectInventory extends InteractableInventory {
|
||||
|
||||
setClickableItem(
|
||||
ItemStack.builder(gameFactory.symbol())
|
||||
.displayName(gameFactory.name().getAssembled(p))
|
||||
.customName(gameFactory.name().getAssembled(p))
|
||||
.lore(gameFactory.description().addWrap().getWrappedAssembled(p))
|
||||
.meta(metaBuilder -> metaBuilder.hideFlag(ItemHideFlag.HIDE_ATTRIBUTES))
|
||||
.build(),
|
||||
offset + itemAlignment.next().get(),
|
||||
itemClick -> itemClick.getPlayer().openInventory(new GameConfigurationInventory(room, itemClick.getPlayer(), gameFactory))
|
||||
|
@ -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.DIMENSION);
|
||||
eventNode().addListener(PlayerMoveEvent.class, CommonEventHandles::cancel);
|
||||
setBlock(0, 0, 0, Block.BARRIER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
return new Pos(0.5, 1, 0.5);
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class Languages {
|
||||
}
|
||||
|
||||
public Lang getLanguage(Player p) {
|
||||
return getLanguage(p.getSettings().getLocale());
|
||||
return getLanguage(p.getSettings().locale().toString()); // TODO funktioniert die locale noch?
|
||||
}
|
||||
public Lang getLanguage(String mapId) {
|
||||
return languages.computeIfAbsent(mapId, unused -> languages.computeIfAbsent(defaultLanguage, (key) -> new DummyLang()));
|
||||
|
@ -10,7 +10,7 @@ import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.*;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.instance.AnvilLoader;
|
||||
import net.minestom.server.instance.anvil.AnvilLoader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -19,13 +19,13 @@ public class TournamentDisplay extends MineNetInstance implements Spawnable {
|
||||
private final Tournament tournament;
|
||||
|
||||
private final Pos[] placePositions = new Pos[] {
|
||||
new Pos(8.5, -57, 21.5, 180, 0),
|
||||
new Pos(9.5, -58, 21.5, 180, 0),
|
||||
new Pos(7.5, -59, 21.5, 180, 0)
|
||||
new Pos(8.5, -56, 22.5, 180, 0),
|
||||
new Pos(12.5, -57, 20.5, 180, 0),
|
||||
new Pos(4.5, -58, 20.5, 180, 0)
|
||||
};
|
||||
|
||||
public TournamentDisplay(Tournament tournament) {
|
||||
super(Dimension.OVERWORLD.DIMENSION);
|
||||
super(Dimension.OVERWORLD.key);
|
||||
setChunkLoader(new AnvilLoader(Resource.RESULT_DISPLAY.getPath()));
|
||||
this.places = tournament.getPlaces();
|
||||
this.tournament = tournament;
|
||||
@ -62,6 +62,6 @@ public class TournamentDisplay extends MineNetInstance implements Spawnable {
|
||||
|
||||
@Override
|
||||
public Pos getSpawn() {
|
||||
return new Pos(8.5, -55, 8.5);
|
||||
return new Pos(8.5, -59, 11.5);
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
package eu.mhsl.minenet.minigames.server.provider;
|
||||
|
||||
import eu.mhsl.minenet.minigames.util.UuidUtil;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.network.UuidProvider;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.mojang.MojangUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ByPlayerNameUuidProvider implements UuidProvider {
|
||||
@Override
|
||||
public UUID provide(PlayerConnection playerConnection, String username) {
|
||||
try {
|
||||
|
||||
if(MinecraftServer.getConnectionManager().getPlayer(username) != null) throw new IllegalStateException();
|
||||
String client = MojangUtils.fromUsername(username).get("id").getAsString();
|
||||
return UuidUtil.unTrimm(client);
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
Logger.getGlobal().info("Player " + username + " is unknown by Mojang! (Using random UUID)");
|
||||
} catch (IllegalStateException e) {
|
||||
Logger.getGlobal().info("Player with the username " + username + " is already online.");
|
||||
playerConnection.disconnect();
|
||||
}
|
||||
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ public class InteractableInventory extends Inventory {
|
||||
|
||||
protected void setDummyItem(Material material, int slot) {
|
||||
this.setDummyItem(
|
||||
ItemStack.builder(material).displayName(Component.text("")).build(),
|
||||
ItemStack.builder(material).customName(Component.text("")).build(),
|
||||
slot
|
||||
);
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ public class SkinCache {
|
||||
MinecraftServer.getSchedulerManager().submitTask(() -> {
|
||||
p.setSkin(SkinCache.getSkin(p.getUsername()));
|
||||
return TaskSchedule.stop();
|
||||
}, ExecutionType.ASYNC);
|
||||
}, ExecutionType.TICK_END);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
package eu.mhsl.minenet.minigames.util;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.entity.PlayerSkin;
|
||||
import net.minestom.server.network.packet.server.play.PlayerInfoUpdatePacket;
|
||||
import net.minestom.server.network.packet.server.play.SpawnPlayerPacket;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PacketUtil {
|
||||
public static void resendPlayerList(Player p) {
|
||||
MinecraftServer.getConnectionManager().getOnlinePlayers().forEach(player -> {
|
||||
if(player.getUuid().equals(p.getUuid())) return;
|
||||
|
||||
final PlayerSkin skin = player.getSkin();
|
||||
List<PlayerInfoUpdatePacket.Property> properties =
|
||||
skin != null ? List.of(new PlayerInfoUpdatePacket.Property("textures", skin.textures(), skin.signature())) : List.of();
|
||||
|
||||
p.sendPacket(
|
||||
new PlayerInfoUpdatePacket(PlayerInfoUpdatePacket.Action.ADD_PLAYER,
|
||||
new PlayerInfoUpdatePacket.Entry(
|
||||
player.getUuid(),
|
||||
player.getUsername(),
|
||||
properties,
|
||||
true,
|
||||
0,
|
||||
GameMode.SURVIVAL,
|
||||
null,
|
||||
null
|
||||
)
|
||||
)
|
||||
);
|
||||
p.sendPacket(
|
||||
new SpawnPlayerPacket(player.getEntityId(), player.getUuid(), player.getPosition())
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ package eu.mhsl.minenet.minigames.util;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.network.packet.server.play.PluginMessagePacket;
|
||||
import net.minestom.server.network.packet.server.common.PluginMessagePacket;
|
||||
|
||||
public class PluginMessageUtil {
|
||||
private static final String bungeeTargetSelector = "bungeecord:main";
|
||||
|
@ -1,5 +0,0 @@
|
||||
package eu.mhsl.minenet.minigames.util;
|
||||
|
||||
public abstract class Static {
|
||||
public abstract void load(); //TODO REMOVE
|
||||
}
|
@ -24,6 +24,6 @@ public class WeatherUtils {
|
||||
} else {
|
||||
return TaskSchedule.stop();
|
||||
}
|
||||
}, ExecutionType.ASYNC);
|
||||
}, ExecutionType.TICK_END);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class CircularPlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
double distance = bottom.distance(new Pos(0, 0, 0));
|
||||
|
||||
if(distance <= this.size && generatePlate()) {
|
||||
unit.modifier().fill(bottom, bottom.add(1, 50, 1), platePallet.rnd());
|
||||
unit.modifier().fill(bottom, bottom.add(1, plateHeight, 1), platePallet.rnd());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class SquarePlateTerrainGenerator extends PlateTerrainGenerator {
|
||||
}
|
||||
|
||||
if(generateBorders) {
|
||||
Runnable generateBorder = () -> unit.modifier().fill(bottom, bottom.add(1, DimensionType.OVERWORLD.getMaxY(), 1), Block.BARRIER);
|
||||
Runnable generateBorder = () -> unit.modifier().fill(bottom, bottom.add(1, 0, 1), Block.BARRIER); // TODO DimensionType.OVERWORLD.getMaxY() is now hardcoded 0, might break behaviour
|
||||
|
||||
if(bottom.z() <= length+1 && bottom.z() >= -1 && bottom.x() >= -1 && bottom.x() <= width+1) {
|
||||
if(bottom.x() == -1 || bottom.x() == width+1) {
|
||||
|
@ -55,6 +55,7 @@ width;Width;Breite
|
||||
length;Length;Länge
|
||||
height;Height;Höhe
|
||||
radius;Radius;Radius
|
||||
seconds;Seconds;Sekunden
|
||||
;;
|
||||
ns:room#;;
|
||||
invTitle;Select a Minigame;Wähle einen Spielmodus
|
||||
@ -89,4 +90,8 @@ description;Protect the path ????;??????
|
||||
ns:game_Spleef#;;
|
||||
name;Spleef;Spleef;
|
||||
description;Spleef other players and be the last survivor;Zerstöre Blöcke unter anderen Spielern und sei der letzte im Feld
|
||||
shovelName;Snow thrower;Schneeflug
|
||||
shovelName;Snow thrower;Schneeflug
|
||||
;;
|
||||
ns:game_AnvilRun#;;
|
||||
name;Anvil Run;Anvil Run
|
||||
description;Run away from falling anvils;Renne von fallenden Ambossen davon
|
Can't render this file because it has a wrong number of fields in line 91.
|
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.
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.
Reference in New Issue
Block a user