Merge pull request 'Add Arrakis spice deposits, P&O buyers and staff inventory tools' (#535) from release/arrakis-worlds-spice-staff-20261123 into main
All checks were successful
DuneRealms Web CI / web (push) Successful in 2m50s
|
|
@ -92,6 +92,7 @@ public final class DuneEss extends JavaPlugin implements CommandExecutor, TabCom
|
|||
getServer().getPluginManager().registerEvents(this, this);
|
||||
basics=new EssentialsBasics(this);
|
||||
basics.register();
|
||||
StaffItemTools.start(this);
|
||||
exchangeMenu = new ExchangeMenu(this);
|
||||
exchangeMenu.register();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) economy.createPlayerAccount(player);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
package com.example.duneess;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.sql.Connection;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
/** Staff conveniences using current native recipes and the shared inventory checkpoint. */
|
||||
public final class StaffItemTools implements CommandExecutor {
|
||||
private final JavaPlugin plugin;
|
||||
public static void start(JavaPlugin plugin){var tools=new StaffItemTools(plugin);for(String name:List.of("condense","fix"))Objects.requireNonNull(plugin.getCommand(name)).setExecutor(tools);}
|
||||
private StaffItemTools(JavaPlugin plugin){this.plugin=plugin;}
|
||||
private record Compression(ItemStack result,int cost){}
|
||||
private static List<RecipeChoice> ingredients(Recipe recipe){
|
||||
if(recipe instanceof ShapedRecipe r){String[] rows=r.getShape();if(rows.length!=2&&rows.length!=3||Arrays.stream(rows).anyMatch(row->row.length()!=rows.length||row.contains(" ")))return List.of();var list=new ArrayList<RecipeChoice>();for(String row:rows)for(char c:row.toCharArray())list.add(r.getChoiceMap().get(c));return list;}
|
||||
if(recipe instanceof ShapelessRecipe r)return r.getChoiceList();return List.of();
|
||||
}
|
||||
private static boolean matches(RecipeChoice choice,ItemStack stack){return choice!=null&&choice.test(stack);}
|
||||
private Compression compression(ItemStack item)throws Exception{
|
||||
var data=item.getItemMeta().getPersistentDataContainer();String custom=data.get(new NamespacedKey("executableitems","ei-id"),PersistentDataType.STRING),legacy=data.get(new NamespacedKey("dunerealms","item"),PersistentDataType.STRING);
|
||||
var jarvis=Bukkit.getPluginManager().getPlugin("JarvisTranslator");
|
||||
if("spice".equals(legacy)||"spice".equals(custom)||"smuggled_spice".equals(custom)){var result=(ItemStack)jarvis.getClass().getMethod("compressedSpice",ItemStack.class).invoke(jarvis,item);return result==null?null:new Compression(result,9);}
|
||||
if(custom!=null||legacy!=null||data.has(new NamespacedKey("dunerealms","preview_only")))return null;
|
||||
var all=new ArrayList<Recipe>();Bukkit.recipeIterator().forEachRemaining(all::add);
|
||||
for(int cost:new int[]{9,4})for(var recipe:all){
|
||||
if(!(recipe instanceof Keyed keyed)||!keyed.getKey().getNamespace().equals("minecraft"))continue;
|
||||
var inputs=ingredients(recipe);var result=recipe.getResult();
|
||||
if(inputs.size()!=cost||result.getAmount()!=1||result.getType()==item.getType()||inputs.stream().anyMatch(c->!matches(c,item)))continue;
|
||||
// Only reversible storage recipes: never silently turn wood into workbenches.
|
||||
boolean reverse=all.stream().anyMatch(r->{var parts=ingredients(r);return parts.size()==1&&matches(parts.getFirst(),result)&&r.getResult().getType()==item.getType()&&r.getResult().getAmount()==cost;});
|
||||
if(reverse){var output=result.clone();if(jarvis!=null)jarvis.getClass().getMethod("markCreatedItem",ItemStack.class).invoke(jarvis,output);return new Compression(output,cost);}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private int condense(Player p)throws Exception{
|
||||
var inventory=p.getInventory();var contents=inventory.getStorageContents();var seen=new ArrayList<ItemStack>();int blocks=0;
|
||||
for(var sample:contents){if(sample==null||sample.isEmpty()||seen.stream().anyMatch(i->i.isSimilar(sample)))continue;seen.add(sample.clone());var rule=compression(sample);if(rule==null)continue;
|
||||
int count=Arrays.stream(contents).filter(i->i!=null&&i.isSimilar(sample)).mapToInt(ItemStack::getAmount).sum(),made=count/rule.cost();if(made==0)continue;
|
||||
var temporary=Bukkit.createInventory(null,36);temporary.setContents(Arrays.stream(contents).map(i->i==null?null:i.clone()).toArray(ItemStack[]::new));int remaining=made*rule.cost();
|
||||
for(int slot=0;slot<36&&remaining>0;slot++){var item=temporary.getItem(slot);if(item==null||!item.isSimilar(sample))continue;int take=Math.min(item.getAmount(),remaining);item.setAmount(item.getAmount()-take);temporary.setItem(slot,item.isEmpty()?null:item);remaining-=take;}
|
||||
var output=rule.result().clone();output.setAmount(made);if(!temporary.addItem(output).isEmpty())continue;
|
||||
contents=temporary.getContents();blocks+=made;
|
||||
}
|
||||
inventory.setStorageContents(contents);return blocks;
|
||||
}
|
||||
private static int repair(Player p){int count=0;for(int slot=0;slot<p.getInventory().getSize();slot++){var item=p.getInventory().getItem(slot);if(item==null)continue;var meta=item.getItemMeta();if(meta instanceof Damageable damage&&damage.getDamage()>0){damage.setDamage(0);item.setItemMeta(meta);p.getInventory().setItem(slot,item);count++;}}return count;}
|
||||
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
|
||||
if(!(sender instanceof Player p))return true;if(!p.hasPermission("dune.admin")){p.sendMessage("This command is for staff.");return true;}if(args.length!=0){p.sendMessage("/"+command.getName());return true;}
|
||||
try{var core=Bukkit.getPluginManager().getPlugin("DuneCore");if(core==null||!core.isEnabled())throw new IllegalStateException("Shared inventory unavailable. Nothing changed.");int[] count={0};Consumer<Connection> action=connection->{try{count[0]=command.getName().equals("fix")?repair(p):condense(p);}catch(Exception e){throw new java.util.concurrent.CompletionException(e);}};core.getClass().getMethod("transactNetworkInventory",Player.class,Consumer.class).invoke(core,p,action);p.sendMessage(command.getName().equals("fix")?"Repaired "+count[0]+" items.":"Created "+count[0]+" condensed items.");}
|
||||
catch(Exception e){Throwable cause=e instanceof InvocationTargetException?e.getCause():e;plugin.getLogger().warning("Staff inventory operation failed: "+cause.getClass().getSimpleName());p.sendMessage("Inventory operation could not be confirmed. Reopen your inventory before retrying.");}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,12 @@ softdepend: [floodgate, ViaVersion, DuneCore, DuneTerrain]
|
|||
prefix: DuneRealms Essentials
|
||||
description: DuneRealms Essentials - Dunemarks economy, Vault provider, spice sales, and Arrakduin travel
|
||||
commands:
|
||||
condense:
|
||||
description: Compress matching resources into storage blocks
|
||||
permission: dune.admin
|
||||
fix:
|
||||
description: Repair every damaged item in your inventory and equipment
|
||||
permission: dune.admin
|
||||
communitycode:
|
||||
description: Claim one community currency reward per UUID and monthly goal
|
||||
usage: /communitycode <code>
|
||||
|
|
|
|||
|
|
@ -863,12 +863,19 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
|
|||
private ItemStack spiceDrop(Player miner, int amount) {
|
||||
ItemStack spice = custom(Material.ORANGE_DYE, "Melange Spice", "spice").asQuantity(amount);
|
||||
ItemMeta meta = spice.getItemMeta();
|
||||
String faction = selected.getOrDefault(miner.getUniqueId(), "Unaffiliated");
|
||||
meta.setLore(List.of(ChatColor.GOLD + "Price: " + spiceSellPrice() + " Solaris each",
|
||||
ChatColor.GRAY + "Mined by: " + miner.getName() + " ; faction: " + faction));
|
||||
meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","origin_world"),PersistentDataType.STRING,"arrakis");
|
||||
meta.setLore(List.of(ChatColor.GRAY+"Harvested from the sands of Arrakis.",ChatColor.DARK_AQUA+"Herkomstwereld: "+ChatColor.GRAY+"Arrakis"));
|
||||
spice.setItemMeta(meta);
|
||||
return spice;
|
||||
}
|
||||
private ItemStack spiceDrop(Player miner,int amount,Location minedAt){return createMinedSpice(miner,amount,minedAt,false);}
|
||||
public ItemStack createMinedSpice(Player miner,int amount,Location minedAt){return createMinedSpice(miner,amount,minedAt,false);}
|
||||
public ItemStack createMinedSpice(Player miner,int amount,Location minedAt,boolean dense){
|
||||
if(miner==null||amount<1||amount>64)throw new IllegalArgumentException("Valid miner and stack amount required");
|
||||
// Raw Melange is one commodity; miner, authorisation and deposit density
|
||||
// cannot split its stack metadata. Mining provenance stays in CoreProtect.
|
||||
return spiceDrop(miner,amount);
|
||||
}
|
||||
private boolean isWorm(Entity entity) {
|
||||
return entity.getPersistentDataContainer().has(wormKey, PersistentDataType.BYTE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ sandworms:
|
|||
spice-raiders:
|
||||
enabled: true
|
||||
max-per-world: 12
|
||||
chance-per-player-check: 0.08
|
||||
chance-near-rich-field: 0.45
|
||||
chance-per-player-check: 0.04
|
||||
chance-near-rich-field: 0.225
|
||||
field-radius: 32
|
||||
field-value-threshold: 5000
|
||||
health: 36.0
|
||||
|
|
|
|||
12
DuneRealmsGUI/assets/menu/spice-portraits.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"guild_navigator": {
|
||||
"cell": 6,
|
||||
"file": "spice_guild.png"
|
||||
},
|
||||
"esmar_tuek": {
|
||||
"file": "spice_smuggler.png",
|
||||
"state": "existing-profile-placeholder",
|
||||
"cell": 7
|
||||
},
|
||||
"source": "website/web/assets/mentat-portraits-atlas-v1.png"
|
||||
}
|
||||
BIN
DuneRealmsGUI/assets/menu/spice_guild.png
Normal file
|
After Width: | Height: | Size: 390 KiB |
BIN
DuneRealmsGUI/assets/menu/spice_smuggler.png
Normal file
|
After Width: | Height: | Size: 279 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "1.1.23"
|
||||
version = "1.1.24"
|
||||
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") }
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
|
|
|
|||
BIN
DuneRealmsGUI/ecology/dr_smuggler_shovel.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
DuneRealmsGUI/ecology/dune_camel.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
DuneRealmsGUI/ecology/dune_camel_baby.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
DuneRealmsGUI/ecology/polluted_refined_smuggled_spice.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
DuneRealmsGUI/ecology/refined_smuggled_spice.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
DuneRealmsGUI/ecology/smuggled_spice.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
DuneRealmsGUI/ecology/spice_block.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
29
DuneRealmsGUI/executablecrafting/recipes/jerboa_leather.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"recipeType": "CRAFTING",
|
||||
"typeOfCraftingTableRecipe": "SHAPELESS",
|
||||
"input1": "minecraft:rabbit_hide[minecraft:custom_data={\"PublicBukkitValues\":{\"executableitems:ei-id\":\"jerboa_hide\",\"score:usage\":-1,\"dunerealms:quality\":\"common\",\"dunerealms:equipment_mark\":\"1\",\"dunerealms:item_class\":\"resource\",\"dunerealms:metadata_policy\":\"s1-item-metadata-v1\"}},minecraft:custom_name={\"text\":\"Jerboa hide\",\"color\":\"white\",\"italic\":false},minecraft:lore=[{\"text\":\"COMMON | MK I\",\"color\":\"gray\",\"italic\":false},{\"text\":\"S1 · ARRAKIS\",\"color\":\"gray\",\"italic\":false}]]",
|
||||
"input2": "minecraft:rabbit_hide[minecraft:custom_data={\"PublicBukkitValues\":{\"executableitems:ei-id\":\"jerboa_hide\",\"score:usage\":-1,\"dunerealms:quality\":\"common\",\"dunerealms:equipment_mark\":\"1\",\"dunerealms:item_class\":\"resource\",\"dunerealms:metadata_policy\":\"s1-item-metadata-v1\"}},minecraft:custom_name={\"text\":\"Jerboa hide\",\"color\":\"white\",\"italic\":false},minecraft:lore=[{\"text\":\"COMMON | MK I\",\"color\":\"gray\",\"italic\":false},{\"text\":\"S1 · ARRAKIS\",\"color\":\"gray\",\"italic\":false}]]",
|
||||
"input3": "minecraft:rabbit_hide[minecraft:custom_data={\"PublicBukkitValues\":{\"executableitems:ei-id\":\"jerboa_hide\",\"score:usage\":-1,\"dunerealms:quality\":\"common\",\"dunerealms:equipment_mark\":\"1\",\"dunerealms:item_class\":\"resource\",\"dunerealms:metadata_policy\":\"s1-item-metadata-v1\"}},minecraft:custom_name={\"text\":\"Jerboa hide\",\"color\":\"white\",\"italic\":false},minecraft:lore=[{\"text\":\"COMMON | MK I\",\"color\":\"gray\",\"italic\":false},{\"text\":\"S1 · ARRAKIS\",\"color\":\"gray\",\"italic\":false}]]",
|
||||
"input4": "minecraft:rabbit_hide[minecraft:custom_data={\"PublicBukkitValues\":{\"executableitems:ei-id\":\"jerboa_hide\",\"score:usage\":-1,\"dunerealms:quality\":\"common\",\"dunerealms:equipment_mark\":\"1\",\"dunerealms:item_class\":\"resource\",\"dunerealms:metadata_policy\":\"s1-item-metadata-v1\"}},minecraft:custom_name={\"text\":\"Jerboa hide\",\"color\":\"white\",\"italic\":false},minecraft:lore=[{\"text\":\"COMMON | MK I\",\"color\":\"gray\",\"italic\":false},{\"text\":\"S1 · ARRAKIS\",\"color\":\"gray\",\"italic\":false}]]",
|
||||
"result": "minecraft:leather",
|
||||
"itemCheckers": {
|
||||
"itemCheckerType": "CUSTOM_CHECKS",
|
||||
"checkAmount": false,
|
||||
"checkDisplayName": false,
|
||||
"checkMaterial": true,
|
||||
"checkCustomModelData": false,
|
||||
"checkLore": false,
|
||||
"checkDurability": false,
|
||||
"checkExecutableItemID": true,
|
||||
"checkExecutableItemUsage": false,
|
||||
"checkExecutableItemVariables": false
|
||||
},
|
||||
"playerConditions": {},
|
||||
"blockConditions": {
|
||||
"requiredItems": {},
|
||||
"requiredExecutableItems": {}
|
||||
},
|
||||
"placeholdersConditions": {},
|
||||
"playerCommands": [],
|
||||
"config_update": true
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"recipeType": "CRAFTING",
|
||||
"typeOfCraftingTableRecipe": "SHAPELESS",
|
||||
"input1": "minecraft:cooked_rabbit[minecraft:custom_data={\"PublicBukkitValues\":{\"executableitems:ei-id\":\"jerboa_cooked_meat\",\"score:usage\":-1,\"dunerealms:quality\":\"rare\",\"dunerealms:equipment_mark\":\"6\",\"dunerealms:item_class\":\"consumable\",\"dunerealms:metadata_policy\":\"s1-item-metadata-v1\"}},minecraft:custom_name={\"text\":\"Cooked Jerboa meat\",\"color\":\"blue\",\"italic\":false},minecraft:lore=[{\"text\":\"RARE | MK VI\",\"color\":\"gray\",\"italic\":false},{\"text\":\"S1 · ARRAKIS\",\"color\":\"gray\",\"italic\":false}]]",
|
||||
"input2": "minecraft:carrot",
|
||||
"input3": "minecraft:baked_potato",
|
||||
"input4": "minecraft:orange_dye[minecraft:custom_data={\"PublicBukkitValues\":{\"executableitems:ei-id\":\"polluted_refined_smuggled_spice\",\"score:usage\":-1,\"dunerealms:quality\":\"rare\",\"dunerealms:equipment_mark\":\"3\",\"dunerealms:item_class\":\"resource\",\"dunerealms:metadata_policy\":\"s1-item-metadata-v1\"}},minecraft:custom_name={\"text\":\"Contaminated spice\",\"color\":\"blue\",\"italic\":false},minecraft:lore=[{\"text\":\"RARE | MK III\",\"color\":\"gray\",\"italic\":false},{\"text\":\"S1 · ARRAKIS\",\"color\":\"gray\",\"italic\":false}]]",
|
||||
"input5": "minecraft:bowl",
|
||||
"result": "minecraft:rabbit_stew[minecraft:custom_data={\"PublicBukkitValues\":{\"executableitems:ei-id\":\"jerboa_stew\",\"score:usage\":-1,\"dunerealms:quality\":\"very_rare\",\"dunerealms:equipment_mark\":\"9\",\"dunerealms:item_class\":\"consumable\",\"dunerealms:metadata_policy\":\"s1-item-metadata-v1\"}},minecraft:custom_name={\"text\":\"Jerboa stew\",\"color\":\"dark_purple\",\"italic\":false},minecraft:lore=[{\"text\":\"VERY RARE | MK IX\",\"color\":\"gray\",\"italic\":false},{\"text\":\"S1 · ARRAKIS\",\"color\":\"gray\",\"italic\":false},{\"text\":\"Jerboa meat, enriched with contaminated spice.\",\"color\":\"gray\",\"italic\":false}]]",
|
||||
"itemCheckers": {
|
||||
"itemCheckerType": "CUSTOM_CHECKS",
|
||||
"checkAmount": false,
|
||||
"checkDisplayName": false,
|
||||
"checkMaterial": true,
|
||||
"checkCustomModelData": false,
|
||||
"checkLore": false,
|
||||
"checkDurability": false,
|
||||
"checkExecutableItemID": true,
|
||||
"checkExecutableItemUsage": false,
|
||||
"checkExecutableItemVariables": false
|
||||
},
|
||||
"playerConditions": {},
|
||||
"blockConditions": {
|
||||
"requiredItems": {},
|
||||
"requiredExecutableItems": {}
|
||||
},
|
||||
"placeholdersConditions": {},
|
||||
"playerCommands": [],
|
||||
"config_update": true
|
||||
}
|
||||
29
DuneRealmsGUI/executableitems/arrakis/dr_smuggler_shovel.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "&aSmuggler Shovel",
|
||||
"material": "WOODEN_SHOVEL",
|
||||
"lore": [
|
||||
"&aUNCOMMON | MK I &7S1 · ARRAKIS"
|
||||
],
|
||||
"glow": false,
|
||||
"disableStack": false,
|
||||
"keepItemOnDeath": false,
|
||||
"storeItemInfo": false,
|
||||
"canBeUsedOnlyByTheOwner": false,
|
||||
"cancelEventIfNoPermission": false,
|
||||
"config_5": true,
|
||||
"config_update": false,
|
||||
"usageFeatures": {
|
||||
"usage": -1,
|
||||
"isRefreshableClean": false,
|
||||
"usageLimit": -1
|
||||
},
|
||||
"hiders": {
|
||||
"hideUsage": true
|
||||
},
|
||||
"giveFirstJoinFeatures": {
|
||||
"giveFirstJoin": false
|
||||
},
|
||||
"activators": {},
|
||||
"variables": {},
|
||||
"itemModel": "dunerealms:ecology/dr_smuggler_shovel"
|
||||
}
|
||||
|
|
@ -28,8 +28,8 @@
|
|||
"variables": {},
|
||||
"foodFeatures": {
|
||||
"isMeat": true,
|
||||
"nutrition": 5,
|
||||
"saturation": 6,
|
||||
"nutrition": 6,
|
||||
"saturation": 14,
|
||||
"canAlwaysEat": false
|
||||
},
|
||||
"consumableFeatures": {
|
||||
|
|
|
|||

Staff