use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project FluffyMachines by NCBPFluffyBear.
the class FluffyMachines method onEnable.
@SneakyThrows
@Override
public void onEnable() {
instance = this;
// Read something from your config.yml
Config cfg = new Config(this);
if (cfg.getBoolean("options.auto-update") && getDescription().getVersion().startsWith("DEV - ")) {
new GitHubBuildsUpdater(this, getFile(), "NCBPFluffyBear/FluffyMachines/master/").start();
}
try {
if (!Enchantment.isAcceptingRegistrations()) {
Field accepting = Enchantment.class.getDeclaredField("acceptingNew");
accepting.setAccessible(true);
accepting.set(null, true);
}
} catch (IllegalAccessException | NoSuchFieldException ignored) {
getLogger().warning("Failed to register enchantment.");
}
registerGlow();
// Register ACT Recipes
Iterator<Recipe> recipeIterator = Bukkit.recipeIterator();
while (recipeIterator.hasNext()) {
Recipe r = recipeIterator.next();
if (r instanceof ShapedRecipe) {
ShapedRecipe sr = (ShapedRecipe) r;
List<RecipeChoice> rc = new ArrayList<>();
ItemStack key = new ItemStack(sr.getResult().getType(), 1);
// Convert the recipe to a list
for (Map.Entry<Character, RecipeChoice> choice : sr.getChoiceMap().entrySet()) {
if (choice.getValue() != null) {
rc.add(choice.getValue());
}
}
if (!shapedVanillaRecipes.containsKey(key)) {
shapedVanillaRecipes.put(key, new ArrayList<>(Collections.singletonList(new Pair<>(sr.getResult(), rc))));
} else {
shapedVanillaRecipes.get(key).add(new Pair<>(sr.getResult(), rc));
}
} else if (r instanceof ShapelessRecipe) {
ShapelessRecipe slr = (ShapelessRecipe) r;
ItemStack key = new ItemStack(slr.getResult().getType(), 1);
// Key has a list of recipe options
if (!shapelessVanillaRecipes.containsKey(key)) {
shapelessVanillaRecipes.put(key, new ArrayList<>(Collections.singletonList(new Pair<>(slr.getResult(), slr.getChoiceList()))));
} else {
shapelessVanillaRecipes.get(key).add(new Pair<>(slr.getResult(), slr.getChoiceList()));
}
}
}
// Register McMMO Events
if (getServer().getPluginManager().isPluginEnabled("McMMO")) {
Bukkit.getLogger().log(Level.INFO, "McMMO found!");
getServer().getPluginManager().registerEvents(new McMMOEvents(), this);
}
// Registering Items
FluffyItemSetup.setup(this);
// Register Events Class
getServer().getPluginManager().registerEvents(new Events(), this);
final Metrics metrics = new Metrics(this, 8927);
getLogger().log(Level.INFO, ChatColor.GREEN + "Hi there! Want to share your server with the " + "Slimefun community?");
getLogger().log(Level.INFO, ChatColor.GREEN + "Join the official Slimefun Discord server at " + "https://discord.gg/slimefun");
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.
the class ArmorTask method checkForSolarHelmet.
private void checkForSolarHelmet(@Nonnull Player p) {
ItemStack helmet = p.getInventory().getHelmet();
if (Slimefun.getRegistry().isBackwardsCompatible() && !SlimefunUtils.isItemSimilar(helmet, SlimefunItems.SOLAR_HELMET, true, false)) {
// Performance saver for slow backwards-compatible versions of Slimefun
return;
}
SlimefunItem item = SlimefunItem.getByItem(helmet);
if (item instanceof SolarHelmet && item.canUse(p, true)) {
((SolarHelmet) item).rechargeItems(p);
}
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.
the class SlimefunStartupTask method run.
@Override
public void run() {
runnable.run();
// Load all items
PostSetup.loadItems();
// Load all worlds
Slimefun.getWorldSettingsService().load(Bukkit.getWorlds());
for (World world : Bukkit.getWorlds()) {
try {
new BlockStorage(world);
} catch (Exception x) {
Slimefun.logger().log(Level.SEVERE, x, () -> "An Error occurred while trying to load World \"" + world.getName() + "\" for Slimefun v" + Slimefun.getVersion());
}
}
// Load/Unload Worlds, only after all plugins have started up. Fixes #2862
new WorldListener(this.plugin);
// Only load this Listener if the corresponding items are enabled
if (isEnabled("ELEVATOR_PLATE", "GPS_ACTIVATION_DEVICE_SHARED", "GPS_ACTIVATION_DEVICE_PERSONAL")) {
new TeleporterListener(plugin);
}
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.
the class PostSetup method loadItems.
public static void loadItems() {
Iterator<SlimefunItem> iterator = Slimefun.getRegistry().getEnabledSlimefunItems().iterator();
while (iterator.hasNext()) {
SlimefunItem item = iterator.next();
if (item == null) {
Slimefun.logger().log(Level.WARNING, "Removed bugged Item ('NULL?')");
iterator.remove();
} else {
try {
item.load();
} catch (Exception | LinkageError x) {
item.error("Failed to properly load this Item", x);
}
}
}
loadOreGrinderRecipes();
loadSmelteryRecipes();
CommandSender sender = Bukkit.getConsoleSender();
int total = Slimefun.getRegistry().getEnabledSlimefunItems().size();
int slimefunOnly = countNonAddonItems();
sender.sendMessage("");
sender.sendMessage(ChatColor.GREEN + "######################### - Slimefun v" + Slimefun.getVersion() + " - #########################");
sender.sendMessage("");
sender.sendMessage(ChatColor.GREEN + "Successfully loaded " + total + " Items and " + Slimefun.getRegistry().getResearches().size() + " Researches");
sender.sendMessage(ChatColor.GREEN + "( " + slimefunOnly + " Items from Slimefun, " + (total - slimefunOnly) + " Items from " + Slimefun.getInstalledAddons().size() + " Addons )");
sender.sendMessage("");
sender.sendMessage(ChatColor.GREEN + "Slimefun is an Open-Source project that is kept alive by a large community.");
sender.sendMessage(ChatColor.GREEN + "Consider helping us maintain this project by contributing on GitHub!");
if (Slimefun.getUpdater().getBranch().isOfficial()) {
sender.sendMessage("");
sender.sendMessage(ChatColor.GREEN + " - Source Code: https://github.com/Slimefun/Slimefun4");
sender.sendMessage(ChatColor.GREEN + " - Wiki: https://github.com/Slimefun/Slimefun4/wiki");
sender.sendMessage(ChatColor.GREEN + " - Addons: https://github.com/Slimefun/Slimefun4/wiki/Addons");
sender.sendMessage(ChatColor.GREEN + " - Bug Reports: https://github.com/Slimefun/Slimefun4/issues");
sender.sendMessage(ChatColor.GREEN + " - Discord: https://discord.gg/slimefun");
} else {
sender.sendMessage(ChatColor.GREEN + " - UNOFFICIALLY MODIFIED BUILD - NO OFFICIAL SUPPORT GIVEN");
}
sender.sendMessage("");
Slimefun.getItemCfg().save();
Slimefun.getResearchCfg().save();
Slimefun.getRegistry().setAutoLoadingMode(true);
}
use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.
the class SlimefunGuideSettings method addHeader.
@ParametersAreNonnullByDefault
private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
LocalizationService locale = Slimefun.getLocalization();
// @formatter:off
menu.addItem(0, new CustomItemStack(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE), "&e\u21E6 " + locale.getMessage(p, "guide.back.title"), "", "&7" + locale.getMessage(p, "guide.back.guide")));
// @formatter:on
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
SlimefunGuide.openGuide(pl, guide);
return false;
});
GitHubService github = Slimefun.getGitHubService();
List<String> contributorsLore = new ArrayList<>();
contributorsLore.add("");
contributorsLore.addAll(locale.getMessages(p, "guide.credits.description", msg -> msg.replace("%contributors%", String.valueOf(github.getContributors().size()))));
contributorsLore.add("");
contributorsLore.add("&7\u21E8 &e" + locale.getMessage(p, "guide.credits.open"));
// @formatter:off
menu.addItem(2, new CustomItemStack(SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"), "&c" + locale.getMessage(p, "guide.title.credits"), contributorsLore.toArray(new String[0])));
// @formatter:on
menu.addMenuClickHandler(2, (pl, slot, action, item) -> {
ContributorsMenu.open(pl, 0);
return false;
});
// @formatter:off
menu.addItem(4, new CustomItemStack(Material.WRITABLE_BOOK, ChatColor.GREEN + locale.getMessage(p, "guide.title.versions"), "&7&o" + locale.getMessage(p, "guide.tooltips.versions-notice"), "", "&fMinecraft: &a" + Bukkit.getBukkitVersion(), "&fSlimefun: &a" + Slimefun.getVersion()), ChestMenuUtils.getEmptyClickHandler());
// @formatter:on
// @formatter:off
menu.addItem(6, new CustomItemStack(Material.COMPARATOR, "&e" + locale.getMessage(p, "guide.title.source"), "", "&7Last Activity: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " ago", "&7Forks: &e" + github.getForks(), "&7Stars: &e" + github.getStars(), "", "&7&oSlimefun 4 is a community project,", "&7&othe source code is available on GitHub", "&7&oand if you want to keep this Plugin alive,", "&7&othen please consider contributing to it", "", "&7\u21E8 &eClick to go to GitHub"));
// @formatter:on
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
pl.closeInventory();
ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4");
return false;
});
// @formatter:off
menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK, "&3" + locale.getMessage(p, "guide.title.wiki"), "", "&7Do you need help with an Item or machine?", "&7You cannot figure out what to do?", "&7Check out our community-maintained Wiki", "&7and become one of our Editors!", "", "&7\u21E8 &eClick to go to the official Slimefun Wiki"));
// @formatter:on
menu.addMenuClickHandler(8, (pl, slot, item, action) -> {
pl.closeInventory();
ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki");
return false;
});
// @formatter:off
menu.addItem(47, new CustomItemStack(Material.BOOKSHELF, "&3" + locale.getMessage(p, "guide.title.addons"), "", "&7Slimefun is huge. But its addons are what makes", "&7this plugin truly shine. Go check them out, some", "&7of them may be exactly what you were missing out on!", "", "&7Installed on this Server: &b" + Slimefun.getInstalledAddons().size(), "", "&7\u21E8 &eClick to see all available addons for Slimefun4"));
// @formatter:on
menu.addMenuClickHandler(47, (pl, slot, item, action) -> {
pl.closeInventory();
ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki/Addons");
return false;
});
if (Slimefun.getUpdater().getBranch().isOfficial()) {
// @formatter:off
menu.addItem(49, new CustomItemStack(Material.REDSTONE_TORCH, "&4" + locale.getMessage(p, "guide.title.bugs"), "", "&7&oBug reports have to be made in English!", "", "&7Open Issues: &a" + github.getOpenIssues(), "&7Pending Pull Requests: &a" + github.getPendingPullRequests(), "", "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker"));
// @formatter:on
menu.addMenuClickHandler(49, (pl, slot, item, action) -> {
pl.closeInventory();
ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/issues");
return false;
});
} else {
menu.addItem(49, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
}
menu.addItem(51, new CustomItemStack(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> {
// Add something here
return false;
});
}
Aggregations