Better lists
This commit is contained in:
parent
40d824c26e
commit
45843478df
@ -13,6 +13,14 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.dom4j.Text;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
public class Commands implements CommandExecutor {
|
public class Commands implements CommandExecutor {
|
||||||
|
|
||||||
@ -39,18 +47,40 @@ public class Commands implements CommandExecutor {
|
|||||||
page = Math.min(Math.max(Integer.parseInt(args[1]) - 1, 0), maxPages);
|
page = Math.min(Math.max(Integer.parseInt(args[1]) - 1, 0), maxPages);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
}
|
}
|
||||||
StringBuilder builder = new StringBuilder();
|
ComponentBuilder builder = new ComponentBuilder("");
|
||||||
builder.append(ChatColor.DARK_PURPLE + "======== Rituals ======== " + ChatColor.YELLOW + "Page " + String.valueOf(page + 1) + " / " + String.valueOf(maxPages + 1));
|
builder.append(ChatColor.DARK_PURPLE + "======== Rituals ======== ");
|
||||||
builder.append("\n" + ChatColor.GREEN);
|
if (page != 0) {
|
||||||
|
builder.append(" < ");
|
||||||
|
builder.color(net.md_5.bungee.api.ChatColor.YELLOW);
|
||||||
|
builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rt list " + String.valueOf(page)));
|
||||||
|
} else {
|
||||||
|
builder.append(" < ");
|
||||||
|
builder.color(net.md_5.bungee.api.ChatColor.GRAY);
|
||||||
|
}
|
||||||
|
builder.append("Page " + String.valueOf(page + 1) + " / " + String.valueOf(maxPages + 1) + " ");
|
||||||
|
builder.color(net.md_5.bungee.api.ChatColor.AQUA);
|
||||||
|
if (page != maxPages) {
|
||||||
|
builder.append(" > ");
|
||||||
|
builder.color(net.md_5.bungee.api.ChatColor.YELLOW);
|
||||||
|
builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rt list " + String.valueOf(page + 2)));
|
||||||
|
} else {
|
||||||
|
builder.append(" > ");
|
||||||
|
builder.color(net.md_5.bungee.api.ChatColor.GRAY);
|
||||||
|
}
|
||||||
for (int i = page * 9; i < page * 9 + 9; i++) {
|
for (int i = page * 9; i < page * 9 + 9; i++) {
|
||||||
if (i > max) {
|
if (i > max) {
|
||||||
builder.append(" \n");
|
builder.append(" \n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
builder.append(ritualNames.get(i));
|
builder.append("\n" + ritualNames.get(i));
|
||||||
builder.append("\n" + ChatColor.GREEN);
|
builder.color(net.md_5.bungee.api.ChatColor.GREEN);
|
||||||
|
builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ritual " + ritualNames.get(i)));
|
||||||
|
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.YELLOW + "Click to see more...").create()));
|
||||||
|
}
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player playerSender = (Player) sender;
|
||||||
|
playerSender.spigot().sendMessage(builder.create());
|
||||||
}
|
}
|
||||||
sender.sendMessage(builder.toString());
|
|
||||||
return true;
|
return true;
|
||||||
} else if (recipes.containsKey(String.join(" ", args).toLowerCase())) {
|
} else if (recipes.containsKey(String.join(" ", args).toLowerCase())) {
|
||||||
String key = String.join(" ", args).toLowerCase();
|
String key = String.join(" ", args).toLowerCase();
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package top.penowl.quidproquo;
|
package top.penowl.quidproquo;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.nio.Buffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
@ -38,10 +40,13 @@ public class QuidProQuo extends JavaPlugin {
|
|||||||
for (Class<? extends Ritual> ritualClass : subClasses) {
|
for (Class<? extends Ritual> ritualClass : subClasses) {
|
||||||
Class<?>[] params = {};
|
Class<?>[] params = {};
|
||||||
try {
|
try {
|
||||||
|
if (ritualClass.getField("enabled").getBoolean(null)) {
|
||||||
Constructor<? extends Ritual> constructor = ritualClass.getConstructor(params);
|
Constructor<? extends Ritual> constructor = ritualClass.getConstructor(params);
|
||||||
Object[] args = {};
|
Object[] args = {};
|
||||||
rituals.add(constructor.newInstance(args));
|
rituals.add(constructor.newInstance(args));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public abstract class Ritual {
|
public abstract class Ritual {
|
||||||
|
|
||||||
|
// whether the ritual is enabled, shouldn't change during runtime
|
||||||
|
public static boolean enabled = true;
|
||||||
|
|
||||||
// ingredients, map of type to count
|
// ingredients, map of type to count
|
||||||
public HashMap<Material, Integer> ingredients = new HashMap<Material, Integer>();
|
public HashMap<Material, Integer> ingredients = new HashMap<Material, Integer>();
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import top.penowl.quidproquo.Ritual;
|
|||||||
|
|
||||||
public class BlankRitual extends Ritual {
|
public class BlankRitual extends Ritual {
|
||||||
|
|
||||||
|
public static boolean enabled = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user