Merge changes
This commit is contained in:
commit
7e4a50226f
19
pom.xml
19
pom.xml
|
@ -44,11 +44,6 @@
|
|||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>telesphoreo-repo</id>
|
||||
<url>https://telesphoreo.me/repo/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
@ -93,16 +88,16 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<groupId>com.github.AtlasMediaGroup</groupId>
|
||||
<artifactId>TotalFreedomMod</artifactId>
|
||||
<version>development-0be2aa718f-1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TotalFreedomMod</artifactId>
|
||||
<version>2020.11.5</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.lenis0012.bukkit.marriage2.config.Settings;
|
|||
|
||||
public enum Gender {
|
||||
/**
|
||||
* Opposite of femaile
|
||||
* Opposite of female
|
||||
*/
|
||||
MALE,
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ public enum Gender {
|
|||
/**
|
||||
* Not set
|
||||
*/
|
||||
UNKNOWN;
|
||||
NONE;
|
||||
|
||||
/**
|
||||
* Get chat prefix for gender.
|
||||
|
@ -22,7 +22,7 @@ public enum Gender {
|
|||
* @return Chat prefix
|
||||
*/
|
||||
public String getChatPrefix() {
|
||||
switch(this) {
|
||||
switch (this) {
|
||||
case MALE:
|
||||
return Settings.PREFIX_MALE.value();
|
||||
case FEMALE:
|
||||
|
@ -31,4 +31,4 @@ public enum Gender {
|
|||
return Settings.PREFIX_GENDERLESS.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public interface Marriage {
|
|||
/**
|
||||
* Register a subcommand to the /marry command.
|
||||
*
|
||||
* @param commandClass Class of the sub command to be registered.
|
||||
* @param commandClass Class of the sub command to be registered.
|
||||
* @param commandClasses Additional command classes
|
||||
*/
|
||||
void register(Class<? extends Command> commandClass, Class<? extends Command>... commandClasses);
|
||||
|
|
|
@ -5,20 +5,16 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFM
|
||||
{
|
||||
public class TFM {
|
||||
private TotalFreedomMod totalFreedomMod = null;
|
||||
|
||||
public TotalFreedomMod getTFM()
|
||||
{
|
||||
if (totalFreedomMod != null)
|
||||
{
|
||||
public TotalFreedomMod getTFM() {
|
||||
if (totalFreedomMod != null) {
|
||||
return totalFreedomMod;
|
||||
}
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("TotalFreedomMod");
|
||||
if (plugin != null && plugin.isEnabled())
|
||||
{
|
||||
TotalFreedomMod tfm = (TotalFreedomMod)plugin;
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
TotalFreedomMod tfm = (TotalFreedomMod) plugin;
|
||||
totalFreedomMod = tfm;
|
||||
return totalFreedomMod;
|
||||
}
|
||||
|
@ -26,8 +22,7 @@ public class TFM
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean isAdmin(Player player)
|
||||
{
|
||||
public boolean isAdmin(Player player) {
|
||||
return getTFM().al.isAdmin(player);
|
||||
}
|
||||
}
|
|
@ -53,13 +53,13 @@ public abstract class Command {
|
|||
|
||||
protected Player getArgAsPlayer(int index) {
|
||||
String name = getArg(index);
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
if(player.getName().equalsIgnoreCase(name)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name)) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
if(player.getName().toLowerCase().contains(name.toLowerCase())) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().contains(name.toLowerCase())) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public abstract class Command {
|
|||
protected int getArgAsInt(int index, int def) {
|
||||
try {
|
||||
return Integer.parseInt(getArg(index));
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
@ -170,12 +170,12 @@ public abstract class Command {
|
|||
}
|
||||
|
||||
protected void setExecutionFee(ConfigOption<Double> setting) {
|
||||
if(!Settings.ECONOMY_ENABLED.value() || !Settings.ECONOMY_SHOW_PRICE.value()) {
|
||||
if (!Settings.ECONOMY_ENABLED.value() || !Settings.ECONOMY_SHOW_PRICE.value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Dependencies dependencies = marriage.dependencies();
|
||||
if(!dependencies.isEconomyEnabled()) {
|
||||
if (!dependencies.isEconomyEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -187,14 +187,14 @@ public abstract class Command {
|
|||
}
|
||||
|
||||
protected boolean hasFee() {
|
||||
if(executionFee <= 0 || player == null) return true; // Success!
|
||||
if (executionFee <= 0 || player == null) return true; // Success!
|
||||
return marriage.dependencies().getEconomyService().has(player, executionFee);
|
||||
}
|
||||
|
||||
protected boolean payFee() {
|
||||
if(executionFee <= 0 || player == null) return true; // Success!
|
||||
if (executionFee <= 0 || player == null) return true; // Success!
|
||||
|
||||
if(marriage.dependencies().getEconomyService().has(player, executionFee)) {
|
||||
if (marriage.dependencies().getEconomyService().has(player, executionFee)) {
|
||||
EconomyResponse response = marriage.dependencies().getEconomyService().withdrawPlayer(player, executionFee);
|
||||
reply(Message.PAID_FEE, marriage.dependencies().getEconomyService().format(executionFee));
|
||||
return response.transactionSuccess();
|
||||
|
|
|
@ -14,7 +14,7 @@ public class CommandChat extends Command {
|
|||
@Override
|
||||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
if(!mPlayer.isMarried()) {
|
||||
if (!mPlayer.isMarried()) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ public class CommandChatSpy extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!marriage.getTFM().isAdmin(player))
|
||||
{
|
||||
if (!marriage.getTFM().isAdmin(player)) {
|
||||
sender.sendMessage(ChatColor.RED + "You are not permitted to use this command.");
|
||||
return;
|
||||
}
|
||||
|
@ -26,4 +25,4 @@ public class CommandChatSpy extends Command {
|
|||
mPlayer.setChatSpy(mode);
|
||||
reply(mode ? Message.CHAT_SPY_ENABLED : Message.CHAT_SPY_DISABLED);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,18 +19,18 @@ public class CommandDivorce extends Command {
|
|||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
MPlayer partner = mPlayer.getPartner();
|
||||
if(partner == null) {
|
||||
if (partner == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!payFee()) return;
|
||||
if (!payFee()) return;
|
||||
mPlayer.divorce();
|
||||
|
||||
// Clear metadata
|
||||
player.removeMetadata("marriedTo", marriage.getPlugin());
|
||||
Player target = Bukkit.getPlayer(partner.getUniqueId());
|
||||
if(target != null) {
|
||||
if (target != null) {
|
||||
target.removeMetadata("marriedTo", marriage.getPlugin());
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ public class CommandGender extends Command {
|
|||
Gender gender;
|
||||
try {
|
||||
gender = Gender.valueOf(getArg(0).toUpperCase());
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
reply(Message.INVALID_GENDER);
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
if(mPlayer.getGender() != Gender.UNKNOWN && !Settings.ALLOW_GENDER_CHANGE.value()) {
|
||||
if (mPlayer.getGender() != Gender.NONE && !Settings.ALLOW_GENDER_CHANGE.value()) {
|
||||
reply(Message.GENDER_ALREADY_CHANGED);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,24 +20,24 @@ public class CommandGift extends Command {
|
|||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
MData marriage = mPlayer.getMarriage();
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
Player partner = Bukkit.getPlayer(marriage.getOtherPlayer(player.getUniqueId()));
|
||||
if(partner == null) {
|
||||
if (partner == null) {
|
||||
reply(Message.PARTNER_NOT_ONLINE);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = player.getItemInHand();
|
||||
if(item == null || item.getType() == Material.AIR) {
|
||||
if (item == null || item.getType() == Material.AIR) {
|
||||
reply(Message.NO_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
if(partner.getInventory().firstEmpty() == -1) {
|
||||
|
||||
if (partner.getInventory().firstEmpty() == -1) {
|
||||
reply(Message.PARTNER_INVENTORY_FULL);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,27 +21,27 @@ public class CommandHeal extends Command {
|
|||
MData marriage = mPlayer.getMarriage();
|
||||
|
||||
// Check if marries
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify partner online
|
||||
Player partner = Bukkit.getPlayer(marriage.getOtherPlayer(player.getUniqueId()));
|
||||
if(partner == null) {
|
||||
if (partner == null) {
|
||||
reply(Message.PARTNER_NOT_ONLINE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check health
|
||||
if(player.getHealth() < 1.0) {
|
||||
if (player.getHealth() < 1.0) {
|
||||
reply(Message.NO_HEALTH);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check health of partner
|
||||
double give = Math.min(partner.getMaxHealth() - partner.getHealth(), player.getHealth() - 0.5);
|
||||
if(give == 0.0) {
|
||||
if (give == 0.0) {
|
||||
reply(Message.NO_HEALTH);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -26,18 +26,18 @@ public class CommandHelp extends Command {
|
|||
// reply("Author: &alenis0012");
|
||||
reply("Version: &a" + marriage.getPlugin().getDescription().getVersion());
|
||||
reply("&2&m---------&2< &a&lMarriage Command Help &2>&2&m---------"); // Play around with the amount of dashes later
|
||||
for(Command command : commandExecutor.getSubCommands()) {
|
||||
if(command.isHidden()) {
|
||||
for (Command command : commandExecutor.getSubCommands()) {
|
||||
if (command.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String alias = command instanceof CommandMarry ? "" : command.getAliases()[0] + " ";
|
||||
String text = "&a/marry " + alias + command.getUsage() + " &f- &7" + command.getDescription();
|
||||
if(command.getExecutionFee() == 0.0 || !Bukkit.getVersion().contains("Spigot") || !marriage.dependencies().isEconomyEnabled() || player == null) {
|
||||
if (command.getExecutionFee() == 0.0 || !Bukkit.getVersion().contains("Spigot") || !marriage.dependencies().isEconomyEnabled() || player == null) {
|
||||
reply(text);
|
||||
continue;
|
||||
}
|
||||
if(player.spigot() == null) {
|
||||
if (player.spigot() == null) {
|
||||
reply(text);
|
||||
continue;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class CommandHelp extends Command {
|
|||
}
|
||||
|
||||
String status = Message.SINGLE.toString();
|
||||
if(player != null && player.hasMetadata("marriedTo")) {
|
||||
if (player != null && player.hasMetadata("marriedTo")) {
|
||||
String partner = player.getMetadata("marriedTo").get(0).asString();
|
||||
status = String.format(Message.MARRIED_TO.toString(), partner);
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ public class CommandHome extends Command {
|
|||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
MData marriage = mPlayer.getMarriage();
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
Location home = marriage.getHome();
|
||||
if(home == null) {
|
||||
if (home == null) {
|
||||
reply(Message.HOME_NOT_SET);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class CommandList extends Command {
|
|||
public void execute() {
|
||||
reply(Message.FETCHING_LIST);
|
||||
final int page = getArgLength() > 0 ? getArgAsInt(0) : 1;
|
||||
if(page < 1) {
|
||||
if (page < 1) {
|
||||
reply(Message.NEGATIVE_NUMBER);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public class CommandMarry extends Command {
|
|||
|
||||
public CommandMarry(Marriage marriage) {
|
||||
super(marriage, "marry");
|
||||
if(Settings.ENABLE_PRIEST.value()) {
|
||||
if (Settings.ENABLE_PRIEST.value()) {
|
||||
setDescription(Message.COMMAND_MARRY_PRIEST.toString());
|
||||
setUsage("<player1> <player2>");
|
||||
setMinArgs(1);
|
||||
|
@ -29,25 +29,25 @@ public class CommandMarry extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
if(Settings.ENABLE_PRIEST.value()) {
|
||||
if (Settings.ENABLE_PRIEST.value()) {
|
||||
Player player1 = getArgAsPlayer(-1);
|
||||
Player player2 = getArgAsPlayer(0);
|
||||
if(player1 == null) {
|
||||
if (player1 == null) {
|
||||
reply(Message.PLAYER_NOT_FOUND, getArg(-1));
|
||||
return;
|
||||
} else if(player2 == null) {
|
||||
} else if (player2 == null) {
|
||||
reply(Message.PLAYER_NOT_FOUND, getArg(0));
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mp1 = marriage.getMPlayer(player1);
|
||||
MPlayer mp2 = marriage.getMPlayer(player2);
|
||||
if(mp1.isMarried() || mp2.isMarried()) {
|
||||
if (mp1.isMarried() || mp2.isMarried()) {
|
||||
reply(Message.ALREADY_MARRIED);
|
||||
return;
|
||||
}
|
||||
MPlayer mp = marriage.getMPlayer(player);
|
||||
if(!mp.isPriest()) {
|
||||
if (!mp.isPriest()) {
|
||||
reply(Message.NOT_A_PRIEST);
|
||||
return;
|
||||
}
|
||||
|
@ -58,36 +58,36 @@ public class CommandMarry extends Command {
|
|||
Player target = getArgAsPlayer(-1);
|
||||
|
||||
// Check if player is valid
|
||||
if(target == null) {
|
||||
if (target == null) {
|
||||
reply(Message.PLAYER_NOT_FOUND, getArg(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if player is self
|
||||
if(target.getName().equalsIgnoreCase(player.getName())) {
|
||||
if (target.getName().equalsIgnoreCase(player.getName())) {
|
||||
reply(Message.MARRY_SELF);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if self married
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
if(mPlayer.isMarried()) {
|
||||
if (mPlayer.isMarried()) {
|
||||
reply(Message.ALREADY_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if player married
|
||||
MPlayer mTarget = marriage.getMPlayer(target);
|
||||
if(mTarget.isMarried()) {
|
||||
if (mTarget.isMarried()) {
|
||||
reply(Message.TARGET_ALREADY_MARRIED, getArg(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
// Request or accept
|
||||
if(mPlayer.isMarriageRequested(target.getUniqueId())) {
|
||||
if(getExecutionFee() > 0.0) {
|
||||
if (mPlayer.isMarriageRequested(target.getUniqueId())) {
|
||||
if (getExecutionFee() > 0.0) {
|
||||
EconomyResponse response = marriage.dependencies().getEconomyService().withdrawPlayer(target, getExecutionFee());
|
||||
if(!response.transactionSuccess()) {
|
||||
if (!response.transactionSuccess()) {
|
||||
reply(Message.PARTNER_FEE);
|
||||
target.sendMessage(response.errorMessage);
|
||||
return;
|
||||
|
@ -98,8 +98,8 @@ public class CommandMarry extends Command {
|
|||
player.setMetadata("marriedTo", new FixedMetadataValue(marriage.getPlugin(), target.getName()));
|
||||
target.setMetadata("marriedTo", new FixedMetadataValue(marriage.getPlugin(), player.getName()));
|
||||
broadcast(Message.MARRIED, player.getName(), target.getName());
|
||||
} else if(!mTarget.isMarriageRequested(player.getUniqueId())) {
|
||||
if(!hasFee()) {
|
||||
} else if (!mTarget.isMarriageRequested(player.getUniqueId())) {
|
||||
if (!hasFee()) {
|
||||
reply(Message.INSUFFICIENT_MONEY, marriage.dependencies().getEconomyService().format(getExecutionFee()));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ public class CommandMigrate extends Command {
|
|||
MarriageCore core = ((MarriageCore) marriage);
|
||||
Driver driver;
|
||||
final DataManager newDatabase = core.getDataManager();
|
||||
if(getArg(0).equalsIgnoreCase("sqlite") && getArg(1).equalsIgnoreCase("mysql")) {
|
||||
if (getArg(0).equalsIgnoreCase("sqlite") && getArg(1).equalsIgnoreCase("mysql")) {
|
||||
driver = Driver.SQLITE;
|
||||
} else if(getArg(0).equalsIgnoreCase("mysql") && getArg(1).equalsIgnoreCase("sqlite")) {
|
||||
} else if (getArg(0).equalsIgnoreCase("mysql") && getArg(1).equalsIgnoreCase("sqlite")) {
|
||||
driver = Driver.MYSQL;
|
||||
} else {
|
||||
reply("&cUsage: /marry migrate <old db> <new db>");
|
||||
|
|
|
@ -20,7 +20,7 @@ public class CommandPVP extends Command {
|
|||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
MData marriage = mPlayer.getMarriage();
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class CommandPVP extends Command {
|
|||
reply(value ? Message.PVP_ENABLED : Message.PVP_DISABLED);
|
||||
|
||||
Player partner = Bukkit.getPlayer(marriage.getOtherPlayer(player.getUniqueId()));
|
||||
if(partner == null) {
|
||||
if (partner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class CommandPVP extends Command {
|
|||
}
|
||||
|
||||
private boolean value(MData marriage) {
|
||||
if(getArgLength() == 0) {
|
||||
if (getArgLength() == 0) {
|
||||
// Toggle
|
||||
return !marriage.isPVPEnabled();
|
||||
}
|
||||
|
|
|
@ -20,32 +20,31 @@ public class CommandPriest extends Command {
|
|||
setMinArgs(2);
|
||||
setPermission(Permissions.ADMIN);
|
||||
|
||||
if(!Settings.ENABLE_PRIEST.value()) {
|
||||
if (!Settings.ENABLE_PRIEST.value()) {
|
||||
setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!marriage.getTFM().isAdmin(player))
|
||||
{
|
||||
if (!marriage.getTFM().isAdmin(player)) {
|
||||
sender.sendMessage(ChatColor.RED + "You are not permitted to use this command.");
|
||||
return;
|
||||
}
|
||||
String type = getArg(0);
|
||||
Player player = getArgAsPlayer(1);
|
||||
if(player == null) {
|
||||
if (player == null) {
|
||||
reply(Message.PLAYER_NOT_FOUND, getArg(1));
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mp = marriage.getMPlayer(player);
|
||||
if(type.equalsIgnoreCase("add")) {
|
||||
if (type.equalsIgnoreCase("add")) {
|
||||
mp.setPriest(true);
|
||||
reply(Message.PRIEST_ADDED);
|
||||
} else if(type.equalsIgnoreCase("remove")) {
|
||||
} else if (type.equalsIgnoreCase("remove")) {
|
||||
mp.setPriest(false);
|
||||
reply(Message.PRIEST_REMOVED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,8 +22,7 @@ public class CommandReload extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!marriage.getTFM().isAdmin(player))
|
||||
{
|
||||
if (!marriage.getTFM().isAdmin(player)) {
|
||||
sender.sendMessage(ChatColor.RED + "You are not permitted to use this command.");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ public class CommandSeen extends Command {
|
|||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
MData marriage = mPlayer.getMarriage();
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mp = this.marriage.getMPlayer(marriage.getOtherPlayer(player.getUniqueId()));
|
||||
Player partner = Bukkit.getPlayer(marriage.getOtherPlayer(player.getUniqueId()));
|
||||
if(partner != null) {
|
||||
if (partner != null) {
|
||||
long time = System.currentTimeMillis() - mp.getLastLogin();
|
||||
reply(Message.ONLINE_SINCE, format(time));
|
||||
} else {
|
||||
|
@ -45,11 +45,11 @@ public class CommandSeen extends Command {
|
|||
long min = TimeUnit.MILLISECONDS.toMinutes(ms) % 60;
|
||||
long hrs = TimeUnit.MILLISECONDS.toHours(ms) % 24;
|
||||
long dys = TimeUnit.MILLISECONDS.toDays(ms);
|
||||
if(dys > 0) {
|
||||
if (dys > 0) {
|
||||
return String.format("%sdys%shrs", dys, hrs);
|
||||
} else if(hrs > 0) {
|
||||
} else if (hrs > 0) {
|
||||
return String.format("%shrs%smin", hrs, min);
|
||||
} else if(min > 0) {
|
||||
} else if (min > 0) {
|
||||
return String.format("%smin%ssec", min, sec);
|
||||
} else {
|
||||
return sec + "sec";
|
||||
|
|
|
@ -18,12 +18,12 @@ public class CommandSethome extends Command {
|
|||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
MData marriage = mPlayer.getMarriage();
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!payFee()) return;
|
||||
if (!payFee()) return;
|
||||
marriage.setHome(player.getLocation().clone());
|
||||
reply(Message.HOME_SET);
|
||||
}
|
||||
|
|
|
@ -29,28 +29,28 @@ public class CommandTeleport extends Command {
|
|||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player);
|
||||
MData marriage = mPlayer.getMarriage();
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
reply(Message.NOT_MARRIED);
|
||||
return;
|
||||
}
|
||||
|
||||
Player partner = Bukkit.getPlayer(marriage.getOtherPlayer(player.getUniqueId()));
|
||||
if(partner == null) {
|
||||
if (partner == null) {
|
||||
reply(Message.PARTNER_NOT_ONLINE);
|
||||
return;
|
||||
}
|
||||
|
||||
Location destination = partner.getLocation();
|
||||
if(player.getGameMode() != GameMode.CREATIVE) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
destination = getSafeLocation(destination);
|
||||
}
|
||||
|
||||
if(destination == null) {
|
||||
if (destination == null) {
|
||||
reply(Message.TELEPORT_UNSAFE);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!payFee()) return;
|
||||
if (!payFee()) return;
|
||||
|
||||
player.teleport(destination);
|
||||
reply(Message.TELEPORTED);
|
||||
|
@ -60,23 +60,23 @@ public class CommandTeleport extends Command {
|
|||
private Location getSafeLocation(Location destination) {
|
||||
World world = destination.getWorld();
|
||||
Block block = destination.getBlock();
|
||||
if(block == null || block.getY() < 0 || block.getY() > world.getMaxHeight()) {
|
||||
if (block == null || block.getY() < 0 || block.getY() > world.getMaxHeight()) {
|
||||
return null; // Out of bounds, cant teleport to void or from a bizarre height.
|
||||
}
|
||||
|
||||
if(isSafeGround(block.getRelative(BlockFace.DOWN))) {
|
||||
if (isSafeGround(block.getRelative(BlockFace.DOWN))) {
|
||||
return destination; // Current destination is valid
|
||||
}
|
||||
|
||||
// Find next potentially safe block
|
||||
while(!(block.getType().isSolid() || block.isLiquid()) && block.getY() > 0) {
|
||||
while (!(block.getType().isSolid() || block.isLiquid()) && block.getY() > 0) {
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
if(UNSAFE_TYPES.contains(block.getType())) {
|
||||
if (UNSAFE_TYPES.contains(block.getType())) {
|
||||
return null; // Obstructed by unsafe block
|
||||
}
|
||||
}
|
||||
|
||||
if(!isSafeGround(block)) {
|
||||
if (!isSafeGround(block)) {
|
||||
return null; // Still not safe
|
||||
}
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ public class CommandUpdate extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!marriage.getTFM().isAdmin(player))
|
||||
{
|
||||
if (!marriage.getTFM().isAdmin(player)) {
|
||||
sender.sendMessage(ChatColor.RED + "You are not permitted to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Updater updater = ((MarriageCore) marriage).getUpdater();
|
||||
final Version version = updater.getNewVersion();
|
||||
if(version == null) {
|
||||
if (version == null) {
|
||||
reply("&cUpdater is not enabled!");
|
||||
return;
|
||||
}
|
||||
|
@ -40,19 +40,19 @@ public class CommandUpdate extends Command {
|
|||
@Override
|
||||
public void run() {
|
||||
reply(response);
|
||||
if(!Settings.ENABLE_CHANGELOG.value()) {
|
||||
if (!Settings.ENABLE_CHANGELOG.value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack changelog = updater.getChangelog();
|
||||
if(changelog == null) {
|
||||
if (changelog == null) {
|
||||
reply("&cChangelog isn't available for this version.");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
player.setItemInHand(changelog);
|
||||
if(inHand != null) {
|
||||
if (inHand != null) {
|
||||
player.getInventory().addItem(inHand);
|
||||
}
|
||||
|
||||
|
@ -63,4 +63,4 @@ public class CommandUpdate extends Command {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ public enum Message {
|
|||
FETCHING_LIST("&eFetching player marriage list..."),
|
||||
HOME_SET("&aYou have set a home for your marriage!"),
|
||||
INVALID_FORMAT("&cThe argument could not be parsed to an integer!"),
|
||||
INVALID_GENDER("&cThat is not a valid gender! Pick \"male\" or \"female\""),
|
||||
INVALID_GENDER("&cThat is not a valid gender! Pick \"male\", \"female\" or \"none\"."),
|
||||
GENDER_SET("&aYour gender has been set to %s!"),
|
||||
MARRY_SELF("&cYou cannot marry yourself!"),
|
||||
NEGATIVE_NUMBER("&cYou must enter a positive number!"),
|
||||
|
@ -100,7 +100,7 @@ public enum Message {
|
|||
|
||||
public static void reloadAll(Marriage marriage) {
|
||||
BConfig config = marriage.getBukkitConfig("messages.yml");
|
||||
for(Message message : values()) {
|
||||
for (Message message : values()) {
|
||||
message.reload(config);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public enum Permissions {
|
|||
|
||||
public static boolean setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServicesManager().getRegistration(Permission.class);
|
||||
if(permissionProvider != null) {
|
||||
if (permissionProvider != null) {
|
||||
permissionService = permissionProvider.getProvider();
|
||||
vaultEnabled = true;
|
||||
MarriagePlugin.getCore().getLogger().log(Level.INFO, "Hooked with " + permissionService.getName() + " using Vault!");
|
||||
|
@ -72,7 +72,7 @@ public enum Permissions {
|
|||
* @return True if has permission, False otherwise
|
||||
*/
|
||||
public boolean has(CommandSender sender) {
|
||||
if(parent >= 0 && values()[parent].has(sender)) {
|
||||
if (parent >= 0 && values()[parent].has(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ public enum Permissions {
|
|||
* @return Permission
|
||||
*/
|
||||
public static Permissions getByNode(String node) {
|
||||
for(Permissions permission : values()) {
|
||||
if(permission.node.equalsIgnoreCase(node)) {
|
||||
for (Permissions permission : values()) {
|
||||
if (permission.node.equalsIgnoreCase(node)) {
|
||||
return permission;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,17 @@ public class Dependencies {
|
|||
|
||||
public Dependencies(MarriageCore core) {
|
||||
boolean useEconomy = Settings.ECONOMY_ENABLED.value();
|
||||
if(!useEconomy) {
|
||||
if (!useEconomy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Bukkit.getPluginManager().isPluginEnabled("Vault")) {
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("Vault")) {
|
||||
core.getLogger().log(Level.WARNING, "Couldn't detect Vault, economy settings will not work");
|
||||
return;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if(economyProvider != null) {
|
||||
if (economyProvider != null) {
|
||||
economyService = economyProvider.getProvider();
|
||||
core.getLogger().log(Level.INFO, "Hooked with " + economyService.getName() + " using Vault");
|
||||
} else {
|
||||
|
|
|
@ -25,7 +25,7 @@ public abstract class MarriageBase implements Marriage {
|
|||
this.plugin = plugin;
|
||||
try {
|
||||
this.classPath = ClassPath.from(getClass().getClassLoader());
|
||||
} catch(IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to intialize class path!", e);
|
||||
}
|
||||
}
|
||||
|
@ -40,15 +40,14 @@ public abstract class MarriageBase implements Marriage {
|
|||
Bukkit.getPluginManager().registerEvents(listener, plugin);
|
||||
}
|
||||
|
||||
public TFM getTFM()
|
||||
{
|
||||
public TFM getTFM() {
|
||||
return tfm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Class<? extends Command> commandClass, Class<? extends Command>... commandClasses) {
|
||||
commandExecutor.register(commandClass);
|
||||
for(Class<? extends Command> cmdclass : commandClasses) {
|
||||
for (Class<? extends Command> cmdclass : commandClasses) {
|
||||
commandExecutor.register(cmdclass);
|
||||
}
|
||||
}
|
||||
|
@ -76,13 +75,13 @@ public abstract class MarriageBase implements Marriage {
|
|||
@SuppressWarnings("unchecked")
|
||||
protected <T> List<Class<? extends T>> findClasses(String pkg, Class<T> type, Object... params) {
|
||||
List<Class<? extends T>> list = Lists.newArrayList();
|
||||
for(ClassPath.ClassInfo info : classPath.getTopLevelClassesRecursive(pkg)) {
|
||||
for (ClassPath.ClassInfo info : classPath.getTopLevelClassesRecursive(pkg)) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(info.getName());
|
||||
if(type.isAssignableFrom(clazz) && !type.equals(clazz)) {
|
||||
if (type.isAssignableFrom(clazz) && !type.equals(clazz)) {
|
||||
list.add((Class<? extends T>) clazz);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to intiate class", e);
|
||||
}
|
||||
}
|
||||
|
@ -92,10 +91,10 @@ public abstract class MarriageBase implements Marriage {
|
|||
|
||||
protected <T> List<T> findObjects(String pkg, Class<T> type, Object... params) {
|
||||
List<T> list = Lists.newArrayList();
|
||||
for(Class<? extends T> clazz : findClasses(pkg, type)) {
|
||||
for (Class<? extends T> clazz : findClasses(pkg, type)) {
|
||||
try {
|
||||
list.add(type.cast(clazz.getConstructors()[0].newInstance(params)));
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to construct class", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,14 @@ public class MarriageCommandExecutor implements CommandExecutor {
|
|||
public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) {
|
||||
String subCommand = args.length > 0 ? args[0] : "help";
|
||||
Command command = commands.get(subCommand.toLowerCase());
|
||||
if(command == null) {
|
||||
if (command == null) {
|
||||
command = commands.get("marry");
|
||||
}
|
||||
|
||||
// Assuming that the command is not null now, if it is, then that is a mistake on my side.
|
||||
if(args.length > command.getMinArgs()) {
|
||||
if(command.getPermission() == null || command.getPermission().has(sender)) {
|
||||
if(command.isAllowConsole() || sender instanceof Player) {
|
||||
if (args.length > command.getMinArgs()) {
|
||||
if (command.getPermission() == null || command.getPermission().has(sender)) {
|
||||
if (command.isAllowConsole() || sender instanceof Player) {
|
||||
command.prepare(sender, args);
|
||||
command.execute();
|
||||
} else {
|
||||
|
@ -51,15 +51,15 @@ public class MarriageCommandExecutor implements CommandExecutor {
|
|||
public void register(Class<? extends Command> commandClass) {
|
||||
try {
|
||||
Command command = commandClass.getConstructor(Marriage.class).newInstance(core);
|
||||
if(Settings.DISABLED_COMMANDS.value().contains(command.getAliases()[0])) {
|
||||
if (Settings.DISABLED_COMMANDS.value().contains(command.getAliases()[0])) {
|
||||
// Command was disabled in config...
|
||||
return;
|
||||
}
|
||||
|
||||
for(String alias : command.getAliases()) {
|
||||
for (String alias : command.getAliases()) {
|
||||
commands.put(alias.toLowerCase(), command);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
core.getLogger().log(Level.SEVERE, "Failed to register sub command", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ public class MarriageCore extends MarriageBase {
|
|||
Message.reloadAll(this);
|
||||
|
||||
// Permissions
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Vault")) {
|
||||
if(!Permissions.setupPermissions()) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("Vault")) {
|
||||
if (!Permissions.setupPermissions()) {
|
||||
getLogger().log(Level.WARNING, "Vault was found, but no permission provider was detected!");
|
||||
getLogger().log(Level.INFO, "Falling back to bukkit permissions.");
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class MarriageCore extends MarriageBase {
|
|||
@Register(name = "dependencies", type = Type.ENABLE, priority = 1)
|
||||
public void loadDependencies() {
|
||||
this.dependencies = new Dependencies(this);
|
||||
if(Settings.PLOTSQUARED_AUTO_TRUST.value() && Bukkit.getPluginManager().isPluginEnabled("PlotSquared")) {
|
||||
if (Settings.PLOTSQUARED_AUTO_TRUST.value() && Bukkit.getPluginManager().isPluginEnabled("PlotSquared")) {
|
||||
Plugin plotSquared = Bukkit.getPluginManager().getPlugin("PlotSquared");
|
||||
getLogger().log(Level.INFO, "Detected PlotSquared v" + plotSquared.getDescription().getVersion() + ". Attempting to hook.");
|
||||
hookPlotSquared();
|
||||
|
@ -78,7 +78,7 @@ public class MarriageCore extends MarriageBase {
|
|||
this.dataManager = new DataManager(this);
|
||||
|
||||
// Load all players
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
MarriagePlayer mp = dataManager.loadPlayer(player.getUniqueId());
|
||||
setMPlayer(player.getUniqueId(), mp);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class MarriageCore extends MarriageBase {
|
|||
@Register(name = "converter", type = Register.Type.ENABLE, priority = 10)
|
||||
public void loadConverter() {
|
||||
DataConverter converter = new DataConverter(this);
|
||||
if(converter.isOutdated()) {
|
||||
if (converter.isOutdated()) {
|
||||
converter.convert();
|
||||
}
|
||||
}
|
||||
|
@ -163,12 +163,12 @@ public class MarriageCore extends MarriageBase {
|
|||
@Override
|
||||
public MPlayer getMPlayer(UUID uuid) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if(player != null && player.isOnline()) {
|
||||
if (player != null && player.isOnline()) {
|
||||
return getMPlayer(player);
|
||||
}
|
||||
|
||||
MarriagePlayer mp = players.get(uuid);
|
||||
if(mp == null) {
|
||||
if (mp == null) {
|
||||
// Load from database, but don't save.
|
||||
mp = dataManager.loadPlayer(uuid);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class MarriageCore extends MarriageBase {
|
|||
@Override
|
||||
public MPlayer getMPlayer(Player player) {
|
||||
MarriagePlayer mp = players.get(player.getUniqueId());
|
||||
if(mp == null) {
|
||||
if (mp == null) {
|
||||
mp = dataManager.loadPlayer(player.getUniqueId());
|
||||
players.put(player.getUniqueId(), mp);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class MarriageCore extends MarriageBase {
|
|||
public MData marry(MPlayer player1, MPlayer player2, MPlayer priest) {
|
||||
PlayerMarryEvent event = new PlayerMarryEvent(player1, player2, priest);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
if (event.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ public class MarriageCore extends MarriageBase {
|
|||
*/
|
||||
public void unloadPlayer(UUID uuid) {
|
||||
final MarriagePlayer mPlayer = players.remove(uuid);
|
||||
if(mPlayer != null) {
|
||||
if (mPlayer != null) {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -255,7 +255,7 @@ public class MarriageCore extends MarriageBase {
|
|||
}
|
||||
|
||||
public void unloadAll() {
|
||||
for(MarriagePlayer mp : players.values()) {
|
||||
for (MarriagePlayer mp : players.values()) {
|
||||
dataManager.savePlayer(mp);
|
||||
}
|
||||
players.clear();
|
||||
|
|
|
@ -25,21 +25,21 @@ public class MarriagePlugin extends PluginHolder {
|
|||
core = new MarriageCore(this);
|
||||
|
||||
//Scan methods
|
||||
for(int i = 0; i < methods.length; i++) {
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
methods[i] = Lists.newArrayList();
|
||||
}
|
||||
scanMethods(core.getClass());
|
||||
}
|
||||
|
||||
private void scanMethods(Class<?> clazz) {
|
||||
if(clazz == null) {
|
||||
if (clazz == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Loop through all methods in class
|
||||
for(Method method : clazz.getMethods()) {
|
||||
for (Method method : clazz.getMethods()) {
|
||||
Register register = method.getAnnotation(Register.class);
|
||||
if(register != null) {
|
||||
if (register != null) {
|
||||
methods[register.type().ordinal()].add(method);
|
||||
}
|
||||
}
|
||||
|
@ -69,24 +69,24 @@ public class MarriagePlugin extends PluginHolder {
|
|||
|
||||
private void executeMethods(Register.Type type) {
|
||||
List<Method> list = Lists.newArrayList(methods[type.ordinal()]);
|
||||
while(!list.isEmpty()) {
|
||||
while (!list.isEmpty()) {
|
||||
Method method = null;
|
||||
int lowestPriority = Integer.MAX_VALUE;
|
||||
for(Method m : list) {
|
||||
for (Method m : list) {
|
||||
Register register = m.getAnnotation(Register.class);
|
||||
if(register.priority() < lowestPriority) {
|
||||
if (register.priority() < lowestPriority) {
|
||||
method = m;
|
||||
lowestPriority = register.priority();
|
||||
}
|
||||
}
|
||||
|
||||
if(method != null) {
|
||||
if (method != null) {
|
||||
list.remove(method);
|
||||
Register register = method.getAnnotation(Register.class);
|
||||
getLogger().log(Level.INFO, "Loading " + register.name() + "...");
|
||||
try {
|
||||
method.invoke(core);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
getLogger().log(Level.SEVERE, "Failed to load " + register.name(), e);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -11,7 +11,7 @@ public class DBUpgrade {
|
|||
}
|
||||
|
||||
public void run(Statement statement, int currentVersion, String prefix) throws SQLException {
|
||||
switch(currentVersion) {
|
||||
switch (currentVersion) {
|
||||
case 1:
|
||||
statement.execute("ALTER TABLE " + prefix + "players ADD last_name VARCHAR(16);");
|
||||
break;
|
||||
|
@ -19,4 +19,4 @@ public class DBUpgrade {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,39 +41,39 @@ public class DataConverter {
|
|||
UUIDFetcher uuidFetcher = new UUIDFetcher(new ArrayList<String>());
|
||||
int ranThroughMojang = 0;
|
||||
int failed = 0;
|
||||
for(int completed = 0; completed < totalFiles; completed++) {
|
||||
for (int completed = 0; completed < totalFiles; completed++) {
|
||||
File file = files[completed];
|
||||
String name = file.getName().replace(".yml", "");
|
||||
|
||||
// status report
|
||||
double progress = (completed + 1.0) / (double) totalFiles;
|
||||
if(System.currentTimeMillis() >= lastMessage) {
|
||||
if (System.currentTimeMillis() >= lastMessage) {
|
||||
lastMessage = System.currentTimeMillis() + 2500; // Update every 2.5 seconds
|
||||
reportStatus(progress);
|
||||
}
|
||||
|
||||
// Pull from cache
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
|
||||
if(offlinePlayer != null) {
|
||||
if (offlinePlayer != null) {
|
||||
UUID userId = offlinePlayer.getUniqueId();
|
||||
if(userId != null) {
|
||||
if (userId != null) {
|
||||
uuidMap.put(name, userId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Pull from mojang
|
||||
if(ranThroughMojang >= 50000) { // Max 500 requests
|
||||
if (ranThroughMojang >= 50000) { // Max 500 requests
|
||||
failed += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
uuidFetcher.addName(name);
|
||||
ranThroughMojang += 1;
|
||||
if(uuidFetcher.size() == 100) {
|
||||
if (uuidFetcher.size() == 100) {
|
||||
try {
|
||||
uuidMap.putAll(uuidFetcher.call());
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to retrieve UUID for 100 players!");
|
||||
}
|
||||
uuidFetcher = new UUIDFetcher(new ArrayList<String>());
|
||||
|
@ -119,7 +119,7 @@ public class DataConverter {
|
|||
// Insert data into new DB...
|
||||
core.getLogger().log(Level.INFO, "Inserting user data into new database...");
|
||||
int completed = 0;
|
||||
for(Map.Entry<String, UUID> entry : uuidMap.entrySet()) {
|
||||
for (Map.Entry<String, UUID> entry : uuidMap.entrySet()) {
|
||||
try {
|
||||
MarriagePlayer mp = core.getDataManager().loadPlayer(entry.getValue());
|
||||
String name = entry.getKey();
|
||||
|
@ -128,15 +128,15 @@ public class DataConverter {
|
|||
FileConfiguration cnf = YamlConfiguration.loadConfiguration(file);
|
||||
cnf.load(file);
|
||||
|
||||
if(cnf.contains("partner") && !mp.isMarried()) {
|
||||
if (cnf.contains("partner") && !mp.isMarried()) {
|
||||
UUID uuid = uuidMap.get(cnf.getString("partner"));
|
||||
if(uuid != null) {
|
||||
if (uuid != null) {
|
||||
MarriagePlayer mp2 = core.getDataManager().loadPlayer(uuid);
|
||||
MData mdata = core.marry(mp, mp2);
|
||||
|
||||
if(cnf.contains("home")) {
|
||||
if (cnf.contains("home")) {
|
||||
World world = Bukkit.getWorld(cnf.getString("home.world"));
|
||||
if(world != null) {
|
||||
if (world != null) {
|
||||
double x = cnf.getDouble("home.x", 0.0);
|
||||
double y = cnf.getDouble("home.y", 0.0);
|
||||
double z = cnf.getDouble("home.z", 0.0);
|
||||
|
@ -151,12 +151,12 @@ public class DataConverter {
|
|||
core.getDataManager().savePlayer(mp2);
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to convert data for player " + entry.getKey(), e);
|
||||
}
|
||||
|
||||
double progress = ++completed / (double) uuidMap.size();
|
||||
if(System.currentTimeMillis() >= lastMessage) {
|
||||
if (System.currentTimeMillis() >= lastMessage) {
|
||||
lastMessage = System.currentTimeMillis() + 2500; // Update every 2.5 seconds
|
||||
reportStatus(progress);
|
||||
}
|
||||
|
@ -165,11 +165,11 @@ public class DataConverter {
|
|||
// Reset old data
|
||||
core.getLogger().log(Level.INFO, "Renaming playerdata file...");
|
||||
int remainingTries = 60; // Try 60 times
|
||||
while(!dir.renameTo(new File(core.getPlugin().getDataFolder(), "playerdata_backup"))) {
|
||||
while (!dir.renameTo(new File(core.getPlugin().getDataFolder(), "playerdata_backup"))) {
|
||||
long sleepTime = 500L;
|
||||
|
||||
// Limit to take 30 seconds max
|
||||
if(remainingTries-- <= 0) {
|
||||
if (remainingTries-- <= 0) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to rename old playerdata file, please do manually!");
|
||||
core.getLogger().log(Level.INFO, "Server starting normally in 10 seconds.");
|
||||
sleepTime = 10000L;
|
||||
|
@ -178,7 +178,7 @@ public class DataConverter {
|
|||
// Wait
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
} catch(InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,10 +186,10 @@ public class DataConverter {
|
|||
private void reportStatus(double progress) {
|
||||
int percent = (int) Math.floor(progress * 100);
|
||||
StringBuilder bar = new StringBuilder("[");
|
||||
for(int i = 0; i < percent; i += 5) {
|
||||
for (int i = 0; i < percent; i += 5) {
|
||||
bar.append('=');
|
||||
}
|
||||
for(int i = percent; i < 100; i += 5) {
|
||||
for (int i = percent; i < 100; i += 5) {
|
||||
bar.append('_');
|
||||
}
|
||||
bar.append("] (").append(percent).append("%)");
|
||||
|
|
|
@ -41,7 +41,7 @@ public class DataManager {
|
|||
public DataManager(MarriageCore core) {
|
||||
this.core = core;
|
||||
File configFile = new File(core.getPlugin().getDataFolder(), "database-settings.yml");
|
||||
if(!configFile.exists()) {
|
||||
if (!configFile.exists()) {
|
||||
BConfig.copyFile(core.getPlugin().getResource("database-settings.yml"), configFile);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class DataManager {
|
|||
|
||||
private void loadWithDriver(Driver driver, FileConfiguration config) {
|
||||
String url, user = "", password = "";
|
||||
if(driver == Driver.MYSQL) {
|
||||
if (driver == Driver.MYSQL) {
|
||||
user = config.getString("MySQL.user", "root");
|
||||
password = config.getString("MySQL.password", "");
|
||||
String host = config.getString("MySQL.host", "localhost:3306");
|
||||
|
@ -76,7 +76,7 @@ public class DataManager {
|
|||
}
|
||||
|
||||
// Purge system
|
||||
if(config.getBoolean("auto-purge.enabled")) {
|
||||
if (config.getBoolean("auto-purge.enabled")) {
|
||||
final long delayTime = 20L * 60 * 60; // Every hour
|
||||
final int days = config.getInt("auto-purge.purge-after-days", 45);
|
||||
final boolean purgeMarried = config.getBoolean("auto-purge.purge-married-players", false);
|
||||
|
@ -87,7 +87,7 @@ public class DataManager {
|
|||
long startTime = System.currentTimeMillis();
|
||||
int purged = purge(daysInMillis, purgeMarried);
|
||||
long duration = System.currentTimeMillis() - startTime;
|
||||
if(purged > 0) {
|
||||
if (purged > 0) {
|
||||
core.getLogger().log(Level.INFO, "Purged " + purged + " player entries in " + duration + "ms");
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class DataManager {
|
|||
|
||||
try {
|
||||
driver.initiate();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
core.getLogger().log(Level.SEVERE, "Failed to initiate database driver", e);
|
||||
}
|
||||
|
||||
|
@ -109,18 +109,18 @@ public class DataManager {
|
|||
Statement statement = connection.createStatement();
|
||||
driver.runSetup(statement, prefix);
|
||||
ResultSet result = statement.executeQuery(String.format("SELECT * FROM %sversion;", prefix));
|
||||
if(result.next()) {
|
||||
if (result.next()) {
|
||||
int dbVersion = result.getInt("version_id");
|
||||
if(dbVersion >= 2) {
|
||||
if (dbVersion >= 2) {
|
||||
// Fix for people that first installed on v2
|
||||
DatabaseMetaData metadata = connection.getMetaData();
|
||||
ResultSet res = metadata.getColumns(null, null, prefix + "players", "last_name");
|
||||
if(!res.next()) {
|
||||
if (!res.next()) {
|
||||
statement.execute("ALTER TABLE " + prefix + "players ADD last_name VARCHAR(16);");
|
||||
}
|
||||
}
|
||||
|
||||
if(dbVersion < upgrade.getVersionId()) {
|
||||
if (dbVersion < upgrade.getVersionId()) {
|
||||
upgrade.run(statement, dbVersion, prefix);
|
||||
PreparedStatement ps = connection.prepareStatement("UPDATE " + prefix + "version SET version_id=? WHERE version_id=?;");
|
||||
ps.setInt(1, upgrade.getVersionId());
|
||||
|
@ -130,7 +130,7 @@ public class DataManager {
|
|||
} else {
|
||||
statement.executeUpdate(String.format("INSERT INTO %sversion (version_id) VALUES(%s);", prefix, upgrade.getVersionId()));
|
||||
}
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to initiate database", e);
|
||||
} finally {
|
||||
supplier.finish();
|
||||
|
@ -146,20 +146,20 @@ public class DataManager {
|
|||
ResultSet result = ps.executeQuery();
|
||||
Set<String> removeList = Sets.newHashSet();
|
||||
Set<Integer> removeList2 = Sets.newHashSet();
|
||||
while(result.next()) {
|
||||
while (result.next()) {
|
||||
removeList.add(result.getString("unique_user_id"));
|
||||
}
|
||||
|
||||
ps.close(); // Release statement
|
||||
supplier.finish(); // Let queued actions run first
|
||||
if(!purgeMarried) {
|
||||
if (!purgeMarried) {
|
||||
connection = supplier.access();
|
||||
ps = connection.prepareStatement("SELECT * FROM " + prefix + "marriages;");
|
||||
result = ps.executeQuery();
|
||||
while(result.next()) {
|
||||
while (result.next()) {
|
||||
boolean remove = removeList.remove(result.getString("player1"));
|
||||
remove = remove || removeList.remove(result.getString("player2"));
|
||||
if(remove) {
|
||||
if (remove) {
|
||||
removeList2.add(result.getInt("id"));
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class DataManager {
|
|||
// Delete player entries
|
||||
connection = supplier.access();
|
||||
ps = connection.prepareStatement("DELETE FROM " + prefix + "players WHERE unique_user_id=?;");
|
||||
for(String uuid : removeList) {
|
||||
for (String uuid : removeList) {
|
||||
ps.setString(1, uuid);
|
||||
ps.addBatch();
|
||||
}
|
||||
|
@ -181,14 +181,14 @@ public class DataManager {
|
|||
// Remove marriage entries
|
||||
connection = supplier.access();
|
||||
ps = connection.prepareStatement("DELETE FROM " + prefix + "marriages WHERE id=?;");
|
||||
for(int id : removeList2) {
|
||||
for (int id : removeList2) {
|
||||
ps.setInt(1, id);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
ps.close();
|
||||
return removeList.size();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to purge user data", e);
|
||||
return 0;
|
||||
} finally {
|
||||
|
@ -206,7 +206,7 @@ public class DataManager {
|
|||
player = new MarriagePlayer(uuid, ps.executeQuery());
|
||||
ps.close(); // Release statement
|
||||
loadMarriages(connection, player, false);
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to load player data", e);
|
||||
} finally {
|
||||
supplier.finish();
|
||||
|
@ -216,14 +216,14 @@ public class DataManager {
|
|||
}
|
||||
|
||||
public void savePlayer(MarriagePlayer player) {
|
||||
if(player == null || player.getUniqueId() == null) return;
|
||||
if (player == null || player.getUniqueId() == null) return;
|
||||
Connection connection = supplier.access();
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(String.format(
|
||||
"SELECT * FROM %splayers WHERE unique_user_id=?;", prefix));
|
||||
ps.setString(1, player.getUniqueId().toString());
|
||||
ResultSet result = ps.executeQuery();
|
||||
if(result.next()) {
|
||||
if (result.next()) {
|
||||
// Already in database (update)
|
||||
PreparedStatement ps2 = connection.prepareStatement(String.format(
|
||||
"UPDATE %splayers SET last_name=?,gender=?,priest=?,lastlogin=? WHERE unique_user_id=?;", prefix));
|
||||
|
@ -243,7 +243,7 @@ public class DataManager {
|
|||
ps2.close();
|
||||
}
|
||||
ps.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to save player data", e);
|
||||
} finally {
|
||||
supplier.finish();
|
||||
|
@ -257,7 +257,7 @@ public class DataManager {
|
|||
ps.setString(1, mdata.getPlayer1Id().toString());
|
||||
ps.setString(2, mdata.getPllayer2Id().toString());
|
||||
ResultSet result = ps.executeQuery();
|
||||
if(result.next()) {
|
||||
if (result.next()) {
|
||||
// Update existing entry
|
||||
PreparedStatement ps2 = connection.prepareStatement(String.format(
|
||||
"UPDATE %smarriages SET player1=?,player2=?,home_world=?,home_x=?,home_y=?,home_z=?,home_yaw=?,home_pitch=?,pvp_enabled=? WHERE id=?;", prefix));
|
||||
|
@ -272,7 +272,7 @@ public class DataManager {
|
|||
ps2.executeUpdate();
|
||||
ps2.close();
|
||||
}
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to save marriage data", e);
|
||||
} finally {
|
||||
supplier.finish();
|
||||
|
@ -284,14 +284,14 @@ public class DataManager {
|
|||
"SELECT * FROM %smarriages WHERE %s=?;", prefix, alt ? "player2" : "player1", prefix));
|
||||
ps.setString(1, player.getUniqueId().toString());
|
||||
ResultSet result = ps.executeQuery();
|
||||
while(result.next()) {
|
||||
while (result.next()) {
|
||||
UUID partnerId = UUID.fromString(result.getString(alt ? "player1" : "player2"));
|
||||
Player partner = Bukkit.getPlayer(partnerId);
|
||||
MarriageData data;
|
||||
if(partner != null && partner.isOnline() && core.isMPlayerSet(partner.getUniqueId())) {
|
||||
if (partner != null && partner.isOnline() && core.isMPlayerSet(partner.getUniqueId())) {
|
||||
// Copy marriage data from partner to ensure a match.
|
||||
data = (MarriageData) core.getMPlayer(partner).getMarriage();
|
||||
} else if((data = marriageDataCache.getIfPresent(player.getUniqueId())) == null) {
|
||||
} else if ((data = marriageDataCache.getIfPresent(player.getUniqueId())) == null) {
|
||||
data = new MarriageData(this, result);
|
||||
marriageDataCache.put(data.getPlayer1Id(), data);
|
||||
marriageDataCache.put(data.getPllayer2Id(), data);
|
||||
|
@ -301,7 +301,7 @@ public class DataManager {
|
|||
}
|
||||
ps.close();
|
||||
|
||||
if(!alt) {
|
||||
if (!alt) {
|
||||
loadMarriages(connection, player, true);
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ public class DataManager {
|
|||
ps.setString(2, player2.toString());
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to load player data", e);
|
||||
} finally {
|
||||
supplier.finish();
|
||||
|
@ -337,13 +337,13 @@ public class DataManager {
|
|||
result = ps.executeQuery();
|
||||
|
||||
List<MData> list = Lists.newArrayList();
|
||||
while(result.next()) {
|
||||
while (result.next()) {
|
||||
list.add(new MarriageData(this, result));
|
||||
}
|
||||
ps.close();
|
||||
|
||||
return new ListQuery(this, pages, page, list);
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to load marriage list", e);
|
||||
return new ListQuery(this, 0, 0, new ArrayList<MData>());
|
||||
} finally {
|
||||
|
@ -358,10 +358,10 @@ public class DataManager {
|
|||
core.getLogger().log(Level.INFO, "Migrating player data... (may take A WHILE)");
|
||||
PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + prefix + "players;");
|
||||
ResultSet result = ps.executeQuery();
|
||||
while(result.next()) {
|
||||
while (result.next()) {
|
||||
UUID uuid = UUID.fromString(result.getString("unique_user_id"));
|
||||
MarriagePlayer player = new MarriagePlayer(uuid, result);
|
||||
if(!player.isMarried() && !migrateUnmarriedPlayers) continue;
|
||||
if (!player.isMarried() && !migrateUnmarriedPlayers) continue;
|
||||
db.savePlayer(player);
|
||||
}
|
||||
ps.close();
|
||||
|
@ -369,7 +369,7 @@ public class DataManager {
|
|||
core.getLogger().log(Level.INFO, "Migrating marriage data...");
|
||||
ps = connection.prepareStatement("SELECT * FROM " + prefix + "marriages;");
|
||||
result = ps.executeQuery();
|
||||
while(result.next()) {
|
||||
while (result.next()) {
|
||||
MarriageData data = new MarriageData(this, result);
|
||||
db.saveMarriage(data);
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ public class DataManager {
|
|||
|
||||
core.getLogger().log(Level.INFO, "Migration complete!");
|
||||
return true;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to load migrate database", e);
|
||||
} finally {
|
||||
supplier.finish();
|
||||
|
@ -403,7 +403,7 @@ public class DataManager {
|
|||
public Connection get() {
|
||||
try {
|
||||
return DriverManager.getConnection(url, user, password);
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ public class DataManager {
|
|||
// Try to close connection
|
||||
try {
|
||||
connection.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public enum Driver {
|
|||
+ "priest BIT,"
|
||||
+ "lastlogin BIGINT);", prefix));
|
||||
|
||||
switch(this) {
|
||||
switch (this) {
|
||||
case MYSQL:
|
||||
statement.executeUpdate(String.format("CREATE TABLE IF NOT EXISTS %smarriages ("
|
||||
+ "id INT NOT NULL AUTO_INCREMENT,"
|
||||
|
|
|
@ -31,7 +31,7 @@ public class MarriageData implements MData {
|
|||
this.player1 = UUID.fromString(data.getString("player1"));
|
||||
this.player2 = UUID.fromString(data.getString("player2"));
|
||||
String world = data.getString("home_world");
|
||||
if(!"NONE".equals(world)) {
|
||||
if (!"NONE".equals(world)) {
|
||||
double x = data.getDouble("home_x");
|
||||
double y = data.getDouble("home_y");
|
||||
double z = data.getDouble("home_z");
|
||||
|
@ -46,7 +46,7 @@ public class MarriageData implements MData {
|
|||
void save(PreparedStatement ps) throws SQLException {
|
||||
ps.setString(1, player1.toString());
|
||||
ps.setString(2, player2.toString());
|
||||
if(home != null) {
|
||||
if (home != null) {
|
||||
ps.setString(3, home.getWorld().getUID().toString());
|
||||
ps.setDouble(4, home.getX());
|
||||
ps.setDouble(5, home.getY());
|
||||
|
|
|
@ -22,7 +22,7 @@ public class MarriagePlayer implements MPlayer {
|
|||
private final UUID uuid;
|
||||
private String lastName;
|
||||
private MData marriage;
|
||||
private Gender gender = Gender.UNKNOWN;
|
||||
private Gender gender = Gender.NONE;
|
||||
private boolean inChat;
|
||||
private boolean chatSpy;
|
||||
private boolean priest;
|
||||
|
@ -31,7 +31,7 @@ public class MarriagePlayer implements MPlayer {
|
|||
|
||||
public MarriagePlayer(UUID uuid, ResultSet data) throws SQLException {
|
||||
this.uuid = uuid;
|
||||
if(data.next()) {
|
||||
if (data.next()) {
|
||||
this.lastName = data.getString("last_name");
|
||||
this.gender = Gender.valueOf(data.getString("gender"));
|
||||
this.priest = data.getBoolean("priest");
|
||||
|
@ -109,7 +109,7 @@ public class MarriagePlayer implements MPlayer {
|
|||
@Override
|
||||
public MPlayer getPartner() {
|
||||
Marriage core = MarriagePlugin.getCore();
|
||||
if(marriage != null) {
|
||||
if (marriage != null) {
|
||||
UUID id = uuid.equals(marriage.getPlayer1Id()) ? marriage.getPllayer2Id() : marriage.getPlayer1Id();
|
||||
return core.getMPlayer(id);
|
||||
}
|
||||
|
@ -119,13 +119,13 @@ public class MarriagePlayer implements MPlayer {
|
|||
|
||||
@Override
|
||||
public void divorce() {
|
||||
if(marriage == null) {
|
||||
if (marriage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerDivorceEvent event = new PlayerDivorceEvent(this, marriage);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -164,4 +164,4 @@ public class MarriagePlayer implements MPlayer {
|
|||
public void setChatSpy(boolean chatSpy) {
|
||||
this.chatSpy = chatSpy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ public class ChatListener implements Listener {
|
|||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
MPlayer mp = core.getMPlayer(player);
|
||||
if(mp.isInChat()) {
|
||||
if (mp.isInChat()) {
|
||||
// Private chat
|
||||
if(!mp.isMarried() || !isOnline(mp.getPartner())) {
|
||||
if (!mp.isMarried() || !isOnline(mp.getPartner())) {
|
||||
mp.setInChat(false);
|
||||
return;
|
||||
}
|
||||
|
@ -46,11 +46,11 @@ public class ChatListener implements Listener {
|
|||
|
||||
// Admin chat spy
|
||||
String adminMessage = null; // No need to format message if we're not going to send it.
|
||||
for(Player admin : Bukkit.getOnlinePlayers()) {
|
||||
if(admin.equals(player) || admin.equals(partner)) continue;
|
||||
for (Player admin : Bukkit.getOnlinePlayers()) {
|
||||
if (admin.equals(player) || admin.equals(partner)) continue;
|
||||
final MPlayer mAdmin = core.getMPlayer(admin);
|
||||
if(!mAdmin.isChatSpy()) continue;
|
||||
if(adminMessage == null) {
|
||||
if (!mAdmin.isChatSpy()) continue;
|
||||
if (adminMessage == null) {
|
||||
// Format message
|
||||
adminMessage = Settings.CHATSPY_FORMAT.value()
|
||||
.replace("{sender}", player.getName())
|
||||
|
@ -72,19 +72,20 @@ public class ChatListener implements Listener {
|
|||
final Player player = event.getPlayer();
|
||||
final MPlayer mplayer = core.getMPlayer(player);
|
||||
|
||||
if(Settings.FORCE_FORMAT.value()) {
|
||||
if (Settings.FORCE_FORMAT.value()) {
|
||||
format = "{marriage_status}" + format; // Enforce marriage format
|
||||
} if(Settings.FORCE_GENDER_FORMAT.value()) {
|
||||
}
|
||||
if (Settings.FORCE_GENDER_FORMAT.value()) {
|
||||
format = "{marriage_gender}" + format;
|
||||
}
|
||||
|
||||
// Marriage status
|
||||
if(format.contains("{marriage_status}")) {
|
||||
if (format.contains("{marriage_status}")) {
|
||||
String status = Settings.CHAT_FORMAT_UNMARRIED.value();
|
||||
if(mplayer.isMarried()) {
|
||||
if (mplayer.isMarried()) {
|
||||
String partner =
|
||||
player.hasMetadata("marriedTo") && player.getMetadata("marriedTo").size() > 0
|
||||
? player.getMetadata("marriedTo").get(0).asString() : "";
|
||||
? player.getMetadata("marriedTo").get(0).asString() : "";
|
||||
|
||||
status = Settings.CHAT_FORMAT.value()
|
||||
.replace("{heart}", "\u2764")
|
||||
|
@ -93,7 +94,7 @@ public class ChatListener implements Listener {
|
|||
status = formatIcons(status);
|
||||
}
|
||||
|
||||
if(!status.isEmpty()) {
|
||||
if (!status.isEmpty()) {
|
||||
status = ChatColor.translateAlternateColorCodes('&', status);
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ public class ChatListener implements Listener {
|
|||
}
|
||||
|
||||
// Gender format
|
||||
if(format.contains("{marriage_gender}")) {
|
||||
if (format.contains("{marriage_gender}")) {
|
||||
String gender = mplayer.getGender().getChatPrefix();
|
||||
gender = formatIcons(gender);
|
||||
gender = ChatColor.translateAlternateColorCodes('&', gender);
|
||||
|
@ -121,7 +122,7 @@ public class ChatListener implements Listener {
|
|||
}
|
||||
|
||||
private boolean isOnline(MPlayer mp) {
|
||||
if(mp == null) return false;
|
||||
if (mp == null) return false;
|
||||
Player player = Bukkit.getPlayer(mp.getUniqueId());
|
||||
return player != null && player.isOnline();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class DatabaseListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogin(AsyncPlayerPreLoginEvent event) {
|
||||
if(event.getLoginResult() == Result.ALLOWED) {
|
||||
if (event.getLoginResult() == Result.ALLOWED) {
|
||||
MarriagePlayer player = core.getDataManager().loadPlayer(event.getUniqueId());
|
||||
player.setLastName(event.getName());
|
||||
cache.put(event.getUniqueId(), player);
|
||||
|
@ -44,7 +44,7 @@ public class DatabaseListener implements Listener {
|
|||
final Player player = event.getPlayer();
|
||||
final UUID userId = player.getUniqueId();
|
||||
MarriagePlayer mplayer = cache.getIfPresent(userId);
|
||||
if(mplayer != null) {
|
||||
if (mplayer != null) {
|
||||
loadPartnerName(mplayer, player);
|
||||
core.setMPlayer(userId, mplayer);
|
||||
return;
|
||||
|
@ -63,18 +63,18 @@ public class DatabaseListener implements Listener {
|
|||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
core.unloadPlayer(player.getUniqueId());
|
||||
if(player.hasMetadata("marriedTo")) {
|
||||
if (player.hasMetadata("marriedTo")) {
|
||||
player.removeMetadata("marriedTo", core.getPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPartnerName(final MPlayer mplayer, final Player player) {
|
||||
if(!mplayer.isMarried()) return;
|
||||
if (!mplayer.isMarried()) return;
|
||||
DataManager.getExecutorService().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String partner = ListQuery.getName(core.getDataManager(), mplayer.getMarriage().getOtherPlayer(player.getUniqueId()));
|
||||
if(partner == null) {
|
||||
if (partner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,30 +29,30 @@ public class KissListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
||||
if(!Settings.KISSES_ENABLED.value()) return; // Disabled
|
||||
if (!Settings.KISSES_ENABLED.value()) return; // Disabled
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
Entity e = event.getRightClicked();
|
||||
if(!(e instanceof Player)) {
|
||||
if (!(e instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player clicked = (Player) e;
|
||||
if(!player.isSneaking() || !clicked.isSneaking()) {
|
||||
if (!player.isSneaking() || !clicked.isSneaking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mp = core.getMPlayer(player);
|
||||
if(!mp.isMarried()) {
|
||||
if (!mp.isMarried()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MData data = mp.getMarriage();
|
||||
if(!clicked.getUniqueId().toString().equalsIgnoreCase(data.getOtherPlayer(player.getUniqueId()).toString())) {
|
||||
if (!clicked.getUniqueId().toString().equalsIgnoreCase(data.getOtherPlayer(player.getUniqueId()).toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!cooldown.performCheck(player.getName()) || !cooldown.performCheck(clicked.getName())) {
|
||||
if (!cooldown.performCheck(player.getName()) || !cooldown.performCheck(clicked.getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,15 +24,15 @@ public class LegacyPlotSquaredListener implements Listener {
|
|||
final UUID player = event.getRequesing().getUniqueId();
|
||||
final UUID partner = event.getRequested().getUniqueId();
|
||||
|
||||
for(Plot plot : plotSquared.getPlots(player)) {
|
||||
if(plot.getTrusted().contains(partner)) {
|
||||
for (Plot plot : plotSquared.getPlots(player)) {
|
||||
if (plot.getTrusted().contains(partner)) {
|
||||
continue;
|
||||
}
|
||||
plot.addTrusted(partner);
|
||||
}
|
||||
|
||||
for(Plot plot : plotSquared.getPlots(partner)) {
|
||||
if(plot.getTrusted().contains(player)) {
|
||||
for (Plot plot : plotSquared.getPlots(partner)) {
|
||||
if (plot.getTrusted().contains(player)) {
|
||||
continue;
|
||||
}
|
||||
plot.addTrusted(player);
|
||||
|
@ -45,15 +45,15 @@ public class LegacyPlotSquaredListener implements Listener {
|
|||
final UUID player = marriage.getPlayer1Id();
|
||||
final UUID partner = marriage.getPllayer2Id();
|
||||
|
||||
for(Plot plot : plotSquared.getPlots(player)) {
|
||||
if(!plot.getTrusted().contains(partner)) {
|
||||
for (Plot plot : plotSquared.getPlots(player)) {
|
||||
if (!plot.getTrusted().contains(partner)) {
|
||||
continue;
|
||||
}
|
||||
plot.removeTrusted(partner);
|
||||
}
|
||||
|
||||
for(Plot plot : plotSquared.getPlots(partner)) {
|
||||
if(!plot.getTrusted().contains(player)) {
|
||||
for (Plot plot : plotSquared.getPlots(partner)) {
|
||||
if (!plot.getTrusted().contains(player)) {
|
||||
continue;
|
||||
}
|
||||
plot.removeTrusted(player);
|
||||
|
|
|
@ -28,21 +28,22 @@ public class PlayerListener implements Listener {
|
|||
final Entity e0 = event.getEntity();
|
||||
final Entity e1 = event.getDamager();
|
||||
// Verify damaged entity is player
|
||||
if(!(e0 instanceof Player)) {
|
||||
if (!(e0 instanceof Player)) {
|
||||
return;
|
||||
} if(!(e1 instanceof Player) && !(e1 instanceof Projectile)) {
|
||||
}
|
||||
if (!(e1 instanceof Player) && !(e1 instanceof Projectile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify damager is player
|
||||
final Player player = (Player) e0;
|
||||
final Player damager;
|
||||
if(e1 instanceof Player) {
|
||||
if (e1 instanceof Player) {
|
||||
damager = (Player) e1;
|
||||
} else {
|
||||
Projectile projectile = (Projectile) e1;
|
||||
final ProjectileSource e3 = projectile.getShooter();
|
||||
if(e3 == null || !(e3 instanceof Player)) {
|
||||
if (e3 == null || !(e3 instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
damager = (Player) e3;
|
||||
|
@ -50,12 +51,12 @@ public class PlayerListener implements Listener {
|
|||
|
||||
// Verify marriage
|
||||
MPlayer mplayer = marriage.getMPlayer(player);
|
||||
if(!mplayer.isMarried() || mplayer.getMarriage().getOtherPlayer(player.getUniqueId()) != damager.getUniqueId()) {
|
||||
if (!mplayer.isMarried() || mplayer.getMarriage().getOtherPlayer(player.getUniqueId()) != damager.getUniqueId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify pvp setting
|
||||
if(mplayer.getMarriage().isPVPEnabled()) {
|
||||
if (mplayer.getMarriage().isPVPEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,38 +65,38 @@ public class PlayerListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerGainExp(PlayerExpChangeEvent event) {
|
||||
if(!Settings.EXP_BOOST_ENABLED.value()) {
|
||||
if (!Settings.EXP_BOOST_ENABLED.value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int gained = event.getAmount();
|
||||
if(gained <= 0) {
|
||||
if (gained <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final MPlayer mplayer = marriage.getMPlayer(player);
|
||||
if(!mplayer.isMarried()) {
|
||||
if (!mplayer.isMarried()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MPlayer mpartner = mplayer.getPartner();
|
||||
Player partner = Bukkit.getPlayer(mpartner.getUniqueId());
|
||||
if(partner == null || !partner.isOnline()) {
|
||||
if (partner == null || !partner.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!partner.getWorld().equals(player.getWorld())) {
|
||||
if (!partner.getWorld().equals(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(partner.getLocation().distanceSquared(partner.getLocation()) > Settings.EXP_BOOST_DISTANCE.value() * Settings.EXP_BOOST_DISTANCE.value()) {
|
||||
if (partner.getLocation().distanceSquared(partner.getLocation()) > Settings.EXP_BOOST_DISTANCE.value() * Settings.EXP_BOOST_DISTANCE.value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setAmount((int) Math.round(gained * Settings.EXP_BOOST_MULTIPLIER.value()));
|
||||
final int bonus = event.getAmount() - gained;
|
||||
if(bonus > 0 && Settings.EXP_BOOST_ANNOUNCE.value()) {
|
||||
if (bonus > 0 && Settings.EXP_BOOST_ANNOUNCE.value()) {
|
||||
Message.BONUS_EXP.send(player, bonus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,18 +22,18 @@ public class UpdateListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if(Permissions.UPDATE.has(player)) {
|
||||
if (Permissions.UPDATE.has(player)) {
|
||||
final Updater updater = core.getUpdater();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(core.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean update = false;
|
||||
if(update) {
|
||||
if (update) {
|
||||
Bukkit.getScheduler().runTask(core.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Version version = updater.getNewVersion();
|
||||
if(version == null) return;
|
||||
if (version == null) return;
|
||||
String message = ChatColor.translateAlternateColorCodes('&',
|
||||
String.format(Message.UPDATE_AVAILABLE.toString(),
|
||||
version.getName(), version.getServerVersion()));
|
||||
|
|
|
@ -26,15 +26,15 @@ public class V5PlotSquaredListener implements Listener {
|
|||
PlotPlayer plotPlayer = plotSquared.wrapPlayer(player);
|
||||
PlotPlayer plotPartner = plotSquared.wrapPlayer(partner);
|
||||
|
||||
for(Plot plot : plotSquared.getPlayerPlots(plotPlayer)) {
|
||||
if(plot.getTrusted().contains(partner)) {
|
||||
for (Plot plot : plotSquared.getPlayerPlots(plotPlayer)) {
|
||||
if (plot.getTrusted().contains(partner)) {
|
||||
continue;
|
||||
}
|
||||
plot.addTrusted(partner);
|
||||
}
|
||||
|
||||
for(Plot plot : plotSquared.getPlayerPlots(plotPartner)) {
|
||||
if(plot.getTrusted().contains(player)) {
|
||||
for (Plot plot : plotSquared.getPlayerPlots(plotPartner)) {
|
||||
if (plot.getTrusted().contains(player)) {
|
||||
continue;
|
||||
}
|
||||
plot.addTrusted(player);
|
||||
|
@ -49,15 +49,15 @@ public class V5PlotSquaredListener implements Listener {
|
|||
PlotPlayer plotPlayer = plotSquared.wrapPlayer(player);
|
||||
PlotPlayer plotPartner = plotSquared.wrapPlayer(partner);
|
||||
|
||||
for(Plot plot : plotSquared.getPlayerPlots(plotPlayer)) {
|
||||
if(!plot.getTrusted().contains(partner)) {
|
||||
for (Plot plot : plotSquared.getPlayerPlots(plotPlayer)) {
|
||||
if (!plot.getTrusted().contains(partner)) {
|
||||
continue;
|
||||
}
|
||||
plot.removeTrusted(partner);
|
||||
}
|
||||
|
||||
for(Plot plot : plotSquared.getPlayerPlots(plotPartner)) {
|
||||
if(!plot.getTrusted().contains(player)) {
|
||||
for (Plot plot : plotSquared.getPlayerPlots(plotPartner)) {
|
||||
if (!plot.getTrusted().contains(player)) {
|
||||
continue;
|
||||
}
|
||||
plot.removeTrusted(player);
|
||||
|
|
|
@ -22,11 +22,10 @@ public class BConfig extends YamlConfiguration {
|
|||
this.core = core;
|
||||
this.file = file;
|
||||
file.getParentFile().mkdirs();
|
||||
if(!file.exists()) {
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch(IOException e) {
|
||||
;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +35,7 @@ public class BConfig extends YamlConfiguration {
|
|||
public void reload() {
|
||||
try {
|
||||
load(file);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to reload configuration file", e);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +43,7 @@ public class BConfig extends YamlConfiguration {
|
|||
public void save() {
|
||||
try {
|
||||
save(file);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to save configuration file", e);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +55,7 @@ public class BConfig extends YamlConfiguration {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getOrSet(String key, T def) {
|
||||
if(contains(key)) {
|
||||
if (contains(key)) {
|
||||
return (T) get(key);
|
||||
} else {
|
||||
set(key, def);
|
||||
|
@ -74,22 +73,22 @@ public class BConfig extends YamlConfiguration {
|
|||
output = new FileOutputStream(file);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while((length = input.read(buffer, 0, buffer.length)) != -1) {
|
||||
while ((length = input.read(buffer, 0, buffer.length)) != -1) {
|
||||
output.write(buffer, 0, length);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
MarriagePlugin.getCore().getLogger().log(Level.WARNING, "Failed to copy file", e);
|
||||
} finally {
|
||||
if(input != null) {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch(IOException e1) {
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
}
|
||||
if(output != null) {
|
||||
if (output != null) {
|
||||
try {
|
||||
output.close();
|
||||
} catch(IOException e1) {
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class Cooldown<T> {
|
|||
* @return Whether key is in cooldown or not
|
||||
*/
|
||||
public boolean performCheck(T key) {
|
||||
if(isCached(key)) return false;
|
||||
if (isCached(key)) return false;
|
||||
set(key);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ListQuery {
|
|||
this.pages = pages;
|
||||
this.page = page;
|
||||
this.marriages = marriages;
|
||||
for(MData marriage : marriages) {
|
||||
for (MData marriage : marriages) {
|
||||
names.put(marriage.getPlayer1Id(), getNameFormat(db, marriage.getPlayer1Id()));
|
||||
names.put(marriage.getPllayer2Id(), getNameFormat(db, marriage.getPllayer2Id()));
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ public class ListQuery {
|
|||
public void run() {
|
||||
to.sendMessage(ChatColor.GOLD + ChatColor.BOLD.toString() + "Married players:");
|
||||
to.sendMessage(ChatColor.GOLD + "Page " + (page + 1) + "/" + pages);
|
||||
if(Settings.GENDER_IN_LIST.value()) {
|
||||
to.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bmale &f- &dfemale &f- &7unknown"));
|
||||
if (Settings.GENDER_IN_LIST.value()) {
|
||||
to.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bmale &f- &dfemale &f- &7none"));
|
||||
}
|
||||
for(MData data : marriages) {
|
||||
for (MData data : marriages) {
|
||||
to.sendMessage(names.get(data.getPlayer1Id()) + ChatColor.WHITE + " + " + names.get(data.getPllayer2Id()));
|
||||
}
|
||||
}
|
||||
|
@ -72,22 +72,22 @@ public class ListQuery {
|
|||
|
||||
public static String getNameFormat(DataManager db, UUID userId) {
|
||||
String name = getName(db, userId);
|
||||
if(name == null) {
|
||||
if (name == null) {
|
||||
return ChatColor.GREEN + "???";
|
||||
}
|
||||
|
||||
ChatColor color = ChatColor.GREEN;
|
||||
if(Settings.GENDER_IN_LIST.value()) {
|
||||
if (Settings.GENDER_IN_LIST.value()) {
|
||||
MarriagePlayer mp = db.loadPlayer(userId);
|
||||
Gender gender = mp == null ? Gender.UNKNOWN : mp.getGender();
|
||||
switch(gender) {
|
||||
Gender gender = mp == null ? Gender.NONE : mp.getGender();
|
||||
switch (gender) {
|
||||
case MALE:
|
||||
color = ChatColor.AQUA;
|
||||
break;
|
||||
case FEMALE:
|
||||
color = ChatColor.LIGHT_PURPLE;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
case NONE:
|
||||
color = ChatColor.GRAY;
|
||||
break;
|
||||
}
|
||||
|
@ -99,13 +99,13 @@ public class ListQuery {
|
|||
public static String getName(DataManager db, UUID userId) {
|
||||
// local uuid cache
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(userId);
|
||||
if(op != null && op.getName() != null) {
|
||||
if (op != null && op.getName() != null) {
|
||||
return op.getName();
|
||||
}
|
||||
|
||||
// local database
|
||||
MarriagePlayer mp = db.loadPlayer(userId);
|
||||
if(mp.getLastName() != null) {
|
||||
if (mp.getLastName() != null) {
|
||||
return mp.getLastName();
|
||||
}
|
||||
|
||||
|
@ -121,16 +121,16 @@ public class ListQuery {
|
|||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while((line = reader.readLine()) != null) {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
|
||||
JsonArray entries = JSON_PARSER.parse(builder.toString()).getAsJsonArray();
|
||||
if(entries.size() == 0) return null; // Fail
|
||||
if (entries.size() == 0) return null; // Fail
|
||||
JsonObject lastEntry = entries.get(entries.size() - 1).getAsJsonObject();
|
||||
return lastEntry.get("name").getAsString();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
return null; // Complete failure
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ public class LockedReference {
|
|||
lock.lock();
|
||||
|
||||
// Check if object not defined or expired.
|
||||
if(timeClaimed + expiryTime < System.currentTimeMillis()) {
|
||||
if (timeClaimed + expiryTime < System.currentTimeMillis()) {
|
||||
// Invalidate old object
|
||||
if(object != null && invalidator != null) {
|
||||
if (object != null && invalidator != null) {
|
||||
invalidator.accept(object);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,19 +63,19 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||
public Map<String, UUID> call() throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
||||
for(int i = 0; i < requests; i++) {
|
||||
for (int i = 0; i < requests; i++) {
|
||||
HttpURLConnection connection = createConnection();
|
||||
String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
|
||||
writeBody(connection, body);
|
||||
JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
for(Object profile : array) {
|
||||
for (Object profile : array) {
|
||||
JSONObject jsonProfile = (JSONObject) profile;
|
||||
String id = (String) jsonProfile.get("id");
|
||||
String name = (String) jsonProfile.get("name");
|
||||
UUID uuid = UUIDFetcher.getUUID(id);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
if(rateLimiting && i != requests - 1) {
|
||||
if (rateLimiting && i != requests - 1) {
|
||||
Thread.sleep(100L);
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||
}
|
||||
|
||||
public static UUID fromBytes(byte[] array) {
|
||||
if(array.length != 16) {
|
||||
if (array.length != 16) {
|
||||
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
|
||||
}
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
|
||||
|
|
Loading…
Reference in New Issue