Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
* The MIT License (MIT)
*
* Copyright © 2025, Alps BTE <bte.atchli@gmail.com>
* Copyright © 2021-2025, Alps BTE <bte.atchli@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -40,24 +40,44 @@
import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.message.ChatMessageTask;
import com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils;
import com.alpsbte.plotsystem.utils.Utils;
import com.alpsbte.plotsystem.utils.io.*;
import com.alpsbte.plotsystem.utils.io.ConfigPaths;
import com.alpsbte.plotsystem.utils.io.ConfigUtil;
import com.alpsbte.plotsystem.utils.io.LangPaths;
import com.alpsbte.plotsystem.utils.io.LangUtil;
import com.alpsbte.plotsystem.utils.io.TutorialPaths;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;

import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.*;
import static com.alpsbte.alpslib.utils.AlpsUtils.deserialize;
import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.Delay;
import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.Sound;
import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.TEXT_CLICK_HIGHLIGHT;
import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.TEXT_HIGHLIGHT_END;
import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.TEXT_HIGHLIGHT_START;
import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.getDocumentationLinks;
import static com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils.setBlockAt;
import static net.kyori.adventure.text.Component.text;
import static com.alpsbte.alpslib.utils.AlpsUtils.deserialize;
import static net.kyori.adventure.text.format.NamedTextColor.*;
import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
import static net.kyori.adventure.text.format.TextDecoration.BOLD;

public class BeginnerTutorial extends AbstractPlotTutorial {
Expand Down Expand Up @@ -106,7 +126,7 @@ public void onTutorialComplete(UUID playerUUID) {
Bukkit.getScheduler().runTaskLaterAsynchronously(PlotSystem.getPlugin(), () -> {
sendTutorialCompletedTipMessage(getPlayer());
getPlayer().playSound(getPlayer().getLocation(), Utils.SoundUtils.NOTIFICATION_SOUND, 1f, 1f);
}, 20 * 7);
}, 20 * 7L);
}

