Offer required network artwork only in Spacing Guild lobby
This commit is contained in:
parent
15417bab45
commit
aecfcb5fa6
8 changed files with 38 additions and 28 deletions
|
|
@ -1,6 +1,6 @@
|
|||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "1.1.24"
|
||||
version = "1.1.25"
|
||||
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")
|
||||
|
|
|
|||
17
DuneRealmsGUI/network-artwork.json
Normal file
17
DuneRealmsGUI/network-artwork.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"version": 1,
|
||||
"url": "https://www.dunerealms.com/downloads/DuneRealms-Network-Artwork-v1.zip",
|
||||
"sha1": "f1bc7d4851f1b361f14f96d260d5a91f769aa966",
|
||||
"sha256": "56071a96d6ea9b117ea5cf2c8a76c5dd4c1f471bf840992345f5d1b234cb5b44",
|
||||
"delivery": "Lobby only; native MCGUI renderer remains a separate lobby layer",
|
||||
"sources": [
|
||||
"DuneRealms-GUI-Houses-1.21.8-v8.zip",
|
||||
"DuneRealms-Ecology-Items-v2.zip",
|
||||
"DuneRealms-Arrakis-Creatures-v3.zip"
|
||||
],
|
||||
"builder": "tools/build-network-artwork-pack.py",
|
||||
"creatureCarriers": {
|
||||
"jerboa": "GOLD rabbit",
|
||||
"wormPet": "SNOWY wolf"
|
||||
}
|
||||
}
|
||||
|
|
@ -43,11 +43,11 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
private final Set<UUID> boarding=new HashSet<>();
|
||||
private final Set<UUID> guiPackLoaded=new HashSet<>();
|
||||
private record Pack(UUID id,String url,String hash){}
|
||||
private static final Pack DEFAULT_PACK=new Pack(UUID.fromString("a7b5ab7d-d8d8-5b51-b016-71a5f4c00008"),"https://www.dunerealms.com/downloads/DuneRealms-GUI-Houses-1.21.8-v8.zip","e4612a6ba0a95d1f031298a0d0a666e7fa2f109f");
|
||||
private static final Pack DEFAULT_PACK=new Pack(UUID.fromString("a7b5ab7d-d8d8-5b51-b016-71a5f4c00008"),"https://www.dunerealms.com/downloads/DuneRealms-Network-Artwork-v1.zip","f1bc7d4851f1b361f14f96d260d5a91f769aa966");
|
||||
private Pack guiPack(){
|
||||
var file=new java.io.File(getDataFolder(),"gui-pack.yml");if(!file.isFile())return DEFAULT_PACK;
|
||||
var data=org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(file);
|
||||
try{String url=data.getString("url",""),hash=data.getString("sha1","");if(!url.matches("https://www\\.dunerealms\\.com/downloads/DuneRealms-GUI-Houses-1\\.21\\.8-v[0-9]+\\.zip")||!hash.matches("[0-9a-f]{40}"))throw new IllegalArgumentException();return new Pack(UUID.fromString(data.getString("id","")),url,hash);}
|
||||
try{String url=data.getString("url",""),hash=data.getString("sha1","");if(!url.matches("https://www\\.dunerealms\\.com/downloads/DuneRealms-(?:GUI-Houses-1\\.21\\.8|Network-Artwork)-v[0-9]+\\.zip")||!hash.matches("[0-9a-f]{40}"))throw new IllegalArgumentException();return new Pack(UUID.fromString(data.getString("id","")),url,hash);}
|
||||
catch(IllegalArgumentException invalid){getLogger().warning("Invalid gui-pack.yml; using the bundled pack definition.");return DEFAULT_PACK;}
|
||||
}
|
||||
private long lastDepartureNotice=-1;
|
||||
|
|
@ -174,8 +174,9 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
@EventHandler(priority=EventPriority.HIGHEST) public void oldNavigator(PlayerInteractEvent e){if(e.getHand()!=EquipmentSlot.HAND||e.getItem()==null||!e.getItem().hasItemMeta()||!e.getAction().isRightClick())return;var data=e.getItem().getItemMeta().getPersistentDataContainer();for(var key:data.getKeys())if(data.has(key,PersistentDataType.STRING)&&"menu_opener".equals(data.get(key,PersistentDataType.STRING))){e.setCancelled(true);organisations.console(e.getPlayer());return;}}
|
||||
@EventHandler(priority=EventPriority.LOWEST,ignoreCancelled=true) public void legacyTravel(PlayerCommandPreprocessEvent e){String[] args=e.getMessage().substring(1).trim().toLowerCase(Locale.ROOT).split("\\s+");String label=args[0].replaceFirst("^[^:]+:","");if(label.equals("balance")||label.equals("bal")||label.equals("money")){e.setCancelled(true);if(!sidebar.enabled(e.getPlayer()))sidebar.toggle(e.getPlayer());refreshSidebar(e.getPlayer());return;}if(label.equals("exchange")){e.setCancelled(true);exchange.open(e.getPlayer());return;}if(label.equals("server")||label.equals("duneess")&&args.length>1&&args[1].equals("travel")){e.setCancelled(true);openGuild(e.getPlayer(),null);}}
|
||||
private void offerGuiPack(Player p){
|
||||
if(!lobby(p)){p.sendMessage("Visit Spacing Guild lobby to update your DuneRealms artwork.");return;}
|
||||
guiPackLoaded.remove(p.getUniqueId());
|
||||
var pack=guiPack();p.addResourcePack(pack.id(),pack.url(),java.util.HexFormat.of().parseHex(pack.hash()),"DuneRealms menus and item artwork",false);
|
||||
var pack=guiPack();p.addResourcePack(pack.id(),pack.url(),java.util.HexFormat.of().parseHex(pack.hash()),"DuneRealms menus and item artwork",true);
|
||||
MCGUIMenus.offerPack(p);
|
||||
ecologyArtwork.offer(p);
|
||||
}
|
||||
|
|
@ -183,8 +184,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
Player p=e.getPlayer();if(!p.isOnline())return;
|
||||
// Offer once in the play phase too: configuration-phase pack loading may finish
|
||||
// before the ordinary Bukkit player status event is available. The hash reuses cache.
|
||||
if(!BedrockForms.isBedrock(p)&&!guiPackLoaded.contains(p.getUniqueId()))offerGuiPack(p);
|
||||
else ecologyArtwork.offer(p);
|
||||
if(lobby(p)&&!BedrockForms.isBedrock(p)){if(!guiPackLoaded.contains(p.getUniqueId()))offerGuiPack(p);else ecologyArtwork.offer(p);}
|
||||
giveCodex(p,false);
|
||||
if(sidebar.enabled(p))refreshSidebar(p);
|
||||
},40L);}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,21 @@
|
|||
package com.dunerealms.gui;
|
||||
|
||||
import java.util.HexFormat;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/** Independent pack layers: carried items are global; creature skins are Arrakis-only. */
|
||||
/** Removes retired ecology layers in lobby; artwork is now one network bundle. */
|
||||
final class EcologyArtwork implements Listener {
|
||||
private static final UUID ITEMS=UUID.fromString("d41ca73d-9fa0-51f1-8a71-74b2cf3ea001"),CREATURES=UUID.fromString("d41ca73d-9fa0-51f1-8a71-74b2cf3ea002");
|
||||
private final Plugin plugin;
|
||||
EcologyArtwork(Plugin plugin){this.plugin=plugin;Bukkit.getPluginManager().registerEvents(this,plugin);Bukkit.getScheduler().runTaskLater(plugin,()->Bukkit.getOnlinePlayers().forEach(this::offer),40L);}
|
||||
void offer(Player player){
|
||||
if(!player.isOnline()||BedrockForms.isBedrock(player))return;
|
||||
player.addResourcePack(ITEMS,"https://www.dunerealms.com/downloads/DuneRealms-Ecology-Items-v2.zip",HexFormat.of().parseHex("66eda26411af8609556e5c06578258c3d6ffdade"),"DuneRealms Jerboa item artwork",false);
|
||||
creatures(player);
|
||||
if(!player.isOnline()||BedrockForms.isBedrock(player)||!player.getWorld().getName().equals("guild_lobby"))return;
|
||||
player.removeResourcePack(ITEMS);player.removeResourcePack(CREATURES);
|
||||
}
|
||||
private void creatures(Player player){
|
||||
if(!player.isOnline()||BedrockForms.isBedrock(player))return;
|
||||
// Resource packs survive proxy transfers. Remove this exact layer on every
|
||||
// other planet; never clear the GUI, MCGUI or carried-item packs.
|
||||
if(!player.getWorld().getName().equalsIgnoreCase("arrakis")){player.removeResourcePack(CREATURES);return;}
|
||||
player.addResourcePack(CREATURES,"https://www.dunerealms.com/downloads/DuneRealms-Arrakis-Creatures-v3.zip",HexFormat.of().parseHex("ebfc67c1d226aabcd3123133535d5500c80b1adf"),"Arrakis Jerboa, camel and worm-pet skins",false);
|
||||
}
|
||||
@EventHandler public void world(PlayerChangedWorldEvent event){creatures(event.getPlayer());}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ final class MCGUIMenus implements AutoCloseable {
|
|||
Class<?> canvas=Class.forName("ai.resourcepack.ui.framework.api.Canvas",true,cl);draw=canvas.getMethod("draw",java.awt.image.BufferedImage.class,int.class,int.class);
|
||||
packId=(UUID)Class.forName("ai.resourcepack.ui.framework.pack.ResourcePack",true,cl).getField("PACK_ID").get(null);
|
||||
packUrl=engine.getConfig().getString("resource-pack.public-url","");
|
||||
// MC GUI external-without-URL means the pack was delivered by lobby.
|
||||
if(packUrl.isBlank())packUrl="https://www.dunerealms.com/downloads/DuneRealms-MCGUI-0.8.6-1.21.11.zip";
|
||||
if(!packUrl.startsWith("https://"))throw new IllegalStateException("A hosted menu pack URL is required");
|
||||
packHash=java.security.MessageDigest.getInstance("SHA-1").digest(Files.readAllBytes(engine.getDataFolder().toPath().resolve("pack.zip")));
|
||||
active=this;plugin.getLogger().info("MC GUI presentation connected for all DuneRealms menus; Jarvis callbacks retained.");
|
||||
|
|
@ -46,10 +48,10 @@ final class MCGUIMenus implements AutoCloseable {
|
|||
return active!=null&&active.present(p,title,description,inventory,actions,gate);
|
||||
}
|
||||
static void offerPack(Player p){if(active!=null&&!BedrockForms.isBedrock(p))active.sendPack(p);}
|
||||
private void sendPack(Player p){p.addResourcePack(packId,packUrl,packHash,"DuneRealms interactive menus",false);}
|
||||
private void sendPack(Player p){if(!p.getWorld().getName().equals("guild_lobby"))return;p.addResourcePack(packId,packUrl,packHash,"DuneRealms interactive menus",true);}
|
||||
private boolean present(Player p,String title,String description,Inventory inventory,Map<Integer,Runnable> actions,GuiSession suppliedGate){
|
||||
if(framework==null||!engine.isEnabled()||!p.isOnline()||BedrockForms.isBedrock(p))return false;
|
||||
try{if(!Boolean.TRUE.equals(hasPack.invoke(framework,p))){sendPack(p);p.sendMessage("Loading the new menu pack. Accept it, then use /menu again.");return true;}}catch(Exception e){p.sendMessage("The new menu is temporarily unavailable. Please retry /menu.");return true;}
|
||||
try{if(!Boolean.TRUE.equals(hasPack.invoke(framework,p))){if(p.getWorld().getName().equals("guild_lobby")){sendPack(p);p.sendMessage("Loading the lobby menu artwork. Reopen your menu after loading.");}else p.sendMessage("Visit Spacing Guild lobby to update your menu artwork.");return true;}}catch(Exception e){p.sendMessage("The new menu is temporarily unavailable. Please retry /menu.");return true;}
|
||||
List<MenuDocument.Card> cards=new ArrayList<>();Set<Runnable> aliases=Collections.newSetFromMap(new IdentityHashMap<>());Set<String> decorations=new HashSet<>(),transparent=new HashSet<>();
|
||||
var plain=PlainTextComponentSerializer.plainText();
|
||||
for(int slot=0;slot<inventory.getSize();slot++){
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ final class SpiceMenus implements Listener {
|
|||
void open(Player p){open(p,null);}
|
||||
void open(Player p,String selected){call(p,action("read"),data->{if(!arrakis(p))return;var panel=new Panel(p);var policy=data.getAsJsonObject("policy");boolean smuggler=data.get("smugglerEnabled").getAsBoolean();int count;try{count=bridge.spiceCount(p,"guild");}catch(Exception e){p.sendMessage("Spice inventory unavailable.");return;}
|
||||
put(panel,4,Material.ORANGE_DYE,"Melange Spice",count+" raw-spice units (1 block = 9)\nP&O pays your personal bank account",null,null);
|
||||
put(panel,11,Material.PLAYER_HEAD,"Spacing Guild",money(policy.get("guild").getAsLong())+" per spice before Trust levy\nGuild Navigator\nReview your sale",()->review(p,"guild"),"spice_guild");
|
||||
put(panel,11,Material.PLAYER_HEAD,"Spacing Guild · Navigator",money(policy.get("guild").getAsLong())+" per spice before Trust levy\nGuild Navigator\nReview your sale",()->review(p,"guild"),"spice_guild");
|
||||
put(panel,15,smuggler?Material.PLAYER_HEAD:Material.BARRIER,"Smuggler · Esmar Tuek",money(policy.get("smuggler").getAsLong())+" per spice before Trust levy\n"+(smuggler?"Contraband spice only · Smuggler quest verified":"Locked · start a Smuggler quest"),smuggler?()->review(p,"smuggler"):null,"spice_smuggler");
|
||||
put(panel,26,Material.GOLD_INGOT,"Collect pending payments","Retry committed P&O spice payments",()->recover(p),null);
|
||||
put(panel,22,Material.ARROW,"Back","Imperial Codex",()->back.accept(p),null);show(p,panel);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name: DunerealmsGUI
|
||||
main: com.dunerealms.gui.DuneGUI
|
||||
version: 1.1.24
|
||||
version: 1.1.25
|
||||
api-version: '1.21.8'
|
||||
depend: [JarvisTranslator]
|
||||
softdepend: [MCGUI, DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public final class ArrakisEcology implements Listener {
|
|||
private void spawnBloomPet(Location location){
|
||||
var chunk=location.getChunk();var marker=new NamespacedKey(plugin,"worm_bloom_"+location.getBlockX()+"_"+location.getBlockY()+"_"+location.getBlockZ());if(chunk.getPersistentDataContainer().has(marker,PersistentDataType.BYTE))return;
|
||||
for(int[] offset:new int[][]{{3,0},{-3,0},{0,3},{0,-3},{4,4}}){int x=location.getBlockX()+offset[0],z=location.getBlockZ()+offset[1];World world=location.getWorld();if(!world.isChunkLoaded(x>>4,z>>4))continue;int y=world.getHighestBlockYAt(x,z);var ground=world.getBlockAt(x,y,z);if(!ground.getType().isSolid()||Set.of(Material.MAGMA_BLOCK,Material.CACTUS,Material.CAMPFIRE,Material.SOUL_CAMPFIRE).contains(ground.getType())||!world.getBlockAt(x,y+1,z).isPassable()||!world.getBlockAt(x,y+2,z).isPassable())continue;
|
||||
world.spawn(new Location(world,x+.5,y+1,z+.5),Wolf.class,w->{w.getPersistentDataContainer().set(PET,PersistentDataType.BYTE,(byte)1);w.setBaby();w.setRemoveWhenFarAway(false);w.customName(Component.text("Tiny worm",NamedTextColor.GOLD));});chunk.getPersistentDataContainer().set(marker,PersistentDataType.BYTE,(byte)1);return;
|
||||
world.spawn(new Location(world,x+.5,y+1,z+.5),Wolf.class,w->{w.getPersistentDataContainer().set(PET,PersistentDataType.BYTE,(byte)1);w.setVariant(Wolf.Variant.SNOWY);w.setBaby();w.setRemoveWhenFarAway(false);w.customName(Component.text("Tiny worm",NamedTextColor.GOLD));});chunk.getPersistentDataContainer().set(marker,PersistentDataType.BYTE,(byte)1);return;
|
||||
}
|
||||
}
|
||||
private static void consume(Player p,EquipmentSlot hand){if(p.getGameMode()==GameMode.CREATIVE)return;var inv=p.getInventory();var item=inv.getItem(hand);if(item!=null){item.setAmount(item.getAmount()-1);inv.setItem(hand,item);}}
|
||||
|
|
@ -69,12 +69,12 @@ public final class ArrakisEcology implements Listener {
|
|||
}
|
||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true) public void breed(EntityBreedEvent event){
|
||||
if(!(event.getEntity() instanceof Wolf child)||!arrakis(child)||!pet(event.getMother())||!pet(event.getFather()))return;
|
||||
var mother=(Wolf)event.getMother();child.getPersistentDataContainer().set(PET,PersistentDataType.BYTE,(byte)1);child.setOwner(mother.getOwner());child.setBaby();child.setRemoveWhenFarAway(false);child.customName(Component.text("Tiny worm",NamedTextColor.GOLD));
|
||||
var mother=(Wolf)event.getMother();child.getPersistentDataContainer().set(PET,PersistentDataType.BYTE,(byte)1);child.setOwner(mother.getOwner());child.setVariant(Wolf.Variant.SNOWY);child.setBaby();child.setRemoveWhenFarAway(false);child.customName(Component.text("Tiny worm",NamedTextColor.GOLD));
|
||||
}
|
||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true) public void suffocation(EntityDamageEvent event){if(pet(event.getEntity())&&event.getCause()==EntityDamageEvent.DamageCause.SUFFOCATION)event.setCancelled(true);}
|
||||
private static void modifier(Wolf wolf,Attribute attribute,NamespacedKey key,boolean enabled){var instance=wolf.getAttribute(attribute);if(instance==null)return;var old=instance.getModifier(key);if(enabled&&old==null)instance.addModifier(new AttributeModifier(key,.25,AttributeModifier.Operation.ADD_SCALAR));else if(!enabled&&old!=null)instance.removeModifier(old);}
|
||||
private static void water(Wolf wolf,long now){boolean fresh=wolf.getPersistentDataContainer().getOrDefault(BOOST,PersistentDataType.LONG,0L)<=now;double before=wolf.getHealth();wolf.getPersistentDataContainer().set(BOOST,PersistentDataType.LONG,now+90000);modifier(wolf,Attribute.ATTACK_DAMAGE,DAMAGE,true);modifier(wolf,Attribute.MAX_HEALTH,HEALTH,true);if(fresh)wolf.setHealth(Math.min(wolf.getAttribute(Attribute.MAX_HEALTH).getValue(),before*1.25));var old=wolf.getPotionEffect(PotionEffectType.REGENERATION);if(old==null||old.getAmplifier()==0)wolf.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,1800,0));}
|
||||
private static void restoreWater(Wolf wolf){long until=wolf.getPersistentDataContainer().getOrDefault(BOOST,PersistentDataType.LONG,0L),remaining=until-System.currentTimeMillis();boolean active=remaining>0;modifier(wolf,Attribute.ATTACK_DAMAGE,DAMAGE,active);modifier(wolf,Attribute.MAX_HEALTH,HEALTH,active);var regen=wolf.getPotionEffect(PotionEffectType.REGENERATION);if(active&&(regen==null||regen.getAmplifier()==0))wolf.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,(int)Math.min(1800,Math.max(1,(remaining+49)/50)),0),true);if(!active){if(until>0&®en!=null&®en.getAmplifier()==0)wolf.removePotionEffect(PotionEffectType.REGENERATION);wolf.getPersistentDataContainer().remove(BOOST);wolf.setHealth(Math.min(wolf.getHealth(),wolf.getAttribute(Attribute.MAX_HEALTH).getValue()));}}
|
||||
private static void restoreWater(Wolf wolf){if(wolf.getVariant()!=Wolf.Variant.SNOWY)wolf.setVariant(Wolf.Variant.SNOWY);long until=wolf.getPersistentDataContainer().getOrDefault(BOOST,PersistentDataType.LONG,0L),remaining=until-System.currentTimeMillis();boolean active=remaining>0;modifier(wolf,Attribute.ATTACK_DAMAGE,DAMAGE,active);modifier(wolf,Attribute.MAX_HEALTH,HEALTH,active);var regen=wolf.getPotionEffect(PotionEffectType.REGENERATION);if(active&&(regen==null||regen.getAmplifier()==0))wolf.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,(int)Math.min(1800,Math.max(1,(remaining+49)/50)),0),true);if(!active){if(until>0&®en!=null&®en.getAmplifier()==0)wolf.removePotionEffect(PotionEffectType.REGENERATION);wolf.getPersistentDataContainer().remove(BOOST);wolf.setHealth(Math.min(wolf.getHealth(),wolf.getAttribute(Attribute.MAX_HEALTH).getValue()));}}
|
||||
@EventHandler(priority=EventPriority.HIGHEST) public void death(EntityDeathEvent event){
|
||||
var entity=event.getEntity();if(!arrakis(entity))return;
|
||||
try{
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff