Fixes from testing

This commit is contained in:
AlexTheCoder 2017-08-02 18:41:46 -04:00
parent ef4aeaaf64
commit d390a9a492
22 changed files with 69 additions and 66 deletions

View File

@ -544,12 +544,6 @@ public class CoreClientManager extends MiniPlugin
String response = _repository.GetClient(client.getName(), uuid, ipAddress);
TimingManager.stop(client.getName() + " GetClient.");
TimingManager.start(client.getName() + " Event.");
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
TimingManager.stop(client.getName() + " Event.");
TimingManager.start(client.getName() + " While Loop.");
while (CLIENT_LOGIN_LOCKS.containsKey(client.getName()) && System.currentTimeMillis() - timeStart < 15000)
{
@ -578,6 +572,11 @@ public class CoreClientManager extends MiniPlugin
client.setPrimaryGroup(newGroup);
_repository.setPrimaryGroup(client.getAccountId(), newGroup.getIdentifier(), null);
}
TimingManager.start(client.getName() + " Event.");
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
TimingManager.stop(client.getName() + " Event.");
TimingManager.stop(client.getName() + " LoadClient Total.");

View File

@ -46,7 +46,7 @@ public class InfoPlayerCommand extends CommandBase<CoreClientManager>
Plugin.fetchGroups(client.getAccountId(), pair ->
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":"));
UtilPlayer.message(caller, C.cBlue + "Primary: " + pair.getLeft().getIdentifier());
UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + pair.getLeft().getIdentifier());
UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):");
for (PermissionGroup group : pair.getRight())
{
@ -72,7 +72,7 @@ public class InfoPlayerCommand extends CommandBase<CoreClientManager>
Plugin.fetchGroups(id.intValue(), pair ->
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Rank Information of " + target + ":"));
UtilPlayer.message(caller, C.cBlue + "Primary: " + pair.getLeft().getIdentifier());
UtilPlayer.message(caller, C.cBlue + "Primary: " + C.cGray + pair.getLeft().getIdentifier());
UtilPlayer.message(caller, C.cBlue + "Additional (" + pair.getRight().size() + "):");
for (PermissionGroup group : pair.getRight())
{

View File

@ -1,9 +1,10 @@
package mineplex.core.account.command;
import java.util.stream.Collectors;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.command.CommandBase;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -19,10 +20,6 @@ public class ListRanksCommand extends CommandBase<CoreClientManager>
@Override
public void Execute(Player caller, String[] args)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Available Ranks:"));
for (PermissionGroup group : Plugin.getPermissionManager().getGroups())
{
UtilPlayer.message(caller, C.cBlue + "- " + C.cGray + group.getIdentifier());
}
UtilPlayer.message(caller, F.main(Plugin.getName(), "Available Ranks: " + Plugin.getPermissionManager().getGroups().stream().map(group -> C.cYellow + group.getIdentifier()).sorted().collect(Collectors.joining(C.cGray + ", "))));
}
}

View File

@ -182,6 +182,10 @@ public class PermissionManager extends MiniPlugin
{
current = "player";
}
else
{
current = legacy;
}
return getGroup(current);
}

View File

