Merge remote-tracking branch 'refs/remotes/origin/develop' into update/hub-makeover

This commit is contained in:
Sam 2017-09-16 23:33:43 +01:00
commit fd75b53bcc
8 changed files with 48 additions and 10 deletions

View File

@ -109,8 +109,8 @@ public class AntiHack extends MiniPlugin
.build();
public static final Map<Class<? extends Check>, CheckThresholds> STRICT_CHECKS = ImmutableMap.<Class<? extends Check>, CheckThresholds>builder()
.put(Glide.class, new CheckThresholds("Flying", 600, 1200, 1600))
.put(Speed.class, new CheckThresholds("Speed", 600, 1200, 1600))
.put(Glide.class, new CheckThresholds("Flying", 600, 1200, 1800))
.put(Speed.class, new CheckThresholds("Speed", 600, 1200, 1800))
.build();
private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
@ -506,7 +506,7 @@ public class AntiHack extends MiniPlugin
Integer pastVl = this._cooldown.getIfPresent(key);
if (pastVl == null)
{
MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage());
MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage(), isStrict());
ServerCommandManager.getInstance().publishCommand(command);
_cooldown.put(key, event.getViolations());
@ -561,16 +561,17 @@ public class AntiHack extends MiniPlugin
private BaseComponent[] getMinimalMessage(MajorViolationCommand violation)
{
Class<? extends Check> checkType = CheckManager.getCheckBySimpleName(violation.getHackType());
if (!CHECKS.containsKey(checkType))
CheckThresholds thresholds = CHECKS.getOrDefault(checkType, NOOP_THRESHOLD);
if (violation.isStrict())
{
System.out.println("Warning: Unknown check type '" + violation.getHackType() + "' " + checkType);
thresholds = STRICT_CHECKS.getOrDefault(checkType, thresholds);
}
ComponentBuilder componentBuilder = new ComponentBuilder("")
.append("A").color(ChatColor.AQUA).obfuscated(true)
.append(" GWEN > ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.RED).bold(true)
.append(violation.getPlayerName(), ComponentBuilder.FormatRetention.NONE).color(ChatColor.GOLD)
.append(" suspected of ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW);
CHECKS.getOrDefault(checkType, NOOP_THRESHOLD).format(componentBuilder, violation.getViolations());
thresholds.format(componentBuilder, violation.getViolations());
if (!violation.getOriginatingServer().equals(this._thisServer))
{

View File

@ -9,14 +9,16 @@ public class MajorViolationCommand extends ServerCommand
private final String _hackType;
private final int _violations;
private final String _message;
private final boolean _strict;
public MajorViolationCommand(String thisServer, String playerName, String hackType, int violations, String message)
public MajorViolationCommand(String thisServer, String playerName, String hackType, int violations, String message, boolean strict)
{
this._thisServer = thisServer;
this._playerName = playerName;
this._hackType = hackType;
this._violations = violations;
this._message = message;
this._strict = strict;
}
public String getOriginatingServer()
@ -43,4 +45,9 @@ public class MajorViolationCommand extends ServerCommand
{
return _message;
}
public boolean isStrict()
{
return _strict;
}
}

View File

@ -1112,6 +1112,8 @@ public class GadgetManager extends MiniPlugin
public void disableAll()
{
_userGadgetPersistence.setEnabled(false);
for (GadgetType gadgetType : _gadgets.keySet())
{
for (Gadget gadget : _gadgets.get(gadgetType))
@ -1140,8 +1142,7 @@ public class GadgetManager extends MiniPlugin
if (gadget instanceof KitSelectorGadget)
continue;
for (Player player : UtilServer.getPlayers())
gadget.disable(player);
gadget.disableForAll();
}
}
}

View File

@ -16,15 +16,27 @@ public class UserGadgetPersistence
private final GadgetManager _manager;
private final PlayerKeyValueRepository<String> _repository;
private boolean _enabled;
public UserGadgetPersistence(GadgetManager manager)
{
_manager = manager;
_repository = new PlayerKeyValueRepository<>("gadgets", String.class);
_enabled = true;
}
public void setEnabled(boolean enabled)
{
_enabled = enabled;
}
public void load(Player player)
{
if (!_enabled)
{
return;
}
_repository.getAll(player.getUniqueId()).thenCompose(BukkitFuture.accept(values ->
{
if (player.isOnline())

View File

@ -123,6 +123,7 @@ public abstract class WinEffectGadget extends Gadget
_allPlayers.clear();
_allPlayers = null;
// Loads gadgets back when players are teleported to the arcade hub, after the win effect
Manager.getUserGadgetPersistence().setEnabled(true);
for (Player player : UtilServer.getPlayers())
{
Manager.getUserGadgetPersistence().load(player);

View File

@ -75,6 +75,7 @@ import mineplex.core.events.EnableArcadeSpawnEvent;
import mineplex.core.explosion.Explosion;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.event.ToggleMobsEvent;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
@ -1689,6 +1690,16 @@ public class ArcadeManager extends MiniPlugin implements IRelation
getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= (GetGameHostManager().isEventServer() ? 120 : 40));
}
@EventHandler(priority = EventPriority.HIGH)
public void disableGadgetsInGame(GadgetEnableEvent event)
{
if (_game != null && _game.InProgress() && _game.GadgetsDisabled && event.getGadget().getGadgetType() == GadgetType.COSTUME)
{
event.setShowMessage(false);
event.setCancelled(true);
}
}
/*public void saveBasicStats(final Game game)
{
if (!IsTournamentServer())

View File

@ -29,7 +29,7 @@ public class KitJumper extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkDoubleJump("Double Jump", 1.2, 1.2, false, 3000, true),
new PerkDoubleJump("Double Jump", 1.2, 1.2, false),
new PerkDummy("Feathered Boots", Collections.singletonList(C.cGray + "You take no fall damage.").toArray(new String[1])),
new PerkCraftman()
};

View File

@ -64,6 +64,11 @@ public class LeashedEntity implements Listener
{
if (event.GetDamageeEntity().equals(_fakeLeash) && event.GetCause() == DamageCause.ENTITY_ATTACK)
{
if (event.GetDamagerEntity(true).equals(_host))
{
event.SetCancelled("Self Leash Damage");
}
event.setDamagee(_host);
event.SetIgnoreRate(false);
}