Lots of changes to get teams to work.

I had a lot of problems finding a bug so I put a lot of debug in.
This commit is contained in:
tastybento 2017-08-12 18:51:48 -07:00
parent 4c69587d9a
commit 55101f7ff2
14 changed files with 226 additions and 150 deletions

View File

@ -294,14 +294,16 @@ expel:
notyourself: "You cannot expel yourself!"
success: "You expelled [name]!"
invite:
errorCantJoinIsland: "You couldn't join the island, maybe it's full."
errorCoolDown: "You can invite that player again in [time] minutes"
errorNoOneInvitedYou: "No one invited you"
errorThatPlayerIsAlreadyInATeam: "That player is already in a team."
errorYouAreAlreadyOnATeam: "You are already on a team!"
errorYouCannotInviteYourself: "You can not invite yourself!"
errorYouMustHaveIslandToInvite: "You must have an island in order to invite people to it!"
errorYourIslandIsFull: "Your island is full, you can't invite anyone else."
error:
CantJoinIsland: "You couldn't join the island, maybe it's full."
CoolDown: "You can invite that player again in [time] minutes"
InvalidInvite: "That invite is no longer valid, sorry."
NoOneInvitedYou: "No one invited you"
ThatPlayerIsAlreadyInATeam: "That player is already in a team."
YouAreAlreadyOnATeam: "You are already on a team!"
YouCannotInviteYourself: "You can not invite yourself!"
YouMustHaveIslandToInvite: "You must have an island in order to invite people to it!"
YourIslandIsFull: "Your island is full, you can't invite anyone else."
hasJoinedYourIsland: "[name] has joined your island!"
help: "Use [/[label] invite <playername>] to invite a player to your island."
inviteSentTo: "Invite sent to [name]"

View File

@ -1,11 +1,19 @@
package us.tastybento.bskyblock;
import java.io.File;
import java.io.FilenameFilter;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Locale;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import us.tastybento.bskyblock.commands.AdminCommand;
import us.tastybento.bskyblock.commands.IslandCommand;
import us.tastybento.bskyblock.config.BSBLocale;
@ -26,13 +34,6 @@ import us.tastybento.bskyblock.schematics.SchematicsMgr;
import us.tastybento.bskyblock.util.FileLister;
import us.tastybento.bskyblock.util.VaultHelper;
import java.io.File;
import java.io.FilenameFilter;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Locale;
import java.util.UUID;
/**
* Main BSkyBlock class - provides an island minigame in the sky
* @author Tastybento

View File

@ -1,18 +1,28 @@
package us.tastybento.bskyblock.api.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.config.BSBLocale;
import us.tastybento.bskyblock.database.managers.IslandsManager;
import us.tastybento.bskyblock.database.managers.PlayersManager;
import us.tastybento.bskyblock.util.Util;
import java.util.*;
/**
*
* @author Poslovitch
@ -38,12 +48,12 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
protected AbstractCommand(BSkyBlock plugin, String label, String[] aliases, boolean help) {
this.plugin = plugin;
this.argumentsMap = new LinkedHashMap<>(1);
this.aliasesMap = new HashMap<>(1);
this.argumentsMap = new LinkedHashMap<>();
this.aliasesMap = new HashMap<>();
this.label = label;
this.aliases = aliases;
this.help = help;
this.teamMembers = new HashSet<UUID>(1);
this.teamMembers = new HashSet<UUID>();
// Register the help argument if needed
if (help) {
@ -250,8 +260,6 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
playerUUID = player.getUniqueId();
} else {
isPlayer = false;
player = null;
playerUUID = null;
}
// Check if the player is in a team or not and if so, grab the team leader's UUID
if (plugin.getPlayers().inTeam(playerUUID)) {
@ -260,8 +268,6 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
teamMembers = plugin.getIslands().getMembers(teamLeaderUUID);
} else {
inTeam = false;
teamLeaderUUID = null;
teamMembers.clear();
}
}

View File

@ -1,12 +1,13 @@
package us.tastybento.bskyblock.commands;
import java.util.Set;
import org.bukkit.command.CommandSender;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.AbstractCommand;
import us.tastybento.bskyblock.config.Settings;
import java.util.Set;
public class AdminCommand extends AbstractCommand {
BSkyBlock plugin;

View File

@ -9,6 +9,7 @@ import java.util.UUID;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -21,10 +22,7 @@ import com.google.common.collect.HashBiMap;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.AbstractCommand;
import us.tastybento.bskyblock.api.events.team.PlayerAcceptInviteEvent;
import us.tastybento.bskyblock.config.BSBLocale;
import us.tastybento.bskyblock.config.Settings;
import us.tastybento.bskyblock.database.managers.IslandsManager;
import us.tastybento.bskyblock.database.managers.PlayersManager;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.schematics.Schematic;
import us.tastybento.bskyblock.util.Util;
@ -447,7 +445,7 @@ public class IslandCommand extends AbstractCommand {
@Override
public void execute(CommandSender sender, String[] args) {
if (DEBUG)
plugin.getLogger().info("DEBUG: executing team command");
plugin.getLogger().info("DEBUG: executing team command for " + teamLeaderUUID);
if (teamLeaderUUID.equals(playerUUID)) {
int maxSize = Settings.maxTeamSize;
for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
@ -475,7 +473,7 @@ public class IslandCommand extends AbstractCommand {
if (teamMembers.size() < maxSize) {
Util.sendMessage(player, ChatColor.GREEN + getLocale(sender).get("invite.youCanInvite").replace("[number]", String.valueOf(maxSize - teamMembers.size())));
} else {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.errorYourIslandIsFull"));
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.YourIslandIsFull"));
}
}
Util.sendMessage(player, ChatColor.YELLOW + getLocale(sender).get("team.listingMembers"));
@ -517,7 +515,7 @@ public class IslandCommand extends AbstractCommand {
if (getPlayers().inTeam(playerUUID)) {
return new CanUseResp(ChatColor.RED + getLocale(sender).get("general.errors.not-leader"));
}
return new CanUseResp(ChatColor.RED + getLocale(sender).get("invite.errorYouMustHaveIslandToInvite"));
return new CanUseResp(ChatColor.RED + getLocale(sender).get("invite.error.YouMustHaveIslandToInvite"));
}
return new CanUseResp(true);
}
@ -546,19 +544,19 @@ public class IslandCommand extends AbstractCommand {
UUID invitedPlayerUUID = invitedPlayer.getUniqueId();
// Player cannot invite themselves
if (playerUUID.equals(invitedPlayerUUID)) {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.errorYouCannotInviteYourself"));
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.YouCannotInviteYourself"));
return;
}
// Check if this player can be invited to this island, or
// whether they are still on cooldown
long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(playerUUID));
if (time > 0 && !player.isOp()) {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.errorCoolDown").replace("[time]", String.valueOf(time)));
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.CoolDown").replace("[time]", String.valueOf(time)));
return;
}
// Player cannot invite someone already on a team
if (getPlayers().inTeam(invitedPlayerUUID)) {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.errorThatPlayerIsAlreadyInATeam"));
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.ThatPlayerIsAlreadyInATeam"));
return;
}
// Check if player has space on their team
@ -588,7 +586,7 @@ public class IslandCommand extends AbstractCommand {
}
if (teamMembers.size() < maxSize) {
// If that player already has an invite out then retract it.
// Players can only have one invite out at a time - interesting
// Players can only have one invite one at a time - interesting
if (inviteList.containsValue(playerUUID)) {
inviteList.inverse().remove(playerUUID);
Util.sendMessage(player, ChatColor.YELLOW + getLocale(sender).get("invite.removingInvite"));
@ -605,7 +603,7 @@ public class IslandCommand extends AbstractCommand {
Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.RED + getLocale(invitedPlayerUUID).get("invite.warningYouWillLoseIsland"));
}
} else {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.errorYourIslandIsFull"));
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.YourIslandIsFull"));
}
}
}
@ -793,53 +791,67 @@ public class IslandCommand extends AbstractCommand {
public void execute(CommandSender sender, String[] args) {
// Check if player has been invited
if (!inviteList.containsKey(playerUUID)) {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.errorNoOneInvitedYou"));
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.NoOneInvitedYou"));
return;
}
// Check if player is already in a team
if (getPlayers().inTeam(playerUUID)) {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.errorYouAreAlreadyOnATeam"));
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.YouAreAlreadyOnATeam"));
return;
}
// If the invitee has an island of their own
if (getPlayers().hasIsland(playerUUID)) {
plugin.getLogger().info(player.getName() + "'s island will be deleted because they joined a party.");
getIslands().deletePlayerIsland(playerUUID, true);
plugin.getLogger().info("Island deleted.");
// Get the team leader
UUID prospectiveTeamLeaderUUID = inviteList.get(playerUUID);
if (!getIslands().hasIsland(prospectiveTeamLeaderUUID)) {
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.InvalidInvite"));
inviteList.remove(playerUUID);
return;
}
// Set the team leader
teamLeaderUUID = inviteList.get(playerUUID);
// TODO implement this
getPlayers().resetPlayer(player);
if (DEBUG)
plugin.getLogger().info("DEBUG: Invite is valid");
// Remove the invite
if (DEBUG)
plugin.getLogger().info("DEBUG: Removing player from invite list");
inviteList.remove(playerUUID);
// Put player into Spectator mode
player.setGameMode(GameMode.SPECTATOR);
// Add the player to the team
if (DEBUG)
plugin.getLogger().info("DEBUG: adding " + playerUUID + " to team " + teamLeaderUUID);
getIslands().setJoinTeam(playerUUID, inviteList.get(playerUUID));
plugin.getLogger().info("DEBUG: adding " + playerUUID + " to team " + prospectiveTeamLeaderUUID);
Island island = getIslands().getIsland(prospectiveTeamLeaderUUID);
if (DEBUG)
plugin.getLogger().info("DEBUG: team members = " + island.getMembers().toString());
if (!getIslands().setJoinTeam(playerUUID, prospectiveTeamLeaderUUID)) {
// Not allowed (blocked by another listener)
return;
}
// TODO implement this
//getPlayers().resetPlayer(player);
setResetWaitTime(player);
if (Settings.teamJoinDeathReset) {
getPlayers().setDeaths(player.getUniqueId(), 0);
}
if (DEBUG)
plugin.getLogger().info("DEBUG: team leader's home is " + getPlayers().getHomeLocation(teamLeaderUUID));
plugin.getLogger().info("DEBUG: Setting home. team leader's home is " + getPlayers().getHomeLocation(prospectiveTeamLeaderUUID));
// Set the player's home
getPlayers().setHomeLocation(playerUUID, getPlayers().getHomeLocation(teamLeaderUUID));
getPlayers().setHomeLocation(playerUUID, getPlayers().getHomeLocation(prospectiveTeamLeaderUUID));
if (DEBUG)
plugin.getLogger().info("DEBUG: teleporting player to new island");
getIslands().homeTeleport(player);
// Fire event so add-ons can run commands, etc.
plugin.getServer().getPluginManager().callEvent(new PlayerAcceptInviteEvent(player));
Util.sendMessage(player, ChatColor.GREEN + getLocale(sender).get("invite.youHaveJoinedAnIsland"));
Util.sendMessage(player, ChatColor.GREEN + getLocale(sender).get("invite.youHaveJoinedAnIsland").replace("[label]", Settings.ISLANDCOMMAND));
if (DEBUG)
plugin.getLogger().info("DEBUG: Removing player from invite list");
if (plugin.getServer().getPlayer(inviteList.get(playerUUID)) != null) {
Util.sendMessage(plugin.getServer().getPlayer(inviteList.get(playerUUID)),
ChatColor.GREEN + getLocale(sender).get("invite.hasJoinedYourIsland").replace("[name]", player.getName()));
}
// Remove the invite
inviteList.remove(playerUUID);
getIslands().save(true);
getIslands().save(false);
if (DEBUG)
plugin.getLogger().info("DEBUG: After save " + getIslands().getIsland(prospectiveTeamLeaderUUID).getMembers().toString());
}
@Override

View File

@ -1,8 +1,5 @@
package us.tastybento.bskyblock.config;
import org.bukkit.ChatColor;
import us.tastybento.bskyblock.BSkyBlock;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@ -10,6 +7,10 @@ import java.net.URLClassLoader;
import java.util.Locale;
import java.util.ResourceBundle;
import org.bukkit.ChatColor;
import us.tastybento.bskyblock.BSkyBlock;
public class BSBLocale {
final static String LOCALE_FOLDER = "locales";

View File

@ -1,17 +1,18 @@
package us.tastybento.bskyblock.config;
import java.util.HashMap;
import java.util.List;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import us.tastybento.bskyblock.database.BSBDatabase.DatabaseType;
import us.tastybento.bskyblock.database.managers.OfflineHistoryMessages.HistoryMessageType;
import us.tastybento.bskyblock.database.objects.Island.SettingsFlag;
import java.util.HashMap;
import java.util.List;
/**
* All the plugin settings are here
* @author Tastybento

View File

@ -2,6 +2,7 @@ package us.tastybento.bskyblock.database.managers;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
@ -24,6 +25,9 @@ import org.bukkit.material.TrapDoor;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.util.Vector;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.events.island.IslandLeaveEvent;
import us.tastybento.bskyblock.config.Settings;
@ -45,11 +49,15 @@ import us.tastybento.bskyblock.util.Util;
*/
public class IslandsManager {
private static final boolean DEBUG = false;
private static final boolean DEBUG = true;
private static final boolean DEBUG2 = false;
private BSkyBlock plugin;
private BSBDatabase database;
private HashMap<Location, Island> islandsByLocation;
private BiMap<Location, Island> islandsByLocation;
/**
* Every player who is associated with an island is in this map.
*/
private HashMap<UUID, Island> islandsByUUID;
// 2D islandGrid of islands, x,z
private TreeMap<Integer, TreeMap<Integer, Island>> islandGrid = new TreeMap<Integer, TreeMap<Integer, Island>>();
@ -70,7 +78,7 @@ public class IslandsManager {
database = BSBDatabase.getDatabase();
// Set up the database handler to store and retrieve Island classes
handler = (AbstractDatabaseHandler<Island>) database.getHandler(plugin, Island.class);
islandsByLocation = new HashMap<Location, Island>();
islandsByLocation = HashBiMap.create();
islandsByUUID = new HashMap<UUID, Island>();
spawn = null;
}
@ -180,10 +188,12 @@ public class IslandsManager {
*/
private void addToGrid(Island newIsland) {
if (islandGrid.containsKey(newIsland.getMinX())) {
//plugin.getLogger().info("DEBUG: min x is in the grid :" + newIsland.getMinX());
if (DEBUG)
plugin.getLogger().info("DEBUG: min x is in the grid :" + newIsland.getMinX());
TreeMap<Integer, Island> zEntry = islandGrid.get(newIsland.getMinX());
if (zEntry.containsKey(newIsland.getMinZ())) {
//plugin.getLogger().info("DEBUG: min z is in the grid :" + newIsland.getMinZ());
if (DEBUG)
plugin.getLogger().info("DEBUG: min z is in the grid :" + newIsland.getMinZ());
// Island already exists
Island conflict = islandGrid.get(newIsland.getMinX()).get(newIsland.getMinZ());
plugin.getLogger().warning("*** Duplicate or overlapping islands! ***");
@ -206,14 +216,16 @@ public class IslandsManager {
return;
} else {
// Add island
//plugin.getLogger().info("DEBUG: added island to grid at " + newIsland.getMinX() + "," + newIsland.getMinZ());
if (DEBUG)
plugin.getLogger().info("DEBUG: added island to grid at " + newIsland.getMinX() + "," + newIsland.getMinZ());
zEntry.put(newIsland.getMinZ(), newIsland);
islandGrid.put(newIsland.getMinX(), zEntry);
// plugin.getLogger().info("Debug: " + newIsland.toString());
}
} else {
// Add island
//plugin.getLogger().info("DEBUG: added island to grid at " + newIsland.getMinX() + "," + newIsland.getMinZ());
if (DEBUG)
plugin.getLogger().info("DEBUG: added island to grid at " + newIsland.getMinX() + "," + newIsland.getMinZ());
TreeMap<Integer, Island> zEntry = new TreeMap<Integer, Island>();
zEntry.put(newIsland.getMinZ(), newIsland);
islandGrid.put(newIsland.getMinX(), zEntry);
@ -224,17 +236,18 @@ public class IslandsManager {
* Deletes an island from the database. Does not remove blocks
* @param location
*/
public void deleteIsland(Location location){
if (islandsByLocation.containsKey(location)) {
Island island = islandsByLocation.get(location);
if (island.getOwner() != null) {
islandsByUUID.remove(island.getOwner());
public void deleteIslandFromCache(Island island) {
islandsByLocation.inverse().remove(island);
Iterator<Entry<UUID, Island>> it = islandsByUUID.entrySet().iterator();
while (it.hasNext()) {
Entry<UUID, Island> en = it.next();
if (en.getValue().equals(island)) {
it.remove();
}
islandsByLocation.remove(location);
}
// Remove from grid
// plugin.getLogger().info("DEBUG: deleting island at " + location);
Island island = getIslandAt(location);
if (DEBUG)
plugin.getLogger().info("DEBUG: deleting island at " + island.getCenter());
if (island != null) {
int x = island.getMinX();
int z = island.getMinZ();
@ -245,9 +258,6 @@ public class IslandsManager {
if (zEntry.containsKey(z)) {
// plugin.getLogger().info("DEBUG: z found - deleting the island");
// Island exists - delete it
Island deletedIsland = zEntry.get(z);
deletedIsland.setOwner(null);
deletedIsland.setLocked(false);
zEntry.remove(z);
islandGrid.put(x, zEntry);
} // else {
@ -257,18 +267,6 @@ public class IslandsManager {
}
}
/**
* Delete island owned by UniqueId
* @param uniqueId
*/
public void deleteIsland(UUID uniqueId){
if (islandsByUUID.containsKey(uniqueId)) {
Island island = islandsByLocation.get(uniqueId);
islandsByUUID.remove(uniqueId);
islandsByLocation.remove(island.getCenter());
}
}
/**
* Delete Island
* Called when an island is restarted or reset
@ -278,27 +276,31 @@ public class IslandsManager {
* @param removeBlocks
* - true to remove the island blocks
*/
public void deletePlayerIsland(final UUID player, boolean removeBlocks) {
public void deleteIsland(final UUID player, boolean removeBlocks) {
// Removes the island
//getLogger().info("DEBUG: deleting player island");
if (DEBUG)
plugin.getLogger().info("DEBUG: deleting player island");
//CoopPlay.getInstance().clearAllIslandCoops(player);
//getWarpSignsListener().removeWarp(player);
Island island = getIsland(player);
final Island island = getIsland(player);
if (island != null) {
// Set the owner of the island to no one.
island.setOwner(null);
island.setLocked(false);
if (removeBlocks) {
// Remove players from island
removePlayersFromIsland(island, player);
new DeleteIslandBlocks(plugin, island);
// Remove island from the cache
deleteIslandFromCache(island);
// Remove the island from the database
try {
handler.deleteObject(island);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
island.setLocked(false);
island.setOwner(null);
// Remove blocks from world
new DeleteIslandBlocks(plugin, island);
}
//getServer().getPluginManager().callEvent(new IslandDeleteEvent(player, island.getCenter()));
} else {
@ -361,15 +363,52 @@ public class IslandsManager {
plugin.getLogger().severe("Team leader does not have an island!");
return false;
}
if (DEBUG) {
plugin.getLogger().info("DEBUG: new team member list 0:");
plugin.getLogger().info(teamIsland.getMembers().toString());
}
if (teamIsland.getMembers().contains(playerUUID)) {
// Player already on island
return true;
}
// TODO: Fire a join team event. If canceled, return false
// Find out if the player had an old island
if (islandsByUUID.containsKey(playerUUID)) {
if (DEBUG)
plugin.getLogger().info("DEBUG: player is a member of an old island");
Island oldIsland = islandsByUUID.get(playerUUID);
oldIsland.removeMember(playerUUID);
if (oldIsland.getOwner() != null && oldIsland.getOwner().equals(playerUUID)) {
if (DEBUG)
plugin.getLogger().info("DEBUG: player's old island was theirs - deleting from grid");
// Delete old island
oldIsland.setOwner(null);
oldIsland.setLocked(false);
islandsByLocation.remove(oldIsland.getCenter());
new DeleteIslandBlocks(plugin, oldIsland);
try {
handler.deleteObject(oldIsland);
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (DEBUG) {
plugin.getLogger().info("DEBUG: new team member list 1:");
plugin.getLogger().info(teamIsland.getMembers().toString());
}
// Add player to new island
if (DEBUG)
plugin.getLogger().info("DEBUG: Adding player to new island");
teamIsland.addMember(playerUUID);
islandsByUUID.put(playerUUID, teamIsland);
if (DEBUG) {
plugin.getLogger().info("DEBUG: new team member list 2:");
plugin.getLogger().info(teamIsland.getMembers().toString());
}
// Save the database
save(false);
return true;
}
@ -414,7 +453,7 @@ public class IslandsManager {
public Set<UUID> getMembers(UUID playerUUID) {
Island island = islandsByUUID.get(playerUUID);
if (island != null)
return island.getMembers();
return new HashSet<UUID>(island.getMembers());
return new HashSet<UUID>(0);
}
@ -463,7 +502,7 @@ public class IslandsManager {
* @return PlayerIsland or null
*/
public Island getIslandAt(int x, int z) {
if (DEBUG) {
if (DEBUG2) {
plugin.getLogger().info("DEBUG: getting island at " + x + "," + z);
plugin.getLogger().info("DEBUG: island grid is " + islandGrid.size());
}
@ -474,11 +513,11 @@ public class IslandsManager {
// Check if in the island range
Island island = ent.getValue();
if (island.inIslandSpace(x, z)) {
if (DEBUG)
if (DEBUG2)
plugin.getLogger().info("DEBUG: In island space");
return island;
}
if (DEBUG)
if (DEBUG2)
plugin.getLogger().info("DEBUG: not in island space");
}
}
@ -889,16 +928,19 @@ public class IslandsManager {
* @param oldIsland - the old island to be deleted after the new island is made
*/
public void newIsland(final Player player, final Schematic schematic, Island oldIsland) {
plugin.getLogger().info("DEBUG: new island");
if (DEBUG)
plugin.getLogger().info("DEBUG: new island");
//long time = System.nanoTime();
final UUID playerUUID = player.getUniqueId();
boolean firstTime = false;
if (!plugin.getPlayers().hasIsland(playerUUID)) {
firstTime = true;
}
plugin.getLogger().info("DEBUG: finding island location");
if (DEBUG)
plugin.getLogger().info("DEBUG: finding island location");
Location next = getNextIsland(player.getUniqueId());
plugin.getLogger().info("DEBUG: found " + next);
if (DEBUG)
plugin.getLogger().info("DEBUG: found " + next);
// Add to the grid
Island myIsland = plugin.getIslands().createIsland(next, playerUUID);
@ -1032,20 +1074,24 @@ public class IslandsManager {
* @return Location of island spot
*/
private Location getNextIsland(UUID playerUUID) {
plugin.getLogger().info("DEBUG: last = " + last);
if (DEBUG)
plugin.getLogger().info("DEBUG: last = " + last);
// Find the next free spot
if (last == null) {
last = new Location(IslandWorld.getIslandWorld(), Settings.islandXOffset + Settings.islandStartX, Settings.islandHeight, Settings.islandZOffset + Settings.islandStartZ);
}
Location next = last.clone();
plugin.getLogger().info("DEBUG: last 2 = " + last);
if (DEBUG)
plugin.getLogger().info("DEBUG: last 2 = " + last);
do {
plugin.getLogger().info("DEBUG: getting next loc");
if (DEBUG)
plugin.getLogger().info("DEBUG: getting next loc");
next = nextGridLocation(next);
} while (isIsland(next));
// Make the last next, last
last = next.clone();
plugin.getLogger().info("DEBUG: last 3 = " + last);
if (DEBUG)
plugin.getLogger().info("DEBUG: last 3 = " + last);
return next;
}
@ -1057,7 +1103,8 @@ public class IslandsManager {
* @return Location of next free island
*/
private Location nextGridLocation(final Location lastIsland) {
plugin.getLogger().info("DEBUG: nextIslandLocation - island distance = " + Settings.islandDistance);
if (DEBUG)
plugin.getLogger().info("DEBUG: nextIslandLocation - island distance = " + Settings.islandDistance);
final int x = lastIsland.getBlockX();
final int z = lastIsland.getBlockZ();
final Location nextPos = lastIsland;
@ -1145,16 +1192,16 @@ public class IslandsManager {
}
Island island = getIslandAt(location);
if (island == null) {
if (DEBUG)
if (DEBUG2)
plugin.getLogger().info("DEBUG: no island at this location");
return null;
}
if (island.onIsland(location)) {
if (DEBUG)
if (DEBUG2)
plugin.getLogger().info("DEBUG: on island");
return island;
}
if (DEBUG)
if (DEBUG2)
plugin.getLogger().info("DEBUG: not in island protection zone");
return null;
}

View File

@ -10,7 +10,6 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import us.tastybento.bskyblock.BSkyBlock;

View File

@ -1,18 +1,23 @@
package us.tastybento.bskyblock.database.objects;
import org.bukkit.*;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import us.tastybento.bskyblock.api.events.island.IslandLockEvent;
import us.tastybento.bskyblock.api.events.island.IslandUnlockEvent;
import us.tastybento.bskyblock.config.Settings;
import us.tastybento.bskyblock.util.Util;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import us.tastybento.bskyblock.api.events.island.IslandLockEvent;
import us.tastybento.bskyblock.api.events.island.IslandUnlockEvent;
import us.tastybento.bskyblock.config.Settings;
import us.tastybento.bskyblock.util.Util;
/**
* Stores all the info about an island
* Managed by IslandsManager
@ -408,7 +413,6 @@ public class Island extends DataObject {
*/
public Set<UUID> getMembers(){
if (members == null) {
Bukkit.getLogger().info("DEBUG: members = null");
members = new HashSet<UUID>();
}
return members;
@ -673,7 +677,6 @@ public class Island extends DataObject {
* @param members - the members to set
*/
public void setMembers(Set<UUID> members){
//Bukkit.getLogger().info("DEBUG: setting members = " + members);
this.members = members;
}

View File

@ -112,7 +112,7 @@ public class Players extends DataObject {
* @param homeLocations the homeLocations to set
*/
public void setHomeLocations(HashMap<Integer, Location> homeLocations) {
Bukkit.getLogger().info("DEBUG: " + homeLocations.toString());
//Bukkit.getLogger().info("DEBUG: " + homeLocations.toString());
this.homeLocations = homeLocations;
}

View File

@ -1,11 +1,12 @@
package us.tastybento.bskyblock.listeners.protection;
import org.bukkit.entity.Player;
import us.tastybento.bskyblock.BSkyBlock;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.entity.Player;
import us.tastybento.bskyblock.BSkyBlock;
/**
* Stashes inventories when required for a player
*

View File

@ -115,8 +115,8 @@ public class DeleteIslandBlocks {
}
}
}
// Remove from database
plugin.getIslands().deleteIsland(island.getCenter());
// Do not do this: Remove from database
//plugin.getIslands().deleteIsland(island.getCenter());
// Clear up any chunks
if (!chunksToClear.isEmpty()) {
try {

View File

@ -1,27 +1,29 @@
package us.tastybento.bskyblock.util;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.config.Settings;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.util.nms.NMSAbstraction;
import us.tastybento.bskyblock.util.placeholders.PlaceholderHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.config.Settings;
import us.tastybento.bskyblock.generators.IslandWorld;
import us.tastybento.bskyblock.util.nms.NMSAbstraction;
import us.tastybento.bskyblock.util.placeholders.PlaceholderHandler;
/**
* A set of utility methods