Compare commits

...

32 Commits

Author SHA1 Message Date
323e316f0f fixed bloodmoon sleep / time skip issue, added endermite hordes for end, fixed server restart during bloodmoon issue 2026-01-17 17:09:54 +01:00
0a16e1e049 added missing setting check for bloodmoon warning messages 2026-01-09 19:25:10 +01:00
c371893407 added support for portable stonecutter alongside crafting table, renamed listener for clarity 2026-01-02 22:29:27 +01:00
f2bf8f1858 fixed username validation to allow exceptions for Bedrock players due to specific naming constraints 2025-12-29 09:05:57 +01:00
a0a33f1f56 filtered null and duplicate player names in ReportCommand responses for improved reliability 2025-12-28 17:36:01 +01:00
164a160dbb fixed bloodmoon hordes for players with deactivated setting 2025-12-28 17:21:33 +01:00
efdbc6fe9f updated feedback link behavior, disabled outdated appliances, adjusted infection spawn and silverfish mechanics 2025-12-28 11:40:21 +01:00
7ac02b4ec4 added missing return for /event 2025-12-27 11:35:20 +01:00
93971650ce adjusted strike punishment durations for better balance and scaling 2025-12-27 11:08:47 +01:00
336e3f934c remove wrong location description 2025-12-27 00:47:13 +01:00
91e350ee62 disabled worldmuseum for craftattack 8 2025-12-26 19:50:59 +01:00
8736e78adf Merge remote-tracking branch 'origin/master' 2025-12-25 22:49:19 +01:00
329ec8e1da renamed adminPermission constant to adminmarker for improved clarity and consistency 2025-12-25 22:49:15 +01:00
ebf392b024 fixed bloodmoon progress bar trying updates when inactive 2025-12-24 14:26:23 +01:00
33d00e97c6 fixed recovery compass at project start 2025-12-24 01:07:53 +01:00
1fdcc11211 Merge pull request 'master-big-events' (#11) from master-big-events into master
Reviewed-on: #11
2025-12-23 23:54:14 +00:00
e0ed7ecdf5 Merge branch 'master' into master-big-events 2025-12-23 23:53:42 +00:00
fc6fd9ebb5 Merge branch 'master-big-events' 2025-12-23 22:34:51 +01:00
84edbcc0e4 Merge branch 'master-big-events' 2025-12-23 22:34:33 +01:00
df39093c69 enhanced Outlawed PVP activation message to include cooldown duration; fixed minor typo in forced status message 2025-12-23 21:32:35 +01:00
dfbf87dcd4 updated ProjectStart to adjust coordinates, music, and glass material; refined player inventory handling logic; renamed vogelfrei to PVP in Outlawed messages for clarity 2025-12-23 21:07:32 +01:00
8953a19400 added Bedrock player warning in joinEvent method to handle potential compatibility issues 2025-12-23 19:52:17 +01:00
85065bcc73 made SignEditListener formatting consistent and optimized ReportJoinListener to handle admin notifications asynchronously 2025-12-23 19:14:53 +01:00
2209b42766 fixed wrong reports info filtering 2025-12-23 19:11:59 +01:00
bf11bb0b70 fixed wrong reports info filtering 2025-12-23 19:05:53 +01:00
b98d33af40 added report reminder on admin join 2025-12-23 18:56:30 +01:00
0d6b21701f Merge remote-tracking branch 'origin/master' 2025-12-23 15:50:41 +01:00
b3240cdb22 fixed maximum of 8 settings per category 2025-12-23 15:50:23 +01:00
89c1c4335b refined SignEditListener to filter illegal characters more robustly by normalizing input and introducing specific character whitelists 2025-12-22 21:41:34 +01:00
71f2da8e99 introduced AntiIllegalSignCharacters appliance to prevent usage of illegal characters in sign edits 2025-12-22 18:44:22 +01:00
a257b604ea updated InventoryTrackerListener to monitor InventoryOpenEvent with high priority and prevent processing of cancelled events 2025-12-21 09:32:40 +01:00
ac7e04829e introduced ReportCreatedListener, updated ReportCreatedEvent to use UUIDs for reporter and reported, and improved admin notifications for new reports 2025-12-20 17:46:02 +01:00
35 changed files with 406 additions and 90 deletions

View File

@@ -23,4 +23,8 @@ public class CraftAttackReportRepository extends ReportRepository {
ReportUrl.class ReportUrl.class
); );
} }
public ReqResp<AllReports> queryAllReports() {
return this.get("reports", AllReports.class);
}
} }

View File

@@ -21,6 +21,11 @@ public abstract class ReportRepository extends HttpRepository {
public record ReportUrl(@NotNull String url) { public record ReportUrl(@NotNull String url) {
} }
public enum Status {
open,
closed,
}
public record PlayerReports( public record PlayerReports(
List<Report> from_self, List<Report> from_self,
List<Report> to_self List<Report> to_self
@@ -31,11 +36,17 @@ public abstract class ReportRepository extends HttpRepository {
@Nullable Long created, @Nullable Long created,
@Nullable Status status, @Nullable Status status,
@NotNull String url @NotNull String url
) { ) { }
public enum Status { }
open,
closed, public record AllReports(List<Report> reports) {
} public record Report(
} @NotNull UUID reporter,
@Nullable UUID reported,
@NotNull String reason,
@Nullable Long created,
@Nullable Status status,
@NotNull String url
) { }
} }
} }

View File

@@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.UUID; import java.util.UUID;
public class AdminMarker extends Appliance implements DisplayName.Colored { public class AdminMarker extends Appliance implements DisplayName.Colored {
public final static String adminPermission = "admin"; public final static String adminPermission = "adminmarker";
@Override @Override
public @Nullable TextColor getNameColor(Player player) { public @Nullable TextColor getNameColor(Player player) {

View File

@@ -19,7 +19,7 @@ public class HelpCommand extends ApplianceCommand<Help> {
Component.text("Willkommen auf Craftattack!", NamedTextColor.GOLD) Component.text("Willkommen auf Craftattack!", NamedTextColor.GOLD)
.appendNewline() .appendNewline()
.append(Component.text("Wenn du hilfe benötigst kannst du dich jederzeit an einen Admin wenden." + .append(Component.text("Wenn du hilfe benötigst kannst du dich jederzeit an einen Admin wenden." +
" Weitere Informationen zu Funktionen und Befehlen erhältst du zudem im Turm am Spawn.", NamedTextColor.GRAY)) " Weitere Informationen zu Funktionen und Befehlen erhältst du zudem am Spawn.", NamedTextColor.GRAY))
); );
} }
} }

