Format Code, Fixed 2 NPE's

This commit is contained in:
Driftay 2019-12-19 14:23:41 -05:00
parent fec07b6fac
commit 368a605d31
23 changed files with 54 additions and 57 deletions

View File

@ -70,8 +70,8 @@ public class FLocation implements Serializable {
String worldName = string.substring(start, index); String worldName = string.substring(start, index);
start = index + 1; start = index + 1;
index = string.indexOf(",", start); index = string.indexOf(",", start);
int x = Integer.valueOf(string.substring(start, index)); int x = Integer.parseInt(string.substring(start, index));
int y = Integer.valueOf(string.substring(index + 1, string.length() - 1)); int y = Integer.parseInt(string.substring(index + 1, string.length() - 1));
return new FLocation(worldName, x, y); return new FLocation(worldName, x, y);
} }

View File

@ -84,7 +84,9 @@ public class CmdAdmin extends FCommand {
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer)); fplayer.msg(TL.COMMAND_ADMIN_PROMOTED,
context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true),
fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
} }
} }

View File

@ -19,12 +19,12 @@ public class CmdDiscord extends FCommand {
if (context.fPlayer.discordSetup()) { if (context.fPlayer.discordSetup()) {
context.fPlayer.msg(TL.DISCORD_ALREADY_LINKED, context.fPlayer.discordUser().getName()); context.fPlayer.msg(TL.DISCORD_ALREADY_LINKED, context.fPlayer.discordUser().getName());
} else { } else {
if (Discord.waitingLink.values().contains(context.fPlayer)) { if (Discord.waitingLink.containsValue(context.fPlayer)) {
context.fPlayer.msg(TL.DISCORD_CODE_SENT, Discord.waitingLinkk.get(context.fPlayer), Discord.mainGuild.getSelfMember().getEffectiveName()); context.fPlayer.msg(TL.DISCORD_CODE_SENT, Discord.waitingLinkk.get(context.fPlayer), Discord.mainGuild.getSelfMember().getEffectiveName());
return; return;
} }
Integer random = new Random().nextInt(9999); Integer random = new Random().nextInt(9999);
while (Discord.waitingLink.values().contains(random)) { while (Discord.waitingLink.containsValue(random)) {
random = new Random().nextInt(9999); random = new Random().nextInt(9999);
} }
Discord.waitingLink.put(random, context.fPlayer); Discord.waitingLink.put(random, context.fPlayer);

View File

@ -63,7 +63,7 @@ public class CmdCheck extends FCommand {
} }
} }
List<Map.Entry<UUID, Integer>> entryList = players.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getValue)).collect(Collectors.toList()); List<Map.Entry<UUID, Integer>> entryList = players.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getValue)).collect(Collectors.toList());
for (int max = (entryList.size() > 10) ? 10 : entryList.size(), current = 0; current < max; ++current) { for (int max = Math.min(entryList.size(), 10), current = 0; current < max; ++current) {
Map.Entry<UUID, Integer> entry = entryList.get(current); Map.Entry<UUID, Integer> entry = entryList.get(current);
OfflinePlayer offlinePlayer = FactionsPlugin.getInstance().getServer().getOfflinePlayer(entry.getKey()); OfflinePlayer offlinePlayer = FactionsPlugin.getInstance().getServer().getOfflinePlayer(entry.getKey());
context.msg(TL.CHECK_LEADERBOARD_LINE.format(current + 1, offlinePlayer.getName(), entry.getValue(), context.faction.getPlayerBufferCheckCount().getOrDefault(entry.getKey(), 0), context.faction.getPlayerWallCheckCount().getOrDefault(entry.getKey(), 0))); context.msg(TL.CHECK_LEADERBOARD_LINE.format(current + 1, offlinePlayer.getName(), entry.getValue(), context.faction.getPlayerBufferCheckCount().getOrDefault(entry.getKey(), 0), context.faction.getPlayerWallCheckCount().getOrDefault(entry.getKey(), 0)));

View File

@ -29,7 +29,7 @@ public class WildGUI implements FactionGUI {
} }
@Override @Override
public void onClick(int slot, ClickType action) { public void onClick(int slot, ClickType action) {
if (map.keySet().contains(slot)) { if (map.containsKey(slot)) {
String zone = map.get(slot); String zone = map.get(slot);
if (fplayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("Wild.Zones." + zone + ".Cost"))) { if (fplayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("Wild.Zones." + zone + ".Cost"))) {
CmdWild.waitingTeleport.put(player, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait")); CmdWild.waitingTeleport.put(player, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait"));

View File

@ -46,6 +46,7 @@ public class CmdSetGuild extends FCommand {
JDA jda = Discord.jda; JDA jda = Discord.jda;
if (jda != null) { if (jda != null) {
if (!this.waiterAdded) { if (!this.waiterAdded) {
//Do Not Change, Must Remain EventWaiter[]
jda.addEventListener(new EventWaiter[]{this.eventWaiter}); jda.addEventListener(new EventWaiter[]{this.eventWaiter});
this.waiterAdded = true; this.waiterAdded = true;
} }

View File

@ -15,6 +15,7 @@ import net.dv8tion.jda.core.exceptions.RateLimitedException;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
public class Discord { public class Discord {
@ -37,7 +38,7 @@ public class Discord {
public static Emote negative; public static Emote negative;
public Discord(FactionsPlugin plugin) { public Discord(FactionsPlugin plugin) {
this.plugin = plugin; Discord.plugin = plugin;
setupLog = new HashSet<>(); setupLog = new HashSet<>();
waitingLink = new HashMap<>(); waitingLink = new HashMap<>();
waitingLinkk = new HashMap<>(); waitingLinkk = new HashMap<>();
@ -216,8 +217,8 @@ public class Discord {
mainGuild.getController().setNickname(m, Discord.getNicknameString(fp)).queue(); mainGuild.getController().setNickname(m, Discord.getNicknameString(fp)).queue();
} }
if (Conf.factionRoles) { if (Conf.factionRoles) {
mainGuild.getController().removeSingleRoleFromMember(m, getRoleFromName(oldTag)).queue(); mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue();
mainGuild.getController().addSingleRoleToMember(m, createFactionRole(f.getTag())).queue(); mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(createFactionRole(f.getTag()))).queue();
} }
} catch (HierarchyException e) {System.out.print(e.getMessage());} } catch (HierarchyException e) {System.out.print(e.getMessage());}
} }

View File

@ -6,7 +6,6 @@ import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.*; import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent;
import net.dv8tion.jda.core.exceptions.PermissionException; import net.dv8tion.jda.core.exceptions.PermissionException;
@ -38,7 +37,7 @@ public class DiscordListener extends ListenerAdapter {
this.decimalFormat = new DecimalFormat("$#,###.##"); this.decimalFormat = new DecimalFormat("$#,###.##");
this.plugin = plugin; this.plugin = plugin;
int minute = 3600; int minute = 3600;
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, DiscordListener::saveGuilds, (long) (minute * 15), (long) (minute * 15)); plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, DiscordListener::saveGuilds, minute * 15, minute * 15);
} }
private static JSONGuilds loadGuilds() { private static JSONGuilds loadGuilds() {
@ -59,29 +58,33 @@ public class DiscordListener extends ListenerAdapter {
try { try {
String content = FactionsPlugin.getInstance().gson.toJson(guilds); String content = FactionsPlugin.getInstance().gson.toJson(guilds);
Files.write(file.toPath(), content.getBytes()); Files.write(file.toPath(), content.getBytes());
} } catch (IOException e) {
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new NullPointerException(); throw new NullPointerException();
} }
} }
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) { public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
Integer i = 0; Integer i;
if (e.getAuthor().isBot()) {return;} if (e.getAuthor().isBot()) {
return;
}
try { try {
i = Integer.valueOf(e.getMessage().getContentDisplay()); i = Integer.valueOf(e.getMessage().getContentDisplay());
} catch (NumberFormatException ex) {e.getChannel().sendMessage(TL.DISCORD_CODE_INVALID_FORMAT.toString()).queue(); } catch (NumberFormatException ex) {
return;} e.getChannel().sendMessage(TL.DISCORD_CODE_INVALID_FORMAT.toString()).queue();
if (Discord.waitingLink.keySet().contains(i)) { return;
}
if (Discord.waitingLink.containsKey(i)) {
FPlayer f = Discord.waitingLink.get(i); FPlayer f = Discord.waitingLink.get(i);
f.setDiscordSetup(true); f.setDiscordSetup(true);
f.setDiscordUserID(e.getAuthor().getId()); f.setDiscordUserID(e.getAuthor().getId());
e.getChannel().sendMessage(TL.DISCORD_LINK_SUCCESS.toString()).queue(); e.getChannel().sendMessage(TL.DISCORD_LINK_SUCCESS.toString()).queue();
Discord.waitingLink.remove(i); Discord.waitingLink.remove(i);
Discord.waitingLinkk.remove(f); Discord.waitingLinkk.remove(f);
} else {e.getChannel().sendMessage(TL.DISCORD_CODE_INVALID_KEY.toString()).queue(); } else {
return;} e.getChannel().sendMessage(TL.DISCORD_CODE_INVALID_KEY.toString()).queue();
}
} }
public void onGuildMessageReceived(GuildMessageReceivedEvent event) { public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
@ -469,7 +472,7 @@ public class DiscordListener extends ListenerAdapter {
List<Map.Entry<UUID, Integer>> entryList = players.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getValue)).collect(Collectors.toList()); List<Map.Entry<UUID, Integer>> entryList = players.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getValue)).collect(Collectors.toList());
EmbedBuilder embedBuilder = new EmbedBuilder().setTitle("Check Leaderboard").setColor(Color.MAGENTA); EmbedBuilder embedBuilder = new EmbedBuilder().setTitle("Check Leaderboard").setColor(Color.MAGENTA);
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
for (int max = (entryList.size() > 10) ? 10 : entryList.size(), current = 0; current < max; ++current) { for (int max = Math.min(entryList.size(), 10), current = 0; current < max; ++current) {
Map.Entry<UUID, Integer> entry2 = entryList.get(current); Map.Entry<UUID, Integer> entry2 = entryList.get(current);
OfflinePlayer offlinePlayer = this.plugin.getServer().getOfflinePlayer(entry2.getKey()); OfflinePlayer offlinePlayer = this.plugin.getServer().getOfflinePlayer(entry2.getKey());
stringBuilder.append("**").append(current + 1).append(".** ").append(offlinePlayer.getName()).append(" __").append(entry2.getValue()).append(" Total (").append(faction.getPlayerBufferCheckCount().getOrDefault(entry2.getKey(), 0)).append(" Buffer, ").append(faction.getPlayerWallCheckCount().getOrDefault(entry2.getKey(), 0)).append(" Wall)__\n"); stringBuilder.append("**").append(current + 1).append(".** ").append(offlinePlayer.getName()).append(" __").append(entry2.getValue()).append(" Total (").append(faction.getPlayerBufferCheckCount().getOrDefault(entry2.getKey(), 0)).append(" Buffer, ").append(faction.getPlayerWallCheckCount().getOrDefault(entry2.getKey(), 0)).append(" Wall)__\n");

View File

@ -71,15 +71,15 @@ public class FactionChatHandler extends ListenerAdapter {
} else if (y.contains("@")) { } else if (y.contains("@")) {
List<Integer> ii = new ArrayList<>(); List<Integer> ii = new ArrayList<>();
int i = x.indexOf(y); int i = x.indexOf(y);
String mention = ""; StringBuilder mention = new StringBuilder();
while (i <= x.size() - 1) { while (i <= x.size() - 1) {
mention = mention + " " + x.get(i); mention.append(" ").append(x.get(i));
ii.add(i); ii.add(i);
if (mention.contains("#")) {break;} if (mention.toString().contains("#")) {break;}
i++; i++;
} }
if (mention.contains("#")) { if (mention.toString().contains("#")) {
String[] mentionA = mention.replace(" @", "").split("#"); String[] mentionA = mention.toString().replace(" @", "").split("#");
for (User u : Discord.jda.getUsersByName(mentionA[0], false)) { for (User u : Discord.jda.getUsersByName(mentionA[0], false)) {
if (u.getDiscriminator().equals(mentionA[1])) { if (u.getDiscriminator().equals(mentionA[1])) {

View File

@ -125,7 +125,7 @@ public class Econ {
} }
// Factions can be controlled by members that are moderators... or any member if any member can withdraw. // Factions can be controlled by members that are moderators... or any member if any member can withdraw.
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) { if (i instanceof FPlayer && you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) {
return true; return true;
} }

View File

@ -352,7 +352,7 @@ public class FactionsBlockListener implements Listener {
int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius"); int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius");
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects"); List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (Entity e1 : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), (double) radius, 255.0, (double) radius)) { for (Entity e1 : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
if (e1 instanceof Player) { if (e1 instanceof Player) {
Player player = (Player) e1; Player player = (Player) e1;
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
@ -468,7 +468,6 @@ public class FactionsBlockListener implements Listener {
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial(); boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) { if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }

View File

@ -171,7 +171,6 @@ public class FactionsPlayerListener implements Listener {
return CheckPlayerAccess(player, me, loc, otherFaction, access, permissableAction, false); return CheckPlayerAccess(player, me, loc, otherFaction, access, permissableAction, false);
} }
@SuppressWarnings("deprecation")
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) { public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) if (Conf.playersWhoBypassAllProtection.contains(player.getName()))
return true; return true;

View File

@ -46,7 +46,7 @@ public class MissionGUI implements FactionGUI {
int pick = r.nextInt(keys.size() - 1); int pick = r.nextInt(keys.size() - 1);
if (!keys.toArray()[pick].toString().equals("FillItem")) { if (!keys.toArray()[pick].toString().equals("FillItem")) {
missionName = keys.toArray()[pick].toString(); missionName = keys.toArray()[pick].toString();
if (!fPlayer.getFaction().getMissions().keySet().contains(missionName)) { if (!fPlayer.getFaction().getMissions().containsKey(missionName)) {
pickedMission = new Mission(missionName, plugin.getConfig().getString("Missions." + missionName + ".Mission.Type")); pickedMission = new Mission(missionName, plugin.getConfig().getString("Missions." + missionName + ".Mission.Type"));
fPlayer.getFaction().getMissions().put(missionName, pickedMission); fPlayer.getFaction().getMissions().put(missionName, pickedMission);
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(plugin.getConfig().getString("Missions." + missionName + ".Name"))); fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(plugin.getConfig().getString("Missions." + missionName + ".Name")));
@ -132,7 +132,7 @@ public class MissionGUI implements FactionGUI {
} }
} }
if (plugin.getConfig().getBoolean("Randomization.Enabled")) { if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
ItemStack start = null; ItemStack start;
ItemMeta meta; ItemMeta meta;
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).parseItem(); start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).parseItem();
meta = start.getItemMeta(); meta = start.getItemMeta();

View File

@ -42,11 +42,11 @@ public class ShopConfig {
getShop().set("items.1.slot", 1); getShop().set("items.1.slot", 1);
getShop().set("items.1.block", "STONE"); getShop().set("items.1.block", "STONE");
getShop().set("items.1.name", "&aTest Shop"); getShop().set("items.1.name", "&aTest Shop");
ArrayList lore = new ArrayList(); ArrayList lore = new ArrayList<>();
lore.add("&cFully Customizable Lore!"); lore.add("&cFully Customizable Lore!");
lore.add("&b&l{cost} &7Points"); lore.add("&b&l{cost} &7Points");
getShop().set("items.1.lore", lore); getShop().set("items.1.lore", lore);
ArrayList t = new ArrayList(); ArrayList t = new ArrayList<>();
t.add("broadcast %player% bought Test Shop!"); t.add("broadcast %player% bought Test Shop!");
getShop().set("items.1.cmds", t); getShop().set("items.1.cmds", t);
getShop().set("items.1.cost", 5); getShop().set("items.1.cost", 5);

View File

@ -30,13 +30,11 @@ public class ShopGUIFrame {
*/ */
private Gui gui; private Gui gui;
private String s;
public ShopGUIFrame(Faction f) { public ShopGUIFrame(Faction f) {
gui = new Gui(FactionsPlugin.getInstance(), gui = new Gui(FactionsPlugin.getInstance(),
FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4), FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4),
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name"))); FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
this.s = s;
} }
public void buildGUI(FPlayer fplayer) { public void buildGUI(FPlayer fplayer) {

View File

@ -449,7 +449,7 @@ public final class ReflectionUtils {
DOUBLE(double.class, Double.class), DOUBLE(double.class, Double.class),
BOOLEAN(boolean.class, Boolean.class); BOOLEAN(boolean.class, Boolean.class);
private static final Map<Class<?>, DataType> CLASS_MAP = new HashMap<Class<?>, DataType>(); private static final Map<Class<?>, DataType> CLASS_MAP = new HashMap<>();
// Initialize map for quick class lookup // Initialize map for quick class lookup
static { static {

View File

@ -17,7 +17,7 @@ public class InventoryItem {
private Runnable runnable; private Runnable runnable;
public InventoryItem(ItemStack original) { public InventoryItem(ItemStack original) {
this.clickMap = new HashMap(); this.clickMap = new HashMap<>();
this.item = original; this.item = original;
} }

View File

@ -18,8 +18,8 @@ import java.util.function.Consumer;
public abstract class SaberGUI { public abstract class SaberGUI {
public static Set<String> allGUINames = new HashSet(); public static Set<String> allGUINames = new HashSet<>();
public static Map<UUID, SaberGUI> activeGUIs = new ConcurrentHashMap(); public static Map<UUID, SaberGUI> activeGUIs = new ConcurrentHashMap<>();
public SaberGUI parentGUI; public SaberGUI parentGUI;
protected String title; protected String title;
protected int size; protected int size;
@ -34,7 +34,7 @@ public abstract class SaberGUI {
} }
public SaberGUI(Player player, String title, int size, InventoryType type) { public SaberGUI(Player player, String title, int size, InventoryType type) {
this.inventoryItems = new HashMap(); this.inventoryItems = new HashMap<>();
this.inventory = type == InventoryType.CHEST ? Bukkit.createInventory(null, size, title) : Bukkit.createInventory(null, type, title); this.inventory = type == InventoryType.CHEST ? Bukkit.createInventory(null, size, title) : Bukkit.createInventory(null, type, title);
this.player = player; this.player = player;
this.size = size; this.size = size;

View File

@ -652,10 +652,7 @@ public class FUpgradesGUI implements Listener {
} }
private boolean takeMoney(FPlayer fme, int amt) { private boolean takeMoney(FPlayer fme, int amt) {
if (fme.takeMoney(amt)) { return fme.takeMoney(amt);
return true;
}
return false;
} }
private boolean upgradeItem(FPlayer fme, UpgradeType upgrade, int level, int cost) { private boolean upgradeItem(FPlayer fme, UpgradeType upgrade, int level, int cost) {

View File

@ -280,7 +280,7 @@ public abstract class MemoryBoard extends Board {
//----------------------------------------------// //----------------------------------------------//
private List<String> oneLineToolTip(Faction faction, FPlayer to) { private List<String> oneLineToolTip(Faction faction, FPlayer to) {
return Arrays.asList(faction.describeTo(to)); return Collections.singletonList(faction.describeTo(to));
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")

View File

@ -419,7 +419,7 @@ public abstract class MemoryFPlayer implements FPlayer {
Discord.mainGuild.getController().removeSingleRoleFromMember(m, Discord.leader).queue(); Discord.mainGuild.getController().removeSingleRoleFromMember(m, Discord.leader).queue();
} }
if (Conf.factionRoles) { if (Conf.factionRoles) {
Discord.mainGuild.getController().removeSingleRoleFromMember(m, Discord.createFactionRole(this.getFaction().getTag())).queue(); Discord.mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(Discord.createFactionRole(this.getFaction().getTag()))).queue();
} }
if (Conf.factionDiscordTags) { if (Conf.factionDiscordTags) {
Discord.resetNick(this); Discord.resetNick(this);
@ -1130,7 +1130,7 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public void setMapHeight(int height) { public void setMapHeight(int height) {
this.mapHeight = height > (Conf.mapHeight * 2) ? (Conf.mapHeight * 2) : height; this.mapHeight = Math.min(height, (Conf.mapHeight * 2));
} }
public String getNameAndTitle(FPlayer fplayer) { public String getNameAndTitle(FPlayer fplayer) {

View File

@ -356,7 +356,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
Discord.mainGuild.getController().removeSingleRoleFromMember(m, Discord.mainGuild.getRoleById(Conf.leaderRole)).queue(); Discord.mainGuild.getController().removeSingleRoleFromMember(m, Discord.mainGuild.getRoleById(Conf.leaderRole)).queue();
} }
if (Conf.factionRoles) { if (Conf.factionRoles) {
Discord.mainGuild.getController().removeSingleRoleFromMember(m, Discord.createFactionRole(this.getTag())).queue(); Discord.mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(Discord.createFactionRole(this.getTag()))).queue();
} }
if (Conf.factionDiscordTags) { if (Conf.factionDiscordTags) {
Discord.resetNick(fplayer); Discord.resetNick(fplayer);
@ -455,7 +455,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
public int getUpgrade(UpgradeType upgrade) { public int getUpgrade(UpgradeType upgrade) {
if (upgrades.keySet().contains(upgrade.toString())) return upgrades.get(upgrade.toString()); if (upgrades.containsKey(upgrade.toString())) return upgrades.get(upgrade.toString());
return 0; return 0;
} }
@ -1330,7 +1330,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
if (Discord.useDiscord && replacements.get(0).discordSetup() && Discord.isInMainGuild(replacements.get(0).discordUser()) && Discord.mainGuild != null) { if (Discord.useDiscord && replacements.get(0).discordSetup() && Discord.isInMainGuild(replacements.get(0).discordUser()) && Discord.mainGuild != null) {
Member m = Discord.mainGuild.getMember(replacements.get(0).discordUser()); Member m = Discord.mainGuild.getMember(replacements.get(0).discordUser());
if (Conf.factionRoles) { if (Conf.factionRoles) {
Discord.mainGuild.getController().addSingleRoleToMember(m, Discord.createFactionRole(this.getTag())).queue(); Discord.mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(Discord.createFactionRole(this.getTag()))).queue();
} }
if (Conf.leaderRoles) { if (Conf.leaderRoles) {
Discord.mainGuild.getController().addSingleRoleToMember(m, Discord.mainGuild.getRoleById(Conf.leaderRole)).queue(); Discord.mainGuild.getController().addSingleRoleToMember(m, Discord.mainGuild.getRoleById(Conf.leaderRole)).queue();

View File

@ -60,10 +60,8 @@ public class TextUtil {
message.then(text).style(color); message.then(text).style(color);
} }
text = ""; text = "";
color = ChatColor.getByChar(chars[i + 1]);
} else {
color = ChatColor.getByChar(chars[i + 1]);
} }
color = ChatColor.getByChar(chars[i + 1]);
i++; // skip color char i++; // skip color char
} else { } else {
text += chars[i]; text += chars[i];
@ -119,8 +117,7 @@ public class TextUtil {
public static String implode(List<String> list, String glue) { public static String implode(List<String> list, String glue) {
StringBuilder ret = new StringBuilder(); StringBuilder ret = new StringBuilder();
for (int i = 0; i < list.size(); i++) for (String s : list) ret.append(glue).append(s);
ret.append(glue).append(list.get(i));
return ret.length() > 0 ? ret.toString().substring(glue.length()) : ""; return ret.length() > 0 ? ret.toString().substring(glue.length()) : "";
} }