Bug fixes.

This commit is contained in:
TadahTech 2016-07-05 14:35:37 -05:00
parent 978ee0055a
commit 9f58e57a67
11 changed files with 80 additions and 63 deletions

View File

@ -1,11 +1,8 @@
package mineplex.core.party;
import mineplex.core.common.util.C;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import static sun.audio.AudioPlayer.player;
import org.bukkit.entity.Player;
/**
* All chat messages for the party system to align with PE
@ -31,6 +28,7 @@ public enum Lang
PARTY_OWNER_LEAVE("{0} has left the party. {1} is the new party owner."),
TRANSFER_OWNER("{0} has given party leadership to {1}."),
DISBANDED("Your party has been disbanded, due to a lack of players."),
DISBANDED_BY_OWNER("Your party has been disbanded!"),
REMOVED("You have been removed from the party."),
NOT_EXIST("Error: {0} is not in a party right now."),

View File

@ -2,12 +2,11 @@ package mineplex.core.party;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import mineplex.core.chat.Chat;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.core.party.event.PartyTransferOwnerEvent;
import mineplex.core.party.event.PartyTransferOwnerEvent.TransferReason;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import java.util.List;
@ -27,6 +26,7 @@ public class Party
private List<UUID> _membersByUUID;
private Map<String, Long> _invites;
private int size;
private boolean _alreadyTeamed;
public Party()
{
@ -86,6 +86,10 @@ public class Party
}
_members.add(player);
Lang.ADD_MEMBER.send(this, player);
getMembers().stream().forEach(s -> {
Player player1 = Bukkit.getPlayer(s);
player1.playSound(player1.getLocation(), Sound.NOTE_PLING, 1.0F, 10.0F);
});
}
public void onPlayerRemove(String player, PartyRemoveReason reason)
@ -149,4 +153,26 @@ public class Party
{
return _membersByUUID;
}
public boolean alreadyTeamed()
{
return _alreadyTeamed;
}
public void setAlreadyTeamed(boolean alreadyTeamed)
{
_alreadyTeamed = alreadyTeamed;
}
public boolean contains(String name)
{
for(String s : _members)
{
if(s.equalsIgnoreCase(name))
{
return true;
}
}
return false;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.party;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
@ -86,6 +87,11 @@ public class PartyManager extends MiniPlugin
}
}
public void addToPartyOnTransfer(UUID uuid, Party party)
{
_players.put(uuid, party);
}
public void addToParty(Player player, Party party)
{
addToParty(player.getUniqueId(), party);
@ -114,10 +120,9 @@ public class PartyManager extends MiniPlugin
{
return;
}
Player player = Bukkit.getPlayer(uuid);
party.getMembers().remove(player.getName());
party.getMembersByUUID().remove(uuid);
party.onPlayerRemove(player.getName(), reason);
if(player.getOpenInventory() != null)
{
if (Menu.get(player.getUniqueId()) != null)
@ -126,6 +131,15 @@ public class PartyManager extends MiniPlugin
Menu.remove(player.getUniqueId());
}
}
if(reason == PartyRemoveReason.DISBANDED_BY_OWNER)
{
return;
}
party.getMembers().remove(player.getName());
party.getMembersByUUID().remove(uuid);
party.onPlayerRemove(player.getName(), reason);
int size = party.getMembers().size();
if(size <= 1)
{
@ -147,14 +161,17 @@ public class PartyManager extends MiniPlugin
public void disbandParty(Party party)
{
List<String> members = party.getMembers();
members.stream().map(Bukkit::getPlayer).forEach(player -> removeFromParty(player.getUniqueId(), PartyRemoveReason.LEFT));
List<UUID> members = Lists.newArrayList(party.getMembersByUUID());
Lang.DISBANDED_BY_OWNER.send(party);
members.stream().forEach(player -> removeFromParty(player, PartyRemoveReason.DISBANDED_BY_OWNER));
party.getMembers().clear();
party.getMembersByUUID().clear();
removeParty(party);
}
public void transferOwner(String newOwner, String oldOwner)
{
Party party = _parties.remove(oldOwner.toLowerCase());
Party party = _parties.remove(oldOwner);
if(party == null)
{
return;

View File

@ -9,6 +9,7 @@ public enum PartyRemoveReason
LEFT(2, "left"),
OTHER(3, "other"),
DISBANDED(4, "disbanded"),
DISBANDED_BY_OWNER(5, "disbandedByOwner"),
;
private int _id;

View File

@ -1,11 +1,9 @@
package mineplex.core.party.command;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.jsonchat.ChildJsonMessage;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.party.Lang;
@ -30,14 +28,14 @@ public class PartyCommand extends CommandBase<PartyManager>
private final String[] HELP = {
F.main("Party", "Party Commands (Click the command!)"),
help("help", "Shows this help screen"),
// help("help", "Shows this help screen"),
help("", "Brings up the Party GUI"),
help("invite <player>", "Invite a player to your party."),
help("accept <party>", "Accept an invite to a party."),
help("deny <party>", "Deny an invite to a party."),
help("leave", "Leave your current party"),
help("kick <player>", "Kick a player from your party."),
help("disband", "Disband your party."),
//help("invite <player>", "Invite a player to your party."),
//help("accept <party>", "Accept an invite to a party."),
//help("deny <party>", "Deny an invite to a party."),
//help("leave", "Leave your current party"),
//help("kick <player>", "Kick a player from your party."),
//help("disband", "Disband your party."),
C.cBlue + "Party> " + C.cWhite + "#<message> " + C.cGray + "- Send a message to your party."
};
@ -49,28 +47,6 @@ public class PartyCommand extends CommandBase<PartyManager>
@Override
public void Execute(Player caller, String[] args)
{
if(_aliasUsed.equalsIgnoreCase("z"))
{
caller.sendMessage(F.main("Party", "That command is no longer allowed! Please use \"/party\""));
caller.sendMessage(HELP[0]);
//Show this menu
for(int i = 1; i < HELP.length; i++)
{
String s = HELP[i];
String command = ChatColor.stripColor(s);
ChildJsonMessage jsonMessage = new ChildJsonMessage(s);
if ((i + 1) == HELP.length)
{
command = "#<message>";
} else
{
command = command.substring(command.indexOf("/"), command.indexOf("-") - 1);
}
jsonMessage.click(ClickEvent.SUGGEST_COMMAND, command);
jsonMessage.sendToPlayer(caller);
}
return;
}
if (args.length == 0)
{
Party party = Plugin.getParty(caller);

View File

@ -7,7 +7,6 @@ import mineplex.core.common.util.F;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.PartyRemoveReason;
import mineplex.core.party.event.PartyDataReceivedEvent;
import mineplex.core.party.manager.PartyInviteManager.InviteResponse;
import mineplex.core.party.manager.PartyJoinManager.JoinResponseReason;
@ -17,20 +16,15 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.jooq.util.derby.sys.Sys;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import static mineplex.core.party.redis.RedisMessageType.INVITE_PLAYER_REQUEST;
import static mineplex.core.party.redis.RedisMessageType.PARTY_INFO;
import static net.minecraft.server.v1_8_R3.PotionBrewer.c;
import static net.minecraft.server.v1_8_R3.PotionBrewer.f;
import static sun.audio.AudioPlayer.player;
/**
* Redis system for Parties
@ -56,6 +50,7 @@ public class PartyRedisManager
_channel = CHANNEL_BASE + "-" + serverName;
plugin.runAsync(() -> {
System.out.println("Connecting to redis and listening on channel " + _channel);
try (Jedis jedis = readPool.getResource())
{
jedis.subscribe(new PartyRedisListener(this), _channel, FIND_PLAYERS_CHANNEL);
@ -65,6 +60,7 @@ public class PartyRedisManager
public void publish(String server, RedisMessageType messageType, String... args)
{
System.out.println("Sending " + messageType.name() + " to " + server);
_plugin.runAsync(() -> {
try (Jedis jedis = _writePool.getResource())
{
@ -200,7 +196,7 @@ public class PartyRedisManager
{
Party party = GSON.fromJson(json, Party.class);
_plugin.addParty(party);
party.getMembersByUUID().forEach(s -> _plugin.addToParty(s, party));
party.getMembersByUUID().forEach(s -> _plugin.addToPartyOnTransfer(s, party));
Bukkit.getServer().getPluginManager().callEvent(new PartyDataReceivedEvent(party));
}
}.runTaskLater(_plugin.getPlugin(), 10L);

View File

@ -3,8 +3,6 @@ package mineplex.core.party.redis;
import mineplex.core.party.manager.PartyRedisManager;
import redis.clients.jedis.JedisPubSub;
import static net.minecraft.server.v1_8_R3.PotionBrewer.m;
/**
* Handles incoming messages into the Party Redis System
*/
@ -21,6 +19,7 @@ public class PartyRedisListener extends JedisPubSub
@Override
public void onMessage(String channel, String message)
{
System.out.println("Message on " + channel + " :: " + message);
if(channel.equalsIgnoreCase(_redisManager.getFinder()))
{
_redisManager.handle(RedisMessageType.PLAYER_FIND_REQUEST, message);

View File

@ -31,6 +31,6 @@ public class TransferOwnerButton extends PartyButton
@Override
public void onClick(Player player, ClickType clickType)
{
new PartyTransferOwnerMenu(getPlugin(), player, getParty());
new PartyTransferOwnerMenu(getPlugin(), player, getParty()).openInventory();
}
}

View File

@ -9,7 +9,6 @@ import mineplex.core.common.util.F;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.anvilMenu.PlayerInputActionMenu;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -33,6 +32,12 @@ public class PlayerSuggestPlayerMenu extends PlayerNameMenu
Lang.NO_PARTY.send(_player);
return;
}
if(_party.contains(name))
{
Lang.ALREADY_MEMBER.send(_player, name);
}
Player player = Bukkit.getPlayerExact(_party.getOwner());
_party.sendMessage(C.mHead + "Party> " + F.name(_player.getName()) + " has suggested " + F.name(name) + " be invited.");

