mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
[CI skip] Some refactoring
This commit is contained in:
parent
aa9652cf88
commit
7cb0c521f6
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -9,12 +9,13 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.HoverAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.String.StringUtils;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -87,25 +88,25 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
actions.add(null);
|
||||
}
|
||||
}
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &6Tier " + tier));
|
||||
texts.add(ChatColors.color("&8\u21E8 &6Tier " + tier));
|
||||
tooltips.add(null);
|
||||
actions.add(null);
|
||||
}
|
||||
if (category instanceof LockedCategory && !((LockedCategory) category).hasUnlocked(p, profile)) {
|
||||
StringBuilder parents = new StringBuilder(ChatColor.translateAlternateColorCodes('&', "&4&lLOCKED\n\n&7In order to unlock this Category,\n&7you need to unlock all Items from\n&7the following Categories first:\n"));
|
||||
StringBuilder parents = new StringBuilder(ChatColors.color("&4&lLOCKED\n\n&7In order to unlock this Category,\n&7you need to unlock all Items from\n&7the following Categories first:\n"));
|
||||
|
||||
for (Category parent: ((LockedCategory) category).getParents()) {
|
||||
parents.append(ChatColor.translateAlternateColorCodes('&', "\n&c" + StringUtils.formatItemName(parent.getItem(), false)));
|
||||
parents.append(ChatColors.color("\n&c" + ItemUtils.getItemName(parent.getItem())));
|
||||
}
|
||||
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&c" , StringUtils.formatItemName(category.getItem(), false))));
|
||||
texts.add(ChatColors.color(shorten("&c" , ItemUtils.getItemName(category.getItem()))));
|
||||
tooltips.add(parents.toString());
|
||||
actions.add(null);
|
||||
}
|
||||
else if (category instanceof SeasonalCategory) {
|
||||
if (((SeasonalCategory) category).isUnlocked()) {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(category.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', "&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false)));
|
||||
texts.add(ChatColors.color(shorten("&a", ItemUtils.getItemName(category.getItem()))));
|
||||
tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem())));
|
||||
actions.add(new PlayerRunnable(1) {
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
@ -115,8 +116,8 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
}
|
||||
else {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(category.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', "&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false)));
|
||||
texts.add(ChatColors.color(shorten("&a", ItemUtils.getItemName(category.getItem()))));
|
||||
tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem())));
|
||||
actions.add(new PlayerRunnable(1) {
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
@ -141,7 +142,7 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
|
||||
for (int i = 0; i < texts.size(); i = i + 10) {
|
||||
TellRawMessage pageMessage = new TellRawMessage();
|
||||
pageMessage.addText(ChatColor.translateAlternateColorCodes('&', "&b&l- Slimefun Guide -\n\n"));
|
||||
pageMessage.addText(ChatColors.color("&b&l- Slimefun Guide -\n\n"));
|
||||
for (int j = i; j < texts.size() && j < i + 10; j++) {
|
||||
pageMessage.addText(texts.get(j) + "\n");
|
||||
if (tooltips.get(j) != null) pageMessage.addHoverEvent(HoverAction.SHOW_TEXT, tooltips.get(j));
|
||||
@ -175,8 +176,8 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
if (survival && !Slimefun.hasUnlocked(p, item, false) && item.getResearch() != null) {
|
||||
final Research research = item.getResearch();
|
||||
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&7", StringUtils.formatItemName(item.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', StringUtils.formatItemName(item.getItem(), false) + "\n&c&lLOCKED\n\n&7Cost: " + (p.getLevel() >= research.getCost() ? "&b": "&4") + research.getCost() + " Levels\n\n&a> Click to unlock"));
|
||||
texts.add(ChatColors.color(shorten("&7", item.getItemName())));
|
||||
tooltips.add(ChatColors.color(item.getItemName() + "\n&c&lLOCKED\n\n&7Cost: " + (p.getLevel() >= research.getCost() ? "&b": "&4") + research.getCost() + " Levels\n\n&a> Click to unlock"));
|
||||
actions.add(new PlayerRunnable(2) {
|
||||
|
||||
@Override
|
||||
@ -207,11 +208,11 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
});
|
||||
}
|
||||
else {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(item.getItem(), false))));
|
||||
texts.add(ChatColors.color(shorten("&a", item.getItemName())));
|
||||
|
||||
StringBuilder tooltip = new StringBuilder();
|
||||
|
||||
tooltip.append(StringUtils.formatItemName(item.getItem(), false));
|
||||
tooltip.append(item.getItemName());
|
||||
|
||||
if (item.getItem().hasItemMeta() && item.getItem().getItemMeta().hasLore()) {
|
||||
for (String line : item.getItem().getItemMeta().getLore()) {
|
||||
@ -219,7 +220,7 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
}
|
||||
|
||||
tooltip.append(ChatColor.translateAlternateColorCodes('&', "\n\n&e&oClick for more Info"));
|
||||
tooltip.append(ChatColors.color("\n\n&e&oClick for more Info"));
|
||||
|
||||
tooltips.add(tooltip.toString());
|
||||
actions.add(new PlayerRunnable(2) {
|
||||
@ -233,15 +234,15 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
}
|
||||
else {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&4", StringUtils.formatItemName(item.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', "&cNo Permission!"));
|
||||
texts.add(ChatColors.color(shorten("&4", ItemUtils.getItemName(item.getItem()))));
|
||||
tooltips.add(ChatColors.color("&cNo Permission!"));
|
||||
actions.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < texts.size(); i = i + 10) {
|
||||
TellRawMessage pageMessage = new TellRawMessage();
|
||||
pageMessage.addText(ChatColor.translateAlternateColorCodes('&', "&b&l- Slimefun Guide -\n\n"));
|
||||
pageMessage.addText(ChatColors.color("&b&l- Slimefun Guide -\n\n"));
|
||||
|
||||
for (int j = i; j < texts.size() && j < i + 10; j++) {
|
||||
pageMessage.addText(texts.get(j) + "\n");
|
||||
@ -250,8 +251,8 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
|
||||
pageMessage.addText("\n");
|
||||
pageMessage.addText(ChatColor.translateAlternateColorCodes('&', "&6\u21E6 &lBack"));
|
||||
pageMessage.addHoverEvent(HoverAction.SHOW_TEXT, ChatColor.translateAlternateColorCodes('&', "&eClick to go back to the Category Overview"));
|
||||
pageMessage.addText(ChatColors.color("&6\u21E6 &lBack"));
|
||||
pageMessage.addHoverEvent(HoverAction.SHOW_TEXT, ChatColors.color("&eClick to go back to the Category Overview"));
|
||||
pageMessage.addClickEvent(new PlayerRunnable(2) {
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
@ -22,8 +22,12 @@ public interface ISlimefunGuide {
|
||||
void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory);
|
||||
|
||||
default String shorten(String string, String string2) {
|
||||
if (ChatColor.stripColor(string + string2).length() > 19) return (string + ChatColor.stripColor(string2)).substring(0, 18) + "...";
|
||||
else return (string + ChatColor.stripColor(string2));
|
||||
if (ChatColor.stripColor(string + string2).length() > 19) {
|
||||
return (string + ChatColor.stripColor(string2)).substring(0, 18) + "...";
|
||||
}
|
||||
else {
|
||||
return string + ChatColor.stripColor(string2);
|
||||
}
|
||||
}
|
||||
|
||||
default Object getLastEntry(PlayerProfile profile, boolean remove) {
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
public enum SlimefunGuideLayout {
|
||||
|
@ -12,16 +12,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.BookSlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.ChestSlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.ISlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.guides.BookSlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.guides.ChestSlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.guides.ISlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.guides.SlimefunGuideLayout;
|
||||
|
||||
public final class SlimefunGuide {
|
||||
|
||||
|
@ -3,11 +3,11 @@ package me.mrCookieSlime.Slimefun.commands.subcommands;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.commands.SlimefunCommand;
|
||||
import me.mrCookieSlime.Slimefun.commands.SubCommand;
|
||||
import me.mrCookieSlime.Slimefun.guides.SlimefunGuideLayout;
|
||||
|
||||
public class GuideCommand extends SubCommand {
|
||||
|
||||
|
@ -3,11 +3,11 @@ package me.mrCookieSlime.Slimefun.commands.subcommands;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.commands.SlimefunCommand;
|
||||
import me.mrCookieSlime.Slimefun.commands.SubCommand;
|
||||
import me.mrCookieSlime.Slimefun.guides.SlimefunGuideLayout;
|
||||
|
||||
public class OpenGuideCommand extends SubCommand {
|
||||
|
||||
|
@ -5,9 +5,9 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.guides.SlimefunGuideLayout;
|
||||
|
||||
public class GuideOnJoinListener implements Listener {
|
||||
|
||||
|
@ -37,6 +37,8 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.GuideSettings;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
@ -58,8 +60,6 @@ import me.mrCookieSlime.Slimefun.api.energy.ItemEnergy;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.guides.GuideSettings;
|
||||
import me.mrCookieSlime.Slimefun.guides.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.Slimefun.utils.Utilities;
|
||||
|
||||
public class ItemListener implements Listener {
|
||||
|
@ -16,6 +16,8 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.ISlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.Slimefun.GEO.OreGenResource;
|
||||
import me.mrCookieSlime.Slimefun.Lists.Categories;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -34,8 +36,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoTransportEvent;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemRequest;
|
||||
import me.mrCookieSlime.Slimefun.guides.ISlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.guides.SlimefunGuideLayout;
|
||||
|
||||
/**
|
||||
* Really dirty way to store stuff, but you can dump
|
||||
|
Loading…
Reference in New Issue
Block a user