Finish NPC and preview routing and retire old GUI release files

This commit is contained in:
unimatrixgit 2026-11-28 21:03:47 +01:00
commit ef7163ac96

View file

@ -16,7 +16,7 @@ public final class SmugglerQuestBridge {
private static final NamespacedKey GUILD=new NamespacedKey("dunerealms","guild"),CHARACTER=new NamespacedKey("dunerealms","quest_character");
private SmugglerQuestBridge(){}
/** The normal service click is unchanged. Sneak-click opens the corresponding quest dialogue. */
public static boolean questInteraction(PlayerInteractEntityEvent event){if(event.getHand()!=EquipmentSlot.HAND||!event.getPlayer().isSneaking())return false;var data=event.getRightClicked().getPersistentDataContainer();String role=data.has(GUILD,PersistentDataType.BYTE)?"guild_navigator":"esmar_tuek".equals(data.get(CHARACTER,PersistentDataType.STRING))?"esmar_tuek":null;if(role==null)return false;if(event.isCancelled())return true;var gui=Bukkit.getPluginManager().getPlugin("DunerealmsGUI");if(gui==null||!gui.isEnabled())return false;try{gui.getClass().getMethod("openNativeQuestContact",Player.class,String.class).invoke(gui,event.getPlayer(),role);event.setCancelled(true);return true;}catch(ReflectiveOperationException unavailable){return false;}}
public static boolean questInteraction(PlayerInteractEntityEvent event){if(event.getHand()!=EquipmentSlot.HAND||!event.getPlayer().isSneaking())return false;var data=event.getRightClicked().getPersistentDataContainer();String role=data.has(GUILD,PersistentDataType.BYTE)?"guild_navigator":"esmar_tuek".equals(data.get(CHARACTER,PersistentDataType.STRING))?"esmar_tuek":null;if(role==null)return false;if(event.isCancelled())return true;var gui=Bukkit.getPluginManager().getPlugin("DuneMenus");if(gui==null||!gui.isEnabled())return false;try{gui.getClass().getMethod("openNativeQuestContact",Player.class,String.class).invoke(gui,event.getPlayer(),role);event.setCancelled(true);return true;}catch(ReflectiveOperationException unavailable){return false;}}
public static boolean spongeCargo(ItemStack item,String commodity){return "water".equals(commodity)&&item!=null&&item.getType()==Material.WET_SPONGE&&item.hasItemMeta()&&"dunesponge_filled".equals(item.getItemMeta().getPersistentDataContainer().get(EI,PersistentDataType.STRING))&&!item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey("dunerealms","preview_only"));}
private static int finiteBuckets(ItemStack[] items){int count=0;for(var i:items)if(i!=null&&i.getType()==Material.WATER_BUCKET&&i.hasItemMeta()&&i.getItemMeta().getPersistentDataContainer().has(FINITE,PersistentDataType.BYTE))count+=i.getAmount();return count;}
public static int legacyRefund(ItemStack[] before,ItemStack[] after){return Math.max(0,finiteBuckets(before)-finiteBuckets(after));}