Inspection and Cleanup
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user