Retain native travel and estate services in replacement GUI
This commit is contained in:
parent
c0d56632eb
commit
bb29868eed
1 changed files with 34 additions and 3 deletions
|
|
@ -28,6 +28,21 @@ public final class NativeMenus {
|
|||
public Choice(String label,String description,Runnable action) { this(label,description,action,null); }
|
||||
}
|
||||
public static void inventory(JavaPlugin plugin, Player player, String title, Inventory model, Map<Integer,Runnable> actions) {
|
||||
var frontend=Bukkit.getPluginManager().getPlugin("DuneMenus");
|
||||
if(frontend!=null&&frontend.isEnabled()) {
|
||||
MenuSession session=new MenuSession(player.getUniqueId());
|
||||
UUID world=player.getWorld().getUID();
|
||||
Map<Integer,Runnable> guarded=new HashMap<>();
|
||||
actions.forEach((slot,action)->guarded.put(slot,()->{
|
||||
if(session.claim(player.getUniqueId())&&player.isOnline()&&world.equals(player.getWorld().getUID()))action.run();
|
||||
}));
|
||||
try {
|
||||
frontend.getClass().getMethod("openSharedMenu",Player.class,String.class,Inventory.class,Map.class)
|
||||
.invoke(frontend,player,ChatColor.stripColor(title),model,guarded);
|
||||
Bukkit.getScheduler().runTaskLater(plugin,session::expire,2400L);
|
||||
return;
|
||||
}catch(ReflectiveOperationException failure){session.expire();plugin.getLogger().warning("Supplied menu bridge unavailable: "+failure.getClass().getSimpleName());}
|
||||
}
|
||||
List<Choice> choices = new ArrayList<>();
|
||||
List<String> information = new ArrayList<>();
|
||||
List<ItemStack> illustrations = new ArrayList<>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff