updated texts and coordinates

This commit is contained in:
Elias Müller 2024-12-24 11:23:19 +01:00
parent 193d8d778f
commit 6475a7b825
6 changed files with 39 additions and 20 deletions

View File

@ -30,8 +30,14 @@ public class CustomAdvancements extends Appliance {
}
try {
NamespacedKey namespacedKey = Objects.requireNonNull(NamespacedKey.fromString("craftattack_advancements:craftattack/" + advancementName), "NamespacedKey is invalid!");
Advancement advancement = Objects.requireNonNull(Bukkit.getAdvancement(namespacedKey), "The advancement does not exist!");
NamespacedKey namespacedKey = Objects.requireNonNull(
NamespacedKey.fromString("craftattack_advancements:craftattack/" + advancementName),
String.format("NamespacedKey with '%s' is invalid!", advancementName)
);
Advancement advancement = Objects.requireNonNull(
Bukkit.getAdvancement(namespacedKey),
String.format("The advancement '%s' does not exist!", namespacedKey.asString())
);
player.getAdvancementProgress(advancement).awardCriteria("criteria");
} catch(Exception e) {
Main.logger().info("Advancement " + advancementName + " not found! (is Custom Advancements data pack loaded?)");

View File

@ -3,6 +3,7 @@ package eu.mhsl.craftattack.spawn.appliances.help.command;
import eu.mhsl.craftattack.spawn.appliance.ApplianceCommand;
import eu.mhsl.craftattack.spawn.appliances.help.Help;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -13,11 +14,14 @@ public class DiscordCommand extends ApplianceCommand<Help> {
super("discord");
}
private final static String discordLink = "https://discord.gg/TXxspGVanq";
@Override
protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
sender.sendMessage(
Component.text("Einen offiziellen Discord Server gibt es nicht, aber Du kannst gerne unserem Teamspeak joinen: ", NamedTextColor.GOLD)
.append(Component.text("mhsl.eu", NamedTextColor.AQUA))
Component.text("Offizieller Discord Server: ", NamedTextColor.GOLD)
.append(Component.text(discordLink, NamedTextColor.AQUA))
.clickEvent(ClickEvent.openUrl(discordLink))
);
}
}

View File

@ -18,7 +18,8 @@ public class HelpCommand extends ApplianceCommand<Help> {
sender.sendMessage(
Component.text("Willkommen auf Craftattack!", NamedTextColor.GOLD)
.appendNewline()
.append(Component.text("Hier ist ein Hilfetext!", NamedTextColor.GRAY))
.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))
);
}
}

View File

@ -2,6 +2,7 @@ package eu.mhsl.craftattack.spawn.appliances.hotbarRefill;
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
import eu.mhsl.craftattack.spawn.appliances.settings.Settings;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
@ -9,6 +10,8 @@ import org.bukkit.event.player.PlayerItemBreakEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class HotbarRefillListener extends ApplianceListener<HotbarRefill> {
private HotbarRefillSetting.HotbarReplaceConfig getPlayerSetting(Player player) {
return Settings.instance().getSetting(
@ -23,6 +26,7 @@ public class HotbarRefillListener extends ApplianceListener<HotbarRefill> {
ItemStack stackInHand = event.getItemInHand();
if(stackInHand.getAmount() != 1) return;
if(stackInHand.getType().getMaxDurability() > 0) return;
if(stackInHand.getType().getMaxStackSize() > 0) return;
if(!this.getPlayerSetting(event.getPlayer()).onBlocks()) return;
this.getAppliance().handleHotbarChange(event.getPlayer(), stackInHand);
@ -37,6 +41,7 @@ public class HotbarRefillListener extends ApplianceListener<HotbarRefill> {
@EventHandler
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
if(List.of(Material.POTION, Material.HONEY_BOTTLE).contains(event.getItem().getType())) return;
if(!this.getPlayerSetting(event.getPlayer()).onConsumable()) return;
this.getAppliance().handleHotbarChange(event.getPlayer(), event.getItem());

View File

@ -29,14 +29,14 @@ import java.util.Map;
import java.util.Objects;
import static java.util.Map.entry;
import static org.bukkit.Sound.MUSIC_DISC_PIGSTEP;
import static org.bukkit.Sound.MUSIC_DISC_PRECIPICE;
public class ProjectStart extends Appliance {
private final int startMusicAt = 137;
private final int startMusicAt = 293;
private final World startWorld = Bukkit.getWorld("world");
private final Location glassLocation = new Location(this.startWorld, 0, 68, -300);
private final Location glassLocation = new Location(this.startWorld, 0, 64, -300);
private final List<Location> netherFireLocations = List.of(
new Location(this.startWorld, 0, 70, -300)
new Location(this.startWorld, 14, 71, -310)
);
private final Countdown countdown = new Countdown(
@ -47,7 +47,7 @@ public class ProjectStart extends Appliance {
);
private final BlockCycle blockCycle = new BlockCycle(
this.glassLocation,
Material.PINK_STAINED_GLASS,
Material.RED_STAINED_GLASS,
List.of(
Material.RED_STAINED_GLASS,
Material.YELLOW_STAINED_GLASS,
@ -78,7 +78,7 @@ public class ProjectStart extends Appliance {
counter -> counter == this.startMusicAt,
counter -> this.glassLocation
.getWorld()
.playSound(this.glassLocation, MUSIC_DISC_PIGSTEP, SoundCategory.RECORDS, 500f, 1f)
.playSound(this.glassLocation, MUSIC_DISC_PRECIPICE, SoundCategory.RECORDS, 500f, 1f)
)
);
}
@ -97,6 +97,16 @@ public class ProjectStart extends Appliance {
IteratorUtil.onlinePlayers(player -> player.sendMessage(message));
}
private void resetAdvancements() {
Bukkit.getServer().advancementIterator().forEachRemaining(
advancement -> Bukkit.getOnlinePlayers().forEach(
player -> player.getAdvancementProgress(advancement).getAwardedCriteria().forEach(
criteria -> player.getAdvancementProgress(advancement).revokeCriteria(criteria)
)
)
);
}
public void startCountdown() {
if(!this.isEnabled()) return;
this.countdown.start();
@ -132,13 +142,7 @@ public class ProjectStart extends Appliance {
PlayerUtils.resetStatistics(player);
});
Bukkit.getServer().advancementIterator().forEachRemaining(
advancement -> Bukkit.getOnlinePlayers().forEach(
player -> player.getAdvancementProgress(advancement).getAwardedCriteria().forEach(
criteria -> player.getAdvancementProgress(advancement).revokeCriteria(criteria)
)
)
);
this.resetAdvancements();
Bukkit.getOnlinePlayers().forEach(
player -> Main.instance().getAppliance(CustomAdvancements.class).grantAdvancement(Advancements.start, player.getUniqueId())
@ -159,7 +163,7 @@ public class ProjectStart extends Appliance {
});
IteratorUtil.worlds(world -> world, world -> IteratorUtil.setGameRules(this.gameRulesAfterStart, true));
this.resetAdvancements();
this.blockCycle.reset();
}

View File

@ -20,7 +20,6 @@ public class Countdown {
private final List<CustomAnnouncements> customAnnouncements = new ArrayList<>();
private final Runnable onDone;
public record AnnouncementData(int count, String unit) {
}