use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class HologramProjector method openEditor.
private static void openEditor(@Nonnull Player p, @Nonnull Block projector) {
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.HOLOGRAM_PROJECTOR.inventory-title"));
menu.addItem(0, new CustomItemStack(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&r" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text"))));
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
pl.closeInventory();
Slimefun.getLocalization().sendMessage(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true);
ChatUtils.awaitInput(pl, message -> {
ArmorStand hologram = getArmorStand(projector, true);
hologram.setCustomName(ChatColors.color(message));
BlockStorage.addBlockInfo(projector, "text", hologram.getCustomName());
openEditor(pl, projector);
});
return false;
});
menu.addItem(1, new CustomItemStack(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
double offset = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F));
ArmorStand hologram = getArmorStand(projector, true);
Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);
hologram.teleport(l);
BlockStorage.addBlockInfo(projector, OFFSET_PARAMETER, String.valueOf(offset));
openEditor(pl, projector);
return false;
});
menu.open(p);
}
use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class ResourceManager method scan.
/**
* This method will start a geo-scan at the given {@link Block} and display the result
* of that scan to the given {@link Player}.
*
* Note that scans are always per {@link Chunk}, not per {@link Block}, the {@link Block}
* parameter only determines the {@link Location} that was clicked but it will still scan
* the entire {@link Chunk}.
*
* @param p
* The {@link Player} who requested these results
* @param block
* The {@link Block} which the scan starts at
* @param page
* The page to display
*/
public void scan(@Nonnull Player p, @Nonnull Block block, int page) {
if (Slimefun.getGPSNetwork().getNetworkComplexity(p.getUniqueId()) < 600) {
Slimefun.getLocalization().sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600"));
return;
}
int x = block.getX() >> 4;
int z = block.getZ() >> 4;
String title = "&4" + Slimefun.getLocalization().getResourceString(p, "tooltips.results");
ChestMenu menu = new ChestMenu(title);
for (int slot : backgroundSlots) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
menu.addItem(4, new CustomItemStack(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler());
List<GEOResource> resources = new ArrayList<>(Slimefun.getRegistry().getGEOResources().values());
resources.sort(Comparator.comparing(a -> a.getName(p).toLowerCase(Locale.ROOT)));
int index = 10;
int pages = (resources.size() - 1) / 36 + 1;
for (int i = page * 28; i < resources.size() && i < (page + 1) * 28; i++) {
GEOResource resource = resources.get(i);
OptionalInt optional = getSupplies(resource, block.getWorld(), x, z);
int supplies = optional.isPresent() ? optional.getAsInt() : generate(resource, block.getWorld(), x, block.getY(), z);
String suffix = Slimefun.getLocalization().getResourceString(p, supplies == 1 ? "tooltips.unit" : "tooltips.units");
ItemStack item = new CustomItemStack(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix);
if (supplies > 1) {
item.setAmount(supplies > item.getMaxStackSize() ? item.getMaxStackSize() : supplies);
}
menu.addItem(index, item, ChestMenuUtils.getEmptyClickHandler());
index++;
if (index % 9 == 8) {
index += 2;
}
}
menu.addItem(47, ChestMenuUtils.getPreviousButton(p, page + 1, pages));
menu.addMenuClickHandler(47, (pl, slot, item, action) -> {
if (page > 0) {
scan(pl, block, page - 1);
}
return false;
});
menu.addItem(51, ChestMenuUtils.getNextButton(p, page + 1, pages));
menu.addMenuClickHandler(51, (pl, slot, item, action) -> {
if (page + 1 < pages) {
scan(pl, block, page + 1);
}
return false;
});
menu.open(p);
}
use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class GPSNetwork method openTransmitterControlPanel.
/**
* This method opens the {@link GPSTransmitter} control panel to the given
* {@link Player}.
*
* @param p
* The {@link Player}
*/
public void openTransmitterControlPanel(@Nonnull Player p) {
ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
for (int slot : border) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, im -> {
im.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
im.setLore(null);
}));
menu.addMenuClickHandler(2, ChestMenuUtils.getEmptyClickHandler());
int complexity = getNetworkComplexity(p.getUniqueId());
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup")));
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
openWaypointControlPanel(pl);
return false;
});
int index = 0;
for (Location l : getTransmitters(p.getUniqueId())) {
if (index >= inventory.length) {
break;
}
SlimefunItem sfi = BlockStorage.check(l);
if (sfi instanceof GPSTransmitter) {
int slot = inventory[index];
menu.addItem(slot, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + ((GPSTransmitter) sfi).getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler());
index++;
}
}
menu.open(p);
}
use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class TeleportationManager method openTeleporterGUI.
@ParametersAreNonnullByDefault
public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity) {
if (teleporterUsers.add(p.getUniqueId())) {
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F);
PlayerProfile.fromUUID(ownerUUID, profile -> {
ChestMenu menu = new ChestMenu("&3Teleporter");
menu.addMenuCloseHandler(pl -> teleporterUsers.remove(pl.getUniqueId()));
for (int slot : teleporterBorder) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
menu.addItem(4, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title")));
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
Location source = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + 2D, b.getZ() + 0.5D);
int index = 0;
for (Waypoint waypoint : profile.getWaypoints()) {
if (index >= teleporterInventory.length) {
break;
}
int slot = teleporterInventory[index];
Location l = waypoint.getLocation();
double time = NumberUtils.reparseDouble(0.5 * getTeleportationTime(complexity, source, l));
// @formatter:off
String[] lore = { "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "&8\u21E8 &7" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s", "", "&8\u21E8 &c" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip") };
// @formatter:on
menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore));
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
pl.closeInventory();
teleport(pl.getUniqueId(), complexity, source, l, false);
return false;
});
index++;
}
Slimefun.runSync(() -> menu.open(p));
});
}
}
use of me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu in project Slimefun4 by Slimefun.
the class ContributorsMenu method open.
public static void open(Player p, int page) {
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.credits"));
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F));
ChestMenuUtils.drawBackground(menu, 0, 2, 3, 4, 5, 6, 7, 8, 45, 47, 48, 49, 50, 51, 53);
menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings"))));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
SlimefunGuideSettings.openSettings(pl, p.getInventory().getItemInMainHand());
return false;
});
List<Contributor> contributors = new ArrayList<>(Slimefun.getGitHubService().getContributors().values());
contributors.sort(Comparator.comparingInt(Contributor::getPosition));
for (int i = page * 36; i < contributors.size() && i < (page + 1) * 36; i++) {
Contributor contributor = contributors.get(i);
ItemStack skull = getContributorHead(p, contributor);
menu.addItem(i - page * 36 + 9, skull);
menu.addMenuClickHandler(i - page * 36 + 9, (pl, slot, item, action) -> {
if (contributor.getProfile() != null) {
pl.closeInventory();
ChatUtils.sendURL(pl, contributor.getProfile());
}
return false;
});
}
int pages = (contributors.size() - 1) / 36 + 1;
menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page + 1, pages));
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
if (page > 0) {
open(pl, page - 1);
}
return false;
});
menu.addItem(52, ChestMenuUtils.getNextButton(p, page + 1, pages));
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
if (page + 1 < pages) {
open(pl, page + 1);
}
return false;
});
menu.open(p);
}
Aggregations