Merge pull request #191 from Mineplex-LLC/bugfix/samczsun
Bugfix/samczsun
This commit is contained in:
commit
8711004bc5
@ -19,13 +19,6 @@ import java.util.*;
|
||||
|
||||
public class UtilServer
|
||||
{
|
||||
// Quite hacky. would be nice if we could have a "MineplexPlugin" interface
|
||||
// which would define a getServerName() method and then implement it in
|
||||
// whatever way needed.
|
||||
// MineplexPlugin plugin = (MineplexPlugin) plugin.getClass().getDeclaredMethod("getMineplexPlugin").invoke(plugin);
|
||||
// plugin.getServerName();
|
||||
private static String _serverName;
|
||||
|
||||
public static Player[] getPlayers()
|
||||
{
|
||||
return getServer().getOnlinePlayers().toArray(new Player[0]);
|
||||
@ -132,77 +125,16 @@ public class UtilServer
|
||||
runnable.runTaskTimer(getPlugin(), time, time);
|
||||
}
|
||||
|
||||
public static String getServerName()
|
||||
{
|
||||
if (_serverName == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> Portal = Class.forName("mineplex.core.portal.Portal");
|
||||
|
||||
Object instance = null;
|
||||
|
||||
List<Field> stringFields = Lists.newArrayList();
|
||||
|
||||
for (Field field : Portal.getDeclaredFields())
|
||||
{
|
||||
if (field.getType().equals(Portal))
|
||||
{
|
||||
field.setAccessible(true);
|
||||
instance = field.get(null);
|
||||
}
|
||||
|
||||
if (field.getType().equals(String.class))
|
||||
{
|
||||
stringFields.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
for (Field field : stringFields)
|
||||
{
|
||||
field.setAccessible(true);
|
||||
String value = (String) field.get(instance);
|
||||
|
||||
if (stringFields.size() > 1)
|
||||
{
|
||||
if (value.contains("-"))
|
||||
{
|
||||
_serverName = new String(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_serverName = new String(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (_serverName == null)
|
||||
{
|
||||
_serverName = "UNKOWN";
|
||||
System.out.println("ERROR: Could not get server name from Portal. Cause is most likely ambiguous fields in the class. Please revise UtilServer's method of getting the current server name.");
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("FATAL ERROR WHILE TRYING TO GET SERVER NAME");
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return _serverName;
|
||||
}
|
||||
|
||||
public static String getServerNameFromConfig()
|
||||
{
|
||||
return getPlugin().getConfig().getString("serverstatus.name");
|
||||
}
|
||||
|
||||
public static Collection<Player> GetPlayers()
|
||||
{
|
||||
return Lists.newArrayList(getPlayers());
|
||||
}
|
||||
|
||||
public static String getServerName()
|
||||
{
|
||||
return getPlugin().getConfig().getString("serverstatus.name");
|
||||
}
|
||||
|
||||
public static boolean isTestServer()
|
||||
{
|
||||
return getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing");
|
||||
|
@ -19,10 +19,14 @@ import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AchievementManager extends MiniPlugin
|
||||
{
|
||||
private static final List<String> NO_FAKE_LEVELS = Arrays.asList("samczsun");
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
private IncognitoManager _incognitoManager;
|
||||
private StatsManager _statsManager;
|
||||
@ -201,6 +205,11 @@ public class AchievementManager extends MiniPlugin
|
||||
{
|
||||
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
|
||||
|
||||
if (NO_FAKE_LEVELS.contains(sender.getName()))
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
if (sender.getName().equalsIgnoreCase("B2_mp"))
|
||||
return 101;
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
DisguiseManager disguiseManager = require(DisguiseManager.class);
|
||||
|
||||
this._thisServer = UtilServer.getServerNameFromConfig();
|
||||
this._thisServer = UtilServer.getServerName();
|
||||
|
||||
_repository = new AntiHackRepository(this._thisServer);
|
||||
_repository.initialize();
|
||||
@ -333,7 +333,7 @@ public class AntiHack extends MiniPlugin
|
||||
)
|
||||
)
|
||||
.addSibling(
|
||||
new ChatComponentText(": " + violation.getMessage() + ". Please investigate!")
|
||||
new ChatComponentText(": " + violation.getMessage() + ".")
|
||||
.setChatModifier(
|
||||
new ChatModifier()
|
||||
.setColor(EnumChatFormat.YELLOW)
|
||||
@ -408,7 +408,7 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
|
||||
return component.addSibling(
|
||||
new ChatComponentText(". Please investigate!")
|
||||
new ChatComponentText(".")
|
||||
.setChatModifier(
|
||||
new ChatModifier()
|
||||
.setColor(EnumChatFormat.YELLOW)
|
||||
@ -455,10 +455,10 @@ public class AntiHack extends MiniPlugin
|
||||
double baseDeg = 18;
|
||||
|
||||
Location center = player.getLocation().add(0, heightAdj, 0);
|
||||
AntiHackGuardian north = new AntiHackGuardian(center.clone().add(0, 0, -radius), 0, 0, 0, 0, 0, 0);
|
||||
AntiHackGuardian east = new AntiHackGuardian(center.clone().add(radius, 0, 0), 0, 0, 0, 0, 0, 0);
|
||||
AntiHackGuardian south = new AntiHackGuardian(center.clone().add(0, 0, radius), 0, 0, 0, 0, 0, 0);
|
||||
AntiHackGuardian west = new AntiHackGuardian(center.clone().add(-radius, 0, 0), 0, 0, 0, 0, 0, 0);
|
||||
AntiHackGuardian north = new AntiHackGuardian(center.clone().add(0, 0, -radius), 0, 0, 0, 0, 0, 0, false);
|
||||
AntiHackGuardian east = new AntiHackGuardian(center.clone().add(radius, 0, 0), 0, 0, 0, 0, 0, 0, false);
|
||||
AntiHackGuardian south = new AntiHackGuardian(center.clone().add(0, 0, radius), 0, 0, 0, 0, 0, 0, false);
|
||||
AntiHackGuardian west = new AntiHackGuardian(center.clone().add(-radius, 0, 0), 0, 0, 0, 0, 0, 0, false);
|
||||
|
||||
UtilEnt.CreatureLook(east.getEntity(), player);
|
||||
UtilEnt.CreatureLook(west.getEntity(), player);
|
||||
@ -1005,7 +1005,7 @@ public class AntiHack extends MiniPlugin
|
||||
if (_clientManager.Get(staff).GetRank().has(Rank.MODERATOR))
|
||||
{
|
||||
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cYellow + report);
|
||||
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation. Please investigate.");
|
||||
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation.");
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
@ -70,6 +70,11 @@ public class AntiHackGuardian implements Listener
|
||||
private final double CENTER_Z;
|
||||
|
||||
public AntiHackGuardian(Location center, int maxX, int minX, int maxY, int minY, int maxZ, int minZ)
|
||||
{
|
||||
this(center,maxX,minX, maxY, minY, maxZ, minZ, true);
|
||||
}
|
||||
|
||||
public AntiHackGuardian(Location center, int maxX, int minX, int maxY, int minY, int maxZ, int minZ, boolean hideForStaff)
|
||||
{
|
||||
UtilServer.RegisterEvents(this);
|
||||
|
||||
@ -107,6 +112,8 @@ public class AntiHackGuardian implements Listener
|
||||
|
||||
disguiseManager.disguise(this._disguise, player ->
|
||||
{
|
||||
if (!hideForStaff) return true;
|
||||
|
||||
// Don't let Builder -> Admin see it
|
||||
Rank rank = clientManager.Get(player).GetRank();
|
||||
if (rank.has(Rank.MAPDEV))
|
||||
|
@ -28,7 +28,7 @@ class BanwaveAction extends AntiHackAction
|
||||
event.getCheckClass(),
|
||||
event.getMessage(),
|
||||
event.getViolations(),
|
||||
UtilServer.getServerNameFromConfig()
|
||||
UtilServer.getServerName()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,11 @@ import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
|
||||
@ -82,6 +84,10 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
// The map of which players should a disguise be shown to
|
||||
private Map<DisguiseBase, Predicate<Player>> _disguisePlayerMap = new HashMap<>();
|
||||
|
||||
// todo understand how this works
|
||||
private Map<Integer, PacketPlayOutEntityVelocity> _movePacketMap = new HashMap<>();
|
||||
private Set<Integer> _goingUp = new HashSet<>();
|
||||
|
||||
private HashSet<String> _blockedNames = new HashSet<>();
|
||||
|
||||
private boolean _handlingPacket = false;
|
||||
@ -98,7 +104,10 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
PacketPlayOutEntityMetadata.class,
|
||||
PacketPlayOutSpawnEntityLiving.class,
|
||||
PacketPlayOutUpdateAttributes.class,
|
||||
PacketPlayOutEntityEquipment.class
|
||||
PacketPlayOutEntityEquipment.class,
|
||||
PacketPlayOutEntityVelocity.class,
|
||||
PacketPlayOutEntity.PacketPlayOutRelEntityMove.class,
|
||||
PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook.class
|
||||
);
|
||||
|
||||
createBedChunk();
|
||||
@ -431,6 +440,127 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
// honestly im not really sure how this works or what it's really meant to do
|
||||
// it unbreaks squid in SSM though so I guess it's useful
|
||||
// todo understand how it works
|
||||
else if (packet instanceof PacketPlayOutEntityVelocity)
|
||||
{
|
||||
PacketPlayOutEntityVelocity velocityPacket = (PacketPlayOutEntityVelocity) packet;
|
||||
|
||||
// Only for viewers
|
||||
if (velocityPacket.a == owner.getEntityId())
|
||||
{
|
||||
if (velocityPacket.c > 0)
|
||||
_goingUp.add(velocityPacket.a);
|
||||
}
|
||||
else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (_spawnPacketMap.containsKey(velocityPacket.a))
|
||||
{
|
||||
packetInfo.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else if (packet instanceof PacketPlayOutEntity.PacketPlayOutRelEntityMove)
|
||||
{
|
||||
final PacketPlayOutEntity.PacketPlayOutRelEntityMove movePacket = (PacketPlayOutEntity.PacketPlayOutRelEntityMove) packet;
|
||||
|
||||
// Only for viewers
|
||||
if (movePacket.a == owner.getEntityId())
|
||||
return;
|
||||
|
||||
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c < 20)
|
||||
{
|
||||
_goingUp.remove(movePacket.a);
|
||||
_movePacketMap.remove(movePacket.a);
|
||||
}
|
||||
|
||||
if (!containsSpawnDisguise(owner, getActiveDisguise(movePacket.a)))
|
||||
return;
|
||||
|
||||
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
|
||||
velocityPacket.a = movePacket.a;
|
||||
velocityPacket.b = movePacket.b * 100;
|
||||
velocityPacket.c = movePacket.c * 100;
|
||||
velocityPacket.d = movePacket.d * 100;
|
||||
|
||||
if (_movePacketMap.containsKey(movePacket.a))
|
||||
{
|
||||
PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a);
|
||||
|
||||
velocityPacket.b = (int) (.8 * lastVelocityPacket.b);
|
||||
velocityPacket.c = (int) (.8 * lastVelocityPacket.c);
|
||||
velocityPacket.d = (int) (.8 * lastVelocityPacket.d);
|
||||
}
|
||||
|
||||
_movePacketMap.put(movePacket.a, velocityPacket);
|
||||
|
||||
packetVerifier.bypassProcess(velocityPacket);
|
||||
|
||||
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
packetVerifier.bypassProcess(velocityPacket);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (getActiveDisguise(movePacket.a) instanceof DisguiseBlock)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else if (packet instanceof PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook)
|
||||
{
|
||||
final PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook movePacket = (PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook) packet;
|
||||
|
||||
// Only for viewers
|
||||
if (movePacket.a == owner.getEntityId())
|
||||
return;
|
||||
|
||||
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c <= 20)
|
||||
{
|
||||
_goingUp.remove(movePacket.a);
|
||||
_movePacketMap.remove(movePacket.a);
|
||||
}
|
||||
|
||||
if (!containsSpawnDisguise(owner, getActiveDisguise(movePacket.a)))
|
||||
return;
|
||||
|
||||
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
|
||||
velocityPacket.a = movePacket.a;
|
||||
velocityPacket.b = movePacket.b * 100;
|
||||
velocityPacket.c = movePacket.c * 100;
|
||||
velocityPacket.d = movePacket.d * 100;
|
||||
|
||||
if (_movePacketMap.containsKey(movePacket.a))
|
||||
{
|
||||
PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a);
|
||||
|
||||
velocityPacket.b = (int) (.8 * lastVelocityPacket.b);
|
||||
velocityPacket.c = (int) (.8 * lastVelocityPacket.c);
|
||||
velocityPacket.d = (int) (.8 * lastVelocityPacket.d);
|
||||
}
|
||||
|
||||
_movePacketMap.put(movePacket.a, velocityPacket);
|
||||
|
||||
packetVerifier.bypassProcess(velocityPacket);
|
||||
|
||||
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
packetVerifier.bypassProcess(velocityPacket);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePacket(Packet packet, PacketVerifier verifier)
|
||||
|
@ -161,6 +161,9 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
CoreClient client = _clients.Get(event.getPlayer());
|
||||
|
||||
if (!client.GetRank().has(event.getPlayer(), Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, false))
|
||||
return;
|
||||
|
||||
if (_redis.elementExists(client.getAccountId() + client.getName()))
|
||||
{
|
||||
DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName());
|
||||
@ -263,11 +266,6 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
return this._punish;
|
||||
}
|
||||
|
||||
public CosmeticManager getCostmeticManager()
|
||||
{
|
||||
return this._cosmetics;
|
||||
}
|
||||
|
||||
public PreferencesManager getPreferencesManager()
|
||||
{
|
||||
return this._prefs;
|
||||
@ -439,6 +437,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
if (other.getName().equalsIgnoreCase(requestedUsername))
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!"));
|
||||
_cannotJoin.remove(requestedUsername.toLowerCase());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -511,17 +511,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
}
|
||||
|
||||
int spectatorCount = 0;
|
||||
|
||||
for (Player players : UtilServer.getPlayersCollection())
|
||||
{
|
||||
if (isVanished(players))
|
||||
{
|
||||
spectatorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write(UtilServer.getPlayers().length - spectatorCount + "/" + GetPlayerFull());
|
||||
scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write( _gameManager.getValidPlayersForGameStart().size() + "/" + GetPlayerFull());
|
||||
scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM));
|
||||
|
||||
if (GetGame() != null)
|
||||
|
@ -206,7 +206,7 @@ public class PerkDestructor extends Perk
|
||||
|
||||
for (Block block : UtilBlock.getInRadius(proj.getLocation(), 4).keySet())
|
||||
{
|
||||
if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.isLiquid())
|
||||
if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.getType() == Material.BARRIER || block.isLiquid())
|
||||
continue;
|
||||
|
||||
//Event
|
||||
|
@ -1106,11 +1106,14 @@ public class GameLobbyManager implements Listener
|
||||
}
|
||||
else
|
||||
{
|
||||
teamId = rankName;
|
||||
|
||||
// It needs to be color first in order for the client to sort the tab list correctly
|
||||
if (gameTeam != null && gameTeam.GetColor() != null)
|
||||
{
|
||||
teamId += "." + gameTeam.GetColor().getChar();
|
||||
teamId = gameTeam.GetColor().getChar() + "." + rankName;
|
||||
}
|
||||
else
|
||||
{
|
||||
teamId = rankName;
|
||||
}
|
||||
}
|
||||
return teamId;
|
||||
|
@ -2,7 +2,9 @@ package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.PlayerSelector;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
@ -329,7 +331,7 @@ public class GameManager implements Listener
|
||||
{
|
||||
//Stop Countdown!
|
||||
if (game.GetCountdown() != -1 &&
|
||||
UtilServer.getPlayers().length < Manager.GetPlayerMin() &&
|
||||
getValidPlayersForGameStart().size() < Manager.GetPlayerMin() &&
|
||||
!game.GetCountdownForce())
|
||||
{
|
||||
game.SetCountdown(-1);
|
||||
@ -338,10 +340,10 @@ public class GameManager implements Listener
|
||||
|
||||
if (Manager.IsGameAutoStart())
|
||||
{
|
||||
if (UtilServer.getPlayers().length >= Manager.GetPlayerFull())
|
||||
if (getValidPlayersForGameStart().size() >= Manager.GetPlayerFull())
|
||||
StateCountdown(game, 20, false);
|
||||
|
||||
else if (UtilServer.getPlayers().length >= Manager.GetPlayerMin())
|
||||
else if (getValidPlayersForGameStart().size() >= Manager.GetPlayerMin())
|
||||
StateCountdown(game, 60, false);
|
||||
|
||||
else if (game.GetCountdown() != -1)
|
||||
@ -410,6 +412,13 @@ public class GameManager implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public List<Player> getValidPlayersForGameStart()
|
||||
{
|
||||
return PlayerSelector.selectPlayers(
|
||||
PlayerSelector.and(PlayerSelector.NOT_VANISHED, player -> !Manager.IsObserver(player))
|
||||
);
|
||||
}
|
||||
|
||||
public void StateCountdown(Game game, int timer, boolean force)
|
||||
{
|
||||
if (game instanceof UHC && !((UHC)game).isMapLoaded())
|
||||
|
Loading…
Reference in New Issue
Block a user