private static class Stage1 extends AbstractPlotStage {
Expand Down Expand Up @@ -312,8 +332,7 @@ public StageTimeline getTimeline() {
}

private static class Stage5 extends AbstractPlotStage {
private final static String BASE_BLOCK = ConfigUtil.getTutorialInstance().getBeginnerTutorial().getString(TutorialPaths.Beginner.BASE_BLOCK);
private final static int BASE_BLOCK_ID = ConfigUtil.getTutorialInstance().getBeginnerTutorial().getInt(TutorialPaths.Beginner.BASE_BLOCK_ID);
private static final List<String> BASE_BLOCKS = ConfigUtil.getTutorialInstance().getBeginnerTutorial().getStringList(TutorialPaths.Beginner.BASE_BLOCKS);

protected Stage5(Player player, TutorialPlot plot) {
super(player, 1, plot, 1);
Expand All @@ -335,7 +354,7 @@ public List<String> setMessages() {
@Override
protected List<String> setTasks() {
return LangUtil.getInstance().getList(getPlayer(), LangPaths.Tutorials.Beginner.STAGE5_TASKS,
TEXT_HIGHLIGHT_START + "//line " + BASE_BLOCK.toLowerCase() + TEXT_HIGHLIGHT_END);
TEXT_HIGHLIGHT_START + "//line " + BASE_BLOCKS.getFirst() + TEXT_HIGHLIGHT_END);
}

@Override
Expand Down Expand Up @@ -364,7 +383,7 @@ public StageTimeline getTimeline() {
}, Sound.NPC_TALK, false)
.delay(Delay.TASK_START)
.addTask(new PlotPermissionChangeTask(getPlayer(), false, true))
.addTask(new LineCmdEventTask(getPlayer(), deserialize(getTasks().getFirst()), BASE_BLOCK, BASE_BLOCK_ID, buildingLinePoints, ((minPoint, maxPoint) -> {
.addTask(new LineCmdEventTask(getPlayer(), deserialize(getTasks().getFirst()), BASE_BLOCKS, buildingLinePoints, ((minPoint, maxPoint) -> {
if (minPoint != null && maxPoint != null) {
buildingLinePoints.remove(minPoint);

Expand All @@ -381,8 +400,8 @@ public StageTimeline getTimeline() {
}

private static class Stage6 extends AbstractPlotStage {
private final static int HEIGHT = ConfigUtil.getTutorialInstance().getBeginnerTutorial().getInt(TutorialPaths.Beginner.HEIGHT);
private final static int HEIGHT_OFFSET = ConfigUtil.getTutorialInstance().getBeginnerTutorial().getInt(TutorialPaths.Beginner.HEIGHT_OFFSET);
private static final int HEIGHT = ConfigUtil.getTutorialInstance().getBeginnerTutorial().getInt(TutorialPaths.Beginner.HEIGHT);
private static final int HEIGHT_OFFSET = ConfigUtil.getTutorialInstance().getBeginnerTutorial().getInt(TutorialPaths.Beginner.HEIGHT_OFFSET);

protected Stage6(Player player, TutorialPlot plot) {
super(player, 1, plot, 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
* The MIT License (MIT)
*
* Copyright © 2023, Alps BTE <bte.atchli@gmail.com>
* Copyright © 2021-2025, Alps BTE <bte.atchli@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -40,7 +40,9 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Map;
import java.util.Objects;

Expand All @@ -53,8 +55,8 @@ public class LineCmdEventTask extends AbstractCmdEventTask {
private Vector minPoint;
private Vector maxPoint;

public LineCmdEventTask(Player player, Component assignmentMessage, String blockName, int blockId, Map<Vector, Vector> linePoints, BiTaskAction<Vector, Vector> lineCmdAction) {
super(player, "//line", new String[]{blockName, String.valueOf(blockId)}, assignmentMessage, linePoints.size(), true);
public LineCmdEventTask(Player player, Component assignmentMessage, @NotNull List<String> blocks, @NotNull Map<Vector, Vector> linePoints, BiTaskAction<Vector, Vector> lineCmdAction) {
super(player, "//line", blocks.toArray(new String[0]), assignmentMessage, linePoints.size(), true);
this.linePoints = linePoints;
this.lineCmdAction = lineCmdAction;
}
Expand Down Expand Up @@ -83,8 +85,8 @@ protected void onCommand(boolean isValid, String[] args) {

@Override
public void performEvent(Event event) {
if (event instanceof PlayerInteractEvent) {
onPlayerInteractEvent((PlayerInteractEvent) event);
if (event instanceof PlayerInteractEvent playerInteractEvent) {
onPlayerInteractEvent(playerInteractEvent);
} else super.performEvent(event);
}

Expand All @@ -108,11 +110,9 @@ private boolean isPointInLine(Vector point) {
}

private boolean drawLine() {
try {
EditSession editSession = WorldEdit.getInstance().newEditSession((new BukkitWorld(player.getWorld())));
try (EditSession editSession = WorldEdit.getInstance().newEditSession((new BukkitWorld(player.getWorld())))) {
editSession.drawLine(Objects.requireNonNull(BlockTypes.WHITE_WOOL).getDefaultState(), BlockVector3.at(minPoint.getX(), minPoint.getY(), minPoint.getZ()),
BlockVector3.at(maxPoint.getX(), maxPoint.getY(), maxPoint.getZ()), 0, false);
editSession.close();
} catch (MaxChangedBlocksException ex) {
PlotSystem.getPlugin().getComponentLogger().error(text("An error occurred while drawing line!"), ex);
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
* The MIT License (MIT)
*
* Copyright © 2023, Alps BTE <bte.atchli@gmail.com>
* Copyright © 2021-2025, Alps BTE <bte.atchli@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -33,8 +33,7 @@ public static final class Beginner {
public static final String POINT_2 = TELEPORT_COORDINATES + "point-2";
public static final String POINT_3 = TELEPORT_COORDINATES + "point-3";
public static final String POINT_4 = TELEPORT_COORDINATES + "point-4";
public static final String BASE_BLOCK = BEGINNER + "base-block";
public static final String BASE_BLOCK_ID = BEGINNER + "base-block-id";
public static final String BASE_BLOCKS = BEGINNER + "base-blocks";
public static final String HEIGHT = BEGINNER + "height";
public static final String HEIGHT_OFFSET = BEGINNER + "height-offset";
public static final String WINDOW_POINTS = BEGINNER + "window-points";
Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/tutorial/tutorial_beginner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ beginner:
point-2: '3693367.0,-4531328.0'
point-3: '3693370.0,-4531337.0'
point-4: '3693357.0,-4531342.0'
# BaseBlock for the building outline
base-block: 'WHITE_WOOL'
base-block-id: 35
# BaseBlocks for the building outline (multiple blocks or legacy id's are supported)
base-blocks: [ 'WHITE_WOOL', 'WHITE', '35', '35:0' ]
# Height of the plot building, which must be calculated
height: 7
height-offset: 1
Expand Down