-
Notifications
You must be signed in to change notification settings - Fork 6
Add initial rail generator implementation #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jasupa
wants to merge
44
commits into
main
Choose a base branch
from
rail-generator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
c80e7b5
feature: added a rail generator command including a custom undo and redo
Jasupa a9766e3
feature: added a first version for the cuboid and poly rail generator
Jasupa 9ca55bf
feature:
Jasupa 7e340ef
feature:
Jasupa f014b16
refactor:
Jasupa 385f8ee
refactor:
Jasupa 2bac069
fix:
Jasupa 693f3fd
fix:
Jasupa 47704c9
refractor:
Jasupa 873526b
refractor:
Jasupa 9a9380a
refractor:
Jasupa 6a6a97e
style(generator): restore single-line guard statements for railscripts
Jasupa e6894d5
refactor(rail): remove custom rail point commands
Jasupa 7e3cbb1
fix(generator): address review feedback
Jasupa a032d46
fix(generator): address rail review feedback
Jasupa d41eb32
fix(generator): address command execution review feedback
Jasupa 5bc7da4
fix(rail): address rail review feedback
Jasupa 7ea760f
fix(generator): improve rail placement and shared block updates
Jasupa 92bd78c
fix(generator): resolve qodana warnings
Jasupa dfc5118
fix(generator): resolve merge issues
Jasupa 1ac7434
fix(generator): avoid deprecated rail type icon parsing
Jasupa f131c80
fix(generator): add rail generation safeguards
Jasupa a067abb
fix(generator): resolve remaining qodana warnings
Jasupa 4c52322
fix(rail): make generation limits configurable
Jasupa 918d88e
fix(generator): resolve main rebase conflicts
Jasupa 48c48c2
fix(generator): resolve qodana warnings
Jasupa 8c6a1b4
fix(generator): added future support logic for multiple lanes using G…
Jasupa 0bca3bb
fix(generator): smooth weighted progress updates
Jasupa a0640e0
fix(generator): keep rail progress continuous until completion
Jasupa 6fad864
Merge branch 'main' into rail-generator
Jasupa 203c744
fix(generator): address config and menu review feedback
Jasupa 4f5d45f
Merge remote-tracking branch 'origin/rail-generator' into rail-generator
Jasupa d6b7362
fix(rail): address generation feedback handling
Jasupa 6124667
fix(rail): resolve underground placement issues
Jasupa c2b5e10
fix(rail): improve height resolution stability
Jasupa 4ddee65
fix(generator): address component and rail menu feedback
Jasupa 1c13c78
fix(generator): align component messaging style
Jasupa 0f24037
fix(generator): address history and utility cleanup
Jasupa 4c3e283
fix(generator): make help wiki links clickable
Jasupa cbf7557
fix(rail): optimize terrain lookup and raise generation limits
Jasupa 4e73d10
fix(generator): address rail review cleanup
Jasupa db3b928
fix(generator): use chat helper for generator feedback
Jasupa fb767a6
fix(generator): use chat helper for generator help
Jasupa d551ff0
fix(generator): remove unused command imports
Jasupa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../java/net/buildtheearth/buildteamtools/modules/generator/components/rail/PositionKey.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package net.buildtheearth.buildteamtools.modules.generator.components.rail; | ||
|
|
||
| import org.bukkit.util.Vector; | ||
|
|
||
| record PositionKey(int x, int y, int z) { | ||
|
|
||
| static PositionKey from(Vector vector) { | ||
| return new PositionKey( | ||
| vector.getBlockX(), | ||
| vector.getBlockY(), | ||
| vector.getBlockZ() | ||
| ); | ||
| } | ||
|
|
||
| static PositionKey of(int x, int y, int z) { | ||
| return new PositionKey(x, y, z); | ||
| } | ||
|
|
||
| Vector toVector() { | ||
| return new Vector(x, y, z); | ||
| } | ||
| } |
59 changes: 52 additions & 7 deletions
59
src/main/java/net/buildtheearth/buildteamtools/modules/generator/components/rail/Rail.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,72 @@ | ||
| package net.buildtheearth.buildteamtools.modules.generator.components.rail; | ||
|
|
||
| import com.alpsbte.alpslib.utils.ChatHelper; | ||
| import com.alpsbte.alpslib.utils.GeneratorUtils; | ||
| import com.sk89q.worldedit.regions.ConvexPolyhedralRegion; | ||
| import com.sk89q.worldedit.regions.CuboidRegion; | ||
| import com.sk89q.worldedit.regions.Polygonal2DRegion; | ||
| import com.sk89q.worldedit.regions.Region; | ||
| import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule; | ||
| import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent; | ||
| import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorType; | ||
| import org.bukkit.Sound; | ||
| import org.bukkit.entity.Player; | ||
|
|
||
| import java.util.Set; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| public class Rail extends GeneratorComponent { | ||
|
|
||
| private final Set<UUID> preparingPlayers = ConcurrentHashMap.newKeySet(); | ||
|
|
||
| public Rail() { | ||
| super(GeneratorType.RAILWAY); | ||
| super(GeneratorType.RAIL); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean checkForPlayer(Player p) { | ||
| return !GeneratorUtils.checkForNoWorldEditSelection(p); | ||
| public boolean checkForPlayer(Player player) { | ||
| if (GeneratorUtils.checkForNoWorldEditSelection(player)) | ||
| return false; | ||
|
|
||
| Region region = GeneratorUtils.getWorldEditSelection(player); | ||
|
|
||
| if (isSupportedRailSelection(region)) | ||
| return true; | ||
|
|
||
| player.sendMessage(ChatHelper.PREFIX_COMPONENT.append(ChatHelper.getErrorComponent( | ||
| "Rail Generator supports cuboid, polygonal and convex WorldEdit selections." | ||
| ))); | ||
| player.closeInventory(); | ||
| player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F); | ||
| return false; | ||
| } | ||
|
|
||
| private boolean isSupportedRailSelection(Region region) { | ||
| return region instanceof CuboidRegion | ||
| || region instanceof Polygonal2DRegion | ||
| || region instanceof ConvexPolyhedralRegion; | ||
| } | ||
|
|
||
| @Override | ||
| public void generate(Player p) { | ||
| if (!GeneratorModule.getInstance().getRail().checkForPlayer(p)) | ||
| public void generate(Player player) { | ||
| if (GeneratorModule.getInstance().isGenerating(player) || !preparingPlayers.add(player.getUniqueId())) { | ||
| sendAlreadyGeneratingMessage(player); | ||
| return; | ||
| } | ||
|
|
||
| if (!GeneratorModule.getInstance().getRail().checkForPlayer(player)) { | ||
| preparingPlayers.remove(player.getUniqueId()); | ||
| return; | ||
| } | ||
|
|
||
| new RailScripts(player, this, () -> preparingPlayers.remove(player.getUniqueId())); | ||
| } | ||
|
|
||
| new RailScripts(p, this); | ||
| private void sendAlreadyGeneratingMessage(Player player) { | ||
| player.sendMessage(ChatHelper.PREFIX_COMPONENT.append(ChatHelper.getErrorComponent( | ||
| "Rail Generator is already running. Please wait until the current generation is finished." | ||
| ))); | ||
| player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.