Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e8f23810a | ||
|
|
986bf4d57e | ||
|
|
903e21dbe6 | ||
|
|
1309c4d338 | ||
|
|
2c6aedaf8a | ||
|
|
0e790bd154 | ||
|
|
aa9ed1ce9f |
29 changed files with 891 additions and 23 deletions
47
.forgejo/workflows/atm-ria-copy.yml
Normal file
47
.forgejo/workflows/atm-ria-copy.yml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
name: ATM RIA Copy and Sigma Goats
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/atm-ria-copy-*']
|
||||
jobs:
|
||||
atm-ria-copy:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '9.2.1'
|
||||
- name: Test ATM controls and preserve Sigma ecology
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
gradle --no-daemon -p DuneMenus test jar
|
||||
gradle --no-daemon -p DuneTerrain test jar
|
||||
mkdir atm-ria-copy
|
||||
PYTHONPATH=tools python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
from plugin_ria_copy import ATM, COPY
|
||||
from plugin_wild_update import read_archive, write_archive
|
||||
compiled=read_archive(Path('DuneMenus/build/libs/DuneMenus.jar').read_bytes())
|
||||
Path('atm-ria-copy/donor.zip').write_bytes(write_archive({p:compiled[p] for p in (ATM,COPY)}))
|
||||
PY
|
||||
cp tools/{plugin_ria_copy.py,plugin_wild_update.py,plugin_sigma_goats.py,SigmaGoatMerge.java} atm-ria-copy/
|
||||
printf '%s\n' "$GITHUB_SHA" > atm-ria-copy/SOURCE_COMMIT
|
||||
(cd atm-ria-copy && sha256sum -- *.zip *.py *.java SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-ATM-RIA-Copy-Sigma-Goats
|
||||
path: atm-ria-copy
|
||||
if-no-files-found: error
|
||||
47
.forgejo/workflows/home-dimension.yml
Normal file
47
.forgejo/workflows/home-dimension.yml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
name: Home Dimension Return Overlay
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/home-dimension-return-*']
|
||||
|
||||
jobs:
|
||||
home-dimension:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '9.2.1'
|
||||
- name: Test DuneEss and extract the dimension route class
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
gradle --no-daemon -p DuneEss test jar
|
||||
mkdir home-dimension
|
||||
PYTHONPATH=tools python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
from plugin_home_dimension import ROUTES
|
||||
from plugin_wild_update import read_archive, write_archive
|
||||
source = read_archive(Path("DuneEss/build/libs/DuneRealms-Essentials.jar").read_bytes())
|
||||
Path("home-dimension/donor.zip").write_bytes(write_archive({ROUTES: source[ROUTES]}))
|
||||
PY
|
||||
cp tools/{HomeDimensionOverlay.java,plugin_home_dimension.py,plugin_wild_update.py} home-dimension/
|
||||
printf '%s\n' "$GITHUB_SHA" > home-dimension/SOURCE_COMMIT
|
||||
(cd home-dimension && sha256sum -- *.zip *.py *.java SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Home-Dimension-Return
|
||||
path: home-dimension
|
||||
if-no-files-found: error
|
||||
51
.forgejo/workflows/station-origins-doors.yml
Normal file
51
.forgejo/workflows/station-origins-doors.yml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
name: Station Origins and Iron Doors Overlay
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['fix/station-origins-*']
|
||||
|
||||
jobs:
|
||||
station-and-doors:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '9.2.1'
|
||||
- name: Test both plugins and extract exact overlay donors
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
gradle --no-daemon -p JarvisConnector test jar
|
||||
gradle --no-daemon -p DuneEss test jar
|
||||
mkdir station-and-doors
|
||||
PYTHONPATH=tools python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
from plugin_station_and_doors import donor_archive
|
||||
output = Path("station-and-doors")
|
||||
for role, jar in (
|
||||
("station", "JarvisConnector/build/libs/jarvistranslator.jar"),
|
||||
("ess", "DuneEss/build/libs/DuneRealms-Essentials.jar"),
|
||||
):
|
||||
(output / (role + "-donor.zip")).write_bytes(donor_archive(role, Path(jar)))
|
||||
PY
|
||||
cp tools/{StationAndDoorOverlay.java,plugin_station_and_doors.py,plugin_wild_update.py} station-and-doors/
|
||||
printf '%s\n' "$GITHUB_SHA" > station-and-doors/SOURCE_COMMIT
|
||||
(cd station-and-doors && sha256sum -- *.zip *.py *.java SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Station-Origins-Iron-Doors
|
||||
path: station-and-doors
|
||||
if-no-files-found: error
|
||||
|
|
@ -90,6 +90,7 @@ public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCom
|
|||
command.setExecutor(this);
|
||||
command.setTabCompleter(this);
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
getServer().getPluginManager().registerEvents(new IronDoorInteraction(), this);
|
||||
basics=new EssentialsBasics(this);
|
||||
basics.register();
|
||||
StaffItemTools.start(this);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.example.duneess;
|
||||
|
||||
import java.util.Set;
|
||||
import org.bukkit.World;
|
||||
|
||||
/** Dimension returns on one backend, preserving the Guild boundary between planets. */
|
||||
final class HomeDimensionRoutes {
|
||||
private static final Set<String> MAIN_WORLDS = Set.of(
|
||||
"arrakis", "caladan", "giedi_prime", "kaitain", "sigma_draconis_iv", "lobby_base");
|
||||
|
||||
private HomeDimensionRoutes() {}
|
||||
|
||||
static boolean canReturn(World source, Object destination) {
|
||||
if (source == null || !(destination instanceof World target)) return false;
|
||||
if (source.equals(target)) return true;
|
||||
String main = target.getName();
|
||||
if (target.getEnvironment() != World.Environment.NORMAL || !MAIN_WORLDS.contains(main)) return false;
|
||||
return source.getEnvironment() == World.Environment.NETHER && source.getName().equals(main + "_nether")
|
||||
|| source.getEnvironment() == World.Environment.THE_END && source.getName().equals(main + "_the_end");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.example.duneess;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
/** Give iron doors a manual interaction while retaining their redstone behavior. */
|
||||
final class IronDoorInteraction implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void interact(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getHand() != EquipmentSlot.HAND
|
||||
|| event.useInteractedBlock() == Event.Result.DENY) return;
|
||||
var clicked = event.getClickedBlock();
|
||||
if (clicked == null || clicked.getType() != Material.IRON_DOOR
|
||||
|| !(clicked.getBlockData() instanceof Door door)) return;
|
||||
var player = event.getPlayer();
|
||||
if (player.getGameMode() == GameMode.SPECTATOR) return;
|
||||
if (player.isSneaking() && (!player.getInventory().getItemInMainHand().isEmpty()
|
||||
|| !player.getInventory().getItemInOffHand().isEmpty())) return;
|
||||
|
||||
var other = clicked.getRelative(door.getHalf() == Bisected.Half.TOP ? BlockFace.DOWN : BlockFace.UP);
|
||||
if (other.getType() != Material.IRON_DOOR || !(other.getBlockData() instanceof Door otherDoor)
|
||||
|| otherDoor.getHalf() == door.getHalf()) return;
|
||||
boolean open = !door.isOpen();
|
||||
door.setOpen(open);
|
||||
otherDoor.setOpen(open);
|
||||
clicked.setBlockData(door, false);
|
||||
other.setBlockData(otherDoor, false);
|
||||
clicked.getWorld().playSound(clicked.getLocation().add(.5, .5, .5),
|
||||
open ? "minecraft:block.iron_door.open" : "minecraft:block.iron_door.close",
|
||||
SoundCategory.BLOCKS, 1, 1);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
event.setUseItemInHand(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ final class PersonalHomeTravel implements Listener {
|
|||
private void begin(Player p,Location destination,String mode){
|
||||
boolean rescue=mode.equals("rescue");
|
||||
if(!valid(destination)){p.sendMessage("That saved home is unavailable or outside the world's playable bounds.");return;}
|
||||
if(!p.getWorld().equals(destination.getWorld())){p.sendMessage("Travel to that world through the Guild first, then use /home.");return;}
|
||||
if(rescue?!p.getWorld().equals(destination.getWorld()):!HomeDimensionRoutes.canReturn(p.getWorld(),destination.getWorld())){p.sendMessage("Travel to that world through the Guild first, then use /home.");return;}
|
||||
String id=p.getUniqueId().toString();if(waiting.containsKey(p.getUniqueId())||journal.contains(id)){p.sendMessage("Your home journey is already being completed.");return;}
|
||||
var connector=Bukkit.getPluginManager().getPlugin("JarvisTranslator");if(connector==null||!connector.isEnabled()){p.sendMessage("Central home travel is unavailable. No payment was made.");return;}
|
||||
UUID token=UUID.randomUUID(),world=p.getWorld().getUID();waiting.put(p.getUniqueId(),token);Location target=destination.clone();
|
||||
|
|
@ -91,7 +91,7 @@ final class PersonalHomeTravel implements Listener {
|
|||
if(!state.equals("pending")){journal.set(id,null);persist();return;}
|
||||
if(!stage.equals("reserve"))return;
|
||||
Player current=Bukkit.getPlayer(UUID.fromString(id));Location target=journal.getLocation(id+".destination");
|
||||
if(current==null||!current.isOnline()||current.isDead()||!valid(target)||rescue&&!safe(target)||!current.getWorld().equals(target.getWorld())){stage(id,"cancel");return;}
|
||||
if(current==null||!current.isOnline()||current.isDead()||!valid(target)||(rescue?!safe(target)||!current.getWorld().equals(target.getWorld()):!HomeDimensionRoutes.canReturn(current.getWorld(),target.getWorld()))){stage(id,"cancel");return;}
|
||||
// Keep the busy latch until the actual native result. Crash recovery re-delivers the same destination.
|
||||
current.teleportAsync(target).whenComplete((success,failure)->Bukkit.getScheduler().runTask(plugin,()->{
|
||||
boolean arrived=Boolean.TRUE.equals(success)&&failure==null;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package com.example.duneess;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class HomeDimensionRoutesTest {
|
||||
@Test void onlyReturnsToTheOwningMainWorld() {
|
||||
var sigma = world("sigma_draconis_iv", World.Environment.NORMAL);
|
||||
var end = world("sigma_draconis_iv_the_end", World.Environment.THE_END);
|
||||
var giedi = world("giedi_prime", World.Environment.NORMAL);
|
||||
var nether = world("giedi_prime_nether", World.Environment.NETHER);
|
||||
var build = world("lobby_arrakis", World.Environment.NORMAL);
|
||||
assertTrue(HomeDimensionRoutes.canReturn(end, sigma));
|
||||
assertTrue(HomeDimensionRoutes.canReturn(nether, giedi));
|
||||
assertTrue(HomeDimensionRoutes.canReturn(giedi, giedi));
|
||||
assertFalse(HomeDimensionRoutes.canReturn(end, giedi));
|
||||
assertFalse(HomeDimensionRoutes.canReturn(nether, sigma));
|
||||
assertFalse(HomeDimensionRoutes.canReturn(sigma, end));
|
||||
assertFalse(HomeDimensionRoutes.canReturn(end, nether));
|
||||
assertFalse(HomeDimensionRoutes.canReturn(build, sigma));
|
||||
assertFalse(HomeDimensionRoutes.canReturn(end, null));
|
||||
assertFalse(HomeDimensionRoutes.canReturn(world("sigma_draconis_iv_the_end", World.Environment.CUSTOM), sigma));
|
||||
}
|
||||
|
||||
private static World world(String name, World.Environment environment) {
|
||||
var world = mock(World.class);
|
||||
when(world.getName()).thenReturn(name);
|
||||
when(world.getEnvironment()).thenReturn(environment);
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
package com.example.duneess;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class IronDoorInteractionTest {
|
||||
private final IronDoorInteraction listener = new IronDoorInteraction();
|
||||
private final PlayerInteractEvent event = mock(PlayerInteractEvent.class);
|
||||
private final Player player = mock(Player.class);
|
||||
private final Block upper = mock(Block.class);
|
||||
private final Block lower = mock(Block.class);
|
||||
private final Door top = mock(Door.class);
|
||||
private final Door bottom = mock(Door.class);
|
||||
private final World world = mock(World.class);
|
||||
|
||||
@BeforeEach void door() {
|
||||
when(event.getAction()).thenReturn(Action.RIGHT_CLICK_BLOCK);
|
||||
when(event.getHand()).thenReturn(EquipmentSlot.HAND);
|
||||
when(event.useInteractedBlock()).thenReturn(Event.Result.DEFAULT);
|
||||
when(event.getPlayer()).thenReturn(player);
|
||||
when(player.getGameMode()).thenReturn(GameMode.SURVIVAL);
|
||||
when(upper.getType()).thenReturn(Material.IRON_DOOR);
|
||||
when(lower.getType()).thenReturn(Material.IRON_DOOR);
|
||||
when(upper.getBlockData()).thenReturn(top);
|
||||
when(lower.getBlockData()).thenReturn(bottom);
|
||||
when(top.getHalf()).thenReturn(Bisected.Half.TOP);
|
||||
when(bottom.getHalf()).thenReturn(Bisected.Half.BOTTOM);
|
||||
when(upper.getRelative(BlockFace.DOWN)).thenReturn(lower);
|
||||
when(lower.getRelative(BlockFace.UP)).thenReturn(upper);
|
||||
when(upper.getWorld()).thenReturn(world);
|
||||
when(lower.getWorld()).thenReturn(world);
|
||||
when(upper.getLocation()).thenReturn(new Location(world, 1, 2, 1));
|
||||
when(lower.getLocation()).thenReturn(new Location(world, 1, 1, 1));
|
||||
}
|
||||
|
||||
@Test void topClickOpensBothHalvesWithoutChangingPower() {
|
||||
when(event.getClickedBlock()).thenReturn(upper);
|
||||
listener.interact(event);
|
||||
verify(top).setOpen(true);
|
||||
verify(bottom).setOpen(true);
|
||||
verify(top, never()).setPowered(anyBoolean());
|
||||
verify(bottom, never()).setPowered(anyBoolean());
|
||||
verify(upper).setBlockData(top, false);
|
||||
verify(lower).setBlockData(bottom, false);
|
||||
verify(world).playSound(any(Location.class), eq("minecraft:block.iron_door.open"), eq(SoundCategory.BLOCKS), eq(1f), eq(1f));
|
||||
verify(event).setUseItemInHand(Event.Result.DENY);
|
||||
}
|
||||
|
||||
@Test void bottomClickClosesBothHalves() {
|
||||
when(event.getClickedBlock()).thenReturn(lower);
|
||||
when(bottom.isOpen()).thenReturn(true);
|
||||
listener.interact(event);
|
||||
verify(top).setOpen(false);
|
||||
verify(bottom).setOpen(false);
|
||||
verify(world).playSound(any(Location.class), eq("minecraft:block.iron_door.close"), eq(SoundCategory.BLOCKS), eq(1f), eq(1f));
|
||||
}
|
||||
|
||||
@Test void protectedAndOffHandClicksNeverToggle() {
|
||||
when(event.getClickedBlock()).thenReturn(upper);
|
||||
when(event.useInteractedBlock()).thenReturn(Event.Result.DENY);
|
||||
listener.interact(event);
|
||||
when(event.useInteractedBlock()).thenReturn(Event.Result.DEFAULT);
|
||||
when(event.getHand()).thenReturn(EquipmentSlot.OFF_HAND);
|
||||
listener.interact(event);
|
||||
verifyNoInteractions(top, bottom, world);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ final class AtmMenu extends Menu {
|
|||
private String entered; // RIA ID typed on the Redeem tab
|
||||
private String receiptOperation,receiptReference,receiptMessage;
|
||||
private Long receiptAmount;
|
||||
private boolean receiptCanRedeem;
|
||||
|
||||
AtmMenu(DuneMenusPlugin plugin, Player p, Menu parent, Tab tab) { super(plugin, p, parent); this.tab = tab; }
|
||||
String id() { return switch(tab){case WITHDRAW->"withdraw";case DEPOSIT->"deposit";case REDEEM->"redeem";case RECEIPT->"receipt";default->"atm";}; }
|
||||
|
|
@ -67,7 +68,12 @@ final class AtmMenu extends Menu {
|
|||
if(tab==Tab.RECEIPT){
|
||||
put(13,Ui.item(Material.PAPER,"<gold>"+receiptOperation,
|
||||
receiptAmount==null?"<gray>"+receiptMessage:"<gray>Amount: <white>"+Ui.dm(receiptAmount),"<gray>"+receiptMessage));
|
||||
if(receiptReference!=null&&!receiptReference.isBlank())put(29,Ui.item(Material.NAME_TAG,"<gold>RIA ID","<white>"+receiptReference));
|
||||
String reference=RiaReference.normalize(receiptReference);
|
||||
if(reference!=null){
|
||||
referenceButton(reference);
|
||||
if(receiptCanRedeem)put(31,Ui.item(Material.ENDER_CHEST,"<aqua>Use this RIA ID",
|
||||
"<gray>Open its payout options","<gray>No need to type the reference"),c->{entered=reference;tab=Tab.REDEEM;redraw();});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (tab == Tab.REDEEM) drawRedeem(); else drawCash();
|
||||
|
|
@ -106,7 +112,19 @@ final class AtmMenu extends Menu {
|
|||
private void receipt(String operation,Backend.CashReceipt facts,String message){
|
||||
receiptOperation=facts!=null&&facts.recovered()?"Recovered Rihla transaction":operation;
|
||||
receiptAmount=facts==null?null:facts.amountMinor();receiptReference=facts==null?null:facts.riaId();receiptMessage=message;
|
||||
receiptCanRedeem="Cash deposit".equals(operation)&&RiaReference.normalize(receiptReference)!=null;
|
||||
selected.clear();tab=Tab.RECEIPT;redraw();
|
||||
if(RiaReference.normalize(receiptReference)!=null)player.sendMessage(RiaClipboard.message(receiptReference));
|
||||
}
|
||||
|
||||
private void referenceButton(String reference){
|
||||
boolean bedrock=plugin.modeFor(player)==Mode.BEDROCK;
|
||||
put(29,Ui.item(Material.NAME_TAG,bedrock?"<gold>Show RIA ID in chat":"<gold>Copy RIA ID",
|
||||
"<white>"+reference,bedrock?"<gray>Send the reference privately to chat":"<gray>Open a private click-to-copy link"),c->{
|
||||
end();plugin.closeNativePresentation(player);
|
||||
if(!bedrock)player.sendMessage(net.kyori.adventure.text.Component.text("Press T, then click the RIA ID below to copy it."));
|
||||
player.sendMessage(RiaClipboard.message(reference));
|
||||
});
|
||||
}
|
||||
|
||||
private void drawRedeem() {
|
||||
|
|
@ -118,7 +136,7 @@ final class AtmMenu extends Menu {
|
|||
});
|
||||
for (int s : new int[]{28, 30}) put(s, Ui.pane(Material.YELLOW_STAINED_GLASS_PANE));
|
||||
if (entered == null) return;
|
||||
put(29,Ui.item(Material.NAME_TAG,"<gold>RIA ID","<white>"+entered));
|
||||
referenceButton(entered);
|
||||
final String id = entered;
|
||||
load(backend().atmLookup(player, id), v -> {
|
||||
if (v == null) { put(22, Ui.item(Material.BARRIER, "<red>RIA ID not found")); return; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.dunerealms.menus;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
/** A private native-client copy action; never submits or redeems a voucher. */
|
||||
final class RiaClipboard {
|
||||
private RiaClipboard() {}
|
||||
|
||||
static Component message(String reference) {
|
||||
String complete=RiaReference.normalize(reference);
|
||||
if(complete==null)throw new IllegalArgumentException("A complete RIA reference is required");
|
||||
return Component.text("RIA ID: ",NamedTextColor.GOLD)
|
||||
.append(Component.text(complete,NamedTextColor.AQUA))
|
||||
.clickEvent(ClickEvent.copyToClipboard(complete))
|
||||
.hoverEvent(HoverEvent.showText(Component.text("Click to copy the complete RIA ID")));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.dunerealms.menus;
|
||||
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class RiaClipboardTest {
|
||||
@Test void copiesTheCompleteReferenceWithoutSubmittingAnyCommand(){
|
||||
String id="RIA-0123456789ABCDEF0123456789ABCDEF";
|
||||
var message=RiaClipboard.message(" "+id.toLowerCase(java.util.Locale.ROOT)+" ");
|
||||
assertEquals(ClickEvent.Action.COPY_TO_CLIPBOARD,message.clickEvent().action());
|
||||
assertEquals(id,message.clickEvent().value());
|
||||
assertTrue(PlainTextComponentSerializer.plainText().serialize(message).contains(id));
|
||||
}
|
||||
@Test void incompleteOrForeignReferencesCannotBecomeCopyActions(){
|
||||
for(String invalid:new String[]{null,"","RIA-1234","ITM-0123456789ABCDEF0123456789ABCDEF"})
|
||||
assertThrows(IllegalArgumentException.class,()->RiaClipboard.message(invalid));
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +74,14 @@
|
|||
"spawners": {
|
||||
"ambient": [],
|
||||
"axolotls": [],
|
||||
"creature": [],
|
||||
"creature": [
|
||||
{
|
||||
"type": "minecraft:goat",
|
||||
"weight": 5,
|
||||
"minCount": 1,
|
||||
"maxCount": 3
|
||||
}
|
||||
],
|
||||
"misc": [],
|
||||
"monster": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,14 @@
|
|||
"spawners": {
|
||||
"ambient": [],
|
||||
"axolotls": [],
|
||||
"creature": [],
|
||||
"creature": [
|
||||
{
|
||||
"type": "minecraft:goat",
|
||||
"weight": 5,
|
||||
"minCount": 1,
|
||||
"maxCount": 3
|
||||
}
|
||||
],
|
||||
"misc": [],
|
||||
"monster": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,14 @@
|
|||
"spawners": {
|
||||
"ambient": [],
|
||||
"axolotls": [],
|
||||
"creature": [],
|
||||
"creature": [
|
||||
{
|
||||
"type": "minecraft:goat",
|
||||
"weight": 5,
|
||||
"minCount": 1,
|
||||
"maxCount": 3
|
||||
}
|
||||
],
|
||||
"misc": [],
|
||||
"monster": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.bukkit.plugin.Plugin;
|
|||
public final class PlanetMobs implements Listener {
|
||||
private static final Set<String> NETHER=Set.of("BLAZE","GHAST","HOGLIN","MAGMA_CUBE","PIGLIN","PIGLIN_BRUTE","STRIDER","WITHER_SKELETON","ZOGLIN","ZOMBIFIED_PIGLIN","SKELETON","ENDERMAN");
|
||||
private static final Set<String> PASSIVE=Set.of("ALLAY","ARMADILLO","AXOLOTL","BAT","CAMEL","CAT","CHICKEN","COD","COW","DONKEY","FROG","GLOW_SQUID","HORSE","MUSHROOM_COW","MOOSHROOM","MULE","OCELOT","PARROT","PIG","PUFFERFISH","RABBIT","SALMON","SHEEP","SNIFFER","SNOWMAN","SNOW_GOLEM","SQUID","STRIDER","TADPOLE","TROPICAL_FISH","TURTLE","VILLAGER","WANDERING_TRADER");
|
||||
public static boolean allowed(String planet,String mob,boolean island){if(allowedColdPig(planet,mob))return true;return switch(planet){case "caladan"->!mob.equals("CREEPER");case "kaitain"->PASSIVE.contains(mob);case "giedi_prime"->NETHER.contains(mob);case "sigma_draconis_iv"->Set.of("SKELETON","STRAY","WITHER_SKELETON","BOGGED").contains(mob)||island&&Set.of("MUSHROOM_COW","MOOSHROOM","SULFUR_CUBE").contains(mob);default->true;};}
|
||||
public static boolean allowed(String planet,String mob,boolean island){if("sigma_draconis_iv".equals(planet)&&"GOAT".equals(mob)||allowedColdPig(planet,mob))return true;return switch(planet){case "caladan"->!mob.equals("CREEPER");case "kaitain"->PASSIVE.contains(mob);case "giedi_prime"->NETHER.contains(mob);case "sigma_draconis_iv"->Set.of("SKELETON","STRAY","WITHER_SKELETON","BOGGED").contains(mob)||island&&Set.of("MUSHROOM_COW","MOOSHROOM","SULFUR_CUBE").contains(mob);default->true;};}
|
||||
public static boolean allowedSpawn(String planet,String mob,boolean island,String reason){return allowed(planet,mob,island)||planet.equals("giedi_prime")&&(reason.equals("SPAWNER")&&Set.of("SKELETON","ZOMBIE","SPIDER","CAVE_SPIDER").contains(mob)||mob.equals("WARDEN"));}
|
||||
public static void start(Plugin plugin){Bukkit.getPluginManager().registerEvents(new PlanetMobs(),plugin);Bukkit.getPluginManager().registerEvents(new NativePlants(),plugin);PlanetSoil.start(plugin);}
|
||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true) public void spawning(CreatureSpawnEvent event){if(sigmaColdPig(event))return;var e=event.getEntity();String planet=e.getWorld().getName();if(!TemperateLandscape.enabled(planet))return;
|
||||
|
|
|
|||
|
|
@ -46,10 +46,7 @@ final class ArrakisBrewing implements Listener {
|
|||
}
|
||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true) public void brewed(BrewEvent event){
|
||||
String world=event.getBlock().getWorld().getName();
|
||||
if(!spice(event.getContents().getIngredient())){
|
||||
// Ordinary brewing is left intact; record the world of newly brewed potions.
|
||||
for(var result:event.getResults())if(result!=null&&!result.isEmpty())ItemOrigin.created(result,world);return;
|
||||
}
|
||||
if(!spice(event.getContents().getIngredient()))return;
|
||||
if(water==null||life==null)return;
|
||||
if(!arrakis(world)){for(int i=0;i<3;i++)if(vial(event.getContents().getItem(i),"blood_vial")||boostable(event.getContents().getItem(i))){event.setCancelled(true);return;}return;}
|
||||
for(int i=0;i<3&&i<event.getResults().size();i++){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
package com.dunerealms.jarvis;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.HopperInventorySearchEvent;
|
||||
import org.bukkit.inventory.BlockInventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/** Tags native composter output at creation or before the hopper takes it. */
|
||||
final class ComposterOrigins implements Listener {
|
||||
private static final StackWalker STACK = StackWalker.getInstance();
|
||||
private static final String COMPOSTER = "net.minecraft.world.level.block.ComposterBlock";
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void dropped(ItemSpawnEvent event) {
|
||||
var entity = event.getEntity();
|
||||
var output = entity.getItemStack();
|
||||
if (!boneMeal(output) || !nativeExtraction()) return;
|
||||
// The native composter spawns the result 1.01 above its bottom, inside its horizontal footprint.
|
||||
var location = entity.getLocation();
|
||||
var source = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() - 1, location.getBlockZ());
|
||||
if (!ready(source)) return;
|
||||
var marked = marked(output, source);
|
||||
if (!marked.equals(output)) entity.setItemStack(marked);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void hopper(HopperInventorySearchEvent event) {
|
||||
if (event.getContainerType() != HopperInventorySearchEvent.ContainerType.SOURCE) return;
|
||||
var source = event.getSearchBlock();
|
||||
var inventory = event.getInventory();
|
||||
if (inventory == null || !ready(source) || inventory.getSize() != 1
|
||||
|| !(inventory.getHolder() instanceof BlockInventoryHolder holder)
|
||||
|| !source.equals(holder.getBlock())) return;
|
||||
var output = inventory.getItem(0);
|
||||
if (!boneMeal(output)) return;
|
||||
var marked = marked(output, source);
|
||||
// Paper's composter output container only empties the block when its slot becomes empty.
|
||||
// Leave the native extraction, inventory capacity and protection checks in control.
|
||||
if (!marked.equals(output)) inventory.setItem(0, marked);
|
||||
}
|
||||
|
||||
private static boolean nativeExtraction() {
|
||||
return STACK.walk(frames -> {
|
||||
var enclosingCalls = frames.filter(frame ->
|
||||
frame.getClassName().equals(COMPOSTER) && frame.getMethodName().equals("extractProduce")
|
||||
|| frame.getClassName().equals("org.bukkit.craftbukkit.event.CraftEventFactory")
|
||||
&& frame.getMethodName().equals("callItemSpawnEvent")).limit(2).toList();
|
||||
return enclosingCalls.size() == 2 && enclosingCalls.get(1).getClassName().equals(COMPOSTER);
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean ready(Block block) {
|
||||
return block.getType() == Material.COMPOSTER && block.getBlockData() instanceof Levelled level
|
||||
&& level.getLevel() == level.getMaximumLevel();
|
||||
}
|
||||
|
||||
private static boolean boneMeal(ItemStack item) {
|
||||
return item != null && item.getType() == Material.BONE_MEAL && item.getAmount() == 1;
|
||||
}
|
||||
|
||||
private static ItemStack marked(ItemStack original, Block source) {
|
||||
var output = original.clone();
|
||||
ItemOrigin.created(output, source.getWorld().getName());
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,10 @@ final class ItemOrigin {
|
|||
static void configure(String value){server=value;}
|
||||
static String label(String value){
|
||||
if("jarvis-hq".equals(value))return "J.A.R.V.I.S. HQ";
|
||||
if("lobby_base".equals(value))return "Lobby";
|
||||
if("lobby_base_nether".equals(value))return "Lobby · Nether";
|
||||
if("lobby_base_the_end".equals(value))return "Lobby · The End";
|
||||
if("lobby_arrakis".equals(value))return "Arrakis build world";
|
||||
String profile=PlanetItemArtwork.profile(value);
|
||||
if(profile==null)return null;
|
||||
return switch(profile){
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ final class ItemOriginRemainders implements Listener {
|
|||
private record Burn(FurnaceBurnEvent event, FurnaceInventory inventory, String origin) {}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void fillLava(PlayerBucketFillEvent event) {
|
||||
public void fillBucket(PlayerBucketFillEvent event) {
|
||||
ItemStack result = event.getItemStack();
|
||||
var source = event.getBlock();
|
||||
if (result == null || !lavaPickup(event.getBucket(), source.getType(), result.getType())) return;
|
||||
if (result == null || !bucketPickup(event.getBucket(), source.getType(), result.getType())) return;
|
||||
var meta = result.getItemMeta();
|
||||
if (meta == null || meta.getPersistentDataContainer().has(ItemOrigin.WORLD)) return;
|
||||
|
||||
|
|
@ -49,9 +49,11 @@ final class ItemOriginRemainders implements Listener {
|
|||
event.setItemStack(tagged);
|
||||
}
|
||||
|
||||
static boolean lavaPickup(Material held, Material source, Material result) {
|
||||
return held == Material.BUCKET && result == Material.LAVA_BUCKET
|
||||
&& (source == Material.LAVA || source == Material.LAVA_CAULDRON);
|
||||
static boolean bucketPickup(Material held, Material source, Material result) {
|
||||
if (held != Material.BUCKET) return false;
|
||||
return result == Material.LAVA_BUCKET && (source == Material.LAVA || source == Material.LAVA_CAULDRON)
|
||||
|| result == Material.WATER_BUCKET && (source == Material.WATER || source == Material.WATER_CAULDRON)
|
||||
|| result == Material.POWDER_SNOW_BUCKET && (source == Material.POWDER_SNOW || source == Material.POWDER_SNOW_CAULDRON);
|
||||
}
|
||||
|
||||
static String pickupOrigin(String previous, String world) {
|
||||
|
|
@ -66,7 +68,8 @@ final class ItemOriginRemainders implements Listener {
|
|||
|| !consumes(event) || !(event.getBlock().getState(false) instanceof Furnace furnace)) return;
|
||||
var meta = fuel.getItemMeta();
|
||||
if (meta == null) return;
|
||||
String origin = meta.getPersistentDataContainer().get(ItemOrigin.WORLD, PersistentDataType.STRING);
|
||||
String origin = pickupOrigin(meta.getPersistentDataContainer().get(ItemOrigin.WORLD, PersistentDataType.STRING),
|
||||
event.getBlock().getWorld().getName());
|
||||
if (origin != null && ItemOrigin.label(origin) != null)
|
||||
burns.put(event.getBlock(), new Burn(event, furnace.getInventory(), origin));
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue

Staff