Changed for loop to foreach / enhanced for loop

This commit is contained in:
Naman 2018-07-11 10:19:22 -05:00
parent bd7b57cf5a
commit fded071136
2 changed files with 6 additions and 2 deletions

View File

@ -387,6 +387,8 @@ public class FactionsPlayerListener implements Listener {
Faction factionFrom = Board.getInstance().getFactionAt(from); Faction factionFrom = Board.getInstance().getFactionAt(from);
Faction factionTo = Board.getInstance().getFactionAt(to); Faction factionTo = Board.getInstance().getFactionAt(to);
boolean changedFaction = (factionFrom != factionTo); boolean changedFaction = (factionFrom != factionTo);
if (changedFaction) { if (changedFaction) {
Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo,factionFrom,me)); Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo,factionFrom,me));
if (P.p.getConfig().getBoolean("Title.Show-Title")) { if (P.p.getConfig().getBoolean("Title.Show-Title")) {
@ -438,6 +440,7 @@ public class FactionsPlayerListener implements Listener {
if (me.isMapAutoUpdating()) { if (me.isMapAutoUpdating()) {
Bukkit.broadcastMessage("");
if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) { if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) {
if (P.p.getConfig().getBoolean("findfactionsexploit.log", false)) { if (P.p.getConfig().getBoolean("findfactionsexploit.log", false)) {
P.p.log(Level.WARNING, "%s tried to show a faction map too soon and triggered exploit blocker.", player.getName()); P.p.log(Level.WARNING, "%s tried to show a faction map too soon and triggered exploit blocker.", player.getName());

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -23,8 +24,8 @@ public class InventoryUtil {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(items.length); dataOutput.writeInt(items.length);
for (int i = 0; i < items.length; i++) { for (ItemStack item: items) {
dataOutput.writeObject(items[i]); dataOutput.writeObject(item);
} }
dataOutput.close(); dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray()); return Base64Coder.encodeLines(outputStream.toByteArray());