forked from unimatrix/web
Add native crossplay menus and organic Arrakis highlands
Recovered from the attached four-commit source patch (original tip 1686291). Includes native Java/Bedrock menus, minimal Essentials, organic highlands, finite Dense Spice, desert villages, Harkonnen fortress and three personal highland sietches. Original validation reports 50 passing tests on Java 21/Paper 1.21.8. Live Paper/Velocity/Bedrock/ViaVersion staging remains pending. Existing world, configuration and player data must be preserved.
This commit is contained in:
parent
c692949a78
commit
d988ea2983
51 changed files with 2005 additions and 138 deletions
36
.github/workflows/build.yml
vendored
36
.github/workflows/build.yml
vendored
|
|
@ -4,7 +4,7 @@ name: Build DuneCore, DuneNPC, DuneEss, and DuneTerrain
|
|||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [main, "feature/native-gui-1.21.8"]
|
||||
|
||||
jobs:
|
||||
build-website:
|
||||
|
|
@ -143,9 +143,27 @@ jobs:
|
|||
path: DuneNPC/build/libs/*.jar
|
||||
if-no-files-found: error
|
||||
|
||||
build-lobby:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '8.14'
|
||||
- run: gradle -p DuneLobby clean build
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: DuneLobby-Plugin
|
||||
path: DuneLobby/build/libs/*.jar
|
||||
if-no-files-found: error
|
||||
|
||||
package-server:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-core, build-ess, build-terrain, build-npc]
|
||||
needs: [build-core, build-ess, build-terrain, build-npc, build-lobby]
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -155,6 +173,8 @@ jobs:
|
|||
pattern: Dune*-Plugin
|
||||
path: DuneRealms-Server-Package
|
||||
merge-multiple: true
|
||||
- name: Download verified crossplay plugins
|
||||
run: python3 tools/download-crossplay.py DuneRealms-Server-Package/crossplay
|
||||
- name: Add resource pack and install instructions
|
||||
run: |
|
||||
curl --fail --location --silent --show-error \
|
||||
|
|
@ -168,28 +188,32 @@ jobs:
|
|||
cp docs/Dune-User-Manual.pdf DuneRealms-Server-Package/
|
||||
cp docs/Dune-Complete-Illustrated-Manual.pdf DuneRealms-Server-Package/
|
||||
cp docs/posters/*.png DuneRealms-Server-Package/
|
||||
cp docs/Native-GUI.md DuneRealms-Server-Package/Native-GUI.md
|
||||
cp README.md DuneRealms-Server-Package/Project-README.md
|
||||
cp website/DISCORD-FEEDS.md DuneRealms-Server-Package/DiscordSRV-Website-Setup.md
|
||||
cat > DuneRealms-Server-Package/README.txt <<'EOF'
|
||||
DuneRealms Paper server package
|
||||
|
||||
Contents: Vault 2.5.0, DuneCore, DuneNPC, DuneEss, and DuneTerrain plugin JARs, plus DuneResourcePack.zip.
|
||||
Contents: Vault 2.5.0, all five Dune plugins, and verified Geyser, Floodgate, ViaVersion JARs.
|
||||
See Native-GUI.md for platform-specific plugin placement.
|
||||
The illustrated user manual and Project-README.md are included for players and administrators.
|
||||
|
||||
Install all five plugin JARs in the Paper server's plugins/ folder and restart the server.
|
||||
Install the applicable plugin JARs in the Paper server's plugins/ folder and restart the server.
|
||||
Install the included resource pack on vanilla or Fabric 1.21.4 clients for sandworm, haunted Fremen, and spice textures.
|
||||
On Fabric, put the ZIP in .minecraft/resourcepacks and enable it in Options > Resource Packs; do not put it in mods/.
|
||||
DuneEss provides the Solaris economy through the included Vault API plugin.
|
||||
Vault 2.5.0 is the GPL-3.0 licensed Foulest/MilkBowl Vault project; its license is included here.
|
||||
Its source is available at https://github.com/Foulest/Vault/tree/2.5.0.
|
||||
|
||||
Compatible build target: Paper 1.21.4, Java 21.
|
||||
Compatible GUI build target: Paper 1.21.8, Java 21.
|
||||
See https://github.com/thomasv6545-glitch/MC for setup and configuration details.
|
||||
EOF
|
||||
- name: ZIP every server plugin JAR together
|
||||
run: zip -r DuneRealms-All-Server-Jars.zip DuneRealms-Server-Package
|
||||
- name: Upload one downloadable server package
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: DuneRealms-Server-Package
|
||||
path: DuneRealms-Server-Package/
|
||||
path: DuneRealms-All-Server-Jars.zip
|
||||
if-no-files-found: error
|
||||
retention-days: 90
|
||||
|
|
|
|||
2
.github/workflows/lobby.yml
vendored
2
.github/workflows/lobby.yml
vendored
|
|
@ -3,7 +3,7 @@ on:
|
|||
workflow_dispatch:
|
||||
push:
|
||||
branches: [main, beta]
|
||||
paths: ['DuneLobby/**', 'worlds/**', '.github/workflows/lobby.yml']
|
||||
paths: ['DuneLobby/**', 'worlds/**', '.github/workflows/lobby.yml', 'gui-common/**']
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
16
.github/workflows/network.yml
vendored
16
.github/workflows/network.yml
vendored
|
|
@ -2,9 +2,12 @@ name: Package DuneRealms Velocity Network
|
|||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [main, "feature/native-gui-1.21.8"]
|
||||
paths:
|
||||
- 'network/**'
|
||||
- 'gui-common/**'
|
||||
- 'tools/**'
|
||||
- 'DuneLobby/**'
|
||||
- 'DuneTerrain/**'
|
||||
- 'DuneEss/**'
|
||||
- 'DuneNPC/**'
|
||||
|
|
@ -26,13 +29,20 @@ jobs:
|
|||
run: |
|
||||
set -e
|
||||
mkdir -p built-plugins
|
||||
for project in DuneRealms-minecraft-only DuneTerrain DuneNPC DuneEss; do
|
||||
for project in DuneRealms-minecraft-only DuneTerrain DuneNPC DuneEss DuneLobby; do
|
||||
(cd "$project" && gradle clean build)
|
||||
done
|
||||
cp DuneRealms-minecraft-only/build/libs/*.jar built-plugins/DuneCore.jar
|
||||
cp DuneTerrain/build/libs/*.jar built-plugins/DuneTerrain.jar
|
||||
cp DuneNPC/build/libs/*.jar built-plugins/DuneNPC.jar
|
||||
cp DuneEss/build/libs/*.jar built-plugins/DuneEss.jar
|
||||
cp DuneEss/build/libs/*.jar built-plugins/DuneRealms-Essentials.jar
|
||||
cp DuneLobby/build/libs/*.jar built-plugins/DuneLobby.jar
|
||||
- name: Download verified crossplay plugins
|
||||
run: |
|
||||
python3 tools/download-crossplay.py built-crossplay
|
||||
curl --fail --location --silent --show-error https://github.com/Foulest/Vault/releases/download/2.5.0/Vault-2.5.0.jar --output built-crossplay/universal/Vault-2.5.0.jar
|
||||
echo "3efb1c893d35807c0f3945068858a96af0f131020eee37545bdddb330044b2d9 built-crossplay/universal/Vault-2.5.0.jar" | sha256sum --check --strict
|
||||
curl --fail --location --silent --show-error https://raw.githubusercontent.com/Foulest/Vault/2.5.0/LICENSE --output built-crossplay/Vault-LICENSE.txt
|
||||
- name: Package six servers and Velocity config
|
||||
run: python3 network/package.py
|
||||
- uses: actions/upload-artifact@v4
|
||||
|
|
|
|||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -4,3 +4,9 @@ build/
|
|||
# Manual render and conversion intermediates
|
||||
tmp/
|
||||
__pycache__/
|
||||
|
||||
# Generated release packages and credentials in fresh-install network templates
|
||||
/built-plugins/
|
||||
/built-crossplay/
|
||||
/DuneRealms-Velocity-Network/
|
||||
/DuneRealms-Velocity-Network.zip
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
plugins { java }
|
||||
group = "com.example"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
|
||||
exclude(group = "org.bukkit", module = "bukkit")
|
||||
}
|
||||
implementation("org.postgresql:postgresql:42.7.4")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
|
||||
testImplementation("com.h2database:h2:2.3.232")
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
testImplementation("org.mockito:mockito-core:5.15.2")
|
||||
testRuntimeOnly("com.github.MilkBowl:VaultAPI:1.7") { exclude(group = "org.bukkit", module = "bukkit") }
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
|
|
@ -27,3 +27,14 @@ tasks.jar {
|
|||
java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) }
|
||||
tasks.withType<JavaCompile> { options.encoding = "UTF-8" }
|
||||
tasks.test { useJUnitPlatform() }
|
||||
|
||||
repositories { maven("https://repo.opencollab.dev/main/") }
|
||||
dependencies { compileOnly("org.geysermc.floodgate:api:2.2.5-SNAPSHOT") }
|
||||
sourceSets.main { java.srcDir("../gui-common/src/main/java") }
|
||||
|
||||
tasks.jar { archiveFileName.set("DuneRealms-Essentials.jar") }
|
||||
|
||||
// Explicit test instrumentation works on Java 21 without dynamic self-attachment.
|
||||
val mockitoAgent by configurations.creating
|
||||
dependencies { mockitoAgent("org.mockito:mockito-core:5.15.2") { isTransitive = false } }
|
||||
tasks.test { jvmArgs("-javaagent:${mockitoAgent.singleFile.absolutePath}") }
|
||||
|
|
|
|||
|
|
@ -30,9 +30,10 @@ import java.sql.PreparedStatement;
|
|||
import java.util.*;
|
||||
|
||||
public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCompleter, Listener {
|
||||
private static final List<String> PLANETS = List.of("arrakis", "giedi_prime", "kaitain", "caladan", "sigma_draconis_iv");
|
||||
private static final List<String> PLANETS = List.of("arrakis", "giedi_prime", "kaitain", "caladan", "sigma_draconis_iv", "spacing_guild");
|
||||
private DuneEconomy economy;
|
||||
private ExchangeMenu exchangeMenu;
|
||||
private EssentialsBasics basics;
|
||||
private String jdbcUrl = "", dbUser = "", dbPassword = "";
|
||||
private boolean networkEnabled;
|
||||
private String localPlanet;
|
||||
|
|
@ -87,10 +88,12 @@ public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCom
|
|||
command.setExecutor(this);
|
||||
command.setTabCompleter(this);
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
basics=new EssentialsBasics(this);
|
||||
basics.register();
|
||||
exchangeMenu = new ExchangeMenu(this);
|
||||
exchangeMenu.register();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) economy.createPlayerAccount(player);
|
||||
getLogger().info("DuneEss enabled as the Solaris Vault provider.");
|
||||
getLogger().info("DuneRealms Essentials enabled as the Solaris Vault provider.");
|
||||
}
|
||||
|
||||
@Override public void onDisable() {
|
||||
|
|
@ -150,6 +153,7 @@ public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCom
|
|||
}
|
||||
|
||||
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(args.length==0 && sender instanceof Player player) { basics.menu(player); return true; }
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
|
||||
int page = 1;
|
||||
if (args.length > 1 && args[1].equalsIgnoreCase("menu")) {
|
||||
|
|
@ -273,7 +277,17 @@ public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCom
|
|||
nextMeta.getPersistentDataContainer().set(helpPageKey, PersistentDataType.INTEGER, index + 2);
|
||||
next.setItemMeta(nextMeta);
|
||||
menu.setItem(53, next);
|
||||
player.openInventory(menu);
|
||||
java.util.Map<Integer,Runnable> actions=new java.util.HashMap<>();
|
||||
actions.put(45,()->openHelpMenu(player,index));
|
||||
actions.put(53,()->openHelpMenu(player,index+2));
|
||||
actions.put(49,player::closeInventory);
|
||||
for(int slot:slots) {
|
||||
ItemStack entry=menu.getItem(slot);
|
||||
if(entry==null) continue;
|
||||
String command=entry.getItemMeta().getPersistentDataContainer().get(helpActionKey,PersistentDataType.STRING);
|
||||
if(command!=null) actions.put(slot,()->player.performCommand(command.substring(1)));
|
||||
}
|
||||
com.example.dunegui.NativeMenus.inventory(this,player,"Dune Field Guide · "+(index+1),menu,actions);
|
||||
}
|
||||
|
||||
private ItemStack helpItem(Material material, String name, List<String> lore) {
|
||||
|
|
@ -306,6 +320,33 @@ public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCom
|
|||
economy.createPlayerAccount(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void spiceSeller(org.bukkit.event.player.PlayerInteractEntityEvent event) {
|
||||
if(!event.getRightClicked().getPersistentDataContainer().has(new NamespacedKey("dunerealms","spice-seller"),PersistentDataType.BYTE))return;
|
||||
event.setCancelled(true);
|
||||
if(event.getHand()!=org.bukkit.inventory.EquipmentSlot.HAND)return;
|
||||
Player player=event.getPlayer();
|
||||
Inventory menu=Bukkit.createInventory(null,9,"Spice Seller");
|
||||
int quantity=16;
|
||||
double price=java.math.BigDecimal.valueOf(Math.max(1,getConfig().getInt("currency.spice-price",15)))
|
||||
.multiply(new java.math.BigDecimal("1.35")).multiply(java.math.BigDecimal.valueOf(quantity)).doubleValue();
|
||||
ItemStack offer=new ItemStack(Material.ORANGE_DYE,quantity); ItemMeta meta=offer.getItemMeta();
|
||||
meta.setDisplayName("Buy 16 spice · "+economy.format(price));
|
||||
meta.setLore(List.of("35% above standard spice price", "Confirm purchase"));offer.setItemMeta(meta);menu.setItem(4,offer);
|
||||
Map<Integer,Runnable> actions=new HashMap<>();
|
||||
actions.put(4,()->{
|
||||
// Recheck proximity and capacity at confirmation; never charge for undeliverable goods.
|
||||
if(!event.getRightClicked().isValid() || !player.getWorld().equals(event.getRightClicked().getWorld())
|
||||
|| player.getLocation().distanceSquared(event.getRightClicked().getLocation())>64)return;
|
||||
ItemStack spice=new ItemStack(Material.ORANGE_DYE,quantity);ItemMeta sm=spice.getItemMeta();
|
||||
sm.setDisplayName(ChatColor.GOLD+"Melange Spice");sm.getPersistentDataContainer().set(spiceKey,PersistentDataType.STRING,"spice");spice.setItemMeta(sm);
|
||||
if(player.getInventory().firstEmpty()<0){player.sendMessage("Make an empty inventory slot first.");return;}
|
||||
if(!economy.withdrawPlayer(player,price).transactionSuccess()){player.sendMessage("Not enough Solaris, or economy unavailable.");return;}
|
||||
player.getInventory().addItem(spice);player.sendMessage(ChatColor.GOLD+"Bought 16 spice for "+economy.format(price)+".");
|
||||
});
|
||||
com.example.dunegui.NativeMenus.inventory(this,player,"Spice Seller · +35%",menu,actions);
|
||||
}
|
||||
|
||||
private void sellSpice(Player player) {
|
||||
int amount = 0;
|
||||
for (ItemStack item : player.getInventory().getStorageContents()) {
|
||||
|
|
@ -346,7 +387,9 @@ public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCom
|
|||
item.setItemMeta(meta);
|
||||
inventory.setItem(i, item);
|
||||
}
|
||||
player.openInventory(inventory);
|
||||
java.util.Map<Integer,Runnable> actions=new java.util.HashMap<>();
|
||||
for(int i=0;i<PLANETS.size();i++) { String planet=PLANETS.get(i); actions.put(i,()->travel(player,planet)); }
|
||||
com.example.dunegui.NativeMenus.inventory(this,player,"Spacing Guild Travel",inventory,actions);
|
||||
}
|
||||
|
||||
@EventHandler public void onTravelMenuClick(InventoryClickEvent event) {
|
||||
|
|
|
|||
138
DuneEss/src/main/java/com/example/duneess/EssentialsBasics.java
Normal file
138
DuneEss/src/main/java/com/example/duneess/EssentialsBasics.java
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
package com.example.duneess;
|
||||
|
||||
import com.example.dunegui.NativeMenus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
|
||||
/** Deliberately small essentials command surface; vanilla owns bed/anchor respawns. */
|
||||
final class EssentialsBasics implements CommandExecutor, TabCompleter, Listener {
|
||||
private final DuneEss plugin;
|
||||
private final File file;
|
||||
private YamlConfiguration homes;
|
||||
private final Map<UUID,Request> requests=new HashMap<>();
|
||||
private record Request(UUID sender,long expires) {}
|
||||
EssentialsBasics(DuneEss plugin) {
|
||||
this.plugin=plugin;
|
||||
file=new File(plugin.getDataFolder(),"homes.yml");
|
||||
homes=YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
void register() {
|
||||
for(String name:List.of("home","sethome","delhome","homes","tpa","tpaccept","tpdeny","spawn","server","essentials")) {
|
||||
PluginCommand command=Objects.requireNonNull(plugin.getCommand(name));
|
||||
command.setExecutor(this); command.setTabCompleter(this);
|
||||
}
|
||||
Bukkit.getPluginManager().registerEvents(this,plugin);
|
||||
}
|
||||
static String homeName(String[] args) {
|
||||
String name=args.length==0?"home":args[0].toLowerCase(Locale.ROOT);
|
||||
if(args.length>1 || !name.matches("[a-z0-9_-]{1,24}")) throw new IllegalArgumentException("Use a home name with 1–24 letters, numbers, underscores or hyphens.");
|
||||
return name;
|
||||
}
|
||||
private String key(Player p,String name) { return p.getUniqueId()+"."+name; }
|
||||
private Set<String> names(Player p) {
|
||||
var section=homes.getConfigurationSection(p.getUniqueId().toString());
|
||||
return section==null?Set.of():section.getKeys(false);
|
||||
}
|
||||
private void save() throws IOException {
|
||||
Path target=file.toPath(), temp=target.resolveSibling("homes.yml.tmp");
|
||||
Files.createDirectories(target.getParent());
|
||||
Files.writeString(temp,homes.saveToString());
|
||||
try { Files.move(temp,target,StandardCopyOption.ATOMIC_MOVE,StandardCopyOption.REPLACE_EXISTING); }
|
||||
catch(AtomicMoveNotSupportedException ex) { Files.move(temp,target,StandardCopyOption.REPLACE_EXISTING); }
|
||||
}
|
||||
private void teleport(Player p,Location location) {
|
||||
// Local essentials never bypass interplanetary permits, fares, or arrival rules.
|
||||
if(location==null || location.getWorld()==null) { p.sendMessage("That destination is unavailable on this server."); return; }
|
||||
if(!p.getWorld().equals(location.getWorld())) { p.sendMessage("Use /server to travel between worlds, then /home at your destination."); return; }
|
||||
if(!location.getWorld().getWorldBorder().isInside(location) || location.getY()<location.getWorld().getMinHeight() || location.getY()>=location.getWorld().getMaxHeight()) {
|
||||
p.sendMessage("That destination is outside the world's playable bounds."); return;
|
||||
}
|
||||
p.teleportAsync(location).thenAccept(success->{ if(!success) p.sendMessage("Teleportation failed. Try again."); });
|
||||
}
|
||||
void menu(Player p) {
|
||||
List<NativeMenus.Choice> choices=new ArrayList<>();
|
||||
choices.add(new NativeMenus.Choice("Set home","Save your current position as home.",()->p.performCommand("sethome")));
|
||||
choices.add(new NativeMenus.Choice("Homes","Choose a saved home on this backend.",()->homeMenu(p)));
|
||||
choices.add(new NativeMenus.Choice("Spawn","Return to this world's spawn.",()->p.performCommand("spawn")));
|
||||
choices.add(new NativeMenus.Choice("Guild servers","Travel using existing Solaris fares and permissions.",()->p.performCommand("duneess travel")));
|
||||
choices.add(new NativeMenus.Choice("Solaris","Show your balance.",()->p.performCommand("duneess balance")));
|
||||
choices.add(new NativeMenus.Choice("CHOAM Exchange","Buy, list and reclaim items.",()->p.performCommand("exchange")));
|
||||
choices.add(new NativeMenus.Choice("Help","Open the Dune Field Guide.",()->p.performCommand("duneess help menu")));
|
||||
NativeMenus.show(plugin,p,"DuneRealms Essentials","Solaris: "+plugin.economy().format(plugin.economy().getBalance(p)),choices);
|
||||
}
|
||||
private void homeMenu(Player p) {
|
||||
List<NativeMenus.Choice> choices=names(p).stream().sorted().map(name->new NativeMenus.Choice(name,"Teleport to this saved home.",()->p.performCommand("home "+name))).toList();
|
||||
if(choices.isEmpty()) p.sendMessage("You have no homes. Use /sethome [name].");
|
||||
else NativeMenus.show(plugin,p,"Your homes",choices);
|
||||
}
|
||||
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args) {
|
||||
if(!(sender instanceof Player p)) { sender.sendMessage("Use this command in-game."); return true; }
|
||||
String action=command.getName();
|
||||
if(!p.hasPermission("duneess.basics")) { p.sendMessage("You do not have permission to use essentials."); return true; }
|
||||
try {
|
||||
switch(action) {
|
||||
case "essentials" -> menu(p);
|
||||
case "homes" -> homeMenu(p);
|
||||
case "sethome" -> {
|
||||
String name=homeName(args), path=key(p,name);
|
||||
if(!homes.contains(path) && names(p).size()>=Math.max(1,plugin.getConfig().getInt("essentials.max-homes",3))) throw new IllegalArgumentException("Your home limit has been reached.");
|
||||
homes.set(path,p.getLocation()); save(); p.sendMessage("Home saved: "+name);
|
||||
}
|
||||
case "home" -> teleport(p,homes.getLocation(key(p,homeName(args))));
|
||||
case "delhome" -> {
|
||||
String name=homeName(args),path=key(p,name);
|
||||
if(!homes.contains(path)) throw new IllegalArgumentException("That home does not exist.");
|
||||
homes.set(path,null); save(); p.sendMessage("Home removed: "+name);
|
||||
}
|
||||
case "spawn" -> teleport(p,p.getWorld().getSpawnLocation());
|
||||
case "server" -> plugin.onCommand(p,Objects.requireNonNull(plugin.getCommand("duneess")),"duneess",args.length==0?new String[]{"travel"}:new String[]{"travel",args[0]});
|
||||
case "tpa" -> {
|
||||
if(args.length!=1) throw new IllegalArgumentException("Usage: /tpa <online player>");
|
||||
Player target=Bukkit.getPlayerExact(args[0]);
|
||||
if(target==null || target.equals(p) || !p.canSee(target)) throw new IllegalArgumentException("Choose another online player on this server.");
|
||||
if(!target.getWorld().equals(p.getWorld())) throw new IllegalArgumentException("Use Guild travel to reach that player's world first.");
|
||||
requests.put(target.getUniqueId(),new Request(p.getUniqueId(),System.nanoTime()+60_000_000_000L));
|
||||
target.sendMessage(p.getName()+" requests to teleport to you. /tpaccept or /tpdeny (60 seconds).");
|
||||
p.sendMessage("Teleport request sent.");
|
||||
}
|
||||
case "tpaccept","tpdeny" -> {
|
||||
Request request=requests.remove(p.getUniqueId());
|
||||
if(request==null || request.expires()<System.nanoTime()) throw new IllegalArgumentException("No active teleport request.");
|
||||
Player requester=Bukkit.getPlayer(request.sender());
|
||||
if(requester==null || !requester.isOnline()) throw new IllegalArgumentException("That player is offline.");
|
||||
if(action.equals("tpaccept")) teleport(requester,p.getLocation());
|
||||
else requester.sendMessage("Your teleport request was declined.");
|
||||
}
|
||||
default -> { return false; }
|
||||
}
|
||||
} catch(IllegalArgumentException ex) { p.sendMessage(ex.getMessage()); }
|
||||
catch(IOException ex) {
|
||||
homes=YamlConfiguration.loadConfiguration(file);
|
||||
plugin.getLogger().warning("Could not persist homes: "+ex.getMessage());
|
||||
p.sendMessage("Could not save your homes. No change was committed.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override public List<String> onTabComplete(CommandSender sender,Command command,String alias,String[] args) {
|
||||
if(!(sender instanceof Player p) || args.length!=1) return List.of();
|
||||
Collection<String> values=switch(command.getName()) {
|
||||
case "home","delhome" -> names(p);
|
||||
case "tpa" -> Bukkit.getOnlinePlayers().stream().filter(p::canSee).map(Player::getName).toList();
|
||||
case "server" -> List.of("arrakis","giedi_prime","caladan","kaitain","sigma_draconis_iv","spacing_guild");
|
||||
default -> List.of();
|
||||
};
|
||||
return values.stream().filter(v->v.toLowerCase(Locale.ROOT).startsWith(args[0].toLowerCase(Locale.ROOT))).toList();
|
||||
}
|
||||
@EventHandler public void quit(PlayerQuitEvent event) {
|
||||
UUID id=event.getPlayer().getUniqueId();
|
||||
requests.remove(id); requests.values().removeIf(request->request.sender().equals(id));
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ import java.math.BigDecimal;
|
|||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
/** Standard inventory slots work on Java and through Geyser without custom client interfaces. */
|
||||
/** Native menus share the existing SQL-backed trading operations. */
|
||||
@SuppressWarnings("deprecation")
|
||||
final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
||||
private static final List<String> CATEGORIES=List.of("ores","spice","building","equipment","farming","misc");
|
||||
|
|
@ -28,6 +28,7 @@ final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
|||
final UUID owner;
|
||||
final Map<Integer,Runnable> actions=new HashMap<>();
|
||||
Inventory inventory;
|
||||
String title;
|
||||
Screen(UUID owner) { this.owner=owner; }
|
||||
@Override public Inventory getInventory() { return inventory; }
|
||||
}
|
||||
|
|
@ -72,6 +73,7 @@ final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
|||
}
|
||||
private Screen screen(Player p,String title) {
|
||||
Screen s=new Screen(p.getUniqueId());
|
||||
s.title="CHOAM | "+title;
|
||||
s.inventory=Bukkit.createInventory(s,54,tint(p)+"CHOAM | "+title);
|
||||
Material glass=switch(faction(p)) {
|
||||
case "Atreides" -> Material.CYAN_STAINED_GLASS_PANE;
|
||||
|
|
@ -106,7 +108,7 @@ final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
|||
});
|
||||
if(p.hasPermission("dune.admin")) button(s,42,Material.COMMAND_BLOCK,"Exchange Administration",()->admin(p));
|
||||
button(s,49,Material.BARRIER,"Close",p::closeInventory);
|
||||
p.openInventory(s.inventory);
|
||||
com.example.dunegui.NativeMenus.inventory(plugin,p,s.title,s.inventory,s.actions);
|
||||
}
|
||||
private void planetMenu(Player p) {
|
||||
Screen s=screen(p,"Planet Filter");
|
||||
|
|
@ -114,7 +116,7 @@ final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
|||
String planet=PLANETS.get(i);
|
||||
button(s,11+i,Material.COMPASS,planet,()->{planets.put(p.getUniqueId(),planet); browse(p,"all",0,false,false);});
|
||||
}
|
||||
p.openInventory(s.inventory);
|
||||
com.example.dunegui.NativeMenus.inventory(plugin,p,s.title,s.inventory,s.actions);
|
||||
}
|
||||
private void admin(Player p) {
|
||||
if(!p.hasPermission("dune.admin")) return;
|
||||
|
|
@ -123,7 +125,7 @@ final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
|||
button(s,24,Material.REDSTONE,"Check Database",()->{
|
||||
if(connected(p)) p.sendMessage(ChatColor.GREEN+"Shared CHOAM database connected.");
|
||||
});
|
||||
p.openInventory(s.inventory);
|
||||
com.example.dunegui.NativeMenus.inventory(plugin,p,s.title,s.inventory,s.actions);
|
||||
}
|
||||
private ItemStack decode(ExchangeStore.Listing offer) {
|
||||
ItemStack item;
|
||||
|
|
@ -158,7 +160,7 @@ final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
|||
if(rows.isEmpty()) s.inventory.setItem(22,icon(Material.PAPER,"No matching listings","Try another planet or list a held item."));
|
||||
if(current>0) button(s,45,Material.ARROW,"Previous",()->browse(p,category,current-1,mine,admin));
|
||||
if(rows.size()>28) button(s,53,Material.ARROW,"Next",()->browse(p,category,current+1,mine,admin));
|
||||
p.openInventory(s.inventory);
|
||||
com.example.dunegui.NativeMenus.inventory(plugin,p,s.title,s.inventory,s.actions);
|
||||
});
|
||||
}
|
||||
private void confirm(Player p,long id,boolean reclaim) {
|
||||
|
|
@ -171,7 +173,7 @@ final class ExchangeMenu implements Listener, CommandExecutor, TabCompleter {
|
|||
button(s,30,Material.LIME_CONCRETE,reclaim?"Confirm Reclaim":"Confirm Purchase",()->{
|
||||
p.closeInventory(); if(reclaim) cancel(p,id); else buy(p,id);
|
||||
});
|
||||
button(s,32,Material.RED_CONCRETE,"Never Mind",()->home(p)); p.openInventory(s.inventory);
|
||||
button(s,32,Material.RED_CONCRETE,"Never Mind",()->home(p)); com.example.dunegui.NativeMenus.inventory(plugin,p,s.title,s.inventory,s.actions);
|
||||
});
|
||||
}
|
||||
private boolean fits(Player p,ItemStack item,int amount) {
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@ network:
|
|||
servers: {}
|
||||
|
||||
worlds: [arrakis, giedi_prime, kaitain, caladan, sigma_draconis_iv]
|
||||
|
||||
# Homes are local to each backend. Vanilla bed/anchor respawns remain authoritative.
|
||||
essentials:
|
||||
max-homes: 3
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
name: DuneEss
|
||||
version: 1.0.2
|
||||
version: 1.0.3
|
||||
main: com.example.duneess.DuneEss
|
||||
api-version: '1.21'
|
||||
api-version: '1.21.8'
|
||||
depend: [Vault]
|
||||
softdepend: [DuneCore, DuneTerrain]
|
||||
description: Dune Solaris economy, Vault provider, spice sales, and Arrakis travel
|
||||
softdepend: [floodgate, ViaVersion, DuneCore, DuneTerrain]
|
||||
prefix: DuneRealms Essentials
|
||||
description: DuneRealms Essentials - Dune Solaris economy, Vault provider, spice sales, and Arrakis travel
|
||||
commands:
|
||||
exchange:
|
||||
description: CHOAM interplanetary player marketplace
|
||||
|
|
@ -14,6 +15,38 @@ commands:
|
|||
description: Solaris, travel, and Arrakis administration
|
||||
usage: /duneess help
|
||||
aliases: [dess]
|
||||
essentials:
|
||||
description: Open DuneRealms Essentials
|
||||
permission: duneess.basics
|
||||
home:
|
||||
description: Teleport to a saved home
|
||||
permission: duneess.basics
|
||||
sethome:
|
||||
description: Save a named home
|
||||
permission: duneess.basics
|
||||
delhome:
|
||||
description: Remove a named home
|
||||
permission: duneess.basics
|
||||
homes:
|
||||
description: Choose a saved home
|
||||
permission: duneess.basics
|
||||
tpa:
|
||||
description: Request player teleportation
|
||||
permission: duneess.basics
|
||||
tpaccept:
|
||||
description: Accept a teleport request
|
||||
permission: duneess.basics
|
||||
tpdeny:
|
||||
description: Decline a teleport request
|
||||
permission: duneess.basics
|
||||
spawn:
|
||||
description: Return to world spawn
|
||||
permission: duneess.basics
|
||||
server:
|
||||
description: Open Guild server travel
|
||||
permission: duneess.basics
|
||||
permissions:
|
||||
duneess.basics:
|
||||
default: true
|
||||
dune.admin:
|
||||
default: op
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package com.example.duneess;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
class EssentialsBasicsTest {
|
||||
@Test void normalizesNamesAndHasAStableDefault() {
|
||||
assertEquals("home",EssentialsBasics.homeName(new String[]{}));
|
||||
assertEquals("sietch_2",EssentialsBasics.homeName(new String[]{"Sietch_2"}));
|
||||
}
|
||||
@Test void rejectsYamlPathsAndInvalidArguments() {
|
||||
for(String name:new String[]{"../other","player.home","","a b","x".repeat(25)})
|
||||
assertThrows(IllegalArgumentException.class,()->EssentialsBasics.homeName(new String[]{name}));
|
||||
assertThrows(IllegalArgumentException.class,()->EssentialsBasics.homeName(new String[]{"one","two"}));
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.io.TempDir java.nio.file.Path directory;
|
||||
@Test void teleportRequestsRequireConsentAndCannotBeAcceptedTwice() {
|
||||
DuneEss plugin=org.mockito.Mockito.mock(DuneEss.class);
|
||||
org.mockito.Mockito.when(plugin.getDataFolder()).thenReturn(directory.toFile());
|
||||
EssentialsBasics basics=new EssentialsBasics(plugin);
|
||||
var source=org.mockito.Mockito.mock(org.bukkit.entity.Player.class);
|
||||
var target=org.mockito.Mockito.mock(org.bukkit.entity.Player.class);
|
||||
var world=org.mockito.Mockito.mock(org.bukkit.World.class);
|
||||
var border=org.mockito.Mockito.mock(org.bukkit.WorldBorder.class);
|
||||
var request=org.mockito.Mockito.mock(org.bukkit.command.Command.class);
|
||||
var accept=org.mockito.Mockito.mock(org.bukkit.command.Command.class);
|
||||
java.util.UUID senderId=java.util.UUID.randomUUID(), targetId=java.util.UUID.randomUUID();
|
||||
org.mockito.Mockito.when(source.getUniqueId()).thenReturn(senderId);
|
||||
org.mockito.Mockito.when(target.getUniqueId()).thenReturn(targetId);
|
||||
org.mockito.Mockito.when(source.getName()).thenReturn("Sender");
|
||||
org.mockito.Mockito.when(source.hasPermission("duneess.basics")).thenReturn(true);
|
||||
org.mockito.Mockito.when(target.hasPermission("duneess.basics")).thenReturn(true);
|
||||
org.mockito.Mockito.when(source.canSee(target)).thenReturn(true);
|
||||
org.mockito.Mockito.when(source.getWorld()).thenReturn(world);
|
||||
org.mockito.Mockito.when(target.getWorld()).thenReturn(world);
|
||||
org.mockito.Mockito.when(source.isOnline()).thenReturn(true);
|
||||
org.mockito.Mockito.when(world.getWorldBorder()).thenReturn(border);
|
||||
org.mockito.Mockito.when(border.isInside(org.mockito.ArgumentMatchers.any())).thenReturn(true);
|
||||
org.mockito.Mockito.when(world.getMinHeight()).thenReturn(-64);
|
||||
org.mockito.Mockito.when(world.getMaxHeight()).thenReturn(320);
|
||||
var destination=new org.bukkit.Location(world,10,80,10);
|
||||
org.mockito.Mockito.when(target.getLocation()).thenReturn(destination);
|
||||
org.mockito.Mockito.when(source.teleportAsync(destination)).thenReturn(java.util.concurrent.CompletableFuture.completedFuture(true));
|
||||
org.mockito.Mockito.when(request.getName()).thenReturn("tpa");
|
||||
org.mockito.Mockito.when(accept.getName()).thenReturn("tpaccept");
|
||||
try(var bukkit=org.mockito.Mockito.mockStatic(org.bukkit.Bukkit.class)) {
|
||||
bukkit.when(()->org.bukkit.Bukkit.getPlayerExact("Target")).thenReturn(target);
|
||||
bukkit.when(()->org.bukkit.Bukkit.getPlayer(senderId)).thenReturn(source);
|
||||
basics.onCommand(source,request,"tpa",new String[]{"Target"});
|
||||
org.mockito.Mockito.verify(source,org.mockito.Mockito.never()).teleportAsync(org.mockito.ArgumentMatchers.any(org.bukkit.Location.class));
|
||||
basics.onCommand(target,accept,"tpaccept",new String[]{});
|
||||
basics.onCommand(target,accept,"tpaccept",new String[]{});
|
||||
org.mockito.Mockito.verify(source,org.mockito.Mockito.times(1)).teleportAsync(destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.example.dunegui;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.UUID;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
class MenuSessionTest {
|
||||
@Test void rejectsAnotherPlayerWithoutConsumingTheOwnerAction() {
|
||||
UUID owner=UUID.randomUUID(); MenuSession session=new MenuSession(owner);
|
||||
assertFalse(session.claim(UUID.randomUUID())); assertTrue(session.claim(owner)); assertFalse(session.claim(owner));
|
||||
}
|
||||
@Test void openingANewMenuInvalidatesThePreviousConfirmation() {
|
||||
UUID owner=UUID.randomUUID(); MenuSession old=new MenuSession(owner), next=new MenuSession(owner);
|
||||
assertFalse(old.claim(owner)); assertTrue(next.claim(owner));
|
||||
}
|
||||
@Test void expiringOldMenuDoesNotInvalidateTheNewMenu() {
|
||||
UUID owner=UUID.randomUUID(); MenuSession old=new MenuSession(owner), next=new MenuSession(owner);
|
||||
old.expire(); assertTrue(next.claim(owner));
|
||||
}
|
||||
@Test void expiredMenuCannotTrade() {
|
||||
UUID owner=UUID.randomUUID(); MenuSession session=new MenuSession(owner); session.expire(); assertFalse(session.claim(owner));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,13 @@ plugins { java }
|
|||
group = "com.example"
|
||||
version = "1.1.0"
|
||||
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/") }
|
||||
dependencies { compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT") }
|
||||
dependencies { compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT") }
|
||||
java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) }
|
||||
tasks.withType<JavaCompile> { options.encoding = "UTF-8" }
|
||||
tasks.processResources { from("artwork") { into("artwork") } }
|
||||
|
||||
repositories { maven("https://repo.opencollab.dev/main/") }
|
||||
dependencies { compileOnly("org.geysermc.floodgate:api:2.2.5-SNAPSHOT") }
|
||||
sourceSets.main { java.srcDir("../gui-common/src/main/java") }
|
||||
|
||||
tasks.jar { archiveFileName.set("DuneRealms-Lobby.jar") }
|
||||
|
|
|
|||
|
|
@ -202,26 +202,28 @@ public final class DuneLobby extends JavaPlugin implements Listener, CommandExec
|
|||
for(int i=0;i<LobbyBuilder.PADS.length;i++) { int[] p=LobbyBuilder.PADS[i]; if(Math.abs(x-p[0])<=3 && z>=p[1]-9 && z<=p[1]-7) { departure(e.getPlayer(),LobbyBuilder.PLANETS.get(i)); return; } }
|
||||
if(b.getType()==Material.LECTERN) {
|
||||
boolean rules=z>0; List<String> text=getConfig().getStringList(rules?"rules":"news");
|
||||
ItemStack book=new ItemStack(Material.WRITTEN_BOOK); BookMeta meta=(BookMeta)book.getItemMeta(); meta.setTitle(rules?"Guild Charter":"Guild News"); meta.setAuthor("Spacing Guild");
|
||||
meta.setPages(text.stream().map(line->ChatColor.DARK_GRAY+line).toList()); book.setItemMeta(meta); e.getPlayer().openBook(book);
|
||||
com.example.dunegui.NativeMenus.show(this,e.getPlayer(),rules?"Guild Charter":"Guild News",String.join("\n\n",text),List.of(
|
||||
new com.example.dunegui.NativeMenus.Choice("Close","",e.getPlayer()::closeInventory)));
|
||||
|
||||
}
|
||||
}
|
||||
private void departure(Player player,String planet) {
|
||||
TravelMenu menu=new TravelMenu(planet); ItemStack confirm=new ItemStack(Material.LIME_CONCRETE); ItemMeta meta=confirm.getItemMeta();
|
||||
meta.setDisplayName("Confirm departure: "+planet); meta.setLore(List.of("DuneEss fares and access rules apply when installed.")); confirm.setItemMeta(meta);
|
||||
menu.inventory.setItem(4,confirm); player.openInventory(menu.inventory);
|
||||
menu.inventory.setItem(4,confirm);
|
||||
com.example.dunegui.NativeMenus.show(this,player,"Guild departure",List.of(
|
||||
new com.example.dunegui.NativeMenus.Choice("Confirm departure: "+planet,"DuneEss fares and access rules apply.",()->depart(player,planet)),
|
||||
new com.example.dunegui.NativeMenus.Choice("Cancel","",player::closeInventory)));
|
||||
}
|
||||
@EventHandler public void menu(InventoryClickEvent e) {
|
||||
if(!(e.getView().getTopInventory().getHolder() instanceof TravelMenu menu)) return;
|
||||
e.setCancelled(true); if(e.getRawSlot()!=4 || !(e.getWhoClicked() instanceof Player player)) return;
|
||||
private void depart(Player player,String planet) {
|
||||
long now=System.currentTimeMillis(); if(now-travelCooldown.getOrDefault(player.getUniqueId(),0L)<5000) return;
|
||||
travelCooldown.put(player.getUniqueId(),now);
|
||||
Bukkit.getScheduler().runTask(this,()-> {
|
||||
player.closeInventory();
|
||||
if(Bukkit.getPluginCommand("duneess")!=null) { player.performCommand("duneess travel "+menu.planet); return; }
|
||||
World target=Bukkit.getWorld(menu.planet);
|
||||
if(Bukkit.getPluginCommand("duneess")!=null) { player.performCommand("duneess travel "+planet); return; }
|
||||
World target=Bukkit.getWorld(planet);
|
||||
if(target!=null) { player.teleport(target.getSpawnLocation()); return; }
|
||||
String server=getConfig().getString("servers."+menu.planet,"");
|
||||
String server=getConfig().getString("servers."+planet,"");
|
||||
if(server.isBlank()) { player.sendMessage("No destination configured."); return; }
|
||||
try {
|
||||
ByteArrayOutputStream bytes=new ByteArrayOutputStream(); DataOutputStream out=new DataOutputStream(bytes); out.writeUTF("Connect"); out.writeUTF(server);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
name: DuneLobby
|
||||
version: 1.1.0
|
||||
main: com.example.dunelobby.DuneLobby
|
||||
api-version: '1.21'
|
||||
api-version: '1.21.8'
|
||||
load: POSTWORLD
|
||||
softdepend: [ImageFrame, DuneEss, DuneCore]
|
||||
softdepend: [floodgate, ViaVersion, ImageFrame, DuneEss, DuneCore]
|
||||
commands:
|
||||
lobby:
|
||||
description: Return to the Spacing Guild lobby
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ repositories {
|
|||
}
|
||||
dependencies {
|
||||
compileOnly(project(":DuneCore"))
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") { exclude(group = "org.bukkit", module = "bukkit") }
|
||||
testImplementation(project(":DuneCore"))
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
|
||||
testImplementation("org.mockito:mockito-core:5.15.2")
|
||||
testRuntimeOnly("com.github.MilkBowl:VaultAPI:1.7") { exclude(group = "org.bukkit", module = "bukkit") }
|
||||
|
|
@ -20,3 +20,10 @@ dependencies {
|
|||
java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) }
|
||||
tasks.withType<JavaCompile> { options.encoding = "UTF-8" }
|
||||
tasks.test { useJUnitPlatform() }
|
||||
|
||||
tasks.jar { archiveFileName.set("DuneRealms-NPC.jar") }
|
||||
|
||||
// Explicit test instrumentation works on Java 21 without dynamic self-attachment.
|
||||
val mockitoAgent by configurations.creating
|
||||
dependencies { mockitoAgent("org.mockito:mockito-core:5.15.2") { isTransitive = false } }
|
||||
tasks.test { jvmArgs("-javaagent:${mockitoAgent.singleFile.absolutePath}") }
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
plugins { java }
|
||||
group = "com.example"
|
||||
version = "1.0.10"
|
||||
version = "1.0.11"
|
||||
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://jitpack.io") }
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
|
||||
exclude(group = "org.bukkit", module = "bukkit")
|
||||
}
|
||||
implementation("org.postgresql:postgresql:42.7.4")
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
|
||||
testImplementation("org.mockito:mockito-core:5.15.2")
|
||||
testRuntimeOnly("com.github.MilkBowl:VaultAPI:1.7") { exclude(group = "org.bukkit", module = "bukkit") }
|
||||
|
|
@ -22,3 +22,14 @@ tasks.jar {
|
|||
java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) }
|
||||
tasks.withType<JavaCompile> { options.encoding = "UTF-8" }
|
||||
tasks.test { useJUnitPlatform() }
|
||||
|
||||
repositories { maven("https://repo.opencollab.dev/main/") }
|
||||
dependencies { compileOnly("org.geysermc.floodgate:api:2.2.5-SNAPSHOT") }
|
||||
sourceSets.main { java.srcDir("../gui-common/src/main/java") }
|
||||
|
||||
tasks.jar { archiveFileName.set("DuneRealms-Core.jar") }
|
||||
|
||||
// Explicit test instrumentation works on Java 21 without dynamic self-attachment.
|
||||
val mockitoAgent by configurations.creating
|
||||
dependencies { mockitoAgent("org.mockito:mockito-core:5.15.2") { isTransitive = false } }
|
||||
tasks.test { jvmArgs("-javaagent:${mockitoAgent.singleFile.absolutePath}") }
|
||||
|
|
|
|||
|
|
@ -100,7 +100,9 @@ final class ConfigurableGui {
|
|||
}
|
||||
opened.put(p.getUniqueId(),page);
|
||||
actions.put(p.getUniqueId(),slots);
|
||||
p.openInventory(inv);
|
||||
Map<Integer,Runnable> nativeActions=new HashMap<>();
|
||||
slots.forEach((slot,action)->nativeActions.put(slot,()->execute(p,action)));
|
||||
com.example.dunegui.NativeMenus.inventory(plugin,p,title,inv,nativeActions);
|
||||
}
|
||||
void click(InventoryClickEvent e) {
|
||||
if(!(e.getWhoClicked() instanceof Player p)) return;
|
||||
|
|
|
|||
|
|
@ -307,14 +307,18 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
|
|||
armorMeta.setTrim(new ArmorTrim(material, pattern));
|
||||
}
|
||||
private void kit(Player p) {
|
||||
String faction = selected.getOrDefault(p.getUniqueId(), "Fremen");
|
||||
for (ItemStack item : createFactionKit(selected.getOrDefault(p.getUniqueId(), "Fremen"))) p.getInventory().addItem(item);
|
||||
}
|
||||
/** Shared authoritative kit factory for player rewards and fortress loot. */
|
||||
public List<ItemStack> createFactionKit(String faction) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
Color armorColor = factionArmorColor(faction);
|
||||
ItemStack shovel=custom(Material.NETHERITE_SHOVEL,"Spice Harvest Shovel","shovel");
|
||||
shovel.addUnsafeEnchantment(Enchantment.EFFICIENCY,5);
|
||||
shovel.addUnsafeEnchantment(Enchantment.UNBREAKING,3);
|
||||
p.getInventory().addItem(shovel);
|
||||
items.add(shovel);
|
||||
if (faction.equalsIgnoreCase("Ordos"))
|
||||
p.getInventory().addItem(custom(Material.WIND_CHARGE,"Ordos Implosion Charge","ordos_wind_charge"));
|
||||
items.add(custom(Material.WIND_CHARGE,"Ordos Implosion Charge","ordos_wind_charge"));
|
||||
for (Material m : new Material[]{Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS}) {
|
||||
ItemStack armor = custom(m, "Stillsuit " + m.name().toLowerCase(Locale.ROOT), "stillsuit");
|
||||
org.bukkit.inventory.meta.LeatherArmorMeta meta = (org.bukkit.inventory.meta.LeatherArmorMeta) armor.getItemMeta();
|
||||
|
|
@ -329,8 +333,9 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
|
|||
}
|
||||
if(faction.equalsIgnoreCase("Corrino"))meta.addEnchant(Enchantment.PROTECTION,3,true);
|
||||
armor.setItemMeta(meta);
|
||||
p.getInventory().addItem(armor);
|
||||
items.add(armor);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
private String fullSetFaction(Player player) {
|
||||
String faction=selected.getOrDefault(player.getUniqueId(),"").toLowerCase(Locale.ROOT);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
name: DuneCore
|
||||
version: 1.0.10
|
||||
version: 1.0.11
|
||||
main: com.example.dunerealms.DuneCore
|
||||
api-version: '1.21'
|
||||
api-version: '1.21.8'
|
||||
depend: [Vault, DuneEss]
|
||||
softdepend: [DuneTerrain, DiscordSRV]
|
||||
softdepend: [floodgate, ViaVersion, DuneTerrain, DiscordSRV]
|
||||
description: Dune factions, Arrakis gameplay, politics, and server mechanics
|
||||
commands:
|
||||
dune:
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue

Staff