Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d36b3039c | ||
|
|
d18ddc7b07 | ||
|
|
b06ba40d16 | ||
|
|
3eca590c6f |
No files matched your search
@@ -1,3 +1,32 @@
|
||||
# Chatcoloring
|
||||
Der Spieler benötigt das Recht "chatcolor" damit dessen Namen blau im Chat angezeigt wird.
|
||||
|
||||
|
||||
# Server Configuration
|
||||
|
||||
## Paper Anti-Xray
|
||||
|
||||
Enable Paper's built-in Anti-Xray protection in the Nether to prevent players from locating Ancient Debris through lava using transparent lava resource packs.
|
||||
|
||||
**File:** `world/dimensions/minecraft/the_nether/paper-world.yml`
|
||||
|
||||
Under `anticheat.anti-xray`, configure:
|
||||
|
||||
```yaml
|
||||
anticheat:
|
||||
anti-xray:
|
||||
enabled: true
|
||||
engine-mode: 1
|
||||
hidden-blocks:
|
||||
- ancient_debris
|
||||
- nether_gold_ore
|
||||
- nether_quartz_ore
|
||||
lava-obscures: true
|
||||
max-block-height: 128
|
||||
update-radius: 2
|
||||
use-permission: false
|
||||
```
|
||||
|
||||
Restart the server to apply the changes.
|
||||
|
||||
**Tested:** Ancient Debris hidden behind lava is no longer visible when using a transparent lava resource pack.
|
||||
+3
-2
@@ -19,7 +19,8 @@ public class InfoBarSetting extends MultiBoolSetting<InfoBarSetting.InfoBarConfi
|
||||
public record InfoBarConfiguration(
|
||||
@DisplayName("Millisekunden pro Tick") boolean mspt,
|
||||
@DisplayName("Spieler online") boolean playerCounter,
|
||||
@DisplayName("Ticks pro Sekunde") boolean tps
|
||||
@DisplayName("Ticks pro Sekunde") boolean tps,
|
||||
@DisplayName("TPS, MSPT & Spieler") boolean tpsMsptPlayerCounter
|
||||
) {}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +40,7 @@ public class InfoBarSetting extends MultiBoolSetting<InfoBarSetting.InfoBarConfi
|
||||
|
||||
@Override
|
||||
protected InfoBarConfiguration defaultValue() {
|
||||
return new InfoBarConfiguration(false, false, false);
|
||||
return new InfoBarConfiguration(false, false, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-1
@@ -1,5 +1,6 @@
|
||||
package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.infoBars;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.infoBars.bars.TpsMsptPlayerCounterBar;
|
||||
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.Settings;
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
|
||||
@@ -16,7 +17,8 @@ public class InfoBars extends Appliance {
|
||||
private final List<Bar> infoBars = List.of(
|
||||
new TpsBar(),
|
||||
new MsptBar(),
|
||||
new PlayerCounterBar()
|
||||
new PlayerCounterBar(),
|
||||
new TpsMsptPlayerCounterBar()
|
||||
);
|
||||
|
||||
public void showAllEnabled(Player player) {
|
||||
@@ -24,6 +26,7 @@ public class InfoBars extends Appliance {
|
||||
this.setVisible(player, MsptBar.name, config.mspt());
|
||||
this.setVisible(player, PlayerCounterBar.name, config.playerCounter());
|
||||
this.setVisible(player, TpsBar.name, config.tps());
|
||||
this.setVisible(player, TpsMsptPlayerCounterBar.name, config.tpsMsptPlayerCounter());
|
||||
}
|
||||
|
||||
public void setVisible(Player player, String bar, boolean visible) {
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.infoBars.bars;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.infoBars.Bar;
|
||||
import eu.mhsl.craftattack.spawn.common.appliances.tooling.playerlimit.PlayerLimit;
|
||||
import eu.mhsl.craftattack.spawn.core.Main;
|
||||
import eu.mhsl.craftattack.spawn.core.util.statistics.ServerMonitor;
|
||||
import eu.mhsl.craftattack.spawn.core.util.text.ColorUtil;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class TpsMsptPlayerCounterBar extends Bar {
|
||||
public static String name = "serverStats";
|
||||
|
||||
@Override
|
||||
protected Duration refresh() {
|
||||
return Duration.ofSeconds(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component title() {
|
||||
float tps = this.currentTps();
|
||||
float mspt = this.currentMspt();
|
||||
int players = this.currentPlayerCount();
|
||||
|
||||
Component separator = Component.text(" | ", NamedTextColor.DARK_GRAY);
|
||||
TextColor color = ColorUtil.mapGreenToRed(players, 0, this.getMaxPlayerCount(), true);
|
||||
|
||||
return Component.text()
|
||||
.append(Component.text("TPS: ", NamedTextColor.GRAY))
|
||||
.append(Component.text(String.format("%.2f", tps), ColorUtil.tpsColor(tps)))
|
||||
.append(separator)
|
||||
.append(Component.text("MSPT: ", NamedTextColor.GRAY))
|
||||
.append(Component.text(String.format("%.2f", mspt), ColorUtil.msptColor(mspt)))
|
||||
.append(separator)
|
||||
.append(Component.text("Spieler: ", NamedTextColor.GRAY))
|
||||
.append(Component.text(players, color))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float progress() {
|
||||
return Math.clamp(this.currentTps() / 20f, 0f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossBar.Color color() {
|
||||
int severity = Math.max(
|
||||
this.tpsSeverity(),
|
||||
Math.max(this.msptSeverity(), this.playerSeverity())
|
||||
);
|
||||
|
||||
return switch (severity) {
|
||||
case 2 -> BossBar.Color.RED;
|
||||
case 1 -> BossBar.Color.YELLOW;
|
||||
default -> BossBar.Color.GREEN;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BossBar.Overlay overlay() {
|
||||
return BossBar.Overlay.PROGRESS;
|
||||
}
|
||||
|
||||
private int tpsSeverity() {
|
||||
float tps = this.currentTps();
|
||||
return tps >= 18 ? 0 : tps >= 15 ? 1 : 2;
|
||||
}
|
||||
|
||||
private int msptSeverity() {
|
||||
return this.currentMspt() <= 50 ? 0 : 2;
|
||||
}
|
||||
|
||||
private int playerSeverity() {
|
||||
int freeSlots = this.getMaxPlayerCount() - this.currentPlayerCount();
|
||||
return freeSlots <= 0 ? 2 : freeSlots < 5 ? 1 : 0;
|
||||
}
|
||||
|
||||
private float currentTps() {
|
||||
return (float) Bukkit.getTPS()[0];
|
||||
}
|
||||
|
||||
private float currentMspt() {
|
||||
return ServerMonitor.getServerMSPT();
|
||||
}
|
||||
|
||||
private int currentPlayerCount() {
|
||||
return Bukkit.getOnlinePlayers().size();
|
||||
}
|
||||
|
||||
private int getMaxPlayerCount() {
|
||||
return Main.instance().getAppliance(PlayerLimit.class).getLimit();
|
||||
}
|
||||
}
|
||||
@@ -110,9 +110,6 @@ tablist:
|
||||
projectTitle: "Title"
|
||||
interface: eth0
|
||||
|
||||
outlawed:
|
||||
voluntarily: []
|
||||
|
||||
packselect:
|
||||
packs:
|
||||
- somepack:
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.outlawed;
|
||||
|
||||
class OutlawChangeNotPermitted extends Exception {
|
||||
public OutlawChangeNotPermitted(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
-165
@@ -1,165 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.outlawed;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.Main;
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
|
||||
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.displayName.DisplayName;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.tooling.whitelist.Whitelist;
|
||||
import eu.mhsl.craftattack.spawn.core.config.Configuration;
|
||||
import eu.mhsl.craftattack.spawn.core.util.text.DisconnectInfo;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Outlawed extends Appliance implements DisplayName.Prefixed {
|
||||
public final int timeoutInMs = 1000 * 60 * 60 * 6;
|
||||
private final Map<UUID, Long> timeouts = new HashMap<>();
|
||||
|
||||
public enum Status {
|
||||
DISABLED,
|
||||
VOLUNTARILY,
|
||||
FORCED
|
||||
}
|
||||
|
||||
private final Map<Player, Status> playerStatusMap = new WeakHashMap<>();
|
||||
private final String voluntarilyEntry = "voluntarily";
|
||||
|
||||
public Outlawed() {
|
||||
super("outlawed");
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(
|
||||
Main.instance(),
|
||||
() -> this.playerStatusMap.forEach((player, status) -> {
|
||||
if(!player.isOnline()) return;
|
||||
if(status != Status.FORCED) return;
|
||||
try {
|
||||
this.queryAppliance(Whitelist.class).fullIntegrityCheck(player);
|
||||
} catch(DisconnectInfo.Throwable e) {
|
||||
e.getDisconnectScreen().applyKick(player);
|
||||
}
|
||||
}),
|
||||
20 * 60,
|
||||
20 * 60 * 5
|
||||
);
|
||||
}
|
||||
|
||||
void askForConfirmation(Player player) {
|
||||
Component confirmationMessage = switch(this.getLawStatus(player)) {
|
||||
case DISABLED -> Component.text("Wenn du den PVP-Modus aktivierst, darfst du von allen anderen PVP-Spielern grundlos angegriffen werden." +
|
||||
" Du kannst den PVP-Modus erst wieder nach " + this.timeoutInMs / 1000 / 60 / 60 + " Stunden deaktivieren!");
|
||||
case VOLUNTARILY -> Component.text("Wenn du den PVP-Modus deaktivierst, darfst du nicht mehr grundlos von anderen Spielern angegriffen werden.");
|
||||
case FORCED -> Component.text("Du darfst zurzeit deinen PVP-Modus nicht ändern, da die˝ser als Strafe auferlegt wurde!");
|
||||
};
|
||||
String command = String.format("/%s confirm", OutlawedCommand.commandName);
|
||||
Component changeText = Component.text(
|
||||
String.format(
|
||||
"Zum ändern deines PVP-Status klicke auf diese Nachricht oder tippe '%s'",
|
||||
command
|
||||
),
|
||||
NamedTextColor.GOLD
|
||||
).clickEvent(ClickEvent.suggestCommand(command));
|
||||
|
||||
player.sendMessage(
|
||||
Component.text()
|
||||
.append(confirmationMessage.color(NamedTextColor.RED))
|
||||
.appendNewline()
|
||||
.append(changeText)
|
||||
);
|
||||
}
|
||||
|
||||
void switchLawStatus(Player player) throws OutlawChangeNotPermitted {
|
||||
if(this.getLawStatus(player).equals(Status.FORCED)) {
|
||||
throw new OutlawChangeNotPermitted("Dein PVP-Status wurde als Strafe auferlegt und kann daher nicht verändert werden.");
|
||||
}
|
||||
|
||||
if(this.isTimeout(player)) {
|
||||
throw new OutlawChangeNotPermitted("Du kannst deinen PVP-Status nicht so schnell wechseln. Bitte warte einige Stunden bevor du umschaltest!");
|
||||
}
|
||||
|
||||
this.setLawStatus(player, this.isOutlawed(player) ? Status.DISABLED : Status.VOLUNTARILY);
|
||||
this.setTimeout(player);
|
||||
}
|
||||
|
||||
public void updateForcedStatus(Player player, boolean forced) {
|
||||
this.setLawStatus(player, forced ? Status.FORCED : this.getLawStatus(player) == Status.FORCED ? Status.DISABLED : this.getLawStatus(player));
|
||||
}
|
||||
|
||||
public Status getLawStatus(Player player) {
|
||||
return this.playerStatusMap.computeIfAbsent(player, p -> {
|
||||
if(this.localConfig().getStringList(this.voluntarilyEntry).contains(p.getUniqueId().toString()))
|
||||
return Status.VOLUNTARILY;
|
||||
return Status.DISABLED;
|
||||
});
|
||||
}
|
||||
|
||||
private void setLawStatus(Player player, Status status) {
|
||||
this.playerStatusMap.put(player, status);
|
||||
this.queryAppliance(DisplayName.class).update(player);
|
||||
|
||||
List<String> newList = this.localConfig().getStringList(this.voluntarilyEntry);
|
||||
if(status.equals(Status.VOLUNTARILY)) {
|
||||
newList.add(player.getUniqueId().toString());
|
||||
} else {
|
||||
newList.remove(player.getUniqueId().toString());
|
||||
}
|
||||
this.localConfig().set(this.voluntarilyEntry, newList.stream().distinct().toList());
|
||||
Configuration.saveChanges();
|
||||
|
||||
}
|
||||
|
||||
public boolean isOutlawed(Player player) {
|
||||
return this.getLawStatus(player) != Status.DISABLED;
|
||||
}
|
||||
|
||||
private boolean isTimeout(Player player) {
|
||||
return this.timeouts.getOrDefault(player.getUniqueId(), 0L) > System.currentTimeMillis() - this.timeoutInMs;
|
||||
}
|
||||
|
||||
private void setTimeout(Player player) {
|
||||
this.timeouts.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public Component getStatusDescription(Status status) {
|
||||
return switch(status) {
|
||||
case DISABLED -> Component.text("PVP-Modus inaktiv: ", NamedTextColor.GREEN)
|
||||
.append(Component.text("Es gelten die normalen Regeln!", NamedTextColor.GOLD));
|
||||
|
||||
case VOLUNTARILY, FORCED -> Component.text("PVP-Modus aktiv: ", NamedTextColor.RED)
|
||||
.append(Component.text(
|
||||
"Du darfst von allen anderen PVP-Spielern angegriffen und getötet werden!\n" +
|
||||
"Wenn du getötet wirst, müssen andere Spieler deine Items *nicht* zurückerstatten!",
|
||||
NamedTextColor.GOLD
|
||||
));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getNamePrefix(Player player) {
|
||||
if(this.isOutlawed(player)) {
|
||||
return Component.text("[☠]", NamedTextColor.RED)
|
||||
.hoverEvent(HoverEvent.showText(Component.text(
|
||||
"PVP-Modus Spieler dürfen von anderen vogelfreien Spielern ohne Grund angegriffen werden!"
|
||||
)));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected List<ApplianceCommand<?>> commands() {
|
||||
return List.of(new OutlawedCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected List<Listener> listeners() {
|
||||
return List.of(new OutlawedReminderListener());
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.outlawed;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class OutlawedCommand extends ApplianceCommand.PlayerChecked<Outlawed> {
|
||||
public static final String commandName = "pvp";
|
||||
|
||||
public OutlawedCommand() {
|
||||
super(commandName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
|
||||
if(args.length == 1 && args[0].equals("confirm")) {
|
||||
try {
|
||||
this.getAppliance().switchLawStatus(this.getPlayer());
|
||||
sender.sendMessage(this.getAppliance().getStatusDescription(this.getAppliance().getLawStatus(this.getPlayer())));
|
||||
} catch(OutlawChangeNotPermitted e) {
|
||||
sender.sendMessage(Component.text(e.getMessage(), NamedTextColor.RED));
|
||||
}
|
||||
} else {
|
||||
this.getAppliance().askForConfirmation(this.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.outlawed;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
class OutlawedReminderListener extends ApplianceListener<Outlawed> {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if(this.getAppliance().isOutlawed(e.getPlayer())) {
|
||||
e.getPlayer().sendMessage(this.getAppliance().getStatusDescription(this.getAppliance().getLawStatus(e.getPlayer())));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user