@ -46,7 +46,7 @@ public class AccountRepository extends MinecraftRepository
private static String REMOVE_ADDITIONAL_RANKS = "DELETE FROM accountRanks WHERE accountId=? AND primaryGroup=false;";
private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ? ORDER BY lastLogin DESC;";
private static String SELECT_ACCOUNT_UUID_BY_ID = "SELECT uuid FROM accounts WHERE id= DESC;";
private static String SELECT_ACCOUNT_UUID_BY_ID = "SELECT uuid FROM accounts WHERE id=?;";
private static String SELECT_ACCOUNT_ID_BY_UUID = "SELECT id FROM accounts WHERE accounts.uuid = ? LIMIT 1";
public AccountRepository()
@ -237,13 +237,13 @@ public class AccountRepository extends MinecraftRepository
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM accountRanks WHERE accountId=" + accountId + " AND primaryGroup=true;");
)
{
if (!rs.next())
if (!rs.next() || rs.getInt(1) == 0)
{
s.execute(ADD_PRIMARY_RANK.replace("?", "" + accountId));
}
}
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier));
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", rankIdentifier.length(), rankIdentifier), new ColumnInt("accountId", accountId));
UtilServer.runSync(() ->
{
@ -360,7 +360,7 @@ public class AccountRepository extends MinecraftRepository
}
}
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnInt("accountId", accountId), new ColumnVarChar("rankIdentifier", "player".length(), "player"));
executeUpdate(c, UPDATE_PRIMARY_RANK, () -> {}, new ColumnVarChar("rankIdentifier", "player".length(), "player"), new ColumnInt("accountId", accountId));
executeUpdate(c, REMOVE_ADDITIONAL_RANKS, () -> success.set(false), new ColumnInt("accountId", accountId));
}
catch (SQLException e)
@ -402,13 +402,16 @@ public class AccountRepository extends MinecraftRepository
executeQuery("SELECT * FROM accountRanks WHERE accountId=?;", rs ->
{
if (rs.getBoolean("primaryGroup"))
while (rs.next())
{
primary.set(rs.getString("rankIdentifier"));
}
else
{
additional.add(rs.getString("rankIdentifier"));
if (rs.getBoolean("primaryGroup"))
{
primary.set(rs.getString("rankIdentifier"));
}
else
{
additional.add(rs.getString("rankIdentifier"));
}
}
}, () ->
{

View File

@ -57,14 +57,23 @@ public class AntihackLogger extends MiniPlugin
registerMetadata(new ViolationInfoMetadata());
registerMetadata(new PartyInfoMetadata());
registerMetadata(new PlayerInfoMetadata());
if (UtilServer.isTestServer())
{
generatePermissions();
}
}
private void generatePermissions()
{
PermissionManager pm = _clientManager.getPermissionManager();
pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SAVE_METADATA_COMMAND_PERMISSION), true, true);
}
public void addCommands()
{
if (UtilServer.isTestServer())
{
PermissionManager pm = _clientManager.getPermissionManager();
pm.setPermission(pm.getGroup("srmod"), GroupPermission.of(SAVE_METADATA_COMMAND_PERMISSION), true, true);
addCommand(new CommandBase<AntihackLogger>(this, SAVE_METADATA_COMMAND_PERMISSION, "savemetadata")
{
@Override

View File

@ -126,7 +126,7 @@ public class CommandCenter implements Listener, IPacketHandler
}
else
{
UtilPlayerBase.message(event.getPlayer(), C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(event.getPlayer(), C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
}
return;
}

View File

@ -76,7 +76,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
}
else
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
}
}
else

View File

@ -147,6 +147,8 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
require(PacketHandler.class).addPacketHandler(this, PacketHandler.ListenerPriority.LOW, PacketPlayOutPlayerInfo.class, PacketPlayOutNamedEntitySpawn.class);
_redis = new RedisDataRepository<>(Region.ALL, DisguisePlayerBean.class, "disguisedPlayer");
generatePermissions();
}
private void generatePermissions()

View File

@ -15,6 +15,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.permissions.GroupPermission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.account.permissions.PermissionManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
@ -32,9 +33,6 @@ import mineplex.core.updater.event.UpdateEvent;
public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{
public static final String USE_INCOGNITO_PERMISSION = "mineplex.core.incognito.use";
public static final String BYPASS_INCOGNITO_PERMISSION = "mineplex.core.incognito.bypass";
public static final String EXTRA_INCOGNITO_PERMISSION = "mineplex.core.incognito.extra";
public static final String INCOGNITO_COMMAND_PERMISSION = "mineplex.core.incognito.command";
private CoreClientManager _clientManager;
private IncognitoRepository _repository;
@ -55,32 +53,23 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
PermissionManager pm = _clientManager.getPermissionManager();
pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(USE_INCOGNITO_PERMISSION), true, true);
pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(BYPASS_INCOGNITO_PERMISSION), true, true);
pm.setPermission(pm.getGroup("admin"), GroupPermission.of(EXTRA_INCOGNITO_PERMISSION), true, true);
pm.setPermission(pm.getGroup("trainee"), GroupPermission.of(INCOGNITO_COMMAND_PERMISSION), true, true);
}
private boolean canSeeThroughIncognito(Player viewer, Player target)
{
boolean bypass = _clientManager.getPermissionManager().hasPermission(viewer, GroupPermission.of(BYPASS_INCOGNITO_PERMISSION));
boolean extra1 = _clientManager.getPermissionManager().hasPermission(viewer, GroupPermission.of(EXTRA_INCOGNITO_PERMISSION));
boolean extra2 = _clientManager.getPermissionManager().hasPermission(target, GroupPermission.of(EXTRA_INCOGNITO_PERMISSION));
PermissionGroup v = _clientManager.Get(viewer).getPrimaryGroup();
PermissionGroup t = _clientManager.Get(target).getPrimaryGroup();
if (bypass)
if (v.getIdentifier().equals(t.getIdentifier()))
{
if (extra2)
{
return extra1;
}
else
{
return true;
}
return true;
}
else
if (_clientManager.getPermissionManager().inheritsFully(v, t))
{
return false;
return true;
}
return false;
}
public void addCommands()

