mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-18 01:25:45 +00:00
New settings inventory framework
Currently in a developement stage of making a inventory based settings system like AdvancedModreq.
This commit is contained in:
parent
07dae8fbc5
commit
bb1c402c42
@ -1,21 +1,21 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP;
|
package me.SuperRonanCraft.BetterRTP;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
|
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.RTP;
|
import me.SuperRonanCraft.BetterRTP.player.RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.events.Listener;
|
import me.SuperRonanCraft.BetterRTP.player.events.Listener;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.Econ;
|
import me.SuperRonanCraft.BetterRTP.references.Econ;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.Permissions;
|
import me.SuperRonanCraft.BetterRTP.references.Permissions;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.Updater;
|
import me.SuperRonanCraft.BetterRTP.references.Updater;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.Files;
|
import me.SuperRonanCraft.BetterRTP.references.file.Files;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.Messages;
|
import me.SuperRonanCraft.BetterRTP.references.file.Messages;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTPInventories;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.settings.Settings;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.web.Metrics;
|
import me.SuperRonanCraft.BetterRTP.references.web.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
@ -25,9 +25,11 @@ public class Main extends JavaPlugin {
|
|||||||
private Commands cmd = new Commands(this);
|
private Commands cmd = new Commands(this);
|
||||||
private RTP rtp = new RTP(this);
|
private RTP rtp = new RTP(this);
|
||||||
private Listener listener = new Listener();
|
private Listener listener = new Listener();
|
||||||
private boolean worldguard = false, griefprevention = false, savagefactions = false;
|
|
||||||
private static Main instance;
|
private static Main instance;
|
||||||
private Files files = new Files();
|
private Files files = new Files();
|
||||||
|
private RTPInventories invs = new RTPInventories();
|
||||||
|
private PlayerInfo pInfo = new PlayerInfo();
|
||||||
|
private Settings settings = new Settings();
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
@ -37,6 +39,10 @@ public class Main extends JavaPlugin {
|
|||||||
listener.registerEvents(this);
|
listener.registerEvents(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
invs.closeAll();
|
||||||
|
}
|
||||||
|
|
||||||
public Files getFiles() {
|
public Files getFiles() {
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
@ -81,67 +87,31 @@ public class Main extends JavaPlugin {
|
|||||||
return rtp;
|
return rtp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWorldguard() {
|
public Settings getSettings() {
|
||||||
return worldguard;
|
return settings;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGriefprevention() {
|
|
||||||
return griefprevention;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload(CommandSender sendi) {
|
public void reload(CommandSender sendi) {
|
||||||
|
invs.closeAll();
|
||||||
loadAll();
|
loadAll();
|
||||||
text.getReload(sendi);
|
text.getReload(sendi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RTPInventories getInvs() {
|
||||||
|
return invs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerInfo getpInfo() {
|
||||||
|
return pInfo;
|
||||||
|
}
|
||||||
|
|
||||||
//Load
|
//Load
|
||||||
private void loadAll() {
|
private void loadAll() {
|
||||||
//recreatePermissions();
|
|
||||||
//registerConfig(reload);
|
|
||||||
files.loadAll();
|
files.loadAll();
|
||||||
|
settings.load();
|
||||||
|
invs.load();
|
||||||
rtp.load();
|
rtp.load();
|
||||||
cmd.load();
|
cmd.load();
|
||||||
listener.load();
|
listener.load();
|
||||||
loadSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
//private void registerConfig(boolean reload) {
|
|
||||||
//if (reload)
|
|
||||||
// reloadConfig();
|
|
||||||
//getConfig().options().copyDefaults(true);
|
|
||||||
//saveConfig();
|
|
||||||
//}
|
|
||||||
|
|
||||||
private void loadSettings() {
|
|
||||||
FileBasics.FILETYPE config = getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
|
||||||
if (config.getBoolean("Settings.RespectWorldGuard"))
|
|
||||||
registerWorldguard();
|
|
||||||
else if (worldguard)
|
|
||||||
worldguard = false;
|
|
||||||
if (config.getBoolean("Settings.RespectGriefPrevention"))
|
|
||||||
registerGriefPrevention();
|
|
||||||
else if (griefprevention)
|
|
||||||
griefprevention = false;
|
|
||||||
if (config.getBoolean("Settings.RespectSavageFactions"))
|
|
||||||
registerSavageFactions();
|
|
||||||
else if (savagefactions)
|
|
||||||
savagefactions = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void recreatePermissions() {
|
|
||||||
//Permissions File
|
|
||||||
saveResource(new File(getDataFolder(), "permissions.yml").getName(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerWorldguard() {
|
|
||||||
worldguard = Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerGriefPrevention() {
|
|
||||||
griefprevention = Bukkit.getPluginManager().isPluginEnabled("GriefPrevention");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerSavageFactions() {
|
|
||||||
savagefactions = Bukkit.getPluginManager().isPluginEnabled("Factions");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class PlayerInfo {
|
||||||
|
|
||||||
|
private HashMap<Player, Inventory> invs = new HashMap<>();
|
||||||
|
private HashMap<Player, RTP_INV_SETTINGS> invType = new HashMap<>();
|
||||||
|
private HashMap<Player, World> invWorld = new HashMap<>();
|
||||||
|
private HashMap<Player, RTP_INV_SETTINGS> invNextInv = new HashMap<>();
|
||||||
|
|
||||||
|
public Inventory getInv(Player p) {
|
||||||
|
return invs.get(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTP_INV_SETTINGS getInvType(Player p) {
|
||||||
|
return invType.get(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getInvWorld(Player p) {
|
||||||
|
return invWorld.get(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTP_INV_SETTINGS getNextInv(Player p) {
|
||||||
|
return invNextInv.get(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInv(Player p, Inventory inv) {
|
||||||
|
invs.put(p, inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvType(Player p, RTP_INV_SETTINGS type) {
|
||||||
|
invType.put(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvWorld(Player p, World type) {
|
||||||
|
invWorld.put(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextInv(Player p, RTP_INV_SETTINGS type) {
|
||||||
|
invNextInv.put(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--Logic--
|
||||||
|
|
||||||
|
public Boolean playerExists(Player p) {
|
||||||
|
return invs.containsKey(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear(Player p) {
|
||||||
|
invs.remove(p);
|
||||||
|
invType.remove(p);
|
||||||
|
//invWorld.remove(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -155,17 +155,6 @@ public class RTP {
|
|||||||
pl.getText().getSuccessPaid(sendi, price, x, y, z, world, attempts);
|
pl.getText().getSuccessPaid(sendi, price, x, y, z, world, attempts);
|
||||||
} else
|
} else
|
||||||
pl.getText().getOtherSuccess(sendi, player, x, y, z, world, attempts);
|
pl.getText().getOtherSuccess(sendi, player, x, y, z, world, attempts);
|
||||||
// Organize which message to output respecting what x and z was chosen
|
|
||||||
/*
|
|
||||||
* if (posOrNeg == 0) msg = msg.replaceAll("%x%",
|
|
||||||
* Integer.toString(x)).replaceAll("%z%", Integer.toString(z)); else if
|
|
||||||
* (posOrNeg == 1) msg = msg.replaceAll("%x%",
|
|
||||||
* Integer.toString(x2)).replaceAll("%z%", Integer.toString(z2)); else
|
|
||||||
* if (posOrNeg == 2) msg = msg.replaceAll("%x%",
|
|
||||||
* Integer.toString(x2)).replaceAll("%z%", Integer.toString(z)); else
|
|
||||||
* msg = msg.replaceAll("%x%", Integer.toString(x)).replaceAll("%z%",
|
|
||||||
* Integer.toString(z2));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation"})
|
@SuppressWarnings({"deprecation"})
|
||||||
@ -216,7 +205,7 @@ public class RTP {
|
|||||||
float yaw = p.getLocation().getYaw(), pitch = p.getLocation().getPitch();
|
float yaw = p.getLocation().getYaw(), pitch = p.getLocation().getPitch();
|
||||||
boolean normal;
|
boolean normal;
|
||||||
try {
|
try {
|
||||||
//1.13
|
//1.13+
|
||||||
normal = !world.getBiome(0, 0).equals(Biome.valueOf("NETHER"));
|
normal = !world.getBiome(0, 0).equals(Biome.valueOf("NETHER"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//1.8-1.12
|
//1.8-1.12
|
||||||
@ -327,14 +316,14 @@ public class RTP {
|
|||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
private boolean checkDepends(Location loc) {
|
private boolean checkDepends(Location loc) {
|
||||||
try {
|
try {
|
||||||
if (pl.isWorldguard()) {
|
if (pl.getSettings().getsDepends().isWorldguard()) {
|
||||||
WorldGuardPlugin plugin = WGBukkit.getPlugin();
|
WorldGuardPlugin plugin = WGBukkit.getPlugin();
|
||||||
RegionContainer container = plugin.getRegionContainer();
|
RegionContainer container = plugin.getRegionContainer();
|
||||||
RegionManager regions = container.get(loc.getWorld());
|
RegionManager regions = container.get(loc.getWorld());
|
||||||
// Check to make sure that "regions" is not null
|
// Check to make sure that "regions" is not null
|
||||||
return regions.getApplicableRegions(loc).size() == 0;
|
return regions.getApplicableRegions(loc).size() == 0;
|
||||||
}
|
}
|
||||||
return !pl.isGriefprevention() || GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
|
return !pl.getSettings().getsDepends().isGriefprevention() || GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -355,26 +344,4 @@ public class RTP {
|
|||||||
return true;
|
return true;
|
||||||
//FALSE MEANS NO BAD BLOCKS WHERE FOUND!
|
//FALSE MEANS NO BAD BLOCKS WHERE FOUND!
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (CenterX >= 0) {
|
|
||||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
|
||||||
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
|
|
||||||
} else {
|
|
||||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
|
||||||
x2 = -(rn.nextInt(borderRad - minVal) + CenterX + minVal);
|
|
||||||
}
|
|
||||||
// Will Check is CenterZ is negative or positive, then set 2 z's
|
|
||||||
// up for choosing up next
|
|
||||||
if (CenterZ >= 0) {
|
|
||||||
z = rn.nextInt((borderRad) - minVal) + CenterZ + minVal;
|
|
||||||
z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
|
|
||||||
//sendi.sendMessage("Radius: " + borderRad + " MinRad: " + minVal + " CenterZ: " + CenterZ + " " + "World:"
|
|
||||||
+ " " + pWorld.getWorld() + " TOP Z: " + z + " BOTTOM Z: " + z2);
|
|
||||||
//sendi.sendMessage("Max: " + ((borderRad - minVal) + CenterX + minVal));
|
|
||||||
//sendi.sendMessage("Min: " + (-(borderRad - minVal) + CenterX - minVal));
|
|
||||||
//sendi.sendMessage("QUADRANT: " + posOrNeg);
|
|
||||||
} else {
|
|
||||||
z = (rn.nextInt(borderRad - minVal)) - CenterZ + minVal;
|
|
||||||
z2 = -(rn.nextInt(borderRad - minVal) + CenterZ + minVal);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ public enum CommandTypes {
|
|||||||
INFO(new CmdInfo()),
|
INFO(new CmdInfo()),
|
||||||
PLAYER(new CmdPlayer()),
|
PLAYER(new CmdPlayer()),
|
||||||
RELOAD(new CmdReload()),
|
RELOAD(new CmdReload()),
|
||||||
|
SETTINGS(new CmdSettings()),
|
||||||
VERSION(new CmdVersion()),
|
VERSION(new CmdVersion()),
|
||||||
WORLD(new CmdWorld());
|
WORLD(new CmdWorld());
|
||||||
|
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdSettings implements RTPCommand {
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
Main.getInstance().getInvs().getInv(RTP_INV_SETTINGS.MAIN).show((Player) sendi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean permission(CommandSender sendi) {
|
||||||
|
return Main.getInstance().getPerms().getSettings(sendi);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTPInventories;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
|
public class Click {
|
||||||
|
|
||||||
|
public void click(InventoryClickEvent e) {
|
||||||
|
if (!validClick(e))
|
||||||
|
return;
|
||||||
|
e.setCancelled(true);
|
||||||
|
handler(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handler(InventoryClickEvent e) {
|
||||||
|
try {
|
||||||
|
PlayerInfo pInfo = Main.getInstance().getpInfo();
|
||||||
|
Player p = (Player) e.getWhoClicked();
|
||||||
|
RTPInventories menu = Main.getInstance().getInvs();
|
||||||
|
menu.getInv(pInfo.getInvType(p)).clickEvent(e);
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
//ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validClick(InventoryClickEvent e) {
|
||||||
|
//Not a player, or Not our inventory
|
||||||
|
if (!(e.getWhoClicked() instanceof Player) || e.isCancelled())
|
||||||
|
return false;
|
||||||
|
// Item is clicked
|
||||||
|
else if (e.getCurrentItem() == null || e.getCurrentItem().getType().equals(Material.AIR))
|
||||||
|
return false;
|
||||||
|
else if (e.getWhoClicked() instanceof Player) {
|
||||||
|
// Clicks the inventory
|
||||||
|
if (!e.getInventory().equals(Main.getInstance().getpInfo().getInv((Player) e.getWhoClicked())))
|
||||||
|
return false;
|
||||||
|
// Clicks their own inventory
|
||||||
|
else if (!e.getClickedInventory().equals(Main.getInstance().getpInfo().getInv((Player) e
|
||||||
|
.getWhoClicked()))) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.player.events;
|
|||||||
import me.SuperRonanCraft.BetterRTP.Main;
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
@ -12,6 +13,7 @@ public class Listener implements org.bukkit.event.Listener {
|
|||||||
private Join join = new Join();
|
private Join join = new Join();
|
||||||
private Leave leave = new Leave();
|
private Leave leave = new Leave();
|
||||||
private Interact interact = new Interact();
|
private Interact interact = new Interact();
|
||||||
|
private Click click = new Click();
|
||||||
|
|
||||||
public void registerEvents(Main pl) {
|
public void registerEvents(Main pl) {
|
||||||
PluginManager pm = pl.getServer().getPluginManager();
|
PluginManager pm = pl.getServer().getPluginManager();
|
||||||
@ -45,4 +47,10 @@ public class Listener implements org.bukkit.event.Listener {
|
|||||||
private void interact(SignChangeEvent e) {
|
private void interact(SignChangeEvent e) {
|
||||||
interact.createSign(e);
|
interact.createSign(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void click(InventoryClickEvent e) {
|
||||||
|
click.click(e);
|
||||||
|
}
|
||||||
}
|
}
|
@ -28,6 +28,10 @@ public class Permissions {
|
|||||||
return perm(pre + "reload", sendi);
|
return perm(pre + "reload", sendi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSettings(CommandSender sendi) {
|
||||||
|
return perm(pre + "settings", sendi);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getInfo(CommandSender sendi) {
|
public boolean getInfo(CommandSender sendi) {
|
||||||
return perm(pre + "info", sendi);
|
return perm(pre + "info", sendi);
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,10 @@ public class FileBasics {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setValue(String path, Object value) {
|
||||||
|
config.set(path, value);
|
||||||
|
}
|
||||||
|
|
||||||
//PROCCESSING
|
//PROCCESSING
|
||||||
private void load() {
|
private void load() {
|
||||||
Main pl = Main.getInstance();
|
Main pl = Main.getInstance();
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTPInventory_Defaults;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class RTPInventories {
|
||||||
|
|
||||||
|
private HashMap<RTP_INV_SETTINGS, RTPInventory_Defaults> invs = new HashMap<>();
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
invs.clear();
|
||||||
|
for (RTP_INV_SETTINGS type : RTP_INV_SETTINGS.values()) {
|
||||||
|
type.load(type);
|
||||||
|
invs.put(type, type.getInv());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeAll() {
|
||||||
|
Main main = Main.getInstance();
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
if (main.getpInfo().playerExists(p)) {
|
||||||
|
//main.getText().getReloadMenu(p);
|
||||||
|
main.getpInfo().clear(p);
|
||||||
|
p.closeInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPInventory_Defaults getInv(RTP_INV_SETTINGS type) {
|
||||||
|
return invs.get(type);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTPInventory;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.types.RTPInvBlacklist;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.types.RTPInvCoordinates;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.types.RTPInvMain;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.types.RTPInvWorlds;
|
||||||
|
|
||||||
|
public enum RTP_INV_SETTINGS {
|
||||||
|
MAIN(new RTPInvMain(), false),
|
||||||
|
BLACKLIST(new RTPInvBlacklist(), true),
|
||||||
|
COORDINATES(new RTPInvCoordinates(), true),
|
||||||
|
WORLDS(new RTPInvWorlds(), false);
|
||||||
|
|
||||||
|
private RTPInventory inv;
|
||||||
|
private boolean showInMain;
|
||||||
|
|
||||||
|
RTP_INV_SETTINGS(RTPInventory inv, boolean showInMain) {
|
||||||
|
this.inv = inv;
|
||||||
|
this.showInMain = showInMain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPInventory getInv() {
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getShowMain() {
|
||||||
|
return showInMain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void load(RTP_INV_SETTINGS type) {
|
||||||
|
inv.load(type);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics.FILETYPE;
|
||||||
|
|
||||||
|
public enum RTP_SETTINGS {
|
||||||
|
BLACKLIST( SETTINGS_TYPE.BOOLEAN, FILETYPE.CONFIG, "Template.Enabled",
|
||||||
|
new Object[]{true, "Templates", "&7Toggle Templates system", "paper"});
|
||||||
|
|
||||||
|
SETTINGS_TYPE type;
|
||||||
|
FILETYPE filetype;
|
||||||
|
String path;
|
||||||
|
String[] condition = null;
|
||||||
|
Object[] info; // = new Object[]{false}; //ENABLED, NAME, DESCRIPTION, ITEM
|
||||||
|
|
||||||
|
RTP_SETTINGS(SETTINGS_TYPE type, FILETYPE filetype, String path, Object[] info) {
|
||||||
|
this.type = type;
|
||||||
|
this.filetype = filetype;
|
||||||
|
this.path = path;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
RTP_SETTINGS(SETTINGS_TYPE type, FILETYPE filetype, String[] arry, Object[] info) {
|
||||||
|
this.type = type;
|
||||||
|
this.filetype = filetype;
|
||||||
|
this.path = null;
|
||||||
|
this.info = info;
|
||||||
|
//Condition
|
||||||
|
this.condition = arry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValue(Object value) {
|
||||||
|
Main.getInstance().getFiles().getType(filetype).setValue(path, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] getInfo() {return info;}
|
||||||
|
|
||||||
|
public Object getValue() {
|
||||||
|
String path = this.path;
|
||||||
|
if (path == null && condition != null) {
|
||||||
|
if (Main.getInstance().getFiles().getType(filetype).getBoolean(condition[0]))
|
||||||
|
path = condition[1];
|
||||||
|
else
|
||||||
|
path = condition[2];
|
||||||
|
}
|
||||||
|
return getValuePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getValuePath(String path) {
|
||||||
|
if (path != null) {
|
||||||
|
if (getType() == SETTINGS_TYPE.BOOLEAN)
|
||||||
|
return Main.getInstance().getFiles().getType(filetype).getBoolean(path);
|
||||||
|
else if (getType() == SETTINGS_TYPE.STRING)
|
||||||
|
return Main.getInstance().getFiles().getType(filetype).getString(path);
|
||||||
|
else if (getType() == SETTINGS_TYPE.INTEGER)
|
||||||
|
return Main.getInstance().getFiles().getType(filetype).getInt(path);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SETTINGS_TYPE getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FILETYPE getFiletype() {
|
||||||
|
return filetype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SETTINGS_TYPE {
|
||||||
|
BOOLEAN(Boolean.class), STRING(String.class), INTEGER(Integer.class);
|
||||||
|
|
||||||
|
private Class cla;
|
||||||
|
|
||||||
|
SETTINGS_TYPE(Class cla) {
|
||||||
|
this.cla = cla;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class getCla() {
|
||||||
|
return cla;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs.enums;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
|
||||||
|
public abstract class RTPInventory implements RTPInventory_Defaults {
|
||||||
|
|
||||||
|
public RTP_INV_SETTINGS type;
|
||||||
|
|
||||||
|
public void load(RTP_INV_SETTINGS type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs.enums;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface RTPInventory_Defaults {
|
||||||
|
|
||||||
|
void show(Player p);
|
||||||
|
|
||||||
|
void clickEvent(InventoryClickEvent event);
|
||||||
|
|
||||||
|
default ItemStack createItem(String item, int amount, String name, List<String> lore) {
|
||||||
|
Material mat = Material.valueOf(item.toUpperCase());
|
||||||
|
ItemStack _stack = new ItemStack(mat, amount);
|
||||||
|
ItemMeta _meta = _stack.getItemMeta();
|
||||||
|
if (_meta != null) {
|
||||||
|
if (lore != null)
|
||||||
|
_meta.setLore(lore);
|
||||||
|
if (name != null)
|
||||||
|
_meta.setDisplayName(name);
|
||||||
|
}
|
||||||
|
_stack.setItemMeta(_meta);
|
||||||
|
return _stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
default void cacheInv(Player p, Inventory inv, RTP_INV_SETTINGS type) {
|
||||||
|
PlayerInfo info = Main.getInstance().getpInfo();
|
||||||
|
info.setInv(p, inv);
|
||||||
|
info.setInvType(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
default Inventory createInv(int size, String title) {
|
||||||
|
title = Main.getInstance().getText().color(title);
|
||||||
|
return Bukkit.createInventory(null, size, title);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs.enums;
|
||||||
|
|
||||||
|
public enum RTP_INV_ITEMS {
|
||||||
|
NORMAL("paper", 1),
|
||||||
|
BACK("book", 1, "Back", 0);
|
||||||
|
|
||||||
|
public String item, name;
|
||||||
|
public int amt, slot = -1;
|
||||||
|
|
||||||
|
RTP_INV_ITEMS(String item, int amt) {
|
||||||
|
this.item = item;
|
||||||
|
this.amt = amt;
|
||||||
|
}
|
||||||
|
|
||||||
|
RTP_INV_ITEMS(String item, int amt, String name, int slot) {
|
||||||
|
this.item = item;
|
||||||
|
this.amt = amt;
|
||||||
|
this.name = name;
|
||||||
|
this.slot = slot;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTPInventory;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTP_INV_ITEMS;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class RTPInvBlacklist extends RTPInventory {
|
||||||
|
|
||||||
|
public void show(Player p) {
|
||||||
|
int slots = (Bukkit.getWorlds().size() - (Bukkit.getWorlds().size() % 9) + 1) * 9;
|
||||||
|
if (slots < 6 * 9)
|
||||||
|
slots += 9;
|
||||||
|
Inventory inv = this.createInv(slots, "Settings: &lBlacklist");
|
||||||
|
int _index = 0;
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
if (_index > 9 * 5)
|
||||||
|
break;
|
||||||
|
ItemStack _item = createItem(RTP_INV_ITEMS.NORMAL.item, RTP_INV_ITEMS.NORMAL.amt, world.getName(), null);
|
||||||
|
inv.setItem(_index, _item);
|
||||||
|
_index ++;
|
||||||
|
}
|
||||||
|
ItemStack _item = createItem(RTP_INV_ITEMS.BACK.item, RTP_INV_ITEMS.BACK.amt, RTP_INV_ITEMS.BACK.name, null);
|
||||||
|
inv.setItem(inv.getSize() - 9 + RTP_INV_ITEMS.BACK.slot, _item);
|
||||||
|
p.openInventory(inv);
|
||||||
|
this.cacheInv(p, inv, this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clickEvent(InventoryClickEvent e) {
|
||||||
|
int slot = e.getSlot();
|
||||||
|
for (RTP_INV_ITEMS type : RTP_INV_ITEMS.values()) {
|
||||||
|
if (type.slot != -1) {
|
||||||
|
switch (type) {
|
||||||
|
case BACK:
|
||||||
|
if (slot == e.getInventory().getSize() - 9 + type.slot)
|
||||||
|
Main.getInstance().getInvs().getInv(RTP_INV_SETTINGS.MAIN).show((Player) e.getWhoClicked());
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics.FILETYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTPInventory;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTP_INV_ITEMS;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class RTPInvCoordinates extends RTPInventory {
|
||||||
|
|
||||||
|
public void show(Player p) {
|
||||||
|
if (Main.getInstance().getpInfo().getInvWorld(p) == null) {
|
||||||
|
Main.getInstance().getpInfo().setNextInv(p, this.type);
|
||||||
|
Main.getInstance().getInvs().getInv(RTP_INV_SETTINGS.WORLDS).show(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int slots = (Bukkit.getWorlds().size() - (Bukkit.getWorlds().size() % 9) + 1) * 9;
|
||||||
|
if (slots < 6 * 9)
|
||||||
|
slots += 9;
|
||||||
|
Inventory inv = this.createInv(slots, "Settings: &lCoordinates");
|
||||||
|
|
||||||
|
ItemStack _item = createItem(RTP_INV_ITEMS.BACK.item, RTP_INV_ITEMS.BACK.amt, RTP_INV_ITEMS.BACK.name, null);
|
||||||
|
inv.setItem(inv.getSize() - 9 + RTP_INV_ITEMS.BACK.slot, _item);
|
||||||
|
p.openInventory(inv);
|
||||||
|
this.cacheInv(p, inv, this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clickEvent(InventoryClickEvent e) {
|
||||||
|
int slot = e.getSlot();
|
||||||
|
for (RTP_INV_ITEMS type : RTP_INV_ITEMS.values()) {
|
||||||
|
if (type.slot != -1) {
|
||||||
|
switch (type) {
|
||||||
|
case BACK:
|
||||||
|
if (slot == e.getInventory().getSize() - 9 + type.slot)
|
||||||
|
Main.getInstance().getInvs().getInv(RTP_INV_SETTINGS.MAIN).show((Player) e.getWhoClicked());
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RTP_COORDINATES_SETTINGS {
|
||||||
|
CATEGORY( SETTINGS_TYPE.BOOLEAN, FILETYPE.CONFIG, "Settings.Importance.Enabled",
|
||||||
|
new Object[]{true, "Category", "&7Toggle Categories system", "paper"}),
|
||||||
|
COOLDOWN( SETTINGS_TYPE.BOOLEAN, FILETYPE.CONFIG, "Settings.Cooldown.Enabled",
|
||||||
|
new Object[]{true, "Cooldown", "&7Toggle Cooldown system", "paper"}),
|
||||||
|
COOLDOWN_TIME( SETTINGS_TYPE.INTEGER, FILETYPE.CONFIG, "Settings.Cooldown.Time",
|
||||||
|
new Object[]{true, "Cooldown Time", new ArrayList<String>() {{
|
||||||
|
add("&7Set the time (in minutes)");
|
||||||
|
add("&7between making a new ticket");
|
||||||
|
}}, "paper"}),
|
||||||
|
DEBUG( SETTINGS_TYPE.BOOLEAN, FILETYPE.CONFIG, "Settings.Debug",
|
||||||
|
new Object[]{true, "Debug", "&7Toggle debugger", "paper"}),
|
||||||
|
TEMPLATE( SETTINGS_TYPE.BOOLEAN, FILETYPE.CONFIG, "Template.Enabled",
|
||||||
|
new Object[]{true, "Templates", "&7Toggle Templates system", "paper"});
|
||||||
|
|
||||||
|
SETTINGS_TYPE type;
|
||||||
|
FILETYPE filetype;
|
||||||
|
String path;
|
||||||
|
String[] condition = null;
|
||||||
|
Object[] info; // = new Object[]{false}; //ENABLED, NAME, DESCRIPTION, ITEM
|
||||||
|
|
||||||
|
RTP_COORDINATES_SETTINGS(SETTINGS_TYPE type, FILETYPE filetype, String path, Object[] info) {
|
||||||
|
this.type = type;
|
||||||
|
this.filetype = filetype;
|
||||||
|
this.path = path;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
RTP_COORDINATES_SETTINGS(SETTINGS_TYPE type, FILETYPE filetype, String[] arry, Object[] info) {
|
||||||
|
this.type = type;
|
||||||
|
this.filetype = filetype;
|
||||||
|
this.path = null;
|
||||||
|
this.info = info;
|
||||||
|
//Condition
|
||||||
|
this.condition = arry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValue(Object value) {
|
||||||
|
Main.getInstance().getFiles().getType(filetype).setValue(path, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] getInfo() {return info;}
|
||||||
|
|
||||||
|
public Object getValue() {
|
||||||
|
String path = this.path;
|
||||||
|
if (path == null && condition != null) {
|
||||||
|
if (Main.getInstance().getFiles().getType(filetype).getBoolean(condition[0]))
|
||||||
|
path = condition[1];
|
||||||
|
else
|
||||||
|
path = condition[2];
|
||||||
|
}
|
||||||
|
return getValuePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getValuePath(String path) {
|
||||||
|
if (path != null) {
|
||||||
|
if (getType() == SETTINGS_TYPE.BOOLEAN)
|
||||||
|
return Main.getInstance().getFiles().getType(filetype).getBoolean(path);
|
||||||
|
else if (getType() == SETTINGS_TYPE.STRING)
|
||||||
|
return Main.getInstance().getFiles().getType(filetype).getString(path);
|
||||||
|
else if (getType() == SETTINGS_TYPE.INTEGER)
|
||||||
|
return Main.getInstance().getFiles().getType(filetype).getInt(path);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SETTINGS_TYPE getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FILETYPE getFiletype() {
|
||||||
|
return filetype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SETTINGS_TYPE {
|
||||||
|
BOOLEAN(Boolean.class), STRING(String.class), INTEGER(Integer.class);
|
||||||
|
|
||||||
|
private Class cla;
|
||||||
|
|
||||||
|
SETTINGS_TYPE(Class cla) {
|
||||||
|
this.cla = cla;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class getCla() {
|
||||||
|
return cla;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTPInventory;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class RTPInvMain extends RTPInventory {
|
||||||
|
|
||||||
|
public void show(Player p) {
|
||||||
|
Inventory inv = this.createInv(9, "&lSettings");
|
||||||
|
int _index = 0;
|
||||||
|
for (RTP_INV_SETTINGS type : RTP_INV_SETTINGS.values()) {
|
||||||
|
if (type.getShowMain()) {
|
||||||
|
String _name = type.name();
|
||||||
|
_name = _name.substring(0, 1).toUpperCase() + _name.substring(1).toLowerCase();
|
||||||
|
ItemStack _item = createItem("paper", 1, _name, null);
|
||||||
|
inv.setItem(_index, _item);
|
||||||
|
_index ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.openInventory(inv);
|
||||||
|
this.cacheInv(p, inv, this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clickEvent(InventoryClickEvent event) {
|
||||||
|
Player p = (Player) event.getWhoClicked();
|
||||||
|
int slot = event.getSlot();
|
||||||
|
int _index = 0;
|
||||||
|
for (RTP_INV_SETTINGS type : RTP_INV_SETTINGS.values()) {
|
||||||
|
if (type.getShowMain()) {
|
||||||
|
if (_index == slot) {
|
||||||
|
type.getInv().show(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.invs.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTPInventory;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.enums.RTP_INV_ITEMS;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class RTPInvWorlds extends RTPInventory {
|
||||||
|
|
||||||
|
public void show(Player p) {
|
||||||
|
int slots = (Bukkit.getWorlds().size() - (Bukkit.getWorlds().size() % 9) + 1) * 9;
|
||||||
|
if (slots < 6 * 9)
|
||||||
|
slots += 9;
|
||||||
|
Inventory inv = this.createInv(slots, "&lSelect a world to edit!");
|
||||||
|
int _index = 0;
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
if (_index > 9 * 5)
|
||||||
|
break;
|
||||||
|
ItemStack _item = createItem(RTP_INV_ITEMS.NORMAL.item, RTP_INV_ITEMS.NORMAL.amt, world.getName(), null);
|
||||||
|
inv.setItem(_index, _item);
|
||||||
|
_index ++;
|
||||||
|
}
|
||||||
|
ItemStack _item = createItem(RTP_INV_ITEMS.BACK.item, RTP_INV_ITEMS.BACK.amt, RTP_INV_ITEMS.BACK.name, null);
|
||||||
|
inv.setItem(inv.getSize() - 9 + RTP_INV_ITEMS.BACK.slot, _item);
|
||||||
|
p.openInventory(inv);
|
||||||
|
this.cacheInv(p, inv, this.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clickEvent(InventoryClickEvent e) {
|
||||||
|
Player p = (Player) e.getWhoClicked();
|
||||||
|
int slot = e.getSlot();
|
||||||
|
for (RTP_INV_ITEMS type : RTP_INV_ITEMS.values()) {
|
||||||
|
if (type.slot != -1) {
|
||||||
|
switch (type) {
|
||||||
|
case BACK:
|
||||||
|
if (slot == e.getInventory().getSize() - 9 + type.slot) {
|
||||||
|
Main.getInstance().getInvs().getInv(RTP_INV_SETTINGS.MAIN).show(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int _index = 0;
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
if (_index == slot) {
|
||||||
|
Main.getInstance().getpInfo().setInvWorld(p, world);
|
||||||
|
Main.getInstance().getInvs().getInv(Main.getInstance().getpInfo().getNextInv(p)).show(p);
|
||||||
|
}
|
||||||
|
_index ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.settings;
|
||||||
|
|
||||||
|
public class Settings {
|
||||||
|
|
||||||
|
private SoftDepends depends = new SoftDepends();
|
||||||
|
|
||||||
|
public void load() { //Load Settings
|
||||||
|
depends.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SoftDepends getsDepends() {
|
||||||
|
return depends;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.settings;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
public class SoftDepends {
|
||||||
|
|
||||||
|
private boolean worldguard = false, griefprevention = false, savagefactions = false;
|
||||||
|
|
||||||
|
public boolean isWorldguard() {
|
||||||
|
return worldguard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGriefprevention() {
|
||||||
|
return griefprevention;
|
||||||
|
}
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||||
|
if (config.getBoolean("Settings.RespectWorldGuard"))
|
||||||
|
registerWorldguard();
|
||||||
|
else if (worldguard)
|
||||||
|
worldguard = false;
|
||||||
|
if (config.getBoolean("Settings.RespectGriefPrevention"))
|
||||||
|
registerGriefPrevention();
|
||||||
|
else if (griefprevention)
|
||||||
|
griefprevention = false;
|
||||||
|
if (config.getBoolean("Settings.RespectSavageFactions"))
|
||||||
|
registerSavageFactions();
|
||||||
|
else if (savagefactions)
|
||||||
|
savagefactions = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerWorldguard() {
|
||||||
|
worldguard = Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerGriefPrevention() {
|
||||||
|
griefprevention = Bukkit.getPluginManager().isPluginEnabled("GriefPrevention");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerSavageFactions() {
|
||||||
|
savagefactions = Bukkit.getPluginManager().isPluginEnabled("Factions");
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ version: 2.10.0
|
|||||||
name: BetterRTP
|
name: BetterRTP
|
||||||
author: SuperRonanCraft
|
author: SuperRonanCraft
|
||||||
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]
|
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]
|
||||||
|
api-version: 1.13
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
betterrtp:
|
betterrtp:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user