View File

@@ -1,6 +1,8 @@
package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report; package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report;
import eu.mhsl.craftattack.spawn.common.api.repositories.ReportRepository; import eu.mhsl.craftattack.spawn.common.api.repositories.ReportRepository;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report.listeners.ReportCreatedListener;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report.listeners.ReportJoinListener;
import eu.mhsl.craftattack.spawn.core.Main; import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.api.client.ReqResp; import eu.mhsl.craftattack.spawn.core.api.client.ReqResp;
import eu.mhsl.craftattack.spawn.common.api.repositories.CraftAttackReportRepository; import eu.mhsl.craftattack.spawn.common.api.repositories.CraftAttackReportRepository;
@@ -16,6 +18,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -132,7 +135,7 @@ public class Report extends Appliance {
} }
Function<List<ReportRepository.PlayerReports.Report>, List<ReportRepository.PlayerReports.Report>> filterClosed = reports -> reports.stream() Function<List<ReportRepository.PlayerReports.Report>, List<ReportRepository.PlayerReports.Report>> filterClosed = reports -> reports.stream()
.filter(report -> Objects.equals(report.status(), ReportRepository.PlayerReports.Report.Status.closed)) .filter(report -> Objects.equals(report.status(), ReportRepository.Status.closed))
.toList(); .toList();
List<ReportRepository.PlayerReports.Report> reportsToOthers = filterClosed.apply(userReports.data().from_self()).reversed(); List<ReportRepository.PlayerReports.Report> reportsToOthers = filterClosed.apply(userReports.data().from_self()).reversed();
@@ -178,6 +181,35 @@ public class Report extends Appliance {
issuer.sendMessage(component.build()); issuer.sendMessage(component.build());
} }
public void sendReportsInfo(Player player) {
ReqResp<ReportRepository.AllReports> allReportsResponse = this.queryRepository(CraftAttackReportRepository.class).queryAllReports();
if(allReportsResponse.status() != 200) {
Main.logger().warning("Failed to request Reports: " + allReportsResponse.status());
return;
}
List<ReportRepository.AllReports.Report> allOpenReports = allReportsResponse.data().reports().stream()
.filter(report -> report.status() == null && report.created() != null)
.toList();
if(allOpenReports.isEmpty()) return;
player.sendMessage(
Component.text("Hey, es gibt noch ", NamedTextColor.GOLD)
.append(Component.text(allOpenReports.size(), NamedTextColor.RED))
.append(Component.text(" unbearbeitete Reports!", NamedTextColor.GOLD))
);
}
@Override
protected @NotNull List<Listener> listeners() {
return List.of(
new ReportCreatedListener(),
new ReportJoinListener()
);
}
@Override @Override
@NotNull @NotNull
protected List<ApplianceCommand<?>> commands() { protected List<ApplianceCommand<?>> commands() {

View File

@@ -13,6 +13,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -46,7 +47,7 @@ class ReportCommand extends ApplianceCommand.PlayerChecked<Report> {
response = Stream.concat( response = Stream.concat(
Bukkit.getOnlinePlayers().stream().map(Player::getName), Bukkit.getOnlinePlayers().stream().map(Player::getName),
Arrays.stream(Bukkit.getOfflinePlayers()).map(OfflinePlayer::getName) Arrays.stream(Bukkit.getOfflinePlayers()).map(OfflinePlayer::getName)
).toList(); ).filter(Objects::nonNull).distinct().toList();
} }
if(args.length == 2) { if(args.length == 2) {

View File

@@ -0,0 +1,27 @@
package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report.listeners;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report.Report;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import eu.mhsl.craftattack.spawn.core.event.ReportCreatedEvent;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.EventHandler;
public class ReportCreatedListener extends ApplianceListener<Report> {
@EventHandler
public void onReport(ReportCreatedEvent event) {
OfflinePlayer reporter = Bukkit.getOfflinePlayer(event.getReport().reporter());
OfflinePlayer reported = Bukkit.getOfflinePlayer(event.getReport().reported());
Component message = Component.text(
"\uD83D\uDD14 Neuer Report von %s gegen %s: %s".formatted(reporter.getName(), reported.getName(), event.getReport().reason()),
NamedTextColor.YELLOW
);
Bukkit.getOnlinePlayers().stream()
.filter(player -> player.hasPermission("admin"))
.forEach(player -> player.sendMessage(message));
}
}

View File

@@ -0,0 +1,19 @@
package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report.listeners;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.report.Report;
import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
public class ReportJoinListener extends ApplianceListener<Report> {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if(!event.getPlayer().hasPermission("admin")) return;
Bukkit.getScheduler().runTaskAsynchronously(
Main.instance(),
() -> this.getAppliance().sendReportsInfo(event.getPlayer())
);
}
}

View File

@@ -128,12 +128,12 @@ public class Settings extends Appliance {
if(categorizedSettings.isEmpty()) return; if(categorizedSettings.isEmpty()) return;
for(int i = 0; i < categorizedSettings.size(); i++) { for(int i = 0; i < categorizedSettings.size(); i++) {
int slot = row.get() * 9 + i % 9; if(i % 9 == 0 && i != 0) {
inventory.setItem(slot, categorizedSettings.get(i).buildItem());
if(i % 9 == 8) {
row.incrementAndGet(); row.incrementAndGet();
} }
int slot = row.get() * 9 + i % 9;
inventory.setItem(slot, categorizedSettings.get(i).buildItem());
} }
row.incrementAndGet(); row.incrementAndGet();
}); });
@@ -143,12 +143,12 @@ public class Settings extends Appliance {
.toList(); .toList();
for(int i = 0; i < uncategorizedSettings.size(); i++) { for(int i = 0; i < uncategorizedSettings.size(); i++) {
int slot = row.get() * 9 + i % 9; if(i % 9 == 0 && i != 0) {
inventory.setItem(slot, uncategorizedSettings.get(i).buildItem());
if(i % 9 == 8) {
row.incrementAndGet(); row.incrementAndGet();
} }
int slot = row.get() * 9 + i % 9;
inventory.setItem(slot, uncategorizedSettings.get(i).buildItem());
} }
player.openInventory(inventory); player.openInventory(inventory);

View File

@@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Boat; import org.bukkit.entity.Boat;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Appliance.Flags(enabled = false)
public class AntiBoatFreecam extends Appliance { public class AntiBoatFreecam extends Appliance {
private static final float MAX_YAW_OFFSET = 106.0f; private static final float MAX_YAW_OFFSET = 106.0f;

View File

@@ -0,0 +1,16 @@
package eu.mhsl.craftattack.spawn.common.appliances.security.antiIllegalSignCharacters;
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class AntiIllegalSignCharacters extends Appliance {
@Override
protected @NotNull List<Listener> listeners() {
return List.of(
new SignEditListener()
);
}
}

View File

@@ -0,0 +1,77 @@
package eu.mhsl.craftattack.spawn.common.appliances.security.antiIllegalSignCharacters;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.SignChangeEvent;
import java.text.Normalizer;
import java.util.Set;
class SignEditListener extends ApplianceListener<AntiIllegalSignCharacters> {
private static final Set<Integer> ALLOWED_CHARS = Set.of(
(int)' ', (int)'.', (int)',', (int)';', (int)':', (int)'!', (int)'?',
(int)'"', (int)'\'',
(int)'(', (int)')', (int)'[', (int)']', (int)'{', (int)'}',
(int)'-', (int)'_', (int)'+', (int)'=', (int)'/', (int)'\\',
(int)'@', (int)'#', (int)'$', (int)'%', (int)'&', (int)'*',
(int)'<', (int)'>', (int)'|',
(int)'~', (int)'`', (int)'^'
);
private static final Set<Integer> ALLOWED_EXTRA = Set.of(
(int)'Ä', (int)'Ö', (int)'Ü', (int)'ä', (int)'ö', (int)'ü', (int)'ß',
(int)'€', (int)'°', (int)'µ'
);
@EventHandler
public void onSignEdit(SignChangeEvent event) {
for (int i = 0; i < 4; i++) {
Component line = event.line(i);
if (line == null) continue;
String plainString = PlainTextComponentSerializer.plainText().serialize(line);
plainString = Normalizer.normalize(plainString, Normalizer.Form.NFC);
String cleaned = filterAllowed(plainString);
event.line(i, Component.text(cleaned));
}
}
private static String filterAllowed(String s) {
StringBuilder out = new StringBuilder(s.length());
for (int off = 0; off < s.length(); ) {
int cp = s.codePointAt(off);
off += Character.charCount(cp);
if (isForbidden(cp)) continue;
if (Character.isLetterOrDigit(cp)) {
out.appendCodePoint(cp);
continue;
}
if (ALLOWED_CHARS.contains(cp) || ALLOWED_EXTRA.contains(cp)) {
out.appendCodePoint(cp);
}
}
return out.toString();
}
private static boolean isForbidden(int cp) {
// Surrogates / invalid
if (cp >= 0xD800 && cp <= 0xDFFF) return true;
// Private Use Area (Mod/Pack-Icons/Placeholder)
if (cp >= 0xE000 && cp <= 0xF8FF) return true;
// Zero-width and control characters
if (cp == 0x200B || cp == 0x200C || cp == 0x200D || cp == 0xFEFF) return true;
// BiDi-Steuerzeichen
if (cp >= 0x202A && cp <= 0x202E) return true;
if (cp >= 0x2066 && cp <= 0x2069) return true;
return cp == '§';
}
}

View File

@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Appliance.Flags(enabled = false)
public class AntiInventoryMove extends Appliance { public class AntiInventoryMove extends Appliance {
private static final long errorTimeMargin = Ticks.SINGLE_TICK_DURATION_MS * 2; private static final long errorTimeMargin = Ticks.SINGLE_TICK_DURATION_MS * 2;

View File

@@ -3,13 +3,15 @@ package eu.mhsl.craftattack.spawn.common.appliances.security.antiInventoryMove;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener; import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
class InventoryTrackerListener extends ApplianceListener<AntiInventoryMove> { class InventoryTrackerListener extends ApplianceListener<AntiInventoryMove> {
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void onOpen(InventoryOpenEvent event) { public void onOpen(InventoryOpenEvent event) {
if(!(event.getPlayer() instanceof Player player)) return; if(!(event.getPlayer() instanceof Player player)) return;
if(event.isCancelled()) return;
this.getAppliance().setInvOpen(player, true); this.getAppliance().setInvOpen(player, true);
} }

View File

@@ -28,14 +28,16 @@ public class WebsiteHook extends HttpHook {
return HttpServer.nothing; return HttpServer.nothing;
})); }));
record CreatedReport(String reporter, String reported, String reason) {} record CreatedReport(UUID reporter, UUID reported, String reason) {}
this.addAction("report", new JsonAction<>(CreatedReport.class, createdReport -> { this.addAction("report", new JsonAction<>(CreatedReport.class, createdReport -> {
Main.logger().info(String.format("New Report from Hook: (%s) Reporter: %s Reported: %s", createdReport.reason, createdReport.reporter, createdReport.reported));
SpawnEvent.call(new ReportCreatedEvent(new ReportCreatedEvent.CreatedReport(createdReport.reporter, createdReport.reported, createdReport.reason))); SpawnEvent.call(new ReportCreatedEvent(new ReportCreatedEvent.CreatedReport(createdReport.reporter, createdReport.reported, createdReport.reason)));
return HttpServer.nothing; return HttpServer.nothing;
})); }));
record CreatedStrike(UUID uuid) {} record CreatedStrike(UUID uuid) {}
this.addAction("strike", new JsonAction<>(CreatedStrike.class, createdStrike -> { this.addAction("strike", new JsonAction<>(CreatedStrike.class, createdStrike -> {
Main.logger().info(String.format("New Strike from Hook! (User %s)", createdStrike.uuid));
SpawnEvent.call(new StrikeCreatedEvent(new StrikeCreatedEvent.CreatedStrike(createdStrike.uuid))); SpawnEvent.call(new StrikeCreatedEvent(new StrikeCreatedEvent.CreatedStrike(createdStrike.uuid)));
return HttpServer.nothing; return HttpServer.nothing;
})); }));

View File

@@ -4,6 +4,8 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public class ReportCreatedEvent extends Event { public class ReportCreatedEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList(); private static final HandlerList HANDLERS = new HandlerList();
@Override @Override
@@ -15,7 +17,7 @@ public class ReportCreatedEvent extends Event {
return HANDLERS; return HANDLERS;
} }
public record CreatedReport(String reporter, String reported, String reason) {} public record CreatedReport(UUID reporter, UUID reported, String reason) {}
private final CreatedReport report; private final CreatedReport report;
public ReportCreatedEvent(CreatedReport report) { public ReportCreatedEvent(CreatedReport report) {

View File

@@ -5,23 +5,18 @@ import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.appliance.Appliance; import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand; import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.commands.BloodmoonCommand; import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.commands.BloodmoonCommand;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonEntityDamageListener; import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.*;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonMonsterDeathListener;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonPlayerJoinListener;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonTimeListener;
import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.bossbar.BossBar;
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.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.util.Ticks; import net.kyori.adventure.util.Ticks;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@@ -70,7 +65,6 @@ public class Bloodmoon extends Appliance {
public final double mobHealthMultiplier = 2; public final double mobHealthMultiplier = 2;
private final ThreadLocalRandom random = ThreadLocalRandom.current(); private final ThreadLocalRandom random = ThreadLocalRandom.current();
private boolean isActive = false;
private final BossBar bossBar = BossBar.bossBar( private final BossBar bossBar = BossBar.bossBar(
Component.text("Blutmond", NamedTextColor.DARK_RED), Component.text("Blutmond", NamedTextColor.DARK_RED),
1f, 1f,
@@ -79,6 +73,7 @@ public class Bloodmoon extends Appliance {
Set.of(BossBar.Flag.CREATE_WORLD_FOG, BossBar.Flag.DARKEN_SCREEN) Set.of(BossBar.Flag.CREATE_WORLD_FOG, BossBar.Flag.DARKEN_SCREEN)
); );
private final boolean hordesEnabled = true; private final boolean hordesEnabled = true;
public final boolean bloodmoonSkippable = true;
private final int hordeSpawnRateTicks = 40 * Ticks.TICKS_PER_SECOND; private final int hordeSpawnRateTicks = 40 * Ticks.TICKS_PER_SECOND;
private final int hordeSpawnRateVariationTicks = 40 * Ticks.TICKS_PER_SECOND; private final int hordeSpawnRateVariationTicks = 40 * Ticks.TICKS_PER_SECOND;
private final int hordeMinPopulation = 3; private final int hordeMinPopulation = 3;
@@ -90,10 +85,10 @@ public class Bloodmoon extends Appliance {
EntityType.SPIDER EntityType.SPIDER
); );
private final Map<Player, @Nullable BukkitTask> hordeSpawnTasks = new WeakHashMap<>(); private final Map<Player, @Nullable BukkitTask> hordeSpawnTasks = new WeakHashMap<>();
private long lastBloodmoonStartTick = 0;
public final int ticksPerDay = 24000; public final int ticksPerDay = 24000;
public final int bloodmoonLength = this.ticksPerDay /2; public final int bloodmoonLength = this.ticksPerDay / 2;
public final int preStartMessageTicks = Ticks.TICKS_PER_SECOND * 50; public final int preStartMessageTicks = Ticks.TICKS_PER_SECOND * 50;
private boolean bossbarActive = false;
private final int bloodmoonFreeDaysAtStart = 3; private final int bloodmoonFreeDaysAtStart = 3;
private final int bloodmoonStartTime = this.ticksPerDay /2; private final int bloodmoonStartTime = this.ticksPerDay /2;
private final int bloodmoonDayInterval = 30; private final int bloodmoonDayInterval = 30;
@@ -113,35 +108,71 @@ public class Bloodmoon extends Appliance {
} }
public boolean bloodmoonIsActive() { public boolean bloodmoonIsActive() {
return this.isActive; long currentTick = Bukkit.getWorlds().getFirst().getFullTime();
long day = currentTick / this.ticksPerDay;
if(day % this.bloodmoonDayInterval != 0 || day - this.bloodmoonFreeDaysAtStart <= 0) return false;
long time = currentTick % this.ticksPerDay;
return time >= this.bloodmoonStartTime && time <= this.bloodmoonStartTime + this.bloodmoonLength;
} }
public void startBloodmoon(long startTick) { public void startBloodmoon() {
this.lastBloodmoonStartTick = startTick; this.bossbarActive = true;
this.isActive = true;
Bukkit.getOnlinePlayers().forEach(this::addPlayerToBossBar); Bukkit.getOnlinePlayers().forEach(this::addPlayerToBossBar);
this.startHordeSpawning(this.getRandomHordeSpawnDelay()); this.startHordeSpawning(this.getRandomHordeSpawnDelay());
this.sendStartMessages(); this.sendStartMessages();
} }
public void stopBloodmoon() { public void stopBloodmoonIfInactive() {
this.isActive = false; Bukkit.getScheduler().runTaskLater(
Main.instance(),
() -> {
if(!this.bossbarActive) return;
if(this.bloodmoonIsActive()) return;
this.bossbarActive = false;
Bukkit.getOnlinePlayers().forEach(player -> player.hideBossBar(this.bossBar));
this.stopHordeSpawning();
this.sendStopMessages();
},
1
);
}
// not working for entity effects and debuffs...
public void forceStopBloodmoon() {
this.bossbarActive = false;
Bukkit.getOnlinePlayers().forEach(player -> player.hideBossBar(this.bossBar)); Bukkit.getOnlinePlayers().forEach(player -> player.hideBossBar(this.bossBar));
this.stopHordeSpawning();
this.sendStopMessages(); this.sendStopMessages();
} }
public void updateBossBar() { public void updateBossBar() {
long tick = Bukkit.getWorlds().getFirst().getFullTime(); long tick = Bukkit.getWorlds().getFirst().getFullTime();
long sinceStart = tick - this.lastBloodmoonStartTick; long sinceStart = tick - this.lastBloodmoonStartTick();
float progress = 1f - ((float) sinceStart / this.bloodmoonLength); float progress = 1f - ((float) sinceStart / this.bloodmoonLength);
if(progress < 0) progress = 1f; if(progress < 0) progress = 1f;
this.bossBar.progress(progress); this.bossBar.progress(progress);
} }
private long lastBloodmoonStartTick() {
long currentTick = Bukkit.getWorlds().getFirst().getFullTime();
long day = currentTick / this.ticksPerDay;
long time = currentTick % this.ticksPerDay;
boolean todayIsBloodmoon = (day % this.bloodmoonDayInterval == 0) && (day > this.bloodmoonFreeDaysAtStart);
if (todayIsBloodmoon && time < this.bloodmoonStartTime) {
day -= this.bloodmoonDayInterval;
} else if (!todayIsBloodmoon) {
day -= (day % this.bloodmoonDayInterval);
}
if (day <= this.bloodmoonFreeDaysAtStart) return -1L;
return day * this.ticksPerDay + this.bloodmoonStartTime;
}
public boolean isStartTick(long tick) { public boolean isStartTick(long tick) {
long day = tick / this.ticksPerDay; long day = tick / this.ticksPerDay;
if(day % this.bloodmoonDayInterval != 0 || day - this.bloodmoonFreeDaysAtStart <= 0) return false; if(day % this.bloodmoonDayInterval != 0 || day <= this.bloodmoonFreeDaysAtStart) return false;
long time = tick - (day * this.ticksPerDay); long time = tick % this.ticksPerDay;
return time == this.bloodmoonStartTime; return time == this.bloodmoonStartTime;
} }
@@ -153,7 +184,14 @@ public class Bloodmoon extends Appliance {
Bukkit.getOnlinePlayers().forEach(player -> this.startHordeSpawning(delay, player)); Bukkit.getOnlinePlayers().forEach(player -> this.startHordeSpawning(delay, player));
} }
private void startHordeSpawning(int delay, Player player) { private void stopHordeSpawning() {
this.hordeSpawnTasks.forEach((player, bukkitTask) -> {
@Nullable BukkitTask task = this.hordeSpawnTasks.get(player);
if(task != null) task.cancel();
});
}
public void startHordeSpawning(int delay, Player player) {
@Nullable BukkitTask task = this.hordeSpawnTasks.get(player); @Nullable BukkitTask task = this.hordeSpawnTasks.get(player);
if(task != null) task.cancel(); if(task != null) task.cancel();
BukkitTask newTask = Bukkit.getScheduler().runTaskLater( BukkitTask newTask = Bukkit.getScheduler().runTaskLater(
@@ -187,14 +225,17 @@ public class Bloodmoon extends Appliance {
public void spawnRandomHorde(Player player) { public void spawnRandomHorde(Player player) {
if(!this.hordesEnabled) return; if(!this.hordesEnabled) return;
if(!this.getBloodmoonSetting(player)) return;
if(!player.getGameMode().equals(GameMode.SURVIVAL)) return; if(!player.getGameMode().equals(GameMode.SURVIVAL)) return;
EntityType hordeEntityType = this.hordeMobList.get(this.random.nextInt(this.hordeMobList.size())); EntityType hordeEntityType = this.hordeMobList.get(this.random.nextInt(this.hordeMobList.size()));
if(player.getLocation().getWorld().getEnvironment().equals(World.Environment.THE_END)) hordeEntityType = EntityType.ENDERMITE;
int hordeSize = this.random.nextInt(this.hordeMinPopulation, this.hordeMaxPopulation + 1); int hordeSize = this.random.nextInt(this.hordeMinPopulation, this.hordeMaxPopulation + 1);
this.spawnHorde(player, hordeSize, hordeEntityType); this.spawnHorde(player, hordeSize, hordeEntityType);
} }
public void sendWarningMessage(Player p) { public void sendWarningMessage(Player p) {
if(!this.getBloodmoonSetting(p)) return;
p.sendMessage(Component.text("Der Blutmond waltet in diesem Augenblick!", NamedTextColor.RED)); p.sendMessage(Component.text("Der Blutmond waltet in diesem Augenblick!", NamedTextColor.RED));
} }
@@ -215,7 +256,7 @@ public class Bloodmoon extends Appliance {
Math.cos(spawnRadiant)*this.hordeSpawnDistance Math.cos(spawnRadiant)*this.hordeSpawnDistance
); );
mobSpawnLocation.setY(player.getWorld().getHighestBlockYAt(mobSpawnLocation) + 1); mobSpawnLocation.setY(player.getWorld().getHighestBlockYAt(mobSpawnLocation) + 1);
player.getWorld().spawnEntity(mobSpawnLocation, type); player.getWorld().spawnEntity(mobSpawnLocation, type, CreatureSpawnEvent.SpawnReason.NATURAL);
player.getWorld().strikeLightningEffect(mobSpawnLocation); player.getWorld().strikeLightningEffect(mobSpawnLocation);
} }
} }
@@ -269,7 +310,8 @@ public class Bloodmoon extends Appliance {
new BloodmoonMonsterDeathListener(), new BloodmoonMonsterDeathListener(),
new BloodmoonPlayerJoinListener(), new BloodmoonPlayerJoinListener(),
new BloodmoonEntityDamageListener(), new BloodmoonEntityDamageListener(),
new BloodmoonTimeListener() new BloodmoonTimeListener(),
new BloodmoonTimeSkipListener()
); );
} }

View File

@@ -19,7 +19,7 @@ public class BloodmoonSetting extends BoolSetting implements CategorizedSetting
@Override @Override
public SettingCategory category() { public SettingCategory category() {
return SettingCategory.Misc; // TODO: mehr als 8 bug fixen return SettingCategory.Gameplay;
} }
@Override @Override

View File

@@ -2,6 +2,7 @@ package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.comm
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand; import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon; import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -23,15 +24,19 @@ public class BloodmoonCommand extends ApplianceCommand<Bloodmoon> {
switch(args[0]) { switch(args[0]) {
case "start": { case "start": {
this.getAppliance().startBloodmoon(0L); this.getAppliance().startBloodmoon();
sender.sendMessage("Started bloodmoon."); sender.sendMessage("Started bloodmoon.");
break; break;
} }
case "stop": { case "stop": {
this.getAppliance().stopBloodmoon(); this.getAppliance().forceStopBloodmoon();
sender.sendMessage("Stopped bloodmoon."); sender.sendMessage("Stopped bloodmoon.");
break; break;
} }
case "time": {
sender.sendMessage(String.valueOf(Bukkit.getWorlds().getFirst().getFullTime()));
break;
}
default: throw new Error("No such option: '%s' !".formatted(args[0])); default: throw new Error("No such option: '%s' !".formatted(args[0]));
} }
} }