View File

@ -12,7 +12,7 @@ public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
{
public IncognitoToggleCommand(IncognitoManager plugin)
{
super(plugin, IncognitoManager.INCOGNITO_COMMAND_PERMISSION, "incognito", "vanish");
super(plugin, IncognitoManager.USE_INCOGNITO_PERMISSION, "incognito", "vanish");
}
@Override

View File

@ -98,7 +98,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
for (Player player : Bukkit.getOnlinePlayers())
{
if (_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), group))
if (_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals(group.getIdentifier()) || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), group))
{
if (command.getDisplayTitle())
{

View File

@ -71,7 +71,7 @@ public class NotificationManager extends MiniPlugin
{
PermissionGroup group = _clientManager.Get(player).getPrimaryGroup();
if (_clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend")))
if (group.getIdentifier().equals("legend") || _clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend")))
{
continue;
}
@ -99,7 +99,7 @@ public class NotificationManager extends MiniPlugin
{
PermissionGroup group = _clientManager.Get(player).getPrimaryGroup();
if (_clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend")))
if (group.getIdentifier().equals("legend") || _clientManager.getPermissionManager().inheritsFully(group, _clientManager.getPermissionManager().getGroup("legend")))
{
continue;
}

View File

@ -100,7 +100,7 @@ public class EternalGiveawayManager extends MiniPlugin
*/
private boolean hasEternal(Player player)
{
return _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group);
return _clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("eternal") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group);
}
public Region getRegion()

View File

@ -81,7 +81,7 @@ public class TitanGiveawayManager extends MiniPlugin
*/
private boolean hasTitan(Player player)
{
return _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group);
return _clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("titan") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _group);
}
public Region getRegion()

View File

@ -1307,7 +1307,7 @@ public class RewardManager
if (rarity == RewardRarity.MYTHICAL)
{
PowerPlayReward rew = new PowerPlayReward(_clientManager, SubscriptionDuration.MONTH, rarity, 0, 0);
if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("titan")))
if (canGiveMythical && (type == RewardType.MYTHICAL_CHEST || type == RewardType.TRICK_OR_TREAT_CHEST || type == RewardType.THANKFUL_CHEST) && !(_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("titan") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("titan"))))
{
return new RankReward(_clientManager, 0, 0, rarity);
}
@ -1315,7 +1315,7 @@ public class RewardManager
{
return rew;
}
else if (!canGiveMythical || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("legend")))
else if (!canGiveMythical || (_clientManager.Get(player).getPrimaryGroup().getIdentifier().equals("legend") || _clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("legend"))))
{
rarity = RewardRarity.LEGENDARY;
}

View File

@ -97,7 +97,7 @@ public class RankReward extends Reward
@Override
public boolean canGiveReward(Player player)
{
return !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("eternal"));
return !_clientManager.Get(player).getPrimaryGroup().equals("eternal") && !_clientManager.getPermissionManager().inheritsFully(_clientManager.Get(player).getPrimaryGroup(), _clientManager.getPermissionManager().getGroup("eternal"));
}
@Override

View File

@ -39,7 +39,7 @@ public class BackCommand extends CommandBase<Teleport>
{
if (!target.equals(caller.getName()) && !_commandCenter.GetClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(Teleport.TELEPORT_OTHER_COMMAND_PERMISSION)))
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
return;
}

View File

@ -34,7 +34,7 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
}
else
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
}
}
@ -47,7 +47,7 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
}
else
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
}
}
@ -60,7 +60,7 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
}
else
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
}
}
@ -73,7 +73,7 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
}
else
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
}
}
@ -86,7 +86,7 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
}
else
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
}
}
else

View File

@ -127,7 +127,7 @@ public class TwoFactorAuth extends MiniClientPlugin<TwoFactorData>
if (!_clientManager.getPermissionManager().hasPermission(caller, GroupPermission.of(RESET_2FA_PERMISSION)))
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
return;
}

View File

@ -45,7 +45,7 @@ public class ClansAdmin
{
if (!Clans.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(USE_ADMIN_COMMANDS_PERMISSION)) && !caller.isOp())
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
return;
}

View File

@ -150,7 +150,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!Plugin.getClientManager().getPermissionManager().hasPermission(caller, GroupPermission.of(ClansManager.FORCE_JOIN_COMMAND_PERMISSION)))
{
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission for that.");
UtilPlayerBase.message(caller, C.mHead + "Permissions> " + C.mBody + "You do not have permission to do that.");
return;
}