mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-22 09:08:03 +01:00
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:
parent
4c69587d9a
commit
55101f7ff2
@ -293,15 +293,17 @@ expel:
|
|||||||
notonisland: "Player is not trespassing on your island!"
|
notonisland: "Player is not trespassing on your island!"
|
||||||
notyourself: "You cannot expel yourself!"
|
notyourself: "You cannot expel yourself!"
|
||||||
success: "You expelled [name]!"
|
success: "You expelled [name]!"
|
||||||
invite:
|
invite:
|
||||||
errorCantJoinIsland: "You couldn't join the island, maybe it's full."
|
error:
|
||||||
errorCoolDown: "You can invite that player again in [time] minutes"
|
CantJoinIsland: "You couldn't join the island, maybe it's full."
|
||||||
errorNoOneInvitedYou: "No one invited you"
|
CoolDown: "You can invite that player again in [time] minutes"
|
||||||
errorThatPlayerIsAlreadyInATeam: "That player is already in a team."
|
InvalidInvite: "That invite is no longer valid, sorry."
|
||||||
errorYouAreAlreadyOnATeam: "You are already on a team!"
|
NoOneInvitedYou: "No one invited you"
|
||||||
errorYouCannotInviteYourself: "You can not invite yourself!"
|
ThatPlayerIsAlreadyInATeam: "That player is already in a team."
|
||||||
errorYouMustHaveIslandToInvite: "You must have an island in order to invite people to it!"
|
YouAreAlreadyOnATeam: "You are already on a team!"
|
||||||
errorYourIslandIsFull: "Your island is full, you can't invite anyone else."
|
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!"
|
hasJoinedYourIsland: "[name] has joined your island!"
|
||||||
help: "Use [/[label] invite <playername>] to invite a player to your island."
|
help: "Use [/[label] invite <playername>] to invite a player to your island."
|
||||||
inviteSentTo: "Invite sent to [name]"
|
inviteSentTo: "Invite sent to [name]"
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
package us.tastybento.bskyblock;
|
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.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.commands.AdminCommand;
|
import us.tastybento.bskyblock.commands.AdminCommand;
|
||||||
import us.tastybento.bskyblock.commands.IslandCommand;
|
import us.tastybento.bskyblock.commands.IslandCommand;
|
||||||
import us.tastybento.bskyblock.config.BSBLocale;
|
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.FileLister;
|
||||||
import us.tastybento.bskyblock.util.VaultHelper;
|
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
|
* Main BSkyBlock class - provides an island minigame in the sky
|
||||||
* @author Tastybento
|
* @author Tastybento
|
||||||
|
@ -1,18 +1,28 @@
|
|||||||
package us.tastybento.bskyblock.api.commands;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.BSkyBlock;
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
import us.tastybento.bskyblock.config.BSBLocale;
|
import us.tastybento.bskyblock.config.BSBLocale;
|
||||||
import us.tastybento.bskyblock.database.managers.IslandsManager;
|
import us.tastybento.bskyblock.database.managers.IslandsManager;
|
||||||
import us.tastybento.bskyblock.database.managers.PlayersManager;
|
import us.tastybento.bskyblock.database.managers.PlayersManager;
|
||||||
import us.tastybento.bskyblock.util.Util;
|
import us.tastybento.bskyblock.util.Util;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
@ -38,12 +48,12 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
protected AbstractCommand(BSkyBlock plugin, String label, String[] aliases, boolean help) {
|
protected AbstractCommand(BSkyBlock plugin, String label, String[] aliases, boolean help) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.argumentsMap = new LinkedHashMap<>(1);
|
this.argumentsMap = new LinkedHashMap<>();
|
||||||
this.aliasesMap = new HashMap<>(1);
|
this.aliasesMap = new HashMap<>();
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
this.teamMembers = new HashSet<UUID>(1);
|
this.teamMembers = new HashSet<UUID>();
|
||||||
|
|
||||||
// Register the help argument if needed
|
// Register the help argument if needed
|
||||||
if (help) {
|
if (help) {
|
||||||
@ -250,8 +260,6 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
|||||||
playerUUID = player.getUniqueId();
|
playerUUID = player.getUniqueId();
|
||||||
} else {
|
} else {
|
||||||
isPlayer = false;
|
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
|
// Check if the player is in a team or not and if so, grab the team leader's UUID
|
||||||
if (plugin.getPlayers().inTeam(playerUUID)) {
|
if (plugin.getPlayers().inTeam(playerUUID)) {
|
||||||
@ -260,8 +268,6 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
|||||||
teamMembers = plugin.getIslands().getMembers(teamLeaderUUID);
|
teamMembers = plugin.getIslands().getMembers(teamLeaderUUID);
|
||||||
} else {
|
} else {
|
||||||
inTeam = false;
|
inTeam = false;
|
||||||
teamLeaderUUID = null;
|
|
||||||
teamMembers.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package us.tastybento.bskyblock.commands;
|
package us.tastybento.bskyblock.commands;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.BSkyBlock;
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
import us.tastybento.bskyblock.api.commands.AbstractCommand;
|
import us.tastybento.bskyblock.api.commands.AbstractCommand;
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class AdminCommand extends AbstractCommand {
|
public class AdminCommand extends AbstractCommand {
|
||||||
|
|
||||||
BSkyBlock plugin;
|
BSkyBlock plugin;
|
||||||
|
@ -9,6 +9,7 @@ import java.util.UUID;
|
|||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -21,10 +22,7 @@ import com.google.common.collect.HashBiMap;
|
|||||||
import us.tastybento.bskyblock.BSkyBlock;
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
import us.tastybento.bskyblock.api.commands.AbstractCommand;
|
import us.tastybento.bskyblock.api.commands.AbstractCommand;
|
||||||
import us.tastybento.bskyblock.api.events.team.PlayerAcceptInviteEvent;
|
import us.tastybento.bskyblock.api.events.team.PlayerAcceptInviteEvent;
|
||||||
import us.tastybento.bskyblock.config.BSBLocale;
|
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
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.database.objects.Island;
|
||||||
import us.tastybento.bskyblock.schematics.Schematic;
|
import us.tastybento.bskyblock.schematics.Schematic;
|
||||||
import us.tastybento.bskyblock.util.Util;
|
import us.tastybento.bskyblock.util.Util;
|
||||||
@ -447,7 +445,7 @@ public class IslandCommand extends AbstractCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
plugin.getLogger().info("DEBUG: executing team command");
|
plugin.getLogger().info("DEBUG: executing team command for " + teamLeaderUUID);
|
||||||
if (teamLeaderUUID.equals(playerUUID)) {
|
if (teamLeaderUUID.equals(playerUUID)) {
|
||||||
int maxSize = Settings.maxTeamSize;
|
int maxSize = Settings.maxTeamSize;
|
||||||
for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
|
for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
|
||||||
@ -475,7 +473,7 @@ public class IslandCommand extends AbstractCommand {
|
|||||||
if (teamMembers.size() < maxSize) {
|
if (teamMembers.size() < maxSize) {
|
||||||
Util.sendMessage(player, ChatColor.GREEN + getLocale(sender).get("invite.youCanInvite").replace("[number]", String.valueOf(maxSize - teamMembers.size())));
|
Util.sendMessage(player, ChatColor.GREEN + getLocale(sender).get("invite.youCanInvite").replace("[number]", String.valueOf(maxSize - teamMembers.size())));
|
||||||
} else {
|
} 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"));
|
Util.sendMessage(player, ChatColor.YELLOW + getLocale(sender).get("team.listingMembers"));
|
||||||
@ -517,7 +515,7 @@ public class IslandCommand extends AbstractCommand {
|
|||||||
if (getPlayers().inTeam(playerUUID)) {
|
if (getPlayers().inTeam(playerUUID)) {
|
||||||
return new CanUseResp(ChatColor.RED + getLocale(sender).get("general.errors.not-leader"));
|
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);
|
return new CanUseResp(true);
|
||||||
}
|
}
|
||||||
@ -546,19 +544,19 @@ public class IslandCommand extends AbstractCommand {
|
|||||||
UUID invitedPlayerUUID = invitedPlayer.getUniqueId();
|
UUID invitedPlayerUUID = invitedPlayer.getUniqueId();
|
||||||
// Player cannot invite themselves
|
// Player cannot invite themselves
|
||||||
if (playerUUID.equals(invitedPlayerUUID)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// Check if this player can be invited to this island, or
|
// Check if this player can be invited to this island, or
|
||||||
// whether they are still on cooldown
|
// whether they are still on cooldown
|
||||||
long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(playerUUID));
|
long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(playerUUID));
|
||||||
if (time > 0 && !player.isOp()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// Player cannot invite someone already on a team
|
// Player cannot invite someone already on a team
|
||||||
if (getPlayers().inTeam(invitedPlayerUUID)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// Check if player has space on their team
|
// Check if player has space on their team
|
||||||
@ -588,7 +586,7 @@ public class IslandCommand extends AbstractCommand {
|
|||||||
}
|
}
|
||||||
if (teamMembers.size() < maxSize) {
|
if (teamMembers.size() < maxSize) {
|
||||||
// If that player already has an invite out then retract it.
|
// 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)) {
|
if (inviteList.containsValue(playerUUID)) {
|
||||||
inviteList.inverse().remove(playerUUID);
|
inviteList.inverse().remove(playerUUID);
|
||||||
Util.sendMessage(player, ChatColor.YELLOW + getLocale(sender).get("invite.removingInvite"));
|
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"));
|
Util.sendMessage(Bukkit.getPlayer(invitedPlayerUUID), ChatColor.RED + getLocale(invitedPlayerUUID).get("invite.warningYouWillLoseIsland"));
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
// Check if player has been invited
|
// Check if player has been invited
|
||||||
if (!inviteList.containsKey(playerUUID)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// Check if player is already in a team
|
// Check if player is already in a team
|
||||||
if (getPlayers().inTeam(playerUUID)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// If the invitee has an island of their own
|
// Get the team leader
|
||||||
if (getPlayers().hasIsland(playerUUID)) {
|
UUID prospectiveTeamLeaderUUID = inviteList.get(playerUUID);
|
||||||
plugin.getLogger().info(player.getName() + "'s island will be deleted because they joined a party.");
|
if (!getIslands().hasIsland(prospectiveTeamLeaderUUID)) {
|
||||||
getIslands().deletePlayerIsland(playerUUID, true);
|
Util.sendMessage(player, ChatColor.RED + getLocale(sender).get("invite.error.InvalidInvite"));
|
||||||
plugin.getLogger().info("Island deleted.");
|
inviteList.remove(playerUUID);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Set the team leader
|
if (DEBUG)
|
||||||
teamLeaderUUID = inviteList.get(playerUUID);
|
plugin.getLogger().info("DEBUG: Invite is valid");
|
||||||
// TODO implement this
|
// Remove the invite
|
||||||
getPlayers().resetPlayer(player);
|
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
|
// Add the player to the team
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
plugin.getLogger().info("DEBUG: adding " + playerUUID + " to team " + teamLeaderUUID);
|
plugin.getLogger().info("DEBUG: adding " + playerUUID + " to team " + prospectiveTeamLeaderUUID);
|
||||||
getIslands().setJoinTeam(playerUUID, inviteList.get(playerUUID));
|
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);
|
setResetWaitTime(player);
|
||||||
|
|
||||||
if (Settings.teamJoinDeathReset) {
|
if (Settings.teamJoinDeathReset) {
|
||||||
getPlayers().setDeaths(player.getUniqueId(), 0);
|
getPlayers().setDeaths(player.getUniqueId(), 0);
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
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
|
// Set the player's home
|
||||||
getPlayers().setHomeLocation(playerUUID, getPlayers().getHomeLocation(teamLeaderUUID));
|
getPlayers().setHomeLocation(playerUUID, getPlayers().getHomeLocation(prospectiveTeamLeaderUUID));
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
plugin.getLogger().info("DEBUG: teleporting player to new island");
|
plugin.getLogger().info("DEBUG: teleporting player to new island");
|
||||||
getIslands().homeTeleport(player);
|
getIslands().homeTeleport(player);
|
||||||
|
|
||||||
// Fire event so add-ons can run commands, etc.
|
// Fire event so add-ons can run commands, etc.
|
||||||
plugin.getServer().getPluginManager().callEvent(new PlayerAcceptInviteEvent(player));
|
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) {
|
if (plugin.getServer().getPlayer(inviteList.get(playerUUID)) != null) {
|
||||||
Util.sendMessage(plugin.getServer().getPlayer(inviteList.get(playerUUID)),
|
Util.sendMessage(plugin.getServer().getPlayer(inviteList.get(playerUUID)),
|
||||||
ChatColor.GREEN + getLocale(sender).get("invite.hasJoinedYourIsland").replace("[name]", player.getName()));
|
ChatColor.GREEN + getLocale(sender).get("invite.hasJoinedYourIsland").replace("[name]", player.getName()));
|
||||||
}
|
}
|
||||||
// Remove the invite
|
getIslands().save(false);
|
||||||
inviteList.remove(playerUUID);
|
if (DEBUG)
|
||||||
getIslands().save(true);
|
plugin.getLogger().info("DEBUG: After save " + getIslands().getIsland(prospectiveTeamLeaderUUID).getMembers().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package us.tastybento.bskyblock.config;
|
package us.tastybento.bskyblock.config;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import us.tastybento.bskyblock.BSkyBlock;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -10,6 +7,10 @@ import java.net.URLClassLoader;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
|
|
||||||
public class BSBLocale {
|
public class BSBLocale {
|
||||||
|
|
||||||
final static String LOCALE_FOLDER = "locales";
|
final static String LOCALE_FOLDER = "locales";
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package us.tastybento.bskyblock.config;
|
package us.tastybento.bskyblock.config;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.database.BSBDatabase.DatabaseType;
|
import us.tastybento.bskyblock.database.BSBDatabase.DatabaseType;
|
||||||
import us.tastybento.bskyblock.database.managers.OfflineHistoryMessages.HistoryMessageType;
|
import us.tastybento.bskyblock.database.managers.OfflineHistoryMessages.HistoryMessageType;
|
||||||
import us.tastybento.bskyblock.database.objects.Island.SettingsFlag;
|
import us.tastybento.bskyblock.database.objects.Island.SettingsFlag;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the plugin settings are here
|
* All the plugin settings are here
|
||||||
* @author Tastybento
|
* @author Tastybento
|
||||||
|
@ -2,6 +2,7 @@ package us.tastybento.bskyblock.database.managers;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@ -24,6 +25,9 @@ import org.bukkit.material.TrapDoor;
|
|||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.util.Vector;
|
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.BSkyBlock;
|
||||||
import us.tastybento.bskyblock.api.events.island.IslandLeaveEvent;
|
import us.tastybento.bskyblock.api.events.island.IslandLeaveEvent;
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
@ -45,11 +49,15 @@ import us.tastybento.bskyblock.util.Util;
|
|||||||
*/
|
*/
|
||||||
public class IslandsManager {
|
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 BSkyBlock plugin;
|
||||||
private BSBDatabase database;
|
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;
|
private HashMap<UUID, Island> islandsByUUID;
|
||||||
// 2D islandGrid of islands, x,z
|
// 2D islandGrid of islands, x,z
|
||||||
private TreeMap<Integer, TreeMap<Integer, Island>> islandGrid = new TreeMap<Integer, TreeMap<Integer, Island>>();
|
private TreeMap<Integer, TreeMap<Integer, Island>> islandGrid = new TreeMap<Integer, TreeMap<Integer, Island>>();
|
||||||
@ -70,7 +78,7 @@ public class IslandsManager {
|
|||||||
database = BSBDatabase.getDatabase();
|
database = BSBDatabase.getDatabase();
|
||||||
// Set up the database handler to store and retrieve Island classes
|
// Set up the database handler to store and retrieve Island classes
|
||||||
handler = (AbstractDatabaseHandler<Island>) database.getHandler(plugin, Island.class);
|
handler = (AbstractDatabaseHandler<Island>) database.getHandler(plugin, Island.class);
|
||||||
islandsByLocation = new HashMap<Location, Island>();
|
islandsByLocation = HashBiMap.create();
|
||||||
islandsByUUID = new HashMap<UUID, Island>();
|
islandsByUUID = new HashMap<UUID, Island>();
|
||||||
spawn = null;
|
spawn = null;
|
||||||
}
|
}
|
||||||
@ -180,10 +188,12 @@ public class IslandsManager {
|
|||||||
*/
|
*/
|
||||||
private void addToGrid(Island newIsland) {
|
private void addToGrid(Island newIsland) {
|
||||||
if (islandGrid.containsKey(newIsland.getMinX())) {
|
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());
|
TreeMap<Integer, Island> zEntry = islandGrid.get(newIsland.getMinX());
|
||||||
if (zEntry.containsKey(newIsland.getMinZ())) {
|
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 already exists
|
||||||
Island conflict = islandGrid.get(newIsland.getMinX()).get(newIsland.getMinZ());
|
Island conflict = islandGrid.get(newIsland.getMinX()).get(newIsland.getMinZ());
|
||||||
plugin.getLogger().warning("*** Duplicate or overlapping islands! ***");
|
plugin.getLogger().warning("*** Duplicate or overlapping islands! ***");
|
||||||
@ -206,14 +216,16 @@ public class IslandsManager {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Add island
|
// 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);
|
zEntry.put(newIsland.getMinZ(), newIsland);
|
||||||
islandGrid.put(newIsland.getMinX(), zEntry);
|
islandGrid.put(newIsland.getMinX(), zEntry);
|
||||||
// plugin.getLogger().info("Debug: " + newIsland.toString());
|
// plugin.getLogger().info("Debug: " + newIsland.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Add island
|
// 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>();
|
TreeMap<Integer, Island> zEntry = new TreeMap<Integer, Island>();
|
||||||
zEntry.put(newIsland.getMinZ(), newIsland);
|
zEntry.put(newIsland.getMinZ(), newIsland);
|
||||||
islandGrid.put(newIsland.getMinX(), zEntry);
|
islandGrid.put(newIsland.getMinX(), zEntry);
|
||||||
@ -224,17 +236,18 @@ public class IslandsManager {
|
|||||||
* Deletes an island from the database. Does not remove blocks
|
* Deletes an island from the database. Does not remove blocks
|
||||||
* @param location
|
* @param location
|
||||||
*/
|
*/
|
||||||
public void deleteIsland(Location location){
|
public void deleteIslandFromCache(Island island) {
|
||||||
if (islandsByLocation.containsKey(location)) {
|
islandsByLocation.inverse().remove(island);
|
||||||
Island island = islandsByLocation.get(location);
|
Iterator<Entry<UUID, Island>> it = islandsByUUID.entrySet().iterator();
|
||||||
if (island.getOwner() != null) {
|
while (it.hasNext()) {
|
||||||
islandsByUUID.remove(island.getOwner());
|
Entry<UUID, Island> en = it.next();
|
||||||
|
if (en.getValue().equals(island)) {
|
||||||
|
it.remove();
|
||||||
}
|
}
|
||||||
islandsByLocation.remove(location);
|
|
||||||
}
|
}
|
||||||
// Remove from grid
|
// Remove from grid
|
||||||
// plugin.getLogger().info("DEBUG: deleting island at " + location);
|
if (DEBUG)
|
||||||
Island island = getIslandAt(location);
|
plugin.getLogger().info("DEBUG: deleting island at " + island.getCenter());
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
int x = island.getMinX();
|
int x = island.getMinX();
|
||||||
int z = island.getMinZ();
|
int z = island.getMinZ();
|
||||||
@ -245,9 +258,6 @@ public class IslandsManager {
|
|||||||
if (zEntry.containsKey(z)) {
|
if (zEntry.containsKey(z)) {
|
||||||
// plugin.getLogger().info("DEBUG: z found - deleting the island");
|
// plugin.getLogger().info("DEBUG: z found - deleting the island");
|
||||||
// Island exists - delete it
|
// Island exists - delete it
|
||||||
Island deletedIsland = zEntry.get(z);
|
|
||||||
deletedIsland.setOwner(null);
|
|
||||||
deletedIsland.setLocked(false);
|
|
||||||
zEntry.remove(z);
|
zEntry.remove(z);
|
||||||
islandGrid.put(x, zEntry);
|
islandGrid.put(x, zEntry);
|
||||||
} // else {
|
} // 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
|
* Delete Island
|
||||||
* Called when an island is restarted or reset
|
* Called when an island is restarted or reset
|
||||||
@ -278,27 +276,31 @@ public class IslandsManager {
|
|||||||
* @param removeBlocks
|
* @param removeBlocks
|
||||||
* - true to remove the island blocks
|
* - 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
|
// Removes the island
|
||||||
//getLogger().info("DEBUG: deleting player island");
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: deleting player island");
|
||||||
//CoopPlay.getInstance().clearAllIslandCoops(player);
|
//CoopPlay.getInstance().clearAllIslandCoops(player);
|
||||||
//getWarpSignsListener().removeWarp(player);
|
//getWarpSignsListener().removeWarp(player);
|
||||||
Island island = getIsland(player);
|
final Island island = getIsland(player);
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
// Set the owner of the island to no one.
|
// Set the owner of the island to no one.
|
||||||
island.setOwner(null);
|
island.setOwner(null);
|
||||||
|
island.setLocked(false);
|
||||||
if (removeBlocks) {
|
if (removeBlocks) {
|
||||||
|
// Remove players from island
|
||||||
removePlayersFromIsland(island, player);
|
removePlayersFromIsland(island, player);
|
||||||
new DeleteIslandBlocks(plugin, island);
|
// Remove island from the cache
|
||||||
|
deleteIslandFromCache(island);
|
||||||
|
// Remove the island from the database
|
||||||
try {
|
try {
|
||||||
handler.deleteObject(island);
|
handler.deleteObject(island);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
// Remove blocks from world
|
||||||
island.setLocked(false);
|
new DeleteIslandBlocks(plugin, island);
|
||||||
island.setOwner(null);
|
|
||||||
}
|
}
|
||||||
//getServer().getPluginManager().callEvent(new IslandDeleteEvent(player, island.getCenter()));
|
//getServer().getPluginManager().callEvent(new IslandDeleteEvent(player, island.getCenter()));
|
||||||
} else {
|
} else {
|
||||||
@ -361,16 +363,53 @@ public class IslandsManager {
|
|||||||
plugin.getLogger().severe("Team leader does not have an island!");
|
plugin.getLogger().severe("Team leader does not have an island!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (DEBUG) {
|
||||||
|
plugin.getLogger().info("DEBUG: new team member list 0:");
|
||||||
|
plugin.getLogger().info(teamIsland.getMembers().toString());
|
||||||
|
}
|
||||||
if (teamIsland.getMembers().contains(playerUUID)) {
|
if (teamIsland.getMembers().contains(playerUUID)) {
|
||||||
// Player already on island
|
// Player already on island
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fire a join team event. If canceled, return false
|
// 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
|
// Add player to new island
|
||||||
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: Adding player to new island");
|
||||||
teamIsland.addMember(playerUUID);
|
teamIsland.addMember(playerUUID);
|
||||||
islandsByUUID.put(playerUUID, teamIsland);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +453,7 @@ public class IslandsManager {
|
|||||||
public Set<UUID> getMembers(UUID playerUUID) {
|
public Set<UUID> getMembers(UUID playerUUID) {
|
||||||
Island island = islandsByUUID.get(playerUUID);
|
Island island = islandsByUUID.get(playerUUID);
|
||||||
if (island != null)
|
if (island != null)
|
||||||
return island.getMembers();
|
return new HashSet<UUID>(island.getMembers());
|
||||||
return new HashSet<UUID>(0);
|
return new HashSet<UUID>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +502,7 @@ public class IslandsManager {
|
|||||||
* @return PlayerIsland or null
|
* @return PlayerIsland or null
|
||||||
*/
|
*/
|
||||||
public Island getIslandAt(int x, int z) {
|
public Island getIslandAt(int x, int z) {
|
||||||
if (DEBUG) {
|
if (DEBUG2) {
|
||||||
plugin.getLogger().info("DEBUG: getting island at " + x + "," + z);
|
plugin.getLogger().info("DEBUG: getting island at " + x + "," + z);
|
||||||
plugin.getLogger().info("DEBUG: island grid is " + islandGrid.size());
|
plugin.getLogger().info("DEBUG: island grid is " + islandGrid.size());
|
||||||
}
|
}
|
||||||
@ -474,11 +513,11 @@ public class IslandsManager {
|
|||||||
// Check if in the island range
|
// Check if in the island range
|
||||||
Island island = ent.getValue();
|
Island island = ent.getValue();
|
||||||
if (island.inIslandSpace(x, z)) {
|
if (island.inIslandSpace(x, z)) {
|
||||||
if (DEBUG)
|
if (DEBUG2)
|
||||||
plugin.getLogger().info("DEBUG: In island space");
|
plugin.getLogger().info("DEBUG: In island space");
|
||||||
return island;
|
return island;
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG2)
|
||||||
plugin.getLogger().info("DEBUG: not in island space");
|
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
|
* @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) {
|
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();
|
//long time = System.nanoTime();
|
||||||
final UUID playerUUID = player.getUniqueId();
|
final UUID playerUUID = player.getUniqueId();
|
||||||
boolean firstTime = false;
|
boolean firstTime = false;
|
||||||
if (!plugin.getPlayers().hasIsland(playerUUID)) {
|
if (!plugin.getPlayers().hasIsland(playerUUID)) {
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
}
|
}
|
||||||
plugin.getLogger().info("DEBUG: finding island location");
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: finding island location");
|
||||||
Location next = getNextIsland(player.getUniqueId());
|
Location next = getNextIsland(player.getUniqueId());
|
||||||
plugin.getLogger().info("DEBUG: found " + next);
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: found " + next);
|
||||||
|
|
||||||
// Add to the grid
|
// Add to the grid
|
||||||
Island myIsland = plugin.getIslands().createIsland(next, playerUUID);
|
Island myIsland = plugin.getIslands().createIsland(next, playerUUID);
|
||||||
@ -1032,20 +1074,24 @@ public class IslandsManager {
|
|||||||
* @return Location of island spot
|
* @return Location of island spot
|
||||||
*/
|
*/
|
||||||
private Location getNextIsland(UUID playerUUID) {
|
private Location getNextIsland(UUID playerUUID) {
|
||||||
plugin.getLogger().info("DEBUG: last = " + last);
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: last = " + last);
|
||||||
// Find the next free spot
|
// Find the next free spot
|
||||||
if (last == null) {
|
if (last == null) {
|
||||||
last = new Location(IslandWorld.getIslandWorld(), Settings.islandXOffset + Settings.islandStartX, Settings.islandHeight, Settings.islandZOffset + Settings.islandStartZ);
|
last = new Location(IslandWorld.getIslandWorld(), Settings.islandXOffset + Settings.islandStartX, Settings.islandHeight, Settings.islandZOffset + Settings.islandStartZ);
|
||||||
}
|
}
|
||||||
Location next = last.clone();
|
Location next = last.clone();
|
||||||
plugin.getLogger().info("DEBUG: last 2 = " + last);
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: last 2 = " + last);
|
||||||
do {
|
do {
|
||||||
plugin.getLogger().info("DEBUG: getting next loc");
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: getting next loc");
|
||||||
next = nextGridLocation(next);
|
next = nextGridLocation(next);
|
||||||
} while (isIsland(next));
|
} while (isIsland(next));
|
||||||
// Make the last next, last
|
// Make the last next, last
|
||||||
last = next.clone();
|
last = next.clone();
|
||||||
plugin.getLogger().info("DEBUG: last 3 = " + last);
|
if (DEBUG)
|
||||||
|
plugin.getLogger().info("DEBUG: last 3 = " + last);
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,7 +1103,8 @@ public class IslandsManager {
|
|||||||
* @return Location of next free island
|
* @return Location of next free island
|
||||||
*/
|
*/
|
||||||
private Location nextGridLocation(final Location lastIsland) {
|
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 x = lastIsland.getBlockX();
|
||||||
final int z = lastIsland.getBlockZ();
|
final int z = lastIsland.getBlockZ();
|
||||||
final Location nextPos = lastIsland;
|
final Location nextPos = lastIsland;
|
||||||
@ -1145,16 +1192,16 @@ public class IslandsManager {
|
|||||||
}
|
}
|
||||||
Island island = getIslandAt(location);
|
Island island = getIslandAt(location);
|
||||||
if (island == null) {
|
if (island == null) {
|
||||||
if (DEBUG)
|
if (DEBUG2)
|
||||||
plugin.getLogger().info("DEBUG: no island at this location");
|
plugin.getLogger().info("DEBUG: no island at this location");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (island.onIsland(location)) {
|
if (island.onIsland(location)) {
|
||||||
if (DEBUG)
|
if (DEBUG2)
|
||||||
plugin.getLogger().info("DEBUG: on island");
|
plugin.getLogger().info("DEBUG: on island");
|
||||||
return island;
|
return island;
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG2)
|
||||||
plugin.getLogger().info("DEBUG: not in island protection zone");
|
plugin.getLogger().info("DEBUG: not in island protection zone");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.BSkyBlock;
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
package us.tastybento.bskyblock.database.objects;
|
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.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
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
|
* Stores all the info about an island
|
||||||
* Managed by IslandsManager
|
* Managed by IslandsManager
|
||||||
@ -408,7 +413,6 @@ public class Island extends DataObject {
|
|||||||
*/
|
*/
|
||||||
public Set<UUID> getMembers(){
|
public Set<UUID> getMembers(){
|
||||||
if (members == null) {
|
if (members == null) {
|
||||||
Bukkit.getLogger().info("DEBUG: members = null");
|
|
||||||
members = new HashSet<UUID>();
|
members = new HashSet<UUID>();
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
@ -673,7 +677,6 @@ public class Island extends DataObject {
|
|||||||
* @param members - the members to set
|
* @param members - the members to set
|
||||||
*/
|
*/
|
||||||
public void setMembers(Set<UUID> members){
|
public void setMembers(Set<UUID> members){
|
||||||
//Bukkit.getLogger().info("DEBUG: setting members = " + members);
|
|
||||||
this.members = members;
|
this.members = members;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class Players extends DataObject {
|
|||||||
* @param homeLocations the homeLocations to set
|
* @param homeLocations the homeLocations to set
|
||||||
*/
|
*/
|
||||||
public void setHomeLocations(HashMap<Integer, Location> homeLocations) {
|
public void setHomeLocations(HashMap<Integer, Location> homeLocations) {
|
||||||
Bukkit.getLogger().info("DEBUG: " + homeLocations.toString());
|
//Bukkit.getLogger().info("DEBUG: " + homeLocations.toString());
|
||||||
this.homeLocations = homeLocations;
|
this.homeLocations = homeLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package us.tastybento.bskyblock.listeners.protection;
|
package us.tastybento.bskyblock.listeners.protection;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import us.tastybento.bskyblock.BSkyBlock;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stashes inventories when required for a player
|
* Stashes inventories when required for a player
|
||||||
*
|
*
|
||||||
|
@ -115,8 +115,8 @@ public class DeleteIslandBlocks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Remove from database
|
// Do not do this: Remove from database
|
||||||
plugin.getIslands().deleteIsland(island.getCenter());
|
//plugin.getIslands().deleteIsland(island.getCenter());
|
||||||
// Clear up any chunks
|
// Clear up any chunks
|
||||||
if (!chunksToClear.isEmpty()) {
|
if (!chunksToClear.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,27 +1,29 @@
|
|||||||
package us.tastybento.bskyblock.util;
|
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.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
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
|
* A set of utility methods
|
||||||
|
Loading…
Reference in New Issue
Block a user