Cleanup/remove arconix.
This commit is contained in:
parent
4c0f76cead
commit
a5bae8a204
|
@ -1,9 +1,6 @@
|
|||
package com.songoda.epicanchors;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epicanchors.anchor.EAnchor;
|
||||
import com.songoda.epicanchors.anchor.EAnchorManager;
|
||||
import com.songoda.epicanchors.api.EpicAnchors;
|
||||
|
@ -18,6 +15,7 @@ import com.songoda.epicanchors.events.InventoryListeners;
|
|||
import com.songoda.epicanchors.handlers.AnchorHandler;
|
||||
import com.songoda.epicanchors.handlers.MenuHandler;
|
||||
import com.songoda.epicanchors.hooks.*;
|
||||
import com.songoda.epicanchors.utils.ConfigWrapper;
|
||||
import com.songoda.epicanchors.utils.Methods;
|
||||
import com.songoda.epicanchors.utils.SettingsManager;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
@ -84,9 +82,9 @@ public class EpicAnchorsPlugin extends JavaPlugin implements EpicAnchors {
|
|||
|
||||
INSTANCE = this;
|
||||
CommandSender console = Bukkit.getConsoleSender();
|
||||
console.sendMessage(TextComponent.formatText("&a============================="));
|
||||
console.sendMessage(TextComponent.formatText("&7EpicAnchors " + this.getDescription().getVersion() + " by &5Brianna <3&7!"));
|
||||
console.sendMessage(TextComponent.formatText("&7Action: &aEnabling&7..."));
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
console.sendMessage(Methods.formatText("&7EpicAnchors " + this.getDescription().getVersion() + " by &5Brianna <3&7!"));
|
||||
console.sendMessage(Methods.formatText("&7Action: &aEnabling&7..."));
|
||||
|
||||
// Locales
|
||||
Locale.init(this);
|
||||
|
@ -129,16 +127,16 @@ public class EpicAnchorsPlugin extends JavaPlugin implements EpicAnchors {
|
|||
if (pluginManager.isPluginEnabled("WorldGuard")) this.register(HookWorldGuard::new);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
||||
console.sendMessage(TextComponent.formatText("&a============================="));
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
saveToFile();
|
||||
CommandSender console = Bukkit.getConsoleSender();
|
||||
console.sendMessage(TextComponent.formatText("&a============================="));
|
||||
console.sendMessage(TextComponent.formatText("&7EpicAnchors " + this.getDescription().getVersion() + " by &5Brianna <3!"));
|
||||
console.sendMessage(TextComponent.formatText("&7Action: &cDisabling&7..."));
|
||||
console.sendMessage(TextComponent.formatText("&a============================="));
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
console.sendMessage(Methods.formatText("&7EpicAnchors " + this.getDescription().getVersion() + " by &5Brianna <3!"));
|
||||
console.sendMessage(Methods.formatText("&7Action: &cDisabling&7..."));
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
|
@ -151,7 +149,7 @@ public class EpicAnchorsPlugin extends JavaPlugin implements EpicAnchors {
|
|||
private void loadAnchorsFromFile() {
|
||||
if (dataFile.getConfig().contains("Anchors")) {
|
||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("Anchors").getKeys(false)) {
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||
Location location = Methods.unserializeLocation(locationStr);
|
||||
int ticksLeft = dataFile.getConfig().getInt("Anchors." + locationStr + ".ticksLeft");
|
||||
|
||||
EAnchor anchor = new EAnchor(location, ticksLeft);
|
||||
|
@ -164,7 +162,7 @@ public class EpicAnchorsPlugin extends JavaPlugin implements EpicAnchors {
|
|||
private void saveToFile() {
|
||||
dataFile.getConfig().set("Anchors", null);
|
||||
for (Anchor anchor : anchorManager.getAnchors().values()) {
|
||||
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(anchor.getLocation());
|
||||
String locationStr = Methods.serializeLocation(anchor.getLocation());
|
||||
dataFile.getConfig().set("Anchors." + locationStr + ".ticksLeft", anchor.getTicksLeft());
|
||||
}
|
||||
dataFile.saveConfig();
|
||||
|
@ -229,11 +227,11 @@ public class EpicAnchorsPlugin extends JavaPlugin implements EpicAnchors {
|
|||
public ItemStack makeAnchorItem(int ticks) {
|
||||
ItemStack item = new ItemStack(Material.valueOf(EpicAnchorsPlugin.getInstance().getConfig().getString("Main.Anchor Block Material")), 1);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Arconix.pl().getApi().format().formatText(Methods.formatName(ticks, true)));
|
||||
meta.setDisplayName(Methods.formatText(Methods.formatName(ticks, true)));
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
String[] parts = getConfig().getString("Main.Anchor-Lore").split("\\|");
|
||||
for (String line : parts) {
|
||||
lore.add(Arconix.pl().getApi().format().formatText(line));
|
||||
lore.add(Methods.formatText(line));
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package com.songoda.epicanchors.anchor;
|
||||
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.arconix.api.methods.formatting.TimeComponent;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import com.songoda.epicanchors.api.anchor.Anchor;
|
||||
import com.songoda.epicanchors.utils.Methods;
|
||||
|
@ -32,9 +28,9 @@ public class EAnchor implements Anchor {
|
|||
public void overview(Player player) {
|
||||
EpicAnchorsPlugin instance = EpicAnchorsPlugin.getInstance();
|
||||
|
||||
String timeRemaining = TimeComponent.makeReadable((long) (ticksLeft / 20) * 1000) + " remaining.";
|
||||
String timeRemaining = Methods.makeReadable((long) (ticksLeft / 20) * 1000) + " remaining.";
|
||||
|
||||
Inventory inventory = Bukkit.createInventory(null, 27, TextComponent.formatText(instance.getLocale().getMessage("interface.anchor.title")));
|
||||
Inventory inventory = Bukkit.createInventory(null, 27, Methods.formatText(instance.getLocale().getMessage("interface.anchor.title")));
|
||||
|
||||
int nu = 0;
|
||||
while (nu != 27) {
|
||||
|
@ -70,16 +66,16 @@ public class EAnchor implements Anchor {
|
|||
ItemMeta itemmetaECO = itemECO.getItemMeta();
|
||||
itemmetaECO.setDisplayName(instance.getLocale().getMessage("interface.button.addtimewitheconomy"));
|
||||
ArrayList<String> loreECO = new ArrayList<>();
|
||||
loreECO.add(instance.getLocale().getMessage("interface.button.addtimewitheconomylore", Arconix.pl().getApi().format().formatEconomy(instance.getConfig().getInt("Main.Economy Cost"))));
|
||||
loreECO.add(instance.getLocale().getMessage("interface.button.addtimewitheconomylore", Methods.formatEconomy(instance.getConfig().getInt("Main.Economy Cost"))));
|
||||
itemmetaECO.setLore(loreECO);
|
||||
itemECO.setItemMeta(itemmetaECO);
|
||||
|
||||
ItemStack item = instance.makeAnchorItem(ticksLeft);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(TextComponent.formatText(instance.getLocale().getMessage("interface.anchor.smalltitle")));
|
||||
meta.setDisplayName(Methods.formatText(instance.getLocale().getMessage("interface.anchor.smalltitle")));
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
lore.add(TextComponent.formatText("&7" + timeRemaining));
|
||||
lore.add(Methods.formatText("&7" + timeRemaining));
|
||||
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.songoda.epicanchors.command;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import com.songoda.epicanchors.command.commands.CommandEpicAnchors;
|
||||
import com.songoda.epicanchors.command.commands.CommandGive;
|
||||
import com.songoda.epicanchors.command.commands.CommandReload;
|
||||
import com.songoda.epicanchors.command.commands.CommandSettings;
|
||||
import com.songoda.epicanchors.utils.Methods;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -52,7 +52,7 @@ public class CommandManager implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
}
|
||||
commandSender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The command you entered does not exist or is spelt incorrectly."));
|
||||
commandSender.sendMessage(instance.references.getPrefix() + Methods.formatText("&7The command you entered does not exist or is spelt incorrectly."));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,8 @@ public class CommandManager implements CommandExecutor {
|
|||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings);
|
||||
if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) {
|
||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cInvalid Syntax!"));
|
||||
sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
|
||||
sender.sendMessage(instance.references.getPrefix() + Methods.formatText("&cInvalid Syntax!"));
|
||||
sender.sendMessage(instance.references.getPrefix() + Methods.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.songoda.epicanchors.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epicanchors.api.EpicAnchors;
|
||||
import com.songoda.epicanchors.command.AbstractCommand;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import com.songoda.epicanchors.utils.Methods;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandEpicAnchors extends AbstractCommand {
|
||||
|
@ -15,11 +14,11 @@ public class CommandEpicAnchors extends AbstractCommand {
|
|||
@Override
|
||||
protected ReturnType runCommand(EpicAnchorsPlugin instance, CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oBrianna"));
|
||||
sender.sendMessage(Methods.formatText(instance.references.getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oBrianna"));
|
||||
|
||||
for (AbstractCommand command : instance.getCommandManager().getCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(TextComponent.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
sender.sendMessage(Methods.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.songoda.epicanchors.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epicanchors.command.AbstractCommand;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import com.songoda.epicanchors.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -28,11 +28,11 @@ public class CommandGive extends AbstractCommand {
|
|||
if (!args[1].trim().toLowerCase().equals("all")) {
|
||||
Player player = Bukkit.getOfflinePlayer(args[1]).getPlayer();
|
||||
player.getInventory().addItem(itemStack);
|
||||
player.sendMessage(TextComponent.formatText(instance.getLocale().getMessage("command.give.success")));
|
||||
player.sendMessage(Methods.formatText(instance.getLocale().getMessage("command.give.success")));
|
||||
} else {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.getInventory().addItem(itemStack);
|
||||
player.sendMessage(TextComponent.formatText(instance.getLocale().getMessage("command.give.success")));
|
||||
player.sendMessage(Methods.formatText(instance.getLocale().getMessage("command.give.success")));
|
||||
}
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.songoda.epicanchors.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epicanchors.api.EpicAnchors;
|
||||
import com.songoda.epicanchors.command.AbstractCommand;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import com.songoda.epicanchors.utils.Methods;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
@ -15,7 +14,7 @@ public class CommandReload extends AbstractCommand {
|
|||
@Override
|
||||
protected ReturnType runCommand(EpicAnchorsPlugin instance, CommandSender sender, String... args) {
|
||||
instance.reload();
|
||||
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Configuration and Language files reloaded."));
|
||||
sender.sendMessage(Methods.formatText(instance.references.getPrefix() + "&7Configuration and Language files reloaded."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.songoda.epicanchors.handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import com.songoda.epicanchors.anchor.EAnchor;
|
||||
import com.songoda.epicanchors.api.anchor.Anchor;
|
||||
|
@ -35,12 +34,12 @@ public class AnchorHandler {
|
|||
float xx = (float) (0 + (Math.random() * .15));
|
||||
float yy = (float) (0 + (Math.random() * 1));
|
||||
float zz = (float) (0 + (Math.random() * .15));
|
||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(location1, xx, yy, zz, 0, "SPELL", 5);
|
||||
location1.getWorld().spawnParticle(Particle.SPELL, location1, 5, xx, yy, zz, 5);
|
||||
|
||||
xx = (float) (0 + (Math.random() * .75));
|
||||
yy = (float) (0 + (Math.random() * 1));
|
||||
zz = (float) (0 + (Math.random() * .75));
|
||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(location1, xx, yy, zz, 0, "REDSTONE", 1);
|
||||
location1.getWorld().spawnParticle(Particle.REDSTONE, location1, 5, xx, yy, zz, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,7 @@ public class AnchorHandler {
|
|||
|
||||
if (ticksLeft <= 0) {
|
||||
instance.getAnchorManager().removeAnchor(location);
|
||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(location.clone().add(.5, .5, .5), 0, 0, 0, 0, "LAVA", 10);
|
||||
location.getWorld().spawnParticle(Particle.LAVA, location.clone().add(.5, .5, .5), 5, 0, 0, 0, 5);
|
||||
location.getWorld().playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 10, 10);
|
||||
location.getBlock().setType(Material.AIR);
|
||||
instance.getMenuHandler().removeAnchor(location);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.songoda.epicanchors.hooks;
|
||||
|
||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.github.intellectualsites.plotsquared.api.PlotAPI;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.songoda.epicanchors.api.utils.ProtectionPluginHook;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -22,8 +23,15 @@ public class HookPlotSquared implements ProtectionPluginHook {
|
|||
|
||||
@Override
|
||||
public boolean canBuild(Player player, Location location) {
|
||||
return plotSquared.getPlot(location) != null && plotSquared.isInPlot(player)
|
||||
&& plotSquared.getPlot(location) == plotSquared.getPlot(player);
|
||||
com.github.intellectualsites.plotsquared.plot.object.Location plotLocation =
|
||||
new com.github.intellectualsites.plotsquared.plot.object.Location(location.getWorld().getName(),
|
||||
location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
|
||||
Plot plot = plotLocation.getPlot();
|
||||
|
||||
return plot != null
|
||||
&& plot.getOwners().contains(player.getUniqueId())
|
||||
&& plot.getMembers().contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.songoda.epicanchors.utils;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* ConfigWrapper made by @clip
|
||||
*/
|
||||
public class ConfigWrapper {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final String folderName, fileName;
|
||||
private FileConfiguration config;
|
||||
private File configFile;
|
||||
|
||||
public ConfigWrapper(final JavaPlugin instance, final String folderName, final String fileName) {
|
||||
this.plugin = instance;
|
||||
this.folderName = folderName;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public void createNewFile(final String message, final String header) {
|
||||
reloadConfig();
|
||||
saveConfig();
|
||||
loadConfig(header);
|
||||
|
||||
if (message != null) {
|
||||
plugin.getLogger().info(message);
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
if (config == null) {
|
||||
reloadConfig();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
public void loadConfig(final String header) {
|
||||
config.options().header(header);
|
||||
config.options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
if (configFile == null) {
|
||||
configFile = new File(plugin.getDataFolder() + folderName, fileName);
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
if (config == null || configFile == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
} catch (final IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +1,23 @@
|
|||
package com.songoda.epicanchors.utils;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import com.songoda.epicanchors.api.EpicAnchors;
|
||||
import org.bukkit.GameMode;
|
||||
import com.songoda.epicspawners.utils.Debugger;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Methods {
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
EpicAnchorsPlugin plugin = EpicAnchorsPlugin.getInstance();
|
||||
return Arconix.pl().getApi().getGUI().getGlass(plugin.getConfig().getBoolean("settings.Rainbow-Glass"), plugin.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
|
||||
}
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
EpicAnchorsPlugin plugin = EpicAnchorsPlugin.getInstance();
|
||||
if (type)
|
||||
return Arconix.pl().getApi().getGUI().getGlass(false, plugin.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
else
|
||||
return Arconix.pl().getApi().getGUI().getGlass(false, plugin.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||
|
||||
}
|
||||
|
||||
private static Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
public static void takeItem(Player p, int amt) {
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
|
@ -49,10 +43,146 @@ public class Methods {
|
|||
|
||||
String info = "";
|
||||
if (full) {
|
||||
info += Arconix.pl().getApi().format().convertToInvisibleString(ticks2 + ":");
|
||||
info += convertToInvisibleString(ticks2 + ":");
|
||||
}
|
||||
|
||||
return info + Arconix.pl().getApi().format().formatText(name);
|
||||
return info + formatText(name);
|
||||
}
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
try {
|
||||
EpicAnchorsPlugin instance = EpicAnchorsPlugin.getInstance();
|
||||
return getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
try {
|
||||
EpicAnchorsPlugin instance = EpicAnchorsPlugin.getInstance();
|
||||
if (type)
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
else
|
||||
return getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ItemStack getGlass(Boolean rainbow, int type) {
|
||||
int randomNum = 1 + (int) (Math.random() * 6);
|
||||
ItemStack glass;
|
||||
if (rainbow) {
|
||||
glass = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE, 1, (short) randomNum);
|
||||
} else {
|
||||
glass = new ItemStack(Material.LEGACY_STAINED_GLASS_PANE, 1, (short) type);
|
||||
}
|
||||
ItemMeta glassmeta = glass.getItemMeta();
|
||||
glassmeta.setDisplayName("§l");
|
||||
glass.setItemMeta(glassmeta);
|
||||
return glass;
|
||||
}
|
||||
|
||||
|
||||
public static String formatText(String text) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
return formatText(text, false);
|
||||
}
|
||||
|
||||
public static String formatText(String text, boolean cap) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
if (cap)
|
||||
text = text.substring(0, 1).toUpperCase() + text.substring(1);
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
public static String convertToInvisibleString(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return "";
|
||||
StringBuilder hidden = new StringBuilder();
|
||||
for (char c : s.toCharArray()) hidden.append(ChatColor.COLOR_CHAR + "").append(c);
|
||||
return hidden.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location of the block specified.
|
||||
*
|
||||
* @param b The block whose location is to be saved.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public static String serializeLocation(Block b) {
|
||||
if (b == null)
|
||||
return "";
|
||||
return serializeLocation(b.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location specified.
|
||||
*
|
||||
* @param location The location that is to be saved.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public static String serializeLocation(Location location) {
|
||||
if (location == null)
|
||||
return "";
|
||||
String w = location.getWorld().getName();
|
||||
double x = location.getX();
|
||||
double y = location.getY();
|
||||
double z = location.getZ();
|
||||
String str = w + ":" + x + ":" + y + ":" + z;
|
||||
str = str.replace(".0", "").replace("/", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes a location from the string.
|
||||
*
|
||||
* @param str The string to parse.
|
||||
* @return The location that was serialized in the string.
|
||||
*/
|
||||
public static Location unserializeLocation(String str) {
|
||||
if (str == null || str.equals(""))
|
||||
return null;
|
||||
if (serializeCache.containsKey(str)) {
|
||||
return serializeCache.get(str).clone();
|
||||
}
|
||||
String cacheKey = str;
|
||||
str = str.replace("y:", ":").replace("z:", ":").replace("w:", "").replace("x:", ":").replace("/", ".");
|
||||
List<String> args = Arrays.asList(str.split("\\s*:\\s*"));
|
||||
|
||||
World world = Bukkit.getWorld(args.get(0));
|
||||
double x = Double.parseDouble(args.get(1)), y = Double.parseDouble(args.get(2)), z = Double.parseDouble(args.get(3));
|
||||
Location location = new Location(world, x, y, z, 0, 0);
|
||||
serializeCache.put(cacheKey, location.clone());
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the specified Unix Epoch time human readable as per the format settings in the Arconix config.
|
||||
*
|
||||
* @param time The time to convert.
|
||||
* @return A human readable string representing to specified time.
|
||||
*/
|
||||
public static String makeReadable(Long time) {
|
||||
if (time == null)
|
||||
return "";
|
||||
return String.format("%d hour(s), %d min(s), %d sec(s)", TimeUnit.MILLISECONDS.toHours(time), TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)), TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the specified double into the Economy format specified in the Arconix config.
|
||||
*
|
||||
* @param amt The double to format.
|
||||
* @return The economy formatted double.
|
||||
*/
|
||||
public static String formatEconomy(double amt) {
|
||||
DecimalFormat formatter = new DecimalFormat("#,###.00");
|
||||
return formatter.format(amt);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.songoda.epicanchors.utils;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.epicanchors.EpicAnchorsPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -106,9 +104,9 @@ public class SettingsManager implements Listener {
|
|||
|
||||
player.closeInventory();
|
||||
player.sendMessage("");
|
||||
player.sendMessage(TextComponent.formatText("&7Please enter a value for &6" + current + "&7."));
|
||||
player.sendMessage(Methods.formatText("&7Please enter a value for &6" + current + "&7."));
|
||||
if (instance.getConfig().isInt(current) || instance.getConfig().isDouble(current)) {
|
||||
player.sendMessage(TextComponent.formatText("&cUse only numbers."));
|
||||
player.sendMessage(Methods.formatText("&cUse only numbers."));
|
||||
}
|
||||
player.sendMessage("");
|
||||
}
|
||||
|
@ -124,8 +122,8 @@ public class SettingsManager implements Listener {
|
|||
for (String key : instance.getConfig().getDefaultSection().getKeys(false)) {
|
||||
ItemStack item = new ItemStack(Material.WHITE_WOOL, 1, (byte) (slot - 9)); //ToDo: Make this function as it was meant to.
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(Collections.singletonList(TextComponent.formatText("&6Click To Edit This Category.")));
|
||||
meta.setDisplayName(TextComponent.formatText("&f&l" + key));
|
||||
meta.setLore(Collections.singletonList(Methods.formatText("&6Click To Edit This Category.")));
|
||||
meta.setDisplayName(Methods.formatText("&f&l" + key));
|
||||
item.setItemMeta(meta);
|
||||
inventory.setItem(slot, item);
|
||||
slot++;
|
||||
|
@ -143,18 +141,18 @@ public class SettingsManager implements Listener {
|
|||
String fKey = cat.get(player) + "." + key;
|
||||
ItemStack item = new ItemStack(Material.DIAMOND_HELMET);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(TextComponent.formatText("&6" + key));
|
||||
meta.setDisplayName(Methods.formatText("&6" + key));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (config.isBoolean(fKey)) {
|
||||
item.setType(Material.LEVER);
|
||||
lore.add(TextComponent.formatText(config.getBoolean(fKey) ? "&atrue" : "&cfalse"));
|
||||
lore.add(Methods.formatText(config.getBoolean(fKey) ? "&atrue" : "&cfalse"));
|
||||
} else if (config.isString(fKey)) {
|
||||
item.setType(Material.PAPER);
|
||||
lore.add(TextComponent.formatText("&9" + config.getString(fKey)));
|
||||
lore.add(Methods.formatText("&9" + config.getString(fKey)));
|
||||
} else if (config.isInt(fKey)) {
|
||||
item.setType(Material.CLOCK);
|
||||
lore.add(TextComponent.formatText("&5" + config.getInt(fKey)));
|
||||
lore.add(Methods.formatText("&5" + config.getInt(fKey)));
|
||||
}
|
||||
|
||||
if (defs.getConfig().contains(fKey)) {
|
||||
|
@ -163,7 +161,7 @@ public class SettingsManager implements Listener {
|
|||
Matcher m = SETTINGS_PATTERN.matcher(text);
|
||||
while (m.find()) {
|
||||
if (m.end() != text.length() || m.group().length() != 0)
|
||||
lore.add(TextComponent.formatText("&7" + m.group()));
|
||||
lore.add(Methods.formatText("&7" + m.group()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
name: EpicAnchors
|
||||
description: EpicAnchors
|
||||
version: 1.1.7
|
||||
depend: [Arconix]
|
||||
softdepend: [EpicSpawners, Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
||||
main: com.songoda.epicanchors.EpicAnchorsPlugin
|
||||
author: songoda
|
||||
|
|
19
pom.xml
19
pom.xml
|
@ -46,23 +46,14 @@
|
|||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<url>http://repo.songoda.com/repository/private</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault</id>
|
||||
<url>http://repo.songoda.com/repository/vault</url>
|
||||
<url>http://repo.songoda.com/artifactory/private/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>arconix</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>1.13.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org</groupId>
|
||||
|
@ -70,9 +61,9 @@
|
|||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>vault</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ryanhamshire</groupId>
|
||||
|
|
Loading…
Reference in New Issue