BlueGit

timfa containerpipes

Add optional pipe cost charged per route block.

Default cost is one iron ingot per 1x1x1 path block; empty config keeps pipes free. Shortage shows smoke along the route, and removals drop the cost items.

Co-authored-by: Cursor <cursoragent@cursor.com>

timfa Tim Falken · pushed by timfa

Authored 2026-08-17 · 3 months ago

Hash
168a91974614da9a4b1467476612c4ee3d848a79
Parent
5a1bae36
4 files changed +184 −6
README.md +4 −2
@@ -11,13 +11,14 @@ Pipes are face-independent: behaviour comes from whether a pipe is incoming or o
11 11
12 12 ## Playing
13 13
14 1. Shift-click a supported container with an empty hand to pick the **source** side.
14 1. Shift-click a supported container with an empty hand (or the configured cost item) to pick the **source** side.
15 15 2. Shift-click the **destination** container the same way.
16 16 3. If a free route exists within range, a pipe appears and transfers start.
17 17
18 - **Shift + shears** on a pipe (or its endpoints) removes the connection.
18 - **Shift + shears** on a pipe (or its endpoints) removes the connection. If a pipe cost is configured, one of that item drops at each 1×1×1 route block.
19 19 - **Shift-click** an *item* pipe segment to open its filter (up to five materials). Liquid pipes have no filter UI.
20 20 - Only **liquid → liquid** (cauldron family) and **item → item** connections are allowed; mixed endpoints cancel the selection.
21 - Pipe cost defaults to iron ingots (`pipe-cost-item: minecraft:iron_ingot`). Each route block costs 1 item. Set the value empty/`free` for no cost. Too few items? Smoke along the intended path and a chat message with how many you are short.
21 22
22 23 Admin command: `/containerpipes <status|reload|refresh>` (`containerpipes.admin`).
23 24
@@ -51,6 +52,7 @@ Item legality uses Paper APIs and datapack tags (not hardcoded item lists), so d
51 52 Defaults live in `config.yml` (copied to the plugin data folder on first run):
52 53
53 54 - Transfer interval and max connection range
55 - Optional pipe cost item (`pipe-cost-item`, default `minecraft:iron_ingot`; empty/`free` = no cost)
54 56 - Visual pipe material, scale, and particles
55 57 - Filter UI titles and player messages (Dutch + English)
56 58 - Performance: idle sleep, wake probes, display refresh
@@ -11,13 +11,14 @@ Pipes are face-independent: behaviour comes from whether a pipe is incoming or o
11
11
12## Playing
12## Playing
13
13
141. Shift-click a supported container with an empty hand to pick the **source** side.
141. Shift-click a supported container with an empty hand (or the configured cost item) to pick the **source** side.
152. Shift-click the **destination** container the same way.
152. Shift-click the **destination** container the same way.
163. If a free route exists within range, a pipe appears and transfers start.
163. If a free route exists within range, a pipe appears and transfers start.
17
17
18- **Shift + shears** on a pipe (or its endpoints) removes the connection.
18- **Shift + shears** on a pipe (or its endpoints) removes the connection. If a pipe cost is configured, one of that item drops at each 1×1×1 route block.
19- **Shift-click** an *item* pipe segment to open its filter (up to five materials). Liquid pipes have no filter UI.
19- **Shift-click** an *item* pipe segment to open its filter (up to five materials). Liquid pipes have no filter UI.
20- Only **liquid → liquid** (cauldron family) and **item → item** connections are allowed; mixed endpoints cancel the selection.
20- Only **liquid → liquid** (cauldron family) and **item → item** connections are allowed; mixed endpoints cancel the selection.
21- Pipe cost defaults to iron ingots (`pipe-cost-item: minecraft:iron_ingot`). Each route block costs 1 item. Set the value empty/`free` for no cost. Too few items? Smoke along the intended path and a chat message with how many you are short.
21
22
22Admin command: `/containerpipes <status|reload|refresh>` (`containerpipes.admin`).
23Admin command: `/containerpipes <status|reload|refresh>` (`containerpipes.admin`).
23
24
@@ -51,6 +52,7 @@ Item legality uses Paper APIs and datapack tags (not hardcoded item lists), so d
51Defaults live in `config.yml` (copied to the plugin data folder on first run):
52Defaults live in `config.yml` (copied to the plugin data folder on first run):
52
53
53- Transfer interval and max connection range
54- Transfer interval and max connection range
55- Optional pipe cost item (`pipe-cost-item`, default `minecraft:iron_ingot`; empty/`free` = no cost)
54- Visual pipe material, scale, and particles
56- Visual pipe material, scale, and particles
55- Filter UI titles and player messages (Dutch + English)
57- Filter UI titles and player messages (Dutch + English)
56- Performance: idle sleep, wake probes, display refresh
58- Performance: idle sleep, wake probes, display refresh
src/README-1.8.0.md added +13 −0
@@ -0,0 +1,13 @@
1 # ContainerPipes 1.8.0
2
3 Builds on 1.7.4 (dispenser bucket wake + sleeping-probe CME fix).
4
5 ## Pipe cost
6
7 Pipes cost **one iron ingot per 1×1×1 route block** by default (`pipe-cost-item: minecraft:iron_ingot`). Empty / `free` / `none` / `air` disables the cost. The charge is per A* path block, not per visual display.
8
9 - Shift-click with an empty hand **or** that cost item to select and connect.
10 - Not enough items: smoke particles along the intended path, and a chat message with how many are missing (`{missing}` / `{have}` / `{needed}` / `{item}`).
11 - When a pipe is removed or breaks for any reason, one cost item drops at each route block (unloaded chunks fall back to a loaded path/endpoint).
12
13 Empty, `free`, `none`, or `air` keeps the old free behaviour. Existing `connections.tsv` stays compatible; cost is always the live config value.
@@ -0,0 +1,13 @@
1# ContainerPipes 1.8.0
2
3Builds on 1.7.4 (dispenser bucket wake + sleeping-probe CME fix).
4
5## Pipe cost
6
7Pipes cost **one iron ingot per 1×1×1 route block** by default (`pipe-cost-item: minecraft:iron_ingot`). Empty / `free` / `none` / `air` disables the cost. The charge is per A* path block, not per visual display.
8
9- Shift-click with an empty hand **or** that cost item to select and connect.
10- Not enough items: smoke particles along the intended path, and a chat message with how many are missing (`{missing}` / `{have}` / `{needed}` / `{item}`).
11- When a pipe is removed or breaks for any reason, one cost item drops at each route block (unloaded chunks fall back to a loaded path/endpoint).
12
13Empty, `free`, `none`, or `air` keeps the old free behaviour. Existing `connections.tsv` stays compatible; cost is always the live config value.
src/main/java/nl/timfalken/containerpipes/ContainerPipesPlugin.java +159 −4
@@ -24,6 +24,9 @@ import org.bukkit.scheduler.BukkitTask;
24 24 import org.bukkit.util.Transformation;
25 25 import org.joml.AxisAngle4f;
26 26 import org.joml.Vector3f;
27 import net.kyori.adventure.text.Component;
28 import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
29 import net.kyori.adventure.translation.GlobalTranslator;
27 30
28 31 import java.io.*;
29 32 import java.nio.charset.StandardCharsets;
@@ -97,7 +100,9 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
97 100 ItemStack held = event.getItem();
98 101 boolean emptyHand = held == null || held.getType().isAir();
99 102 boolean shears = held != null && held.getType() == Material.SHEARS;
100 if (!emptyHand && !shears) return;
103 Material cost = pipeCostMaterial();
104 boolean holdingCost = cost != null && held != null && held.getType() == cost;
105 if (!emptyHand && !shears && !holdingCost) return;
101 106 event.setCancelled(true);
102 107
103 108 if (shears) {
@@ -122,7 +127,7 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
122 127 }
123 128 selections.put(player.getUniqueId(), new Selection(clicked, System.currentTimeMillis()));
124 129 spawnSelectionParticles(player, clicked);
125 send(player, "selected-source");
130 sendSelectedSource(player);
126 131 return;
127 132 }
128 133
@@ -140,6 +145,7 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
140 145 Set<BlockPos> occupied = occupiedPipeBlocks(source.world);
141 146 List<BlockPos> route = findRoute(world, start, goal, maxRange, occupied);
142 147 if (route == null) { send(player, "no-route"); return; }
148 if (!tryPayPipeCost(player, world, route)) return;
143 149
144 150 long id = nextId.getAndIncrement();
145 151 Connection c = new Connection(id, source, clicked, route, List.of());
@@ -450,11 +456,152 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
450 456
451 457 private void removeConnection(long id, boolean save) {
452 458 Connection removed = connections.get(id);
453 if (removed != null) unregisterConnection(removed);
459 if (removed != null) {
460 dropPipeCost(removed);
461 unregisterConnection(removed);
462 }
454 463 removeDisplays(id);
455 464 if (save) saveConnections();
456 465 }
457 466
467 /** Null means pipes are free. */
468 private Material pipeCostMaterial() {
469 String raw = getConfig().getString("pipe-cost-item", "minecraft:iron_ingot");
470 if (raw == null) return null;
471 raw = raw.trim();
472 if (raw.isEmpty() || raw.equalsIgnoreCase("free") || raw.equalsIgnoreCase("none")
473 || raw.equalsIgnoreCase("air") || raw.equals("-")) {
474 return null;
475 }
476 Material material = Material.matchMaterial(raw);
477 if (material == null || material.isAir() || !material.isItem()) return null;
478 return material;
479 }
480
481 private boolean tryPayPipeCost(Player player, World world, List<BlockPos> route) {
482 Material cost = pipeCostMaterial();
483 if (cost == null) return true;
484 int needed = route.size();
485 if (needed <= 0) return true;
486 int have = countItems(player, cost);
487 if (have >= needed) {
488 takeItems(player, cost, needed);
489 return true;
490 }
491 spawnCostFailParticles(world, route);
492 send(player, "not-enough-cost", Map.of(
493 "missing", Integer.toString(needed - have),
494 "needed", Integer.toString(needed),
495 "have", Integer.toString(have),
496 "item", costItemDisplayName(player, cost)
497 ));
498 return false;
499 }
500
501 private int countItems(Player player, Material material) {
502 int total = 0;
503 for (ItemStack stack : player.getInventory().getStorageContents()) {
504 if (stack != null && stack.getType() == material) total += stack.getAmount();
505 }
506 ItemStack offhand = player.getInventory().getItemInOffHand();
507 if (offhand != null && offhand.getType() == material) total += offhand.getAmount();
508 return total;
509 }
510
511 private void takeItems(Player player, Material material, int amount) {
512 if (amount <= 0) return;
513 int remaining = amount;
514 int max = Math.max(1, material.getMaxStackSize());
515 while (remaining > 0) {
516 int batch = Math.min(remaining, max);
517 int leftover = 0;
518 for (ItemStack stack : player.getInventory().removeItem(new ItemStack(material, batch)).values()) {
519 leftover += stack.getAmount();
520 }
521 remaining -= (batch - leftover);
522 if (leftover > 0) break;
523 }
524 }
525
526 private void spawnCostFailParticles(World world, List<BlockPos> path) {
527 for (BlockPos pos : path) {
528 if (!world.isChunkLoaded(pos.x >> 4, pos.z >> 4)) continue;
529 Location location = new Location(world, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5);
530 world.spawnParticle(Particle.SMOKE, location, 10, 0.28, 0.28, 0.28, 0.02);
531 }
532 }
533
534 private void dropPipeCost(Connection connection) {
535 Material cost = pipeCostMaterial();
536 if (cost == null || connection.path.isEmpty()) return;
537 World world = Bukkit.getWorld(connection.source.world);
538 if (world == null) return;
539 int leftover = 0;
540 for (BlockPos pos : connection.path) {
541 if (!world.isChunkLoaded(pos.x >> 4, pos.z >> 4)) {
542 leftover++;
543 continue;
544 }
545 world.dropItemNaturally(new Location(world, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5), new ItemStack(cost, 1));
546 }
547 if (leftover <= 0) return;
548 Location fallback = fallbackDropLocation(world, connection);
549 if (fallback != null) dropStacks(world, fallback, cost, leftover);
550 }
551
552 private Location fallbackDropLocation(World world, Connection connection) {
553 for (BlockPos pos : connection.path) {
554 if (world.isChunkLoaded(pos.x >> 4, pos.z >> 4)) {
555 return new Location(world, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5);
556 }
557 }
558 Endpoint source = connection.source;
559 if (world.isChunkLoaded(source.x >> 4, source.z >> 4)) {
560 return new Location(world, source.x + 0.5, source.y + 0.5, source.z + 0.5);
561 }
562 Endpoint destination = connection.destination;
563 if (world.isChunkLoaded(destination.x >> 4, destination.z >> 4)) {
564 return new Location(world, destination.x + 0.5, destination.y + 0.5, destination.z + 0.5);
565 }
566 return null;
567 }
568
569 private void dropStacks(World world, Location location, Material material, int amount) {
570 int max = Math.max(1, material.getMaxStackSize());
571 while (amount > 0) {
572 int stack = Math.min(max, amount);
573 world.dropItemNaturally(location, new ItemStack(material, stack));
574 amount -= stack;
575 }
576 }
577
578 private void sendSelectedSource(Player player) {
579 Material cost = pipeCostMaterial();
580 if (cost == null) {
581 send(player, "selected-source");
582 return;
583 }
584 String item = costItemDisplayName(player, cost);
585 if (localizedMessage(player, "selected-source-cost").isBlank()) {
586 String template = "nl".equals(playerLanguage(player))
587 ? "<green>Bronzijde gekozen. Shift-klik met lege hand of {item} op de bestemmingscontainer.</green>"
588 : "<green>Source side selected. Shift-click the destination container with an empty hand or {item}.</green>";
589 player.sendMessage(legacyMessage(template.replace("{item}", item)));
590 return;
591 }
592 send(player, "selected-source-cost", Map.of("item", item));
593 }
594
595 private String costItemDisplayName(Player player, Material material) {
596 try {
597 ItemStack stack = new ItemStack(material);
598 Component translated = GlobalTranslator.render(Component.translatable(stack.translationKey()), player.locale());
599 String name = PlainTextComponentSerializer.plainText().serialize(translated).trim();
600 if (!name.isEmpty() && !name.equals(stack.translationKey())) return name;
601 } catch (Throwable ignored) {}
602 return material.getKey().getKey().replace('_', ' ');
603 }
604
458 605 private void clearConnectionIndices() {
459 606 connections.clear();
460 607 endpointIndex.clear();
@@ -553,7 +700,15 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
553 700 }
554 701
555 702 private void send(Player p, String key) {
556 p.sendMessage(legacyMessage(localizedMessage(p, key)));
703 send(p, key, Map.of());
704 }
705
706 private void send(Player p, String key, Map<String, String> placeholders) {
707 String value = localizedMessage(p, key);
708 for (Map.Entry<String, String> entry : placeholders.entrySet()) {
709 value = value.replace("{" + entry.getKey() + "}", entry.getValue());
710 }
711 p.sendMessage(legacyMessage(value));
557 712 }
558 713
559 714 private String localizedMessage(Player player, String key) {
@@ -24,6 +24,9 @@ import org.bukkit.scheduler.BukkitTask;
24import org.bukkit.util.Transformation;
24import org.bukkit.util.Transformation;
25import org.joml.AxisAngle4f;
25import org.joml.AxisAngle4f;
26import org.joml.Vector3f;
26import org.joml.Vector3f;
27import net.kyori.adventure.text.Component;
28import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
29import net.kyori.adventure.translation.GlobalTranslator;
27
30
28import java.io.*;
31import java.io.*;
29import java.nio.charset.StandardCharsets;
32import java.nio.charset.StandardCharsets;
@@ -97,7 +100,9 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
97 ItemStack held = event.getItem();
100 ItemStack held = event.getItem();
98 boolean emptyHand = held == null || held.getType().isAir();
101 boolean emptyHand = held == null || held.getType().isAir();
99 boolean shears = held != null && held.getType() == Material.SHEARS;
102 boolean shears = held != null && held.getType() == Material.SHEARS;
100 if (!emptyHand && !shears) return;
103 Material cost = pipeCostMaterial();
104 boolean holdingCost = cost != null && held != null && held.getType() == cost;
105 if (!emptyHand && !shears && !holdingCost) return;
101 event.setCancelled(true);
106 event.setCancelled(true);
102
107
103 if (shears) {
108 if (shears) {
@@ -122,7 +127,7 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
122 }
127 }
123 selections.put(player.getUniqueId(), new Selection(clicked, System.currentTimeMillis()));
128 selections.put(player.getUniqueId(), new Selection(clicked, System.currentTimeMillis()));
124 spawnSelectionParticles(player, clicked);
129 spawnSelectionParticles(player, clicked);
125 send(player, "selected-source");
130 sendSelectedSource(player);
126 return;
131 return;
127 }
132 }
128
133
@@ -140,6 +145,7 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
140 Set<BlockPos> occupied = occupiedPipeBlocks(source.world);
145 Set<BlockPos> occupied = occupiedPipeBlocks(source.world);
141 List<BlockPos> route = findRoute(world, start, goal, maxRange, occupied);
146 List<BlockPos> route = findRoute(world, start, goal, maxRange, occupied);
142 if (route == null) { send(player, "no-route"); return; }
147 if (route == null) { send(player, "no-route"); return; }
148 if (!tryPayPipeCost(player, world, route)) return;
143
149
144 long id = nextId.getAndIncrement();
150 long id = nextId.getAndIncrement();
145 Connection c = new Connection(id, source, clicked, route, List.of());
151 Connection c = new Connection(id, source, clicked, route, List.of());
@@ -450,11 +456,152 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
450
456
451 private void removeConnection(long id, boolean save) {
457 private void removeConnection(long id, boolean save) {
452 Connection removed = connections.get(id);
458 Connection removed = connections.get(id);
453 if (removed != null) unregisterConnection(removed);
459 if (removed != null) {
460 dropPipeCost(removed);
461 unregisterConnection(removed);
462 }
454 removeDisplays(id);
463 removeDisplays(id);
455 if (save) saveConnections();
464 if (save) saveConnections();
456 }
465 }
457
466
467 /** Null means pipes are free. */
468 private Material pipeCostMaterial() {
469 String raw = getConfig().getString("pipe-cost-item", "minecraft:iron_ingot");
470 if (raw == null) return null;
471 raw = raw.trim();
472 if (raw.isEmpty() || raw.equalsIgnoreCase("free") || raw.equalsIgnoreCase("none")
473 || raw.equalsIgnoreCase("air") || raw.equals("-")) {
474 return null;
475 }
476 Material material = Material.matchMaterial(raw);
477 if (material == null || material.isAir() || !material.isItem()) return null;
478 return material;
479 }
480
481 private boolean tryPayPipeCost(Player player, World world, List<BlockPos> route) {
482 Material cost = pipeCostMaterial();
483 if (cost == null) return true;
484 int needed = route.size();
485 if (needed <= 0) return true;
486 int have = countItems(player, cost);
487 if (have >= needed) {
488 takeItems(player, cost, needed);
489 return true;
490 }
491 spawnCostFailParticles(world, route);
492 send(player, "not-enough-cost", Map.of(
493 "missing", Integer.toString(needed - have),
494 "needed", Integer.toString(needed),
495 "have", Integer.toString(have),
496 "item", costItemDisplayName(player, cost)
497 ));
498 return false;
499 }
500
501 private int countItems(Player player, Material material) {
502 int total = 0;
503 for (ItemStack stack : player.getInventory().getStorageContents()) {
504 if (stack != null && stack.getType() == material) total += stack.getAmount();
505 }
506 ItemStack offhand = player.getInventory().getItemInOffHand();
507 if (offhand != null && offhand.getType() == material) total += offhand.getAmount();
508 return total;
509 }
510
511 private void takeItems(Player player, Material material, int amount) {
512 if (amount <= 0) return;
513 int remaining = amount;
514 int max = Math.max(1, material.getMaxStackSize());
515 while (remaining > 0) {
516 int batch = Math.min(remaining, max);
517 int leftover = 0;
518 for (ItemStack stack : player.getInventory().removeItem(new ItemStack(material, batch)).values()) {
519 leftover += stack.getAmount();
520 }
521 remaining -= (batch - leftover);
522 if (leftover > 0) break;
523 }
524 }
525
526 private void spawnCostFailParticles(World world, List<BlockPos> path) {
527 for (BlockPos pos : path) {
528 if (!world.isChunkLoaded(pos.x >> 4, pos.z >> 4)) continue;
529 Location location = new Location(world, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5);
530 world.spawnParticle(Particle.SMOKE, location, 10, 0.28, 0.28, 0.28, 0.02);
531 }
532 }
533
534 private void dropPipeCost(Connection connection) {
535 Material cost = pipeCostMaterial();
536 if (cost == null || connection.path.isEmpty()) return;
537 World world = Bukkit.getWorld(connection.source.world);
538 if (world == null) return;
539 int leftover = 0;
540 for (BlockPos pos : connection.path) {
541 if (!world.isChunkLoaded(pos.x >> 4, pos.z >> 4)) {
542 leftover++;
543 continue;
544 }
545 world.dropItemNaturally(new Location(world, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5), new ItemStack(cost, 1));
546 }
547 if (leftover <= 0) return;
548 Location fallback = fallbackDropLocation(world, connection);
549 if (fallback != null) dropStacks(world, fallback, cost, leftover);
550 }
551
552 private Location fallbackDropLocation(World world, Connection connection) {
553 for (BlockPos pos : connection.path) {
554 if (world.isChunkLoaded(pos.x >> 4, pos.z >> 4)) {
555 return new Location(world, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5);
556 }
557 }
558 Endpoint source = connection.source;
559 if (world.isChunkLoaded(source.x >> 4, source.z >> 4)) {
560 return new Location(world, source.x + 0.5, source.y + 0.5, source.z + 0.5);
561 }
562 Endpoint destination = connection.destination;
563 if (world.isChunkLoaded(destination.x >> 4, destination.z >> 4)) {
564 return new Location(world, destination.x + 0.5, destination.y + 0.5, destination.z + 0.5);
565 }
566 return null;
567 }
568
569 private void dropStacks(World world, Location location, Material material, int amount) {
570 int max = Math.max(1, material.getMaxStackSize());
571 while (amount > 0) {
572 int stack = Math.min(max, amount);
573 world.dropItemNaturally(location, new ItemStack(material, stack));
574 amount -= stack;
575 }
576 }
577
578 private void sendSelectedSource(Player player) {
579 Material cost = pipeCostMaterial();
580 if (cost == null) {
581 send(player, "selected-source");
582 return;
583 }
584 String item = costItemDisplayName(player, cost);
585 if (localizedMessage(player, "selected-source-cost").isBlank()) {
586 String template = "nl".equals(playerLanguage(player))
587 ? "<green>Bronzijde gekozen. Shift-klik met lege hand of {item} op de bestemmingscontainer.</green>"
588 : "<green>Source side selected. Shift-click the destination container with an empty hand or {item}.</green>";
589 player.sendMessage(legacyMessage(template.replace("{item}", item)));
590 return;
591 }
592 send(player, "selected-source-cost", Map.of("item", item));
593 }
594
595 private String costItemDisplayName(Player player, Material material) {
596 try {
597 ItemStack stack = new ItemStack(material);
598 Component translated = GlobalTranslator.render(Component.translatable(stack.translationKey()), player.locale());
599 String name = PlainTextComponentSerializer.plainText().serialize(translated).trim();
600 if (!name.isEmpty() && !name.equals(stack.translationKey())) return name;
601 } catch (Throwable ignored) {}
602 return material.getKey().getKey().replace('_', ' ');
603 }
604
458 private void clearConnectionIndices() {
605 private void clearConnectionIndices() {
459 connections.clear();
606 connections.clear();
460 endpointIndex.clear();
607 endpointIndex.clear();
@@ -553,7 +700,15 @@ public final class ContainerPipesPlugin extends JavaPlugin implements Listener,
553 }
700 }
554
701
555 private void send(Player p, String key) {
702 private void send(Player p, String key) {
556 p.sendMessage(legacyMessage(localizedMessage(p, key)));
703 send(p, key, Map.of());
704 }
705
706 private void send(Player p, String key, Map<String, String> placeholders) {
707 String value = localizedMessage(p, key);
708 for (Map.Entry<String, String> entry : placeholders.entrySet()) {
709 value = value.replace("{" + entry.getKey() + "}", entry.getValue());
710 }
711 p.sendMessage(legacyMessage(value));
557 }
712 }
558
713
559 private String localizedMessage(Player player, String key) {
714 private String localizedMessage(Player player, String key) {
src/main/resources/config.yml +8 −0
@@ -4,6 +4,10 @@ transfer-interval-ticks: 3
4 4 # Maximum distance between the two clicked containers.
5 5 maximum-connection-range: 32
6 6
7 # Item charged per 1x1x1 pipe route block (not per visual display).
8 # Empty / free / none / air = no cost.
9 pipe-cost-item: minecraft:iron_ingot
10
7 11 # Only main-hand container interactions are processed. This debounce catches
8 12 # duplicate interactions within the same client tick.
9 13 interaction-debounce-millis: 100
@@ -43,22 +47,26 @@ filter-title:
43 47 messages:
44 48 nl:
45 49 selected-source: '<green>Bronzijde gekozen. Shift-klik met lege hand op de bestemmingscontainer.</green>'
50 selected-source-cost: '<green>Bronzijde gekozen. Shift-klik met lege hand of {item} op de bestemmingscontainer.</green>'
46 51 selection-cancelled: '<yellow>Selectie geannuleerd.</yellow>'
47 52 connected: '<green>Containers verbonden.</green>'
48 53 disconnected: '<yellow>Verbinding verwijderd.</yellow>'
49 54 side-in-use: '<red>Deze containerzijde heeft al een verbinding.</red>'
50 55 too-far: '<red>De bestemming ligt buiten het toegestane bereik.</red>'
51 56 no-route: '<red>Er is geen vrije buisroute gevonden.</red>'
57 not-enough-cost: '<red>Niet genoeg {item}: je komt {missing} tekort ({have}/{needed}).</red>'
52 58 invalid-container: '<red>Dit containertype wordt niet ondersteund.</red>'
53 59 different-world: '<red>Beide containers moeten in dezelfde wereld staan.</red>'
54 60 en:
55 61 selected-source: '<green>Source side selected. Shift-click the destination container with an empty hand.</green>'
62 selected-source-cost: '<green>Source side selected. Shift-click the destination container with an empty hand or {item}.</green>'
56 63 selection-cancelled: '<yellow>Selection cancelled.</yellow>'
57 64 connected: '<green>Containers connected.</green>'
58 65 disconnected: '<yellow>Connection removed.</yellow>'
59 66 side-in-use: '<red>This container side already has a connection.</red>'
60 67 too-far: '<red>The destination is outside the allowed range.</red>'
61 68 no-route: '<red>No unobstructed pipe route could be found.</red>'
69 not-enough-cost: '<red>Not enough {item}: you are {missing} short ({have}/{needed}).</red>'
62 70 invalid-container: '<red>This container type is not supported.</red>'
63 71 different-world: '<red>Both containers must be in the same world.</red>'
64 72
@@ -4,6 +4,10 @@ transfer-interval-ticks: 3
4# Maximum distance between the two clicked containers.
4# Maximum distance between the two clicked containers.
5maximum-connection-range: 32
5maximum-connection-range: 32
6
6
7# Item charged per 1x1x1 pipe route block (not per visual display).
8# Empty / free / none / air = no cost.
9pipe-cost-item: minecraft:iron_ingot
10
7# Only main-hand container interactions are processed. This debounce catches
11# Only main-hand container interactions are processed. This debounce catches
8# duplicate interactions within the same client tick.
12# duplicate interactions within the same client tick.
9interaction-debounce-millis: 100
13interaction-debounce-millis: 100
@@ -43,22 +47,26 @@ filter-title:
43messages:
47messages:
44 nl:
48 nl:
45 selected-source: '<green>Bronzijde gekozen. Shift-klik met lege hand op de bestemmingscontainer.</green>'
49 selected-source: '<green>Bronzijde gekozen. Shift-klik met lege hand op de bestemmingscontainer.</green>'
50 selected-source-cost: '<green>Bronzijde gekozen. Shift-klik met lege hand of {item} op de bestemmingscontainer.</green>'
46 selection-cancelled: '<yellow>Selectie geannuleerd.</yellow>'
51 selection-cancelled: '<yellow>Selectie geannuleerd.</yellow>'
47 connected: '<green>Containers verbonden.</green>'
52 connected: '<green>Containers verbonden.</green>'
48 disconnected: '<yellow>Verbinding verwijderd.</yellow>'
53 disconnected: '<yellow>Verbinding verwijderd.</yellow>'
49 side-in-use: '<red>Deze containerzijde heeft al een verbinding.</red>'
54 side-in-use: '<red>Deze containerzijde heeft al een verbinding.</red>'
50 too-far: '<red>De bestemming ligt buiten het toegestane bereik.</red>'
55 too-far: '<red>De bestemming ligt buiten het toegestane bereik.</red>'
51 no-route: '<red>Er is geen vrije buisroute gevonden.</red>'
56 no-route: '<red>Er is geen vrije buisroute gevonden.</red>'
57 not-enough-cost: '<red>Niet genoeg {item}: je komt {missing} tekort ({have}/{needed}).</red>'
52 invalid-container: '<red>Dit containertype wordt niet ondersteund.</red>'
58 invalid-container: '<red>Dit containertype wordt niet ondersteund.</red>'
53 different-world: '<red>Beide containers moeten in dezelfde wereld staan.</red>'
59 different-world: '<red>Beide containers moeten in dezelfde wereld staan.</red>'
54 en:
60 en:
55 selected-source: '<green>Source side selected. Shift-click the destination container with an empty hand.</green>'
61 selected-source: '<green>Source side selected. Shift-click the destination container with an empty hand.</green>'
62 selected-source-cost: '<green>Source side selected. Shift-click the destination container with an empty hand or {item}.</green>'
56 selection-cancelled: '<yellow>Selection cancelled.</yellow>'
63 selection-cancelled: '<yellow>Selection cancelled.</yellow>'
57 connected: '<green>Containers connected.</green>'
64 connected: '<green>Containers connected.</green>'
58 disconnected: '<yellow>Connection removed.</yellow>'
65 disconnected: '<yellow>Connection removed.</yellow>'
59 side-in-use: '<red>This container side already has a connection.</red>'
66 side-in-use: '<red>This container side already has a connection.</red>'
60 too-far: '<red>The destination is outside the allowed range.</red>'
67 too-far: '<red>The destination is outside the allowed range.</red>'
61 no-route: '<red>No unobstructed pipe route could be found.</red>'
68 no-route: '<red>No unobstructed pipe route could be found.</red>'
69 not-enough-cost: '<red>Not enough {item}: you are {missing} short ({have}/{needed}).</red>'
62 invalid-container: '<red>This container type is not supported.</red>'
70 invalid-container: '<red>This container type is not supported.</red>'
63 different-world: '<red>Both containers must be in the same world.</red>'
71 different-world: '<red>Both containers must be in the same world.</red>'
64
72