View File

@ -9,6 +9,7 @@ import mineplex.core.elo.EloTeam;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.party.Party;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -1112,8 +1113,7 @@ public abstract class Game implements Listener
{
return team.GetSize() < PlayersPerTeam;
}
return Manager.IsTeamBalance() ? team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size())
: true;
return !Manager.IsTeamBalance() || team.GetSize() < Math.max(1, UtilServer.getPlayers().length / GetTeamList().size());
}
@EventHandler

View File

@ -1,7 +1,5 @@
package nautilus.game.arcade.managers;
import java.util.ArrayList;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -23,7 +21,6 @@ import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -41,6 +38,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
public class GamePlayerManager implements Listener
{
ArcadeManager Manager;
@ -267,6 +266,7 @@ public class GamePlayerManager implements Listener
TeamClick(player, team);
}
public void TeamClick(final Player player, final GameTeam team)
{
if (Manager.GetGame() == null)
@ -301,8 +301,9 @@ public class GamePlayerManager implements Listener
}
if (!game.GetTeamPreferences().containsKey(team))
game.GetTeamPreferences().put(team, new ArrayList<Player>());
{
game.GetTeamPreferences().put(team, new ArrayList<>());
}
game.GetTeamPreferences().get(team).add(player);
}
@ -317,8 +318,6 @@ public class GamePlayerManager implements Listener
Player player = event.getPlayer();
Kit kit = Manager.GetLobby().GetClickedKit(event.getRightClicked());
if (kit == null)