View File

@@ -2,6 +2,7 @@ package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.list
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener; import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon; import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@@ -9,7 +10,9 @@ public class BloodmoonPlayerJoinListener extends ApplianceListener<Bloodmoon> {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
if(!this.getAppliance().bloodmoonIsActive()) return; if(!this.getAppliance().bloodmoonIsActive()) return;
this.getAppliance().addPlayerToBossBar(event.getPlayer()); Player player = event.getPlayer();
this.getAppliance().sendWarningMessage(event.getPlayer()); this.getAppliance().addPlayerToBossBar(player);
this.getAppliance().startHordeSpawning(1500, player);
this.getAppliance().sendWarningMessage(player);
} }
} }

View File

@@ -12,14 +12,14 @@ public class BloodmoonTimeListener extends ApplianceListener<Bloodmoon> {
public void onServerTick(ServerTickStartEvent event) { public void onServerTick(ServerTickStartEvent event) {
long currentTime = Bukkit.getWorlds().getFirst().getFullTime(); long currentTime = Bukkit.getWorlds().getFirst().getFullTime();
if(this.getAppliance().isStartTick(currentTime)) { if(this.getAppliance().isStartTick(currentTime)) {
this.getAppliance().startBloodmoon(currentTime); this.getAppliance().startBloodmoon();
return; return;
} }
if(this.getAppliance().isStartTick(currentTime - this.getAppliance().bloodmoonLength)) { if(this.getAppliance().isStartTick(currentTime - this.getAppliance().bloodmoonLength)) {
this.getAppliance().stopBloodmoon(); this.getAppliance().stopBloodmoonIfInactive();
return; return;
} }
if(currentTime % Ticks.TICKS_PER_SECOND == 0) this.getAppliance().updateBossBar(); if(currentTime % Ticks.TICKS_PER_SECOND == 0 && this.getAppliance().bloodmoonIsActive()) this.getAppliance().updateBossBar();
if(this.getAppliance().isStartTick(currentTime + this.getAppliance().ticksPerDay)) { if(this.getAppliance().isStartTick(currentTime + this.getAppliance().ticksPerDay)) {
this.getAppliance().sendAnnouncementMessages(); this.getAppliance().sendAnnouncementMessages();
return; return;

View File

@@ -0,0 +1,29 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
import net.kyori.adventure.text.Component;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.world.TimeSkipEvent;
public class BloodmoonTimeSkipListener extends ApplianceListener<Bloodmoon> {
@EventHandler
public void onTimeSkip(TimeSkipEvent event) {
if(this.getAppliance().bloodmoonSkippable || !event.getSkipReason().equals(TimeSkipEvent.SkipReason.NIGHT_SKIP)) {
this.getAppliance().stopBloodmoonIfInactive();
return;
}
event.setCancelled(true);
}
@EventHandler
public void onPlayerSleep(PlayerBedEnterEvent event) {
if(!this.getAppliance().bloodmoonIsActive()) return;
if(this.getAppliance().bloodmoonSkippable) return;
if(!event.getBedEnterResult().equals(PlayerBedEnterEvent.BedEnterResult.OK)) return;
event.setUseBed(Event.Result.DENY);
event.getPlayer().sendActionBar(Component.text("Du kannst während dem Blutmond nicht schlafen"));
}
}

View File

@@ -51,14 +51,15 @@ public class Outlawed extends Appliance implements DisplayName.Prefixed {
void askForConfirmation(Player player) { void askForConfirmation(Player player) {
Component confirmationMessage = switch(this.getLawStatus(player)) { Component confirmationMessage = switch(this.getLawStatus(player)) {
case DISABLED -> Component.text("Wenn du Vogelfrei aktivierst, darfst du von allen anderen vogelfreien Spielern grundlos angegriffen werden."); case DISABLED -> Component.text("Wenn du den PVP-Modus aktivierst, darfst du von allen anderen PVP-Spielern grundlos angegriffen werden." +
case VOLUNTARILY -> Component.text("Wenn du Vogelfrei deaktivierst, darfst du nicht mehr grundlos von anderen Spielern angegriffen werden."); " Du kannst den PVP-Modus erst wieder nach " + this.timeoutInMs / 1000 / 60 / 60 + " Stunden deaktivieren!");
case FORCED -> Component.text("Du darfst zurzeit deinen Vogelfreistatus nicht ändern, da dieser als Strafe auferlegt wurde!"); 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); String command = String.format("/%s confirm", OutlawedCommand.commandName);
Component changeText = Component.text( Component changeText = Component.text(
String.format( String.format(
"Zum ändern deines Vogelfrei status klicke auf diese Nachricht oder tippe '%s'", "Zum ändern deines PVP-Status klicke auf diese Nachricht oder tippe '%s'",
command command
), ),
NamedTextColor.GOLD NamedTextColor.GOLD

View File

@@ -0,0 +1,20 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.portableCrafting;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.Settings;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
class OnCraftingBlockUseListener extends ApplianceListener<PortableCrafting> {
@EventHandler
public void inInteract(PlayerInteractEvent event) {
if(!event.getAction().equals(Action.RIGHT_CLICK_AIR)) return;
if(!Settings.instance().getSetting(event.getPlayer(), Settings.Key.EnablePortableCrafting, Boolean.class)) return;
switch(event.getMaterial()) {
case CRAFTING_TABLE -> this.getAppliance().openCraftingTable(event.getPlayer());
case STONECUTTER -> this.getAppliance().openStonecutter(event.getPlayer());
}
}
}

View File

@@ -1,16 +0,0 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.portableCrafting;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
class OnCraftingTableUseListener extends ApplianceListener<PortableCrafting> {
@EventHandler
public void inInteract(PlayerInteractEvent event) {
if(!event.getAction().equals(Action.RIGHT_CLICK_AIR)) return;
if(!event.getMaterial().equals(Material.CRAFTING_TABLE)) return;
this.getAppliance().openFor(event.getPlayer());
}
}

View File

@@ -14,13 +14,16 @@ public class PortableCrafting extends Appliance {
Settings.instance().declareSetting(PortableCraftingSetting.class); Settings.instance().declareSetting(PortableCraftingSetting.class);
} }
public void openFor(Player player) { public void openCraftingTable(Player player) {
if(!Settings.instance().getSetting(player, Settings.Key.EnablePortableCrafting, Boolean.class)) return;
player.openWorkbench(null, true); player.openWorkbench(null, true);
} }
public void openStonecutter(Player player) {
player.openStonecutter(null, true);
}
@Override @Override
protected @NotNull List<Listener> listeners() { protected @NotNull List<Listener> listeners() {
return List.of(new OnCraftingTableUseListener()); return List.of(new OnCraftingBlockUseListener());
} }
} }

View File

@@ -18,7 +18,7 @@ public class PortableCraftingSetting extends BoolSetting implements CategorizedS
@Override @Override
protected String description() { protected String description() {
return "Erlaubt das öffnen einer Werkbank in der Hand, ohne sie plazieren zu müssen"; return "Erlaubt das öffnen einer Werkbank oder einer Steinsäge in der Hand, ohne den Block plazieren zu müssen";
} }
@Override @Override

View File

@@ -2,6 +2,7 @@ package eu.mhsl.craftattack.spawn.craftattack.appliances.metaGameplay.event;
import eu.mhsl.craftattack.spawn.core.Main; import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.core.api.client.ReqResp; import eu.mhsl.craftattack.spawn.core.api.client.ReqResp;
import eu.mhsl.craftattack.spawn.core.util.server.Floodgate;
import eu.mhsl.craftattack.spawn.craftattack.api.repositories.EventRepository; import eu.mhsl.craftattack.spawn.craftattack.api.repositories.EventRepository;
import eu.mhsl.craftattack.spawn.core.api.server.HttpServer; import eu.mhsl.craftattack.spawn.core.api.server.HttpServer;
import eu.mhsl.craftattack.spawn.core.appliance.Appliance; import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
@@ -26,6 +27,7 @@ import org.bukkit.entity.Villager;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.geysermc.cumulus.form.SimpleForm;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.*;
@@ -106,6 +108,10 @@ public class Event extends Appliance {
} }
public void joinEvent(Player p) { public void joinEvent(Player p) {
this.joinEvent(p, false);
}
public void joinEvent(Player p, boolean ignoreBedrock) {
if(!this.isOpen) { if(!this.isOpen) {
p.sendMessage(Component.text("Zurzeit ist kein Event geöffnet.", NamedTextColor.RED)); p.sendMessage(Component.text("Zurzeit ist kein Event geöffnet.", NamedTextColor.RED));
return; return;
@@ -121,6 +127,23 @@ public class Event extends Appliance {
return; return;
} }
if(!ignoreBedrock && Floodgate.isBedrock(p)) {
Floodgate.getBedrockPlayer(p).sendForm(
SimpleForm.builder()
.title("Achtung!")
.content("Je nach deiner Minecraft-Bedrock-Version kann dein Minecraft in den Events abstürzen. " +
"Ggf. ist also für dich ein Mitspielen auf der Bedrock-Edition nicht möglich.")
.button("Ok, lass es uns versuchen")
.button("Abbrechen")
.validResultHandler(simpleFormResponse -> {
if(simpleFormResponse.clickedButtonId() != 0) return;
this.joinEvent(p, true);
})
.build()
);
return;
}
Main.instance().getLogger().info("Verbinde mit eventserver: " + p.getName()); Main.instance().getLogger().info("Verbinde mit eventserver: " + p.getName());
p.sendMessage(Component.text("Authentifiziere...", NamedTextColor.GREEN)); p.sendMessage(Component.text("Authentifiziere...", NamedTextColor.GREEN));
@@ -137,6 +160,7 @@ public class Event extends Appliance {
p.sendMessage(Component.text("Betrete...", NamedTextColor.GREEN)); p.sendMessage(Component.text("Betrete...", NamedTextColor.GREEN));
PluginMessage.connect(p, this.localConfig().getString("connect-server-name")); PluginMessage.connect(p, this.localConfig().getString("connect-server-name"));
}); });
return;
} }
PluginMessage.connect(p, "grand-event"); PluginMessage.connect(p, "grand-event");

View File

@@ -9,7 +9,6 @@ import eu.mhsl.craftattack.spawn.core.api.HttpStatus;
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.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -52,7 +51,7 @@ public class Feedback extends Appliance {
message message
.append(Component.text("Klicke hier und gib uns Feedback, damit wir dein Spielerlebnis verbessern können!", NamedTextColor.DARK_GREEN) .append(Component.text("Klicke hier und gib uns Feedback, damit wir dein Spielerlebnis verbessern können!", NamedTextColor.DARK_GREEN)
.hoverEvent(HoverEvent.showText(ComponentUtil.clickLink(feedbackUrl)))) .append(ComponentUtil.clickLink(feedbackUrl)))
.appendNewline() .appendNewline()
.append(border); .append(border);

View File

@@ -17,6 +17,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
@Appliance.Flags(autoload = false, enabled = false)
public class WorldMuseum extends Appliance { public class WorldMuseum extends Appliance {
public DisplayVillager.ConfigBound villager; public DisplayVillager.ConfigBound villager;

View File

@@ -22,6 +22,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
@@ -29,14 +30,14 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import static java.util.Map.entry; import static java.util.Map.entry;
import static org.bukkit.Sound.MUSIC_DISC_PRECIPICE; import static org.bukkit.Sound.MUSIC_DISC_LAVA_CHICKEN;
public class ProjectStart extends Appliance { public class ProjectStart extends Appliance {
private final int startMusicAt = 293; private final int startMusicAt = 130;
private final World startWorld = Bukkit.getWorld("world"); private final World startWorld = Bukkit.getWorld("world");
private final Location glassLocation = new Location(this.startWorld, 0, 64, -300); private final Location glassLocation = new Location(this.startWorld, -363, 126, 613);
private final List<Location> netherFireLocations = List.of( private final List<Location> netherFireLocations = List.of(
new Location(this.startWorld, 14, 71, -310) new Location(this.startWorld, -352, 131, 627)
); );
private final Countdown countdown = new Countdown( private final Countdown countdown = new Countdown(
@@ -47,7 +48,7 @@ public class ProjectStart extends Appliance {
); );
private final BlockCycle blockCycle = new BlockCycle( private final BlockCycle blockCycle = new BlockCycle(
this.glassLocation, this.glassLocation,
Material.RED_STAINED_GLASS, Material.WHITE_STAINED_GLASS,
List.of( List.of(
Material.RED_STAINED_GLASS, Material.RED_STAINED_GLASS,
Material.YELLOW_STAINED_GLASS, Material.YELLOW_STAINED_GLASS,
@@ -77,7 +78,7 @@ public class ProjectStart extends Appliance {
counter -> counter == this.startMusicAt, counter -> counter == this.startMusicAt,
counter -> this.glassLocation counter -> this.glassLocation
.getWorld() .getWorld()
.playSound(this.glassLocation, MUSIC_DISC_PRECIPICE, SoundCategory.RECORDS, 500f, 1f) .playSound(this.glassLocation, MUSIC_DISC_LAVA_CHICKEN, SoundCategory.RECORDS, 500f, 1f)
) )
); );
} }
@@ -128,7 +129,13 @@ public class ProjectStart extends Appliance {
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
player.setFoodLevel(20); player.setFoodLevel(20);
player.setHealth(20); player.setHealth(20);
player.getInventory().clear(); if(player.getInventory().contains(Material.RECOVERY_COMPASS)) {
player.getInventory().clear();
player.getInventory().addItem(new ItemStack(Material.RECOVERY_COMPASS));
} else {
player.getInventory().clear();
}
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
player.setExp(0); player.setExp(0);
player.setLevel(0); player.setLevel(0);

View File

@@ -20,9 +20,10 @@ public class Strikes extends Appliance {
private final Map<Integer, Duration> strikePunishmentMap = Map.of( private final Map<Integer, Duration> strikePunishmentMap = Map.of(
1, Duration.ofHours(1), 1, Duration.ofHours(1),
2, Duration.ofHours(24), 2, Duration.ofHours(3),
3, Duration.ofDays(3), 3, Duration.ofDays(1),
4, Duration.ofDays(7) 4, Duration.ofDays(2),
5, Duration.ofDays(3)
); );

View File

@@ -49,7 +49,7 @@ public class Whitelist extends Appliance {
? Floodgate.getBedrockPlayer(player).getUsername() ? Floodgate.getBedrockPlayer(player).getUsername()
: player.getName(); : player.getName();
if(!user.username().trim().equalsIgnoreCase(purePlayerName)) if(!user.username().trim().equalsIgnoreCase(purePlayerName) && !Floodgate.isBedrock(player)) // TODO: Bedrock Namen mit leerzeichen funktionieren nicht, daher die ausnahme bei der NUtzernamenprüfung
throw new DisconnectInfo.Throwable( throw new DisconnectInfo.Throwable(
"Nutzername geändert", "Nutzername geändert",
String.format("Der Name '%s' stimmt nicht mit '%s' überein.", user.username(), player.getName()), String.format("Der Name '%s' stimmt nicht mit '%s' überein.", user.username(), player.getName()),

View File

@@ -12,6 +12,6 @@ class InfectionSpawnListener extends ApplianceListener<ArmadilloInfectionReducer
public void onSpawn(CreatureSpawnEvent event) { public void onSpawn(CreatureSpawnEvent event) {
if(!event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) return; if(!event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) return;
if(!event.getEntity().getType().equals(EntityType.SILVERFISH)) return; if(!event.getEntity().getType().equals(EntityType.SILVERFISH)) return;
if(ThreadLocalRandom.current().nextDouble() > 0.7) event.setCancelled(true); if(ThreadLocalRandom.current().nextDouble() > 0.8) event.setCancelled(true);
} }
} }

View File

@@ -1,10 +1,12 @@
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.silverfishExpReducer; package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.silverfishExpReducer;
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener; import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
@Appliance.Flags(enabled = false)
class SilverfishDeathListener extends ApplianceListener<SilverfishExpReducer> { class SilverfishDeathListener extends ApplianceListener<SilverfishExpReducer> {
@EventHandler @EventHandler
public void onDeath(EntityDeathEvent event) { public void onDeath(EntityDeathEvent event) {