Inspection and Cleanup
This commit is contained in:
parent
6907a767c6
commit
c9bc9dd2da
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<pattern value="eu.mhsl.minenet.minigames.util.InventoryItemAlignment.ItemOffset" method="getX" />
|
||||||
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="JavadocGenerationManager">
|
<component name="JavadocGenerationManager">
|
||||||
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/docs" />
|
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/docs" />
|
||||||
|
@ -1 +0,0 @@
|
|||||||
,elias,ELIAS-PC,03.10.2022 16:40,file:///home/elias/.config/libreoffice/4;
|
|
@ -1,81 +0,0 @@
|
|||||||
map;en_us;de_de
|
|
||||||
localName;English;Deutsch
|
|
||||||
name;English;German
|
|
||||||
symbol;eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q5MTQ1Njg3N2Y1NGJmMWFjZTI1MWU0Y2VlNDBkYmE1OTdkMmNjNDAzNjJjYjhmNGVkNzExZTUwYjBiZTViMyJ9fX0=;eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWU3ODk5YjQ4MDY4NTg2OTdlMjgzZjA4NGQ5MTczZmU0ODc4ODY0NTM3NzQ2MjZiMjRiZDhjZmVjYzc3YjNmIn19fQ==
|
|
||||||
sample;The quick brown fox jumps over the lazy dog;Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich
|
|
||||||
;;
|
|
||||||
ns:common#;;
|
|
||||||
select_language;Please select your prefered Language;Bitte wähle deine bevorzugte Sprache!
|
|
||||||
welcome;Welcome!;Willkommen!
|
|
||||||
back;Back;Zurück
|
|
||||||
forward;Next;Nächste
|
|
||||||
;;
|
|
||||||
ns:GameType#;;
|
|
||||||
other;Other games;Andere Spiele
|
|
||||||
other_description;Games which does not fit into other Categories;Spiele welche nicht in die anderen Kategorien passen
|
|
||||||
pvp;Player vs Player;Spieler gegen Spieler
|
|
||||||
pvp_description;Fight against other Players;Kämpfe gegen andere Spieler
|
|
||||||
pve;Player vs Enviroment;Spieler gegen Umwelt
|
|
||||||
pve_description;Surivie the world or fight entities;Überlebe die Welt oder kämpfe gegen Mobs
|
|
||||||
;;
|
|
||||||
ns:hub#;;
|
|
||||||
invTitle;MineNet Servernetwork;MineNet Servernetzwerk
|
|
||||||
create;Create your personal Lobby;Erstelle deine persönliche Lobby
|
|
||||||
create_description;Let other players join your Lobby to play with them;Lasse andere Spieler auf deine Lobby joinen um mit ihnen zusammen zu spielen
|
|
||||||
join;Join existing Lobby;Betrete eine bestehende Lobby
|
|
||||||
join_description;All you need is the Username of the Lobby you want to join;Alles was du benötigst ist der Nutzername des Besitzers, dessen Lobby du beitreten möchtest
|
|
||||||
join_title;Enter Username;Benutzername
|
|
||||||
join_notFound;Lobby not found: ;Lobby konnte nicht gefunden werden:
|
|
||||||
;;
|
|
||||||
ns:score#;;
|
|
||||||
result;Results;Ergebnisse
|
|
||||||
thanks;Thank you for Playing;Danke für‘s spielen
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
ns:restriction#;;
|
|
||||||
fail;Some requirements are not met;Bedinungen sind nicht erfüllt
|
|
||||||
success;Play;Spielen
|
|
||||||
minPlayersInRoom;Minimal amount of Players in Lobby;Minimale Anzahl von Spielern in deiner Lobby
|
|
||||||
minPlayersInRoomDescription;You need more Players in your room to play this;Die Anzahl der Spieler ist zu gering um dieses Spiel zu starten
|
|
||||||
maxPlayersInRoom;Maximal amount of Players in Lobby;Maximale Anzahl von Spielern in deiner Lobby
|
|
||||||
maxPlayersInRoomDescription;There are too many players in your room;Die Anzahl der Spieler in deiner Lobby ist zu hoch für dieses Spiel
|
|
||||||
;;
|
|
||||||
ns:optionCommon#;;
|
|
||||||
value;Value;Wert
|
|
||||||
width;Width;Breite
|
|
||||||
length;Length;Länge
|
|
||||||
height;Height;Höhe
|
|
||||||
radius;Radius;Radius
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
;;
|
|
||||||
ns:room#;;
|
|
||||||
invTitle;Select a Minigame;Wähle einen Spielmodus
|
|
||||||
noOption;No options here;Keine Optionen hier
|
|
||||||
noOptionDescription;There are no options for this Game;Es gibt keine Einstellungen für dieses Spiel
|
|
||||||
;;
|
|
||||||
ns:GameFactory#;;
|
|
||||||
missingDescription;No description;Keine Beschreibung
|
|
||||||
;;
|
|
||||||
ns:game_Minerun#;;
|
|
||||||
name;Minerun;Minenrennen
|
|
||||||
description;Ditch deadly Mines in the ground an be the first in the goal;Weiche den tödlichen Bodenmienen aus und sei der erste im Ziel
|
|
||||||
optionPercentageMines;Percentage of Miens;Prozentsatz der Minen
|
|
||||||
;;
|
|
||||||
ns:game_Deathcube#;;
|
|
||||||
name;Deathcube;Todeswürfel
|
|
||||||
description;Find a way to jump higher and be the first on the top;Finde einen weg nach oben und sei der erste im Ziel
|
|
||||||
optionPercentageBlocks;Percentage of Blocks;Prozentsatz der Blöcke
|
|
||||||
;;
|
|
||||||
ns:game_Stickfight#;;
|
|
||||||
name;Stickfight;Stockschlacht
|
|
||||||
description;Push your opponents off the Bridge;Stoße deine Gegener von der Brücke
|
|
||||||
;;
|
|
||||||
ns:game_TrafficlightRace#;;
|
|
||||||
name;Red light green light;Rotes licht, Grünes licht
|
|
||||||
description;Only go forward if the Trafficlights show green;Gehe nur bei Grün vorran
|
|
|
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.
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.
@ -10,8 +10,6 @@ import net.minestom.server.MinecraftServer;
|
|||||||
import net.minestom.server.extras.lan.OpenToLAN;
|
import net.minestom.server.extras.lan.OpenToLAN;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
|
|
||||||
import java.util.logging.ConsoleHandler;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
@ -13,9 +13,7 @@ import java.util.logging.Logger;
|
|||||||
public enum Resource {
|
public enum Resource {
|
||||||
HUB_MAP("maps/hub"),
|
HUB_MAP("maps/hub"),
|
||||||
LOBBY_MAP("maps/lobby"),
|
LOBBY_MAP("maps/lobby"),
|
||||||
RBB("rbb"),
|
LOCALES("lang");
|
||||||
LOCALES("lang"),
|
|
||||||
SCHEMATICS("schematics");
|
|
||||||
|
|
||||||
private final Path path;
|
private final Path path;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -4,7 +4,6 @@ import eu.mhsl.minenet.minigames.message.Icon;
|
|||||||
import eu.mhsl.minenet.minigames.message.type.ActionBarMessage;
|
import eu.mhsl.minenet.minigames.message.type.ActionBarMessage;
|
||||||
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
||||||
import eu.mhsl.minenet.minigames.message.type.TitleMessage;
|
import eu.mhsl.minenet.minigames.message.type.TitleMessage;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.command.builder.Command;
|
import net.minestom.server.command.builder.Command;
|
||||||
|
|
||||||
public class DebugCommand extends Command {
|
public class DebugCommand extends Command {
|
||||||
|
@ -11,8 +11,6 @@ public class GamemodeCommand extends Command {
|
|||||||
|
|
||||||
setCondition((sender, commandString) -> sender.hasPermission("admin"));
|
setCondition((sender, commandString) -> sender.hasPermission("admin"));
|
||||||
|
|
||||||
addSyntax((sender, context) -> {
|
addSyntax((sender, context) -> ((Player) sender).setGameMode(context.get("target")), ArgumentType.Enum("target", GameMode.class));
|
||||||
((Player) sender).setGameMode(context.get("target"));
|
|
||||||
}, ArgumentType.Enum("target", GameMode.class));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class GcCommand extends Command {
|
|||||||
setCondition((sender, commandString) -> sender.hasPermission("admin"));
|
setCondition((sender, commandString) -> sender.hasPermission("admin"));
|
||||||
|
|
||||||
setDefaultExecutor((sender, context) -> {
|
setDefaultExecutor((sender, context) -> {
|
||||||
long nextRun = (long) (lastRun - (System.currentTimeMillis() - 30*1000)) / 1000;
|
long nextRun = (lastRun - (System.currentTimeMillis() - 30*1000)) / 1000;
|
||||||
if(nextRun > 0) {
|
if(nextRun > 0) {
|
||||||
new ChatMessage(Icon.ERROR).appendStatic("Please wait ").appendStatic(String.valueOf(nextRun)).appendStatic(" seconds before running GC again!").send(sender);
|
new ChatMessage(Icon.ERROR).appendStatic("Please wait ").appendStatic(String.valueOf(nextRun)).appendStatic(" seconds before running GC again!").send(sender);
|
||||||
return;
|
return;
|
||||||
|
@ -15,15 +15,11 @@ public class LangTestCommand extends Command {
|
|||||||
|
|
||||||
setCondition((sender, commandString) -> sender.hasPermission("admin"));
|
setCondition((sender, commandString) -> sender.hasPermission("admin"));
|
||||||
|
|
||||||
setDefaultExecutor((sender, context) -> {
|
setDefaultExecutor((sender, context) -> sendMessage(Languages.getInstance().getLanguage((Player) sender), "sample").send(sender));
|
||||||
sendMessage(Languages.getInstance().getLanguage((Player) sender), "sample").send(sender);
|
|
||||||
});
|
|
||||||
|
|
||||||
var targetString = ArgumentType.String("mapId");
|
var targetString = ArgumentType.String("mapId");
|
||||||
|
|
||||||
addSyntax((sender, context) -> {
|
addSyntax((sender, context) -> sendMessage(Languages.getInstance().getLanguage((Player) sender), context.get("mapId")).send(sender), targetString);
|
||||||
sendMessage(Languages.getInstance().getLanguage((Player) sender), context.get("mapId")).send(sender);
|
|
||||||
}, targetString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TranslatableMessage sendMessage(Lang lang, String mapId) {
|
private TranslatableMessage sendMessage(Lang lang, String mapId) {
|
||||||
|
@ -18,13 +18,11 @@ public class RoomCommand extends Command {
|
|||||||
setDefaultExecutor((sender, context) -> {
|
setDefaultExecutor((sender, context) -> {
|
||||||
TranslatableMessage out = new ChatMessage(Icon.SCIENCE).appendStatic("Rooms:").indent(1).newLine();
|
TranslatableMessage out = new ChatMessage(Icon.SCIENCE).appendStatic("Rooms:").indent(1).newLine();
|
||||||
|
|
||||||
Room.getAllRooms().forEach((roomInstance) -> {
|
Room.getAllRooms().forEach((roomInstance) -> out
|
||||||
out
|
.newLine()
|
||||||
.newLine()
|
.appendStatic("Owner: ").appendStatic(roomInstance.getOwner().getUsername()).newLine()
|
||||||
.appendStatic("Owner: ").appendStatic(roomInstance.getOwner().getUsername()).newLine()
|
.appendStatic("Players: ").appendStatic(String.valueOf(roomInstance.getAllMembers().size())).indent(1).newLine()
|
||||||
.appendStatic("Players: ").appendStatic(String.valueOf(roomInstance.getAllMembers().size())).indent(1).newLine()
|
.list(roomInstance.getAllMembers().stream().map(Player::getUsername).collect(Collectors.toList())).indent(-1).newLine());
|
||||||
.list(roomInstance.getAllMembers().stream().map(Player::getUsername).collect(Collectors.toList())).indent(-1).newLine();
|
|
||||||
});
|
|
||||||
|
|
||||||
out.send(sender);
|
out.send(sender);
|
||||||
});
|
});
|
||||||
|
@ -11,8 +11,6 @@ public class LeaveCommand extends Command {
|
|||||||
|
|
||||||
setCondition((sender, commandString) -> ((Player) sender).getInstance() instanceof Game);
|
setCondition((sender, commandString) -> ((Player) sender).getInstance() instanceof Game);
|
||||||
|
|
||||||
setDefaultExecutor((sender, context) -> {
|
setDefaultExecutor((sender, context) -> Room.setOwnRoom((Player) sender));
|
||||||
Room.setOwnRoom((Player) sender);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,26 +5,19 @@ import eu.mhsl.minenet.minigames.instance.game.minigame.config.GameFactory;
|
|||||||
import eu.mhsl.minenet.minigames.util.CommonEventHandles;
|
import eu.mhsl.minenet.minigames.util.CommonEventHandles;
|
||||||
import eu.mhsl.minenet.minigames.instance.Spawnable;
|
import eu.mhsl.minenet.minigames.instance.Spawnable;
|
||||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
import io.github.bloepiloepi.pvp.config.PvPConfig;
|
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.EventNode;
|
|
||||||
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
|
||||||
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
|
||||||
import net.minestom.server.event.item.ItemDropEvent;
|
import net.minestom.server.event.item.ItemDropEvent;
|
||||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||||
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
|
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
import net.minestom.server.event.trait.InstanceEvent;
|
|
||||||
import net.minestom.server.instance.InstanceContainer;
|
|
||||||
import net.minestom.server.timer.ExecutionType;
|
import net.minestom.server.timer.ExecutionType;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import net.minestom.server.world.DimensionType;
|
import net.minestom.server.world.DimensionType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ public enum GameList {
|
|||||||
MINERUN(new MinerunFactory(), GameType.PVE),
|
MINERUN(new MinerunFactory(), GameType.PVE),
|
||||||
TRAFFICLIGHTRACE(new TrafficLightRaceFactory(), GameType.OTHER);
|
TRAFFICLIGHTRACE(new TrafficLightRaceFactory(), GameType.OTHER);
|
||||||
|
|
||||||
private GameFactory factory;
|
private final GameFactory factory;
|
||||||
private GameType type;
|
private final GameType type;
|
||||||
GameList(GameFactory factory, GameType type) {
|
GameList(GameFactory factory, GameType type) {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -9,9 +9,9 @@ public enum GameType {
|
|||||||
PVE(Material.DIAMOND_PICKAXE, TranslatedComponent.byId("GameType#pve"), TranslatedComponent.byId("GameType#pve_description"));
|
PVE(Material.DIAMOND_PICKAXE, TranslatedComponent.byId("GameType#pve"), TranslatedComponent.byId("GameType#pve_description"));
|
||||||
|
|
||||||
|
|
||||||
Material icon;
|
final Material icon;
|
||||||
TranslatedComponent title;
|
final TranslatedComponent title;
|
||||||
TranslatedComponent description;
|
final TranslatedComponent description;
|
||||||
|
|
||||||
GameType(Material icon, TranslatedComponent title, TranslatedComponent description) {
|
GameType(Material icon, TranslatedComponent title, TranslatedComponent description) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -9,22 +9,20 @@ import eu.mhsl.minenet.minigames.score.Score;
|
|||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
|
||||||
import net.minestom.server.timer.ExecutionType;
|
import net.minestom.server.timer.ExecutionType;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
import net.minestom.server.world.DimensionType;
|
import net.minestom.server.world.DimensionType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class Minigame extends Game {
|
public class Minigame extends Game {
|
||||||
private final String name;
|
private final String name;
|
||||||
private Score score = new Score(this);
|
private final Score score = new Score(this);
|
||||||
|
|
||||||
private int timeLimit = 0;
|
private int timeLimit = 0;
|
||||||
private int timePlayed = 0;
|
private int timePlayed = 0;
|
||||||
private boolean preventExit = false;
|
private final boolean preventExit = false;
|
||||||
public Minigame(DimensionType dimensionType, String gameName) {
|
public Minigame(DimensionType dimensionType, String gameName) {
|
||||||
super(dimensionType);
|
super(dimensionType);
|
||||||
|
|
||||||
@ -54,14 +52,10 @@ public class Minigame extends Game {
|
|||||||
*/
|
*/
|
||||||
protected CompletableFuture<Void> countdownStart() {
|
protected CompletableFuture<Void> countdownStart() {
|
||||||
return new Countdown(TitleMessage.class)
|
return new Countdown(TitleMessage.class)
|
||||||
.countdown(Audience.audience(getPlayers()), 5, countdownModifier -> {
|
.countdown(Audience.audience(getPlayers()), 5, countdownModifier -> countdownModifier.message = new TitleMessage(Duration.ofMillis(300), Duration.ofMillis(700))
|
||||||
countdownModifier.message = new TitleMessage(Duration.ofMillis(300), Duration.ofMillis(700))
|
.subtitle(subtitleMessage -> subtitleMessage.appendStatic(Component.text("in ", NamedTextColor.DARK_GREEN))
|
||||||
.subtitle(subtitleMessage -> {
|
.appendStatic(Component.text(countdownModifier.timeLeft, NamedTextColor.GREEN))
|
||||||
subtitleMessage.appendStatic(Component.text("in ", NamedTextColor.DARK_GREEN))
|
.appendStatic(Component.text(" seconds", NamedTextColor.DARK_GREEN))));
|
||||||
.appendStatic(Component.text(countdownModifier.timeLeft, NamedTextColor.GREEN))
|
|
||||||
.appendStatic(Component.text(" seconds", NamedTextColor.DARK_GREEN));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
package eu.mhsl.minenet.minigames.instance.game.minigame.config;
|
package eu.mhsl.minenet.minigames.instance.game.minigame.config;
|
||||||
|
|
||||||
import com.extollit.linalg.mutable.Vec2d;
|
|
||||||
import eu.mhsl.minenet.minigames.instance.game.Game;
|
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.IRestriction;
|
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.Restriction;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.Restriction;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionData;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionData;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionHandler;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionHandler;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
||||||
import eu.mhsl.minenet.minigames.util.InventoryItemAlignment;
|
import eu.mhsl.minenet.minigames.util.InventoryItemAlignment;
|
||||||
import eu.mhsl.minenet.minigames.util.TextUtil;
|
|
||||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.coordinate.Vec;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
||||||
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
||||||
@ -116,7 +111,7 @@ public class GameConfigurationInventory extends InteractableInventory {
|
|||||||
|
|
||||||
if(!map.containsKey(slot)) return;
|
if(!map.containsKey(slot)) return;
|
||||||
|
|
||||||
Option item = map.get(slot);
|
Option<?> item = map.get(slot);
|
||||||
setDummyItem(
|
setDummyItem(
|
||||||
item.getNext(p),
|
item.getNext(p),
|
||||||
slot
|
slot
|
||||||
@ -138,9 +133,7 @@ public class GameConfigurationInventory extends InteractableInventory {
|
|||||||
.lore(restrictionHandler.getWarnings(restrictionData).stream().map(translatedComponent -> translatedComponent.getAssembled(p)).collect(Collectors.toList()))
|
.lore(restrictionHandler.getWarnings(restrictionData).stream().map(translatedComponent -> translatedComponent.getAssembled(p)).collect(Collectors.toList()))
|
||||||
.build(),
|
.build(),
|
||||||
8,
|
8,
|
||||||
itemClick -> {
|
itemClick -> Game.initialize(factory, itemClick.getPlayer()),
|
||||||
Game.initialize(factory, itemClick.getPlayer());
|
|
||||||
},
|
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -152,8 +145,8 @@ public class GameConfigurationInventory extends InteractableInventory {
|
|||||||
.lore(
|
.lore(
|
||||||
restrictionHandler.getRestrictions()
|
restrictionHandler.getRestrictions()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(iRestriction -> iRestriction.calculate(restrictionData).getType().equals(Restriction.Type.FAIL))
|
.filter(iRestriction -> iRestriction.calculate(restrictionData).type().equals(Restriction.Type.FAIL))
|
||||||
.map(iRestriction -> iRestriction.calculate(restrictionData).getDescription().getAssembled(p))
|
.map(iRestriction -> iRestriction.calculate(restrictionData).description().getAssembled(p))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.build(),
|
.build(),
|
||||||
8,
|
8,
|
||||||
|
@ -3,8 +3,6 @@ package eu.mhsl.minenet.minigames.instance.game.minigame.config;
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.Minigame;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.Minigame;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionHandler;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionHandler;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.instance.block.Block;
|
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.mhsl.minenet.minigames.instance.game.minigame.config.common;
|
package eu.mhsl.minenet.minigames.instance.game.minigame.config.common;
|
||||||
|
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.Option;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.Option;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionHandler;
|
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
|
@ -2,40 +2,19 @@ package eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction;
|
|||||||
|
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
|
||||||
public class Restriction {
|
public record Restriction(TranslatedComponent name, TranslatedComponent description, TranslatedComponent warnMessage,
|
||||||
final private TranslatedComponent name;
|
eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.Restriction.Type type) {
|
||||||
final private TranslatedComponent description;
|
|
||||||
final private TranslatedComponent warnMessage;
|
|
||||||
|
|
||||||
final private Type type;
|
|
||||||
|
|
||||||
public Restriction(TranslatedComponent name, TranslatedComponent description, TranslatedComponent warnMessage, Type type) {
|
public Restriction(TranslatedComponent name, TranslatedComponent description, TranslatedComponent warnMessage, Type type) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.warnMessage = warnMessage;
|
this.warnMessage = warnMessage;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
if(this.warnMessage == null && this.type.equals(Type.WARN)) {
|
if (this.warnMessage == null && this.type.equals(Type.WARN)) {
|
||||||
throw new IllegalStateException("warnMessage cannot be null when RestrictionType is WARN");
|
throw new IllegalStateException("warnMessage cannot be null when RestrictionType is WARN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TranslatedComponent getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TranslatedComponent getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TranslatedComponent getWarnMessage() {
|
|
||||||
return warnMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
OK,
|
OK,
|
||||||
WARN,
|
WARN,
|
||||||
|
@ -2,14 +2,5 @@ package eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction;
|
|||||||
|
|
||||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
|
|
||||||
public class RestrictionData {
|
public record RestrictionData(Room room) {
|
||||||
final private Room room;
|
|
||||||
|
|
||||||
public RestrictionData(Room room) {
|
|
||||||
this.room = room;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Room getRoom() {
|
|
||||||
return room;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction;
|
|||||||
|
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -29,16 +28,16 @@ public class RestrictionHandler {
|
|||||||
public boolean canPlay(RestrictionData data) {
|
public boolean canPlay(RestrictionData data) {
|
||||||
if(restrictions.size() < 1) return true;
|
if(restrictions.size() < 1) return true;
|
||||||
return this.restrictions.stream()
|
return this.restrictions.stream()
|
||||||
.noneMatch(iRestriction -> iRestriction.calculate(data).getType().equals(Restriction.Type.FAIL));
|
.noneMatch(iRestriction -> iRestriction.calculate(data).type().equals(Restriction.Type.FAIL));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TranslatedComponent> getWarnings(RestrictionData data) {
|
public List<TranslatedComponent> getWarnings(RestrictionData data) {
|
||||||
List<TranslatedComponent> warnings = new ArrayList<>();
|
List<TranslatedComponent> warnings = new ArrayList<>();
|
||||||
for (IRestriction r : this.restrictions) {
|
for (IRestriction r : this.restrictions) {
|
||||||
Restriction calculated = r.calculate(data);
|
Restriction calculated = r.calculate(data);
|
||||||
if(!calculated.getType().equals(Restriction.Type.WARN)) continue;
|
if(!calculated.type().equals(Restriction.Type.WARN)) continue;
|
||||||
|
|
||||||
warnings.add(calculated.getWarnMessage());
|
warnings.add(calculated.warnMessage());
|
||||||
}
|
}
|
||||||
return warnings;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.Restr
|
|||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
|
||||||
public class MaximalPlayeramountGameRestriction implements IRestriction {
|
public class MaximalPlayeramountGameRestriction implements IRestriction {
|
||||||
private int max;
|
private final int max;
|
||||||
|
|
||||||
public MaximalPlayeramountGameRestriction(int max) {
|
public MaximalPlayeramountGameRestriction(int max) {
|
||||||
this.max = max;
|
this.max = max;
|
||||||
@ -18,7 +18,7 @@ public class MaximalPlayeramountGameRestriction implements IRestriction {
|
|||||||
TranslatedComponent.byId("restriction#maxPlayersInRoom"),
|
TranslatedComponent.byId("restriction#maxPlayersInRoom"),
|
||||||
TranslatedComponent.byId("restriction#maxPlayersInRoomDescription"),
|
TranslatedComponent.byId("restriction#maxPlayersInRoomDescription"),
|
||||||
null,
|
null,
|
||||||
data.getRoom().getAllMembers().size() > this.max ? Restriction.Type.FAIL : Restriction.Type.OK
|
data.room().getAllMembers().size() > this.max ? Restriction.Type.FAIL : Restriction.Type.OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,8 @@ import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.Restr
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionData;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionData;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
|
||||||
import javax.xml.transform.OutputKeys;
|
|
||||||
|
|
||||||
public class MinimalPlayeramountGameRestriction implements IRestriction {
|
public class MinimalPlayeramountGameRestriction implements IRestriction {
|
||||||
private int min;
|
private final int min;
|
||||||
|
|
||||||
public MinimalPlayeramountGameRestriction(int min) {
|
public MinimalPlayeramountGameRestriction(int min) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
@ -20,7 +18,7 @@ public class MinimalPlayeramountGameRestriction implements IRestriction {
|
|||||||
TranslatedComponent.byId("restriction#minPlayersInRoom"),
|
TranslatedComponent.byId("restriction#minPlayersInRoom"),
|
||||||
TranslatedComponent.byId("restriction#minPlayersInRoomDescription"),
|
TranslatedComponent.byId("restriction#minPlayersInRoomDescription"),
|
||||||
null,
|
null,
|
||||||
data.getRoom().getAllMembers().size() < this.min ? Restriction.Type.FAIL : Restriction.Type.OK
|
data.room().getAllMembers().size() < this.min ? Restriction.Type.FAIL : Restriction.Type.OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,9 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
|
|
||||||
class Deathcube extends Minigame {
|
class Deathcube extends Minigame {
|
||||||
|
|
||||||
int radius, height, percentage;
|
final int radius;
|
||||||
|
final int height;
|
||||||
|
final int percentage;
|
||||||
|
|
||||||
public Deathcube(int radius, int height, int percentage) {
|
public Deathcube(int radius, int height, int percentage) {
|
||||||
super(Dimension.THE_END.DIMENSION, "Deathcube");
|
super(Dimension.THE_END.DIMENSION, "Deathcube");
|
||||||
|
@ -6,7 +6,6 @@ import eu.mhsl.minenet.minigames.instance.game.minigame.config.Option;
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.ConfigManager;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.ConfigManager;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.common.NumericOption;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.common.NumericOption;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -28,7 +28,6 @@ class Minerun extends Minigame {
|
|||||||
private int width = 100;
|
private int width = 100;
|
||||||
private int length = 50;
|
private int length = 50;
|
||||||
|
|
||||||
private final int backRun = -5;
|
|
||||||
private final int preRun = 5;
|
private final int preRun = 5;
|
||||||
private final int afterMines = 2;
|
private final int afterMines = 2;
|
||||||
private final int afterFinishLine = 10;
|
private final int afterFinishLine = 10;
|
||||||
@ -45,7 +44,6 @@ class Minerun extends Minigame {
|
|||||||
@Override
|
@Override
|
||||||
protected void onLoad(CompletableFuture<Void> callback) {
|
protected void onLoad(CompletableFuture<Void> callback) {
|
||||||
int spawnToFinishLine = preRun + length + afterMines;
|
int spawnToFinishLine = preRun + length + afterMines;
|
||||||
int spawnToEnd = spawnToFinishLine + afterFinishLine;
|
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
|
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
|
||||||
@ -71,9 +69,7 @@ class Minerun extends Minigame {
|
|||||||
batch.setBlock(x, 49, preRun, Block.GOLD_BLOCK);
|
batch.setBlock(x, 49, preRun, Block.GOLD_BLOCK);
|
||||||
batch.setBlock(x, 50, preRun, Block.OAK_FENCE.withProperties(properties));
|
batch.setBlock(x, 50, preRun, Block.OAK_FENCE.withProperties(properties));
|
||||||
}
|
}
|
||||||
BatchUtil.loadAndApplyBatch(batch, this, () -> {
|
BatchUtil.loadAndApplyBatch(batch, this, () -> callback.complete(null));
|
||||||
callback.complete(null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -83,9 +79,7 @@ class Minerun extends Minigame {
|
|||||||
batch.setBlock(x, 50, preRun, Block.AIR);
|
batch.setBlock(x, 50, preRun, Block.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
BatchUtil.loadAndApplyBatch(batch, this, () -> {
|
BatchUtil.loadAndApplyBatch(batch, this, () -> playSound(Sound.sound(SoundEvent.BLOCK_WOOD_BREAK, Sound.Source.BLOCK, 1f, 1f)));
|
||||||
playSound(Sound.sound(SoundEvent.BLOCK_WOOD_BREAK, Sound.Source.BLOCK, 1f, 1f));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,7 +6,6 @@ import eu.mhsl.minenet.minigames.instance.game.minigame.config.GameFactory;
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.Option;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.Option;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.common.NumericOption;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.common.NumericOption;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -4,16 +4,11 @@ import eu.mhsl.minenet.minigames.instance.Dimension;
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.Minigame;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.Minigame;
|
||||||
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
import eu.mhsl.minenet.minigames.util.BatchUtil;
|
||||||
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularTerrainGenerator;
|
import eu.mhsl.minenet.minigames.world.generator.terrain.CircularTerrainGenerator;
|
||||||
import eu.mhsl.minenet.minigames.world.generator.terrain.SquareTerrainGenerator;
|
|
||||||
import io.github.bloepiloepi.pvp.PvpExtension;
|
|
||||||
import io.github.bloepiloepi.pvp.config.*;
|
import io.github.bloepiloepi.pvp.config.*;
|
||||||
import io.github.bloepiloepi.pvp.events.FinalAttackEvent;
|
import io.github.bloepiloepi.pvp.events.FinalAttackEvent;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.EventNode;
|
|
||||||
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
import net.minestom.server.event.trait.InstanceEvent;
|
|
||||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -5,7 +5,6 @@ import eu.mhsl.minenet.minigames.instance.game.minigame.config.GameFactory;
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.ConfigManager;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.ConfigManager;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.minigame.config.Option;
|
import eu.mhsl.minenet.minigames.instance.game.minigame.config.Option;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -8,13 +8,10 @@ import eu.mhsl.minenet.minigames.instance.Spawnable;
|
|||||||
import eu.mhsl.minenet.minigames.instance.Dimension;
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
|
||||||
import net.minestom.server.event.player.*;
|
import net.minestom.server.event.player.*;
|
||||||
import net.minestom.server.instance.AnvilLoader;
|
import net.minestom.server.instance.AnvilLoader;
|
||||||
import net.minestom.server.instance.InstanceContainer;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Hub extends MineNetInstance implements Spawnable {
|
public class Hub extends MineNetInstance implements Spawnable {
|
||||||
public static final Hub INSTANCE = new Hub();
|
public static final Hub INSTANCE = new Hub();
|
||||||
|
@ -3,7 +3,6 @@ package eu.mhsl.minenet.minigames.instance.hub.inventory;
|
|||||||
import eu.mhsl.minenet.minigames.instance.room.Room;
|
import eu.mhsl.minenet.minigames.instance.room.Room;
|
||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.inventory.InventoryType;
|
import net.minestom.server.inventory.InventoryType;
|
||||||
import net.minestom.server.item.ItemHideFlag;
|
import net.minestom.server.item.ItemHideFlag;
|
||||||
|
@ -17,7 +17,6 @@ import net.minestom.server.entity.Player;
|
|||||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||||
import net.minestom.server.event.player.PlayerDisconnectEvent;
|
import net.minestom.server.event.player.PlayerDisconnectEvent;
|
||||||
import net.minestom.server.instance.AnvilLoader;
|
import net.minestom.server.instance.AnvilLoader;
|
||||||
import net.minestom.server.instance.InstanceContainer;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -114,9 +113,7 @@ public class Room extends MineNetInstance implements Spawnable {
|
|||||||
|
|
||||||
public void moveMembersToGame(Game game) {
|
public void moveMembersToGame(Game game) {
|
||||||
logger.info("Move room group with " + this.getAllMembers().size() + " players to Game " + game.getUniqueId());
|
logger.info("Move room group with " + this.getAllMembers().size() + " players to Game " + game.getUniqueId());
|
||||||
this.getAllMembers().forEach(player -> {
|
this.getAllMembers().forEach(player -> MoveInstance.move(player, game));
|
||||||
MoveInstance.move(player, game);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Player> getAllMembers() {
|
public Set<Player> getAllMembers() {
|
||||||
|
@ -8,7 +8,6 @@ import eu.mhsl.minenet.minigames.instance.room.Room;
|
|||||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
|
||||||
import eu.mhsl.minenet.minigames.util.InventoryItemAlignment;
|
import eu.mhsl.minenet.minigames.util.InventoryItemAlignment;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.inventory.InventoryType;
|
import net.minestom.server.inventory.InventoryType;
|
||||||
import net.minestom.server.item.ItemHideFlag;
|
import net.minestom.server.item.ItemHideFlag;
|
||||||
@ -34,9 +33,7 @@ public class MinigameSelectInventory extends InteractableInventory {
|
|||||||
.lore(type.getDescription().getAssembled(p))
|
.lore(type.getDescription().getAssembled(p))
|
||||||
.build(),
|
.build(),
|
||||||
itemAlignment.next().get(),
|
itemAlignment.next().get(),
|
||||||
itemClick -> {
|
itemClick -> drawGames(type)
|
||||||
drawGames(type);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class Lang {
|
public class Lang {
|
||||||
|
|
||||||
private String langId;
|
private final String langId;
|
||||||
private Map<String, String> entries = new HashMap<>();
|
private final Map<String, String> entries = new HashMap<>();
|
||||||
|
|
||||||
public Lang(String langId) {
|
public Lang(String langId) {
|
||||||
this.langId = langId;
|
this.langId = langId;
|
||||||
|
@ -4,7 +4,6 @@ import eu.mhsl.minenet.minigames.Resource;
|
|||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -13,11 +12,10 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class Languages {
|
public class Languages {
|
||||||
private static Languages instance;
|
private static Languages instance;
|
||||||
private boolean blockAccess = false;
|
|
||||||
private static final Logger logger = Logger.getLogger("translation");
|
private static final Logger logger = Logger.getLogger("translation");
|
||||||
|
|
||||||
|
|
||||||
private Map<String, Lang> languages = new HashMap<>();
|
private final Map<String, Lang> languages = new HashMap<>();
|
||||||
|
|
||||||
public static final String defaultLanguage = "de_de";
|
public static final String defaultLanguage = "de_de";
|
||||||
public static Languages getInstance() {
|
public static Languages getInstance() {
|
||||||
|
@ -11,9 +11,7 @@ public interface Sendable {
|
|||||||
void send(Player p);
|
void send(Player p);
|
||||||
|
|
||||||
default void send(Audience players) {
|
default void send(Audience players) {
|
||||||
players.forEachAudience(audience -> {
|
players.forEachAudience(audience -> this.send((Player) audience));
|
||||||
this.send((Player) audience);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default void send(List<Player> players) {
|
default void send(List<Player> players) {
|
||||||
|
@ -5,6 +5,7 @@ import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentBuilder;
|
import net.kyori.adventure.text.ComponentBuilder;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class TranslatableMessage implements Sendable {
|
public abstract class TranslatableMessage implements Sendable {
|
||||||
int indention = 0;
|
int indention = 0;
|
||||||
List<ComponentLike> chain = new ArrayList<>();
|
final List<ComponentLike> chain = new ArrayList<>();
|
||||||
|
|
||||||
public TranslatableMessage() {
|
public TranslatableMessage() {
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ public abstract class TranslatableMessage implements Sendable {
|
|||||||
|
|
||||||
|
|
||||||
public Component build(Player p) {
|
public Component build(Player p) {
|
||||||
ComponentBuilder out = Component.text();
|
ComponentBuilder<TextComponent, TextComponent.Builder> out = Component.text();
|
||||||
chain.forEach(componentLike -> {
|
chain.forEach(componentLike -> {
|
||||||
if(componentLike instanceof Translatable t) t.assemble(p);
|
if(componentLike instanceof Translatable t) t.assemble(p);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package eu.mhsl.minenet.minigames.message.component;
|
|||||||
|
|
||||||
|
|
||||||
public class NamespacedTranslatable {
|
public class NamespacedTranslatable {
|
||||||
private String namespace;
|
private final String namespace;
|
||||||
|
|
||||||
public NamespacedTranslatable(String namespace) {
|
public NamespacedTranslatable(String namespace) {
|
||||||
this.namespace = namespace;
|
this.namespace = namespace;
|
||||||
|
@ -8,7 +8,7 @@ import net.minestom.server.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class TranslatedComponent implements ComponentLike, Translatable {
|
public class TranslatedComponent implements ComponentLike, Translatable {
|
||||||
private String mapId;
|
private final String mapId;
|
||||||
private String result;
|
private String result;
|
||||||
|
|
||||||
private NamedTextColor color;
|
private NamedTextColor color;
|
||||||
|
@ -2,7 +2,6 @@ package eu.mhsl.minenet.minigames.message.type;
|
|||||||
|
|
||||||
import eu.mhsl.minenet.minigames.message.Icon;
|
import eu.mhsl.minenet.minigames.message.Icon;
|
||||||
import eu.mhsl.minenet.minigames.message.TranslatableMessage;
|
import eu.mhsl.minenet.minigames.message.TranslatableMessage;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
|
||||||
public class ChatMessage extends TranslatableMessage {
|
public class ChatMessage extends TranslatableMessage {
|
||||||
|
@ -4,8 +4,6 @@ import eu.mhsl.minenet.minigames.message.Icon;
|
|||||||
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
|
||||||
import eu.mhsl.minenet.minigames.message.type.TitleMessage;
|
import eu.mhsl.minenet.minigames.message.type.TitleMessage;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.Game;
|
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.event.Event;
|
import net.minestom.server.event.Event;
|
||||||
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
||||||
|
@ -6,7 +6,6 @@ import net.minestom.server.network.UuidProvider;
|
|||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
import net.minestom.server.utils.mojang.MojangUtils;
|
import net.minestom.server.utils.mojang.MojangUtils;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
package eu.mhsl.minenet.minigames.shared.entity;
|
package eu.mhsl.minenet.minigames.shared.entity;
|
||||||
|
|
||||||
import eu.mhsl.minenet.minigames.instance.Spawnable;
|
import eu.mhsl.minenet.minigames.instance.Spawnable;
|
||||||
import net.minestom.server.coordinate.Pos;
|
|
||||||
import net.minestom.server.entity.EntityCreature;
|
import net.minestom.server.entity.EntityCreature;
|
||||||
import net.minestom.server.entity.EntityType;
|
import net.minestom.server.entity.EntityType;
|
||||||
import net.minestom.server.entity.Player;
|
|
||||||
import net.minestom.server.entity.ai.target.ClosestEntityTarget;
|
|
||||||
import net.minestom.server.event.entity.EntityAttackEvent;
|
import net.minestom.server.event.entity.EntityAttackEvent;
|
||||||
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
||||||
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
||||||
import net.minestom.server.event.player.PlayerEntityInteractEvent;
|
import net.minestom.server.event.player.PlayerEntityInteractEvent;
|
||||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
|
||||||
import net.minestom.server.timer.ExecutionType;
|
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
@ -36,9 +30,7 @@ public class InteractableEntity extends EntityCreature {
|
|||||||
|
|
||||||
private void setInstanceEvent(@NotNull AddEntityToInstanceEvent addEntityToInstanceEvent) {
|
private void setInstanceEvent(@NotNull AddEntityToInstanceEvent addEntityToInstanceEvent) {
|
||||||
if(addEntityToInstanceEvent.getInstance() instanceof Spawnable instance) {
|
if(addEntityToInstanceEvent.getInstance() instanceof Spawnable instance) {
|
||||||
scheduleNextTick((unused) -> {
|
scheduleNextTick((unused) -> this.teleport(this.position.withPitch(180).withYaw(0)));
|
||||||
this.teleport(this.position.withPitch(180).withYaw(0));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addEntityToInstanceEvent.getInstance().eventNode()
|
addEntityToInstanceEvent.getInstance().eventNode()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.mhsl.minenet.minigames.shared.inventory;
|
package eu.mhsl.minenet.minigames.shared.inventory;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minestom.server.MinecraftServer;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.inventory.Inventory;
|
import net.minestom.server.inventory.Inventory;
|
||||||
import net.minestom.server.inventory.InventoryType;
|
import net.minestom.server.inventory.InventoryType;
|
||||||
@ -9,8 +8,6 @@ import net.minestom.server.inventory.click.ClickType;
|
|||||||
import net.minestom.server.inventory.condition.InventoryConditionResult;
|
import net.minestom.server.inventory.condition.InventoryConditionResult;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
import net.minestom.server.timer.ExecutionType;
|
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package eu.mhsl.minenet.minigames.skin;
|
package eu.mhsl.minenet.minigames.skin;
|
||||||
|
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.Entity;
|
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
import net.minestom.server.entity.PlayerSkin;
|
||||||
import net.minestom.server.thread.Acquirable;
|
|
||||||
import net.minestom.server.thread.Acquired;
|
|
||||||
import net.minestom.server.timer.ExecutionType;
|
import net.minestom.server.timer.ExecutionType;
|
||||||
import net.minestom.server.timer.TaskSchedule;
|
import net.minestom.server.timer.TaskSchedule;
|
||||||
|
|
||||||
|
@ -4,12 +4,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
|||||||
|
|
||||||
public class ColorUtil {
|
public class ColorUtil {
|
||||||
public static NamedTextColor scoreColor(int score) {
|
public static NamedTextColor scoreColor(int score) {
|
||||||
switch (score) {
|
return switch (score) {
|
||||||
case 1: return NamedTextColor.GOLD;
|
case 1 -> NamedTextColor.GOLD;
|
||||||
case 2: return NamedTextColor.GREEN;
|
case 2 -> NamedTextColor.GREEN;
|
||||||
case 3: return NamedTextColor.DARK_GREEN;
|
case 3 -> NamedTextColor.DARK_GREEN;
|
||||||
}
|
default -> NamedTextColor.GRAY;
|
||||||
|
};
|
||||||
|
|
||||||
return NamedTextColor.GRAY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.mhsl.minenet.minigames.util;
|
package eu.mhsl.minenet.minigames.util;
|
||||||
|
|
||||||
import eu.mhsl.minenet.minigames.world.generator.BlockPallet;
|
import eu.mhsl.minenet.minigames.world.generator.BlockPallet;
|
||||||
import net.minestom.server.coordinate.Point;
|
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.instance.Instance;
|
import net.minestom.server.instance.Instance;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package eu.mhsl.minenet.minigames.util;
|
package eu.mhsl.minenet.minigames.util;
|
||||||
|
|
||||||
|
|
||||||
import com.extollit.linalg.mutable.Vec2d;
|
|
||||||
import it.unimi.dsi.fastutil.Pair;
|
|
||||||
import net.minestom.server.coordinate.Vec;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InventoryItemAlignment {
|
public class InventoryItemAlignment {
|
||||||
private int size;
|
private final int size;
|
||||||
private int x;
|
private final int x;
|
||||||
private int y;
|
private final int y;
|
||||||
|
|
||||||
private int counter = -1;
|
private int counter = -1;
|
||||||
|
|
||||||
@ -36,7 +32,7 @@ public class InventoryItemAlignment {
|
|||||||
|
|
||||||
if(this.size < 9) return new ItemOffset(this.row(this.size).get(counter), y > 1 ? 1 : 0);
|
if(this.size < 9) return new ItemOffset(this.row(this.size).get(counter), y > 1 ? 1 : 0);
|
||||||
//TODO more items?
|
//TODO more items?
|
||||||
return new ItemOffset(0,0);
|
return new ItemOffset(0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,8 +40,9 @@ public class InventoryItemAlignment {
|
|||||||
private List<Integer> row(int count) {
|
private List<Integer> row(int count) {
|
||||||
return new ArrayList<ArrayList<Integer>>() {
|
return new ArrayList<ArrayList<Integer>>() {
|
||||||
{
|
{
|
||||||
|
//noinspection EmptyClassInitializer
|
||||||
add(new ArrayList<>() {
|
add(new ArrayList<>() {
|
||||||
{
|
static {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(new ArrayList<>() {
|
add(new ArrayList<>() {
|
||||||
@ -133,9 +130,9 @@ public class InventoryItemAlignment {
|
|||||||
}.get(count);
|
}.get(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ItemOffset {
|
public static class ItemOffset {
|
||||||
private int x;
|
private final int x;
|
||||||
private int z;
|
private final int z;
|
||||||
|
|
||||||
public ItemOffset(int x, int z) {
|
public ItemOffset(int x, int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -17,9 +17,7 @@ public class CircularTerrainGenerator implements Generator {
|
|||||||
protected final Random rnd = new Random();
|
protected final Random rnd = new Random();
|
||||||
private final int size;
|
private final int size;
|
||||||
|
|
||||||
protected final Pos mapCenter = new Pos(0, 50, 0);
|
private final boolean generatePlate;
|
||||||
|
|
||||||
private boolean generatePlate;
|
|
||||||
|
|
||||||
public CircularTerrainGenerator(int size, boolean generatePlate) {
|
public CircularTerrainGenerator(int size, boolean generatePlate) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
@ -16,10 +16,10 @@ import java.util.Random;
|
|||||||
public class SquareTerrainGenerator implements Generator {
|
public class SquareTerrainGenerator implements Generator {
|
||||||
protected final Random rnd = new Random();
|
protected final Random rnd = new Random();
|
||||||
|
|
||||||
private int width;
|
private final int width;
|
||||||
private int length;
|
private final int length;
|
||||||
|
|
||||||
private boolean generatePlate;
|
private final boolean generatePlate;
|
||||||
|
|
||||||
protected final Pos mapStart = new Pos(0, 50, 0);
|
protected final Pos mapStart = new Pos(0, 50, 0);
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user