Inspection and Cleanup

This commit is contained in:
Elias Müller 2022-10-03 21:13:35 +02:00
parent 6907a767c6
commit c9bc9dd2da
78 changed files with 76 additions and 275 deletions
.idea
resources
src/main

3
.idea/misc.xml generated

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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="JavadocGenerationManager">
<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ürs 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
1 map en_us de_de
2 localName English Deutsch
3 name English German
4 symbol eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2Q5MTQ1Njg3N2Y1NGJmMWFjZTI1MWU0Y2VlNDBkYmE1OTdkMmNjNDAzNjJjYjhmNGVkNzExZTUwYjBiZTViMyJ9fX0= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWU3ODk5YjQ4MDY4NTg2OTdlMjgzZjA4NGQ5MTczZmU0ODc4ODY0NTM3NzQ2MjZiMjRiZDhjZmVjYzc3YjNmIn19fQ==
5 sample The quick brown fox jumps over the lazy dog Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich
6
7 ns:common#
8 select_language Please select your prefered Language Bitte wähle deine bevorzugte Sprache!
9 welcome Welcome! Willkommen!
10 back Back Zurück
11 forward Next Nächste
12
13 ns:GameType#
14 other Other games Andere Spiele
15 other_description Games which does not fit into other Categories Spiele welche nicht in die anderen Kategorien passen
16 pvp Player vs Player Spieler gegen Spieler
17 pvp_description Fight against other Players Kämpfe gegen andere Spieler
18 pve Player vs Enviroment Spieler gegen Umwelt
19 pve_description Surivie the world or fight entities Überlebe die Welt oder kämpfe gegen Mobs
20
21 ns:hub#
22 invTitle MineNet Servernetwork MineNet Servernetzwerk
23 create Create your personal Lobby Erstelle deine persönliche Lobby
24 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
25 join Join existing Lobby Betrete eine bestehende Lobby
26 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
27 join_title Enter Username Benutzername
28 join_notFound Lobby not found: Lobby konnte nicht gefunden werden:
29
30 ns:score#
31 result Results Ergebnisse
32 thanks Thank you for Playing Danke für‘s spielen
33
34
35 ns:restriction#
36 fail Some requirements are not met Bedinungen sind nicht erfüllt
37 success Play Spielen
38 minPlayersInRoom Minimal amount of Players in Lobby Minimale Anzahl von Spielern in deiner Lobby
39 minPlayersInRoomDescription You need more Players in your room to play this Die Anzahl der Spieler ist zu gering um dieses Spiel zu starten
40 maxPlayersInRoom Maximal amount of Players in Lobby Maximale Anzahl von Spielern in deiner Lobby
41 maxPlayersInRoomDescription There are too many players in your room Die Anzahl der Spieler in deiner Lobby ist zu hoch für dieses Spiel
42
43 ns:optionCommon#
44 value Value Wert
45 width Width Breite
46 length Length Länge
47 height Height Höhe
48 radius Radius Radius
49
50
51
52
53
54
55
56
57 ns:room#
58 invTitle Select a Minigame Wähle einen Spielmodus
59 noOption No options here Keine Optionen hier
60 noOptionDescription There are no options for this Game Es gibt keine Einstellungen für dieses Spiel
61
62 ns:GameFactory#
63 missingDescription No description Keine Beschreibung
64
65 ns:game_Minerun#
66 name Minerun Minenrennen
67 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
68 optionPercentageMines Percentage of Miens Prozentsatz der Minen
69
70 ns:game_Deathcube#
71 name Deathcube Todeswürfel
72 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
73 optionPercentageBlocks Percentage of Blocks Prozentsatz der Blöcke
74
75 ns:game_Stickfight#
76 name Stickfight Stockschlacht
77 description Push your opponents off the Bridge Stoße deine Gegener von der Brücke
78
79 ns:game_TrafficlightRace#
80 name Red light green light Rotes licht, Grünes licht
81 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.timer.TaskSchedule;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main {

@ -13,9 +13,7 @@ import java.util.logging.Logger;
public enum Resource {
HUB_MAP("maps/hub"),
LOBBY_MAP("maps/lobby"),
RBB("rbb"),
LOCALES("lang"),
SCHEMATICS("schematics");
LOCALES("lang");
private final Path path;
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.ChatMessage;
import eu.mhsl.minenet.minigames.message.type.TitleMessage;
import net.kyori.adventure.text.Component;
import net.minestom.server.command.builder.Command;
public class DebugCommand extends Command {

@ -11,8 +11,6 @@ public class GamemodeCommand extends Command {
setCondition((sender, commandString) -> sender.hasPermission("admin"));
addSyntax((sender, context) -> {
((Player) sender).setGameMode(context.get("target"));
}, ArgumentType.Enum("target", GameMode.class));
addSyntax((sender, context) -> ((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"));
setDefaultExecutor((sender, context) -> {
long nextRun = (long) (lastRun - (System.currentTimeMillis() - 30*1000)) / 1000;
long nextRun = (lastRun - (System.currentTimeMillis() - 30*1000)) / 1000;
if(nextRun > 0) {
new ChatMessage(Icon.ERROR).appendStatic("Please wait ").appendStatic(String.valueOf(nextRun)).appendStatic(" seconds before running GC again!").send(sender);
return;

@ -15,15 +15,11 @@ public class LangTestCommand extends Command {
setCondition((sender, commandString) -> sender.hasPermission("admin"));
setDefaultExecutor((sender, context) -> {
sendMessage(Languages.getInstance().getLanguage((Player) sender), "sample").send(sender);
});
setDefaultExecutor((sender, context) -> sendMessage(Languages.getInstance().getLanguage((Player) sender), "sample").send(sender));
var targetString = ArgumentType.String("mapId");
addSyntax((sender, context) -> {
sendMessage(Languages.getInstance().getLanguage((Player) sender), context.get("mapId")).send(sender);
}, targetString);
addSyntax((sender, context) -> sendMessage(Languages.getInstance().getLanguage((Player) sender), context.get("mapId")).send(sender), targetString);
}
private TranslatableMessage sendMessage(Lang lang, String mapId) {

@ -18,13 +18,11 @@ public class RoomCommand extends Command {
setDefaultExecutor((sender, context) -> {
TranslatableMessage out = new ChatMessage(Icon.SCIENCE).appendStatic("Rooms:").indent(1).newLine();
Room.getAllRooms().forEach((roomInstance) -> {
out
.newLine()
.appendStatic("Owner: ").appendStatic(roomInstance.getOwner().getUsername()).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();
});
Room.getAllRooms().forEach((roomInstance) -> out
.newLine()
.appendStatic("Owner: ").appendStatic(roomInstance.getOwner().getUsername()).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());
out.send(sender);
});

@ -11,8 +11,6 @@ public class LeaveCommand extends Command {
setCondition((sender, commandString) -> ((Player) sender).getInstance() instanceof Game);
setDefaultExecutor((sender, context) -> {
Room.setOwnRoom((Player) sender);
});
setDefaultExecutor((sender, context) -> 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.instance.Spawnable;
import eu.mhsl.minenet.minigames.instance.room.Room;
import io.github.bloepiloepi.pvp.config.PvPConfig;
import net.minestom.server.MinecraftServer;
import net.minestom.server.coordinate.Pos;
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.player.PlayerBlockBreakEvent;
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
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.TaskSchedule;
import net.minestom.server.world.DimensionType;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Logger;

@ -12,8 +12,8 @@ public enum GameList {
MINERUN(new MinerunFactory(), GameType.PVE),
TRAFFICLIGHTRACE(new TrafficLightRaceFactory(), GameType.OTHER);
private GameFactory factory;
private GameType type;
private final GameFactory factory;
private final GameType type;
GameList(GameFactory factory, GameType type) {
this.factory = factory;
this.type = type;

@ -9,9 +9,9 @@ public enum GameType {
PVE(Material.DIAMOND_PICKAXE, TranslatedComponent.byId("GameType#pve"), TranslatedComponent.byId("GameType#pve_description"));
Material icon;
TranslatedComponent title;
TranslatedComponent description;
final Material icon;
final TranslatedComponent title;
final TranslatedComponent description;
GameType(Material icon, TranslatedComponent title, TranslatedComponent description) {
this.title = title;

@ -9,22 +9,20 @@ 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.event.player.PlayerMoveEvent;
import net.minestom.server.timer.ExecutionType;
import net.minestom.server.timer.TaskSchedule;
import net.minestom.server.world.DimensionType;
import org.jetbrains.annotations.NotNull;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
public class Minigame extends Game {
private final String name;
private Score score = new Score(this);
private final Score score = new Score(this);
private int timeLimit = 0;
private int timePlayed = 0;
private boolean preventExit = false;
private final boolean preventExit = false;
public Minigame(DimensionType dimensionType, String gameName) {
super(dimensionType);
@ -54,14 +52,10 @@ public class Minigame extends Game {
*/
protected CompletableFuture<Void> countdownStart() {
return new Countdown(TitleMessage.class)
.countdown(Audience.audience(getPlayers()), 5, countdownModifier -> {
countdownModifier.message = new TitleMessage(Duration.ofMillis(300), Duration.ofMillis(700))
.subtitle(subtitleMessage -> {
subtitleMessage.appendStatic(Component.text("in ", NamedTextColor.DARK_GREEN))
.appendStatic(Component.text(countdownModifier.timeLeft, NamedTextColor.GREEN))
.appendStatic(Component.text(" seconds", NamedTextColor.DARK_GREEN));
});
});
.countdown(Audience.audience(getPlayers()), 5, countdownModifier -> countdownModifier.message = new TitleMessage(Duration.ofMillis(300), Duration.ofMillis(700))
.subtitle(subtitleMessage -> subtitleMessage.appendStatic(Component.text("in ", 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;
import com.extollit.linalg.mutable.Vec2d;
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.RestrictionData;
import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.RestrictionHandler;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
import eu.mhsl.minenet.minigames.util.InventoryItemAlignment;
import eu.mhsl.minenet.minigames.util.TextUtil;
import eu.mhsl.minenet.minigames.instance.room.Room;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minestom.server.MinecraftServer;
import net.minestom.server.coordinate.Vec;
import net.minestom.server.entity.Player;
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
@ -116,7 +111,7 @@ public class GameConfigurationInventory extends InteractableInventory {
if(!map.containsKey(slot)) return;
Option item = map.get(slot);
Option<?> item = map.get(slot);
setDummyItem(
item.getNext(p),
slot
@ -138,9 +133,7 @@ public class GameConfigurationInventory extends InteractableInventory {
.lore(restrictionHandler.getWarnings(restrictionData).stream().map(translatedComponent -> translatedComponent.getAssembled(p)).collect(Collectors.toList()))
.build(),
8,
itemClick -> {
Game.initialize(factory, itemClick.getPlayer());
},
itemClick -> Game.initialize(factory, itemClick.getPlayer()),
true
);
@ -152,8 +145,8 @@ public class GameConfigurationInventory extends InteractableInventory {
.lore(
restrictionHandler.getRestrictions()
.stream()
.filter(iRestriction -> iRestriction.calculate(restrictionData).getType().equals(Restriction.Type.FAIL))
.map(iRestriction -> iRestriction.calculate(restrictionData).getDescription().getAssembled(p))
.filter(iRestriction -> iRestriction.calculate(restrictionData).type().equals(Restriction.Type.FAIL))
.map(iRestriction -> iRestriction.calculate(restrictionData).description().getAssembled(p))
.collect(Collectors.toList()))
.build(),
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.config.restriction.RestrictionHandler;
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 java.util.HashMap;

@ -1,7 +1,6 @@
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.restriction.RestrictionHandler;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
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;
public class Restriction {
final private TranslatedComponent name;
final private TranslatedComponent description;
final private TranslatedComponent warnMessage;
final private Type type;
public record Restriction(TranslatedComponent name, TranslatedComponent description, TranslatedComponent warnMessage,
eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.Restriction.Type type) {
public Restriction(TranslatedComponent name, TranslatedComponent description, TranslatedComponent warnMessage, Type type) {
this.name = name;
this.description = description;
this.warnMessage = warnMessage;
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");
}
}
public TranslatedComponent getName() {
return name;
}
public TranslatedComponent getDescription() {
return description;
}
public TranslatedComponent getWarnMessage() {
return warnMessage;
}
public Type getType() {
return type;
}
public enum Type {
OK,
WARN,

@ -2,14 +2,5 @@ package eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction;
import eu.mhsl.minenet.minigames.instance.room.Room;
public class RestrictionData {
final private Room room;
public RestrictionData(Room room) {
this.room = room;
}
public Room getRoom() {
return room;
}
public record RestrictionData(Room room) {
}

@ -2,7 +2,6 @@ package eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
@ -29,16 +28,16 @@ public class RestrictionHandler {
public boolean canPlay(RestrictionData data) {
if(restrictions.size() < 1) return true;
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) {
List<TranslatedComponent> warnings = new ArrayList<>();
for (IRestriction r : this.restrictions) {
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;
}

@ -6,7 +6,7 @@ import eu.mhsl.minenet.minigames.instance.game.minigame.config.restriction.Restr
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
public class MaximalPlayeramountGameRestriction implements IRestriction {
private int max;
private final int max;
public MaximalPlayeramountGameRestriction(int max) {
this.max = max;
@ -18,7 +18,7 @@ public class MaximalPlayeramountGameRestriction implements IRestriction {
TranslatedComponent.byId("restriction#maxPlayersInRoom"),
TranslatedComponent.byId("restriction#maxPlayersInRoomDescription"),
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.message.component.TranslatedComponent;
import javax.xml.transform.OutputKeys;
public class MinimalPlayeramountGameRestriction implements IRestriction {
private int min;
private final int min;
public MinimalPlayeramountGameRestriction(int min) {
this.min = min;
@ -20,7 +18,7 @@ public class MinimalPlayeramountGameRestriction implements IRestriction {
TranslatedComponent.byId("restriction#minPlayersInRoom"),
TranslatedComponent.byId("restriction#minPlayersInRoomDescription"),
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 {
int radius, height, percentage;
final int radius;
final int height;
final int percentage;
public Deathcube(int radius, int height, int percentage) {
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.common.NumericOption;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
import net.kyori.adventure.text.Component;
import net.minestom.server.item.Material;
import java.util.Map;

@ -28,7 +28,6 @@ class Minerun extends Minigame {
private int width = 100;
private int length = 50;
private final int backRun = -5;
private final int preRun = 5;
private final int afterMines = 2;
private final int afterFinishLine = 10;
@ -45,7 +44,6 @@ class Minerun extends Minigame {
@Override
protected void onLoad(CompletableFuture<Void> callback) {
int spawnToFinishLine = preRun + length + afterMines;
int spawnToEnd = spawnToFinishLine + afterFinishLine;
Random random = new Random();
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
@ -71,9 +69,7 @@ class Minerun extends Minigame {
batch.setBlock(x, 49, preRun, Block.GOLD_BLOCK);
batch.setBlock(x, 50, preRun, Block.OAK_FENCE.withProperties(properties));
}
BatchUtil.loadAndApplyBatch(batch, this, () -> {
callback.complete(null);
});
BatchUtil.loadAndApplyBatch(batch, this, () -> callback.complete(null));
}
@Override
@ -83,9 +79,7 @@ class Minerun extends Minigame {
batch.setBlock(x, 50, preRun, Block.AIR);
}
BatchUtil.loadAndApplyBatch(batch, this, () -> {
playSound(Sound.sound(SoundEvent.BLOCK_WOOD_BREAK, Sound.Source.BLOCK, 1f, 1f));
});
BatchUtil.loadAndApplyBatch(batch, this, () -> playSound(Sound.sound(SoundEvent.BLOCK_WOOD_BREAK, Sound.Source.BLOCK, 1f, 1f)));
}
@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.common.NumericOption;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
import net.kyori.adventure.text.Component;
import net.minestom.server.item.Material;
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.util.BatchUtil;
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.events.FinalAttackEvent;
import net.minestom.server.coordinate.Pos;
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.trait.InstanceEvent;
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
import net.minestom.server.instance.block.Block;
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.Option;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
import net.kyori.adventure.text.Component;
import net.minestom.server.item.Material;
import java.util.Map;

@ -8,13 +8,10 @@ import eu.mhsl.minenet.minigames.instance.Spawnable;
import eu.mhsl.minenet.minigames.instance.Dimension;
import net.minestom.server.MinecraftServer;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
import net.minestom.server.event.player.*;
import net.minestom.server.instance.AnvilLoader;
import net.minestom.server.instance.InstanceContainer;
import java.nio.file.Path;
import java.util.UUID;
public class Hub extends MineNetInstance implements Spawnable {
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.message.component.TranslatedComponent;
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
import net.kyori.adventure.text.Component;
import net.minestom.server.entity.Player;
import net.minestom.server.inventory.InventoryType;
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.PlayerDisconnectEvent;
import net.minestom.server.instance.AnvilLoader;
import net.minestom.server.instance.InstanceContainer;
import java.util.*;
import java.util.logging.Logger;
@ -114,9 +113,7 @@ public class Room extends MineNetInstance implements Spawnable {
public void moveMembersToGame(Game game) {
logger.info("Move room group with " + this.getAllMembers().size() + " players to Game " + game.getUniqueId());
this.getAllMembers().forEach(player -> {
MoveInstance.move(player, game);
});
this.getAllMembers().forEach(player -> MoveInstance.move(player, game));
}
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.shared.inventory.InteractableInventory;
import eu.mhsl.minenet.minigames.util.InventoryItemAlignment;
import net.kyori.adventure.text.Component;
import net.minestom.server.entity.Player;
import net.minestom.server.inventory.InventoryType;
import net.minestom.server.item.ItemHideFlag;
@ -34,9 +33,7 @@ public class MinigameSelectInventory extends InteractableInventory {
.lore(type.getDescription().getAssembled(p))
.build(),
itemAlignment.next().get(),
itemClick -> {
drawGames(type);
}
itemClick -> drawGames(type)
);
}

@ -6,8 +6,8 @@ import java.util.logging.Logger;
public class Lang {
private String langId;
private Map<String, String> entries = new HashMap<>();
private final String langId;
private final Map<String, String> entries = new HashMap<>();
public Lang(String langId) {
this.langId = langId;

@ -4,7 +4,6 @@ import eu.mhsl.minenet.minigames.Resource;
import net.minestom.server.entity.Player;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.HashMap;
@ -13,11 +12,10 @@ import java.util.logging.Logger;
public class Languages {
private static Languages instance;
private boolean blockAccess = false;
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 Languages getInstance() {

@ -11,9 +11,7 @@ public interface Sendable {
void send(Player p);
default void send(Audience players) {
players.forEachAudience(audience -> {
this.send((Player) audience);
});
players.forEachAudience(audience -> this.send((Player) audience));
}
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.ComponentBuilder;
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minestom.server.entity.Player;
@ -13,7 +14,7 @@ import java.util.List;
public abstract class TranslatableMessage implements Sendable {
int indention = 0;
List<ComponentLike> chain = new ArrayList<>();
final List<ComponentLike> chain = new ArrayList<>();
public TranslatableMessage() {
@ -65,7 +66,7 @@ public abstract class TranslatableMessage implements Sendable {
public Component build(Player p) {
ComponentBuilder out = Component.text();
ComponentBuilder<TextComponent, TextComponent.Builder> out = Component.text();
chain.forEach(componentLike -> {
if(componentLike instanceof Translatable t) t.assemble(p);

@ -2,7 +2,7 @@ package eu.mhsl.minenet.minigames.message.component;
public class NamespacedTranslatable {
private String namespace;
private final String namespace;
public NamespacedTranslatable(String namespace) {
this.namespace = namespace;

@ -8,7 +8,7 @@ import net.minestom.server.entity.Player;
import org.jetbrains.annotations.NotNull;
public class TranslatedComponent implements ComponentLike, Translatable {
private String mapId;
private final String mapId;
private String result;
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.TranslatableMessage;
import net.kyori.adventure.text.Component;
import net.minestom.server.entity.Player;
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.TitleMessage;
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.event.Event;
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.utils.mojang.MojangUtils;
import java.net.UnknownHostException;
import java.util.UUID;
import java.util.logging.Logger;

@ -1,18 +1,12 @@
package eu.mhsl.minenet.minigames.shared.entity;
import eu.mhsl.minenet.minigames.instance.Spawnable;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.EntityCreature;
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.instance.AddEntityToInstanceEvent;
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
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;
@ -36,9 +30,7 @@ public class InteractableEntity extends EntityCreature {
private void setInstanceEvent(@NotNull AddEntityToInstanceEvent addEntityToInstanceEvent) {
if(addEntityToInstanceEvent.getInstance() instanceof Spawnable instance) {
scheduleNextTick((unused) -> {
this.teleport(this.position.withPitch(180).withYaw(0));
});
scheduleNextTick((unused) -> this.teleport(this.position.withPitch(180).withYaw(0)));
}
addEntityToInstanceEvent.getInstance().eventNode()

@ -1,7 +1,6 @@
package eu.mhsl.minenet.minigames.shared.inventory;
import net.kyori.adventure.text.Component;
import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Player;
import net.minestom.server.inventory.Inventory;
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.item.ItemStack;
import net.minestom.server.item.Material;
import net.minestom.server.timer.ExecutionType;
import net.minestom.server.timer.TaskSchedule;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;

@ -1,11 +1,8 @@
package eu.mhsl.minenet.minigames.skin;
import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Player;
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.TaskSchedule;

@ -4,12 +4,12 @@ import net.kyori.adventure.text.format.NamedTextColor;
public class ColorUtil {
public static NamedTextColor scoreColor(int score) {
switch (score) {
case 1: return NamedTextColor.GOLD;
case 2: return NamedTextColor.GREEN;
case 3: return NamedTextColor.DARK_GREEN;
}
return switch (score) {
case 1 -> NamedTextColor.GOLD;
case 2 -> NamedTextColor.GREEN;
case 3 -> NamedTextColor.DARK_GREEN;
default -> NamedTextColor.GRAY;
};
return NamedTextColor.GRAY;
}
}

@ -1,7 +1,6 @@
package eu.mhsl.minenet.minigames.util;
import eu.mhsl.minenet.minigames.world.generator.BlockPallet;
import net.minestom.server.coordinate.Point;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block;

@ -1,17 +1,13 @@
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.List;
public class InventoryItemAlignment {
private int size;
private int x;
private int y;
private final int size;
private final int x;
private final int y;
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);
//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) {
return new ArrayList<ArrayList<Integer>>() {
{
//noinspection EmptyClassInitializer
add(new ArrayList<>() {
{
static {
}
});
add(new ArrayList<>() {
@ -133,9 +130,9 @@ public class InventoryItemAlignment {
}.get(count);
}
public class ItemOffset {
private int x;
private int z;
public static class ItemOffset {
private final int x;
private final int z;
public ItemOffset(int x, int z) {
this.x = x;

@ -17,9 +17,7 @@ public class CircularTerrainGenerator implements Generator {
protected final Random rnd = new Random();
private final int size;
protected final Pos mapCenter = new Pos(0, 50, 0);
private boolean generatePlate;
private final boolean generatePlate;
public CircularTerrainGenerator(int size, boolean generatePlate) {
this.size = size;

@ -16,10 +16,10 @@ import java.util.Random;
public class SquareTerrainGenerator implements Generator {
protected final Random rnd = new Random();
private int width;
private int length;
private final int width;
private final int length;
private boolean generatePlate;
private final boolean generatePlate;
protected final Pos mapStart = new Pos(0, 50, 0);