Merge branch 'develop' of https://github.com/Mineplex-LLC/Minecraft-PC into bugfix/disguises
This commit is contained in:
commit
a4e9fb04d8
@ -11,7 +11,6 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -22,6 +21,11 @@ public class UtilWorld
|
||||
{
|
||||
return Bukkit.getServer().getWorld(world);
|
||||
}
|
||||
|
||||
public static boolean isInChunk(Location location, Chunk chunk)
|
||||
{
|
||||
return location.getChunk().getX() == chunk.getX() && location.getChunk().getZ() == chunk.getZ() && chunk.getWorld().equals(location.getChunk().getWorld());
|
||||
}
|
||||
|
||||
public static boolean areChunksEqual(Location first, Location second)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>anticheat</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.tukaani</groupId>
|
||||
|
@ -48,6 +48,7 @@ import com.mineplex.anticheat.checks.combat.KillauraTypeF;
|
||||
import com.mineplex.anticheat.checks.move.Glide;
|
||||
import com.mineplex.anticheat.checks.move.HeadRoll;
|
||||
import com.mineplex.anticheat.checks.move.Speed;
|
||||
import com.mineplex.anticheat.checks.move.Timer;
|
||||
import com.mineplex.anticheat.checks.move.Toggle;
|
||||
import com.mineplex.anticheat.checks.player.BadPackets;
|
||||
|
||||
@ -88,7 +89,7 @@ import mineplex.serverdata.commands.ServerCommandManager;
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class AntiHack extends MiniPlugin
|
||||
{
|
||||
private static final Map<Class<? extends Check>, CheckThresholds> CHECKS = ImmutableMap.<Class<? extends Check>, CheckThresholds>builder()
|
||||
public static final Map<Class<? extends Check>, CheckThresholds> CHECKS = ImmutableMap.<Class<? extends Check>, CheckThresholds>builder()
|
||||
.put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 25, 45, 60))
|
||||
.put(KillauraTypeB.class, new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE))
|
||||
.put(KillauraTypeC.class, new CheckThresholds("Reach", 25, Integer.MAX_VALUE, Integer.MAX_VALUE))
|
||||
@ -100,11 +101,12 @@ public class AntiHack extends MiniPlugin
|
||||
.put(Speed.class, new CheckThresholds("Speed", 1000, 2000, 3500))
|
||||
.put(HeadRoll.class, new CheckThresholds("Illegal Movement", 0, 0, 1000))
|
||||
.put(Toggle.class, new CheckThresholds("AutoSneak", 100, 200, 300))
|
||||
.put(Timer.class, new CheckThresholds("Timer", 1000, 2000, 3000))
|
||||
.build();
|
||||
|
||||
private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
|
||||
private static final Map<Class<? extends Check>, AntiHackAction> ACTIONS = ImmutableMap.<Class<? extends Check>, AntiHackAction>builder()
|
||||
public static final Map<Class<? extends Check>, AntiHackAction> ACTIONS = ImmutableMap.<Class<? extends Check>, AntiHackAction>builder()
|
||||
.put(KillauraTypeA.class, new ImmediateBanAction(200))
|
||||
.put(KillauraTypeD.class, new BanwaveAction(1500))
|
||||
.put(KillauraTypeF.class, new BanwaveAction(600))
|
||||
@ -158,7 +160,7 @@ public class AntiHack extends MiniPlugin
|
||||
require(GuardianManager.class);
|
||||
_banWaveManager = require(BanWaveManager.class);
|
||||
|
||||
Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), this._plugin, ServicePriority.Normal);
|
||||
Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), _plugin, ServicePriority.Normal);
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation ->
|
||||
{
|
||||
@ -167,9 +169,13 @@ public class AntiHack extends MiniPlugin
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (_detailedMessages.contains(player.getName()))
|
||||
{
|
||||
player.spigot().sendMessage(detailed);
|
||||
}
|
||||
else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || _preferences.get(player).isActive(Preference.GLOBAL_GWEN_REPORTS)))
|
||||
{
|
||||
player.spigot().sendMessage(minimal);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -222,12 +228,19 @@ public class AntiHack extends MiniPlugin
|
||||
{
|
||||
Consumer<Consumer<PunishmentResponse>> doPunish = after ->
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
|
||||
});
|
||||
runAsync(() ->
|
||||
{
|
||||
new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish();
|
||||
});
|
||||
|
||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after);
|
||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, hoursBanned, true, after);
|
||||
if (UtilServer.getGroup().equals("Clans"))
|
||||
{
|
||||
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
|
||||
{
|
||||
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, finalMessage, null, ban -> {});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
||||
@ -266,14 +279,21 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
Consumer<Consumer<PunishmentResponse>> doPunish = after ->
|
||||
{
|
||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, getHoursBanned(player), true, after);
|
||||
final int hoursBanned = getHoursBanned(player);
|
||||
_punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, hoursBanned, true, after);
|
||||
String[] serverSplit = info.getServer().split("-");
|
||||
if (serverSplit.length > 0 && serverSplit[0].equals("Clans"))
|
||||
{
|
||||
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
|
||||
{
|
||||
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, info.getMessage(), null, ban -> {});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (coreClient.GetRank().has(Rank.TWITCH))
|
||||
{
|
||||
doPunish.accept(response ->
|
||||
{
|
||||
});
|
||||
doPunish.accept(response -> {});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -332,14 +352,18 @@ public class AntiHack extends MiniPlugin
|
||||
public void on(EntityDamageEvent event)
|
||||
{
|
||||
if (_pendingBan.contains(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void on(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (_pendingBan.contains(event.getDamager()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public int getPunishments(Player player)
|
||||
@ -414,7 +438,9 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
|
||||
if (_ignoredChecks.contains(event.getCheckClass()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ACTIONS.getOrDefault(event.getCheckClass(), NOOP_ACTION).handle(event);
|
||||
|
||||
@ -434,7 +460,7 @@ public class AntiHack extends MiniPlugin
|
||||
MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage());
|
||||
ServerCommandManager.getInstance().publishCommand(command);
|
||||
|
||||
this._cooldown.put(key, event.getViolations());
|
||||
_cooldown.put(key, event.getViolations());
|
||||
}
|
||||
}
|
||||
|
||||
@ -525,6 +551,6 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
public void setStrict(boolean strict)
|
||||
{
|
||||
this._strict = strict;
|
||||
_strict = strict;
|
||||
}
|
||||
}
|
||||
}
|
@ -116,4 +116,4 @@ public class BanWaveInfo
|
||||
{
|
||||
return Objects.hash(_accountId, _timeToBan, _hackType, _message, _vl, _server);
|
||||
}
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ public class BanWaveManager extends MiniPlugin
|
||||
|
||||
CoreClient client = _clientManager.Get(player);
|
||||
|
||||
if (this._repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server))
|
||||
if (_repository.insertBanWaveInfo(client.getAccountId(), timeToBan, CheckManager.getCheckSimpleName(checkClass), newMessage, vl, server))
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
@ -81,4 +81,4 @@ public class BanWaveManager extends MiniPlugin
|
||||
{
|
||||
_repository.flagDone(client.getAccountId());
|
||||
}
|
||||
}
|
||||
}
|
@ -2,21 +2,16 @@ package mineplex.core.imagemap;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.FileUtil;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.imagemap.objects.PlayerMapBoard;
|
||||
import mineplex.core.imagemap.objects.PlayerMapImage;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilScheduler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -65,7 +60,7 @@ public class ImageMapManager extends MiniPlugin
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 50);
|
||||
runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 40);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -73,13 +68,13 @@ public class ImageMapManager extends MiniPlugin
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
_boards.forEach(board -> board.getImages().forEach(image -> image.removeViewer(player)));
|
||||
_boards.forEach(board -> board.onPlayerQuit(player));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void refreshBoards(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOWER)
|
||||
if (event.getType() != UpdateType.TWOSEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -256,11 +251,6 @@ public class ImageMapManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
board.getImages().forEach(image ->
|
||||
{
|
||||
image.getViewers().clear();
|
||||
image.getItemFrames().forEach(Entity::remove);
|
||||
image.getItemFrames().clear();
|
||||
});
|
||||
board.cleanup();
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ package mineplex.core.imagemap.objects;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerMapBoard
|
||||
{
|
||||
@ -16,66 +17,74 @@ public class PlayerMapBoard
|
||||
|
||||
private final Location _location;
|
||||
private final List<PlayerMapImage> _images;
|
||||
private final Set<Player> _viewers;
|
||||
private final Map<Player, Integer> _viewers;
|
||||
|
||||
public PlayerMapBoard(Location location, List<PlayerMapImage> images)
|
||||
{
|
||||
_location = location;
|
||||
_images = images;
|
||||
_viewers = new HashSet<>();
|
||||
_viewers = new HashMap<>();
|
||||
}
|
||||
|
||||
public void goTo(Player player, boolean next)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (PlayerMapImage image : _images)
|
||||
if (!_viewers.containsKey(player))
|
||||
{
|
||||
if (image.getViewers().contains(player))
|
||||
{
|
||||
if (next && _images.size() - 1 == i)
|
||||
{
|
||||
i = -1;
|
||||
}
|
||||
else if (!next && i == 0)
|
||||
{
|
||||
i = _images.size();
|
||||
}
|
||||
|
||||
image.removeViewer(player);
|
||||
_images.get(next ? i + 1 : i - 1).addViewer(player);
|
||||
return;
|
||||
}
|
||||
|
||||
i++;
|
||||
return;
|
||||
}
|
||||
|
||||
int index = _viewers.get(player);
|
||||
|
||||
if (next && _images.size() - 1 == index)
|
||||
{
|
||||
index = -1;
|
||||
}
|
||||
else if (!next && index == 0)
|
||||
{
|
||||
index = _images.size();
|
||||
}
|
||||
|
||||
int newIndex = next ? index + 1 : index - 1;
|
||||
_viewers.put(player, newIndex);
|
||||
_images.get(newIndex).addViewer(player, true);
|
||||
}
|
||||
|
||||
public void onPlayerJoin(Player player)
|
||||
{
|
||||
_images.get(0).addViewer(player);
|
||||
_viewers.put(player, 0);
|
||||
_images.get(0).addViewer(player, true);
|
||||
}
|
||||
|
||||
public void onPlayerQuit(Player player)
|
||||
{
|
||||
_viewers.remove(player);
|
||||
}
|
||||
|
||||
public void onRefresh()
|
||||
{
|
||||
Bukkit.getOnlinePlayers().forEach(player ->
|
||||
{
|
||||
|
||||
if (UtilMath.offset2dSquared(player.getLocation(), _location) < VIEW_DIST_SQUARED)
|
||||
if (player.getWorld().equals(_location.getWorld()) && UtilMath.offset2dSquared(player.getLocation(), _location) < VIEW_DIST_SQUARED && _viewers.containsKey(player))
|
||||
{
|
||||
_viewers.add(player);
|
||||
int index = _viewers.get(player);
|
||||
_images.get(index).addViewer(player, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cleanup()
|
||||
{
|
||||
_viewers.clear();
|
||||
_images.forEach(image ->
|
||||
{
|
||||
image.getItemFrames().forEach(Entity::remove);
|
||||
image.getItemFrames().clear();
|
||||
});
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public List<PlayerMapImage> getImages()
|
||||
{
|
||||
return _images;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ public class PlayerMapImage extends MapImage
|
||||
|
||||
private final CustomItemFrames _itemFramesManager;
|
||||
private final List<ItemStack> _itemMaps;
|
||||
private final List<Player> _viewers;
|
||||
|
||||
public PlayerMapImage(CustomItemFrames itemFramesManager, BufferedImage image, List<ItemFrame> itemFrames, int width, int height)
|
||||
{
|
||||
@ -24,7 +23,6 @@ public class PlayerMapImage extends MapImage
|
||||
|
||||
_itemFramesManager = itemFramesManager;
|
||||
_itemMaps = new ArrayList<>();
|
||||
_viewers = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,22 +44,20 @@ public class PlayerMapImage extends MapImage
|
||||
return _itemFrames;
|
||||
}
|
||||
|
||||
public void addViewer(Player player)
|
||||
public void addViewer(Player player, boolean sendMap)
|
||||
{
|
||||
if (!_viewers.add(player))
|
||||
if (sendMap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//FIXME
|
||||
int slot = 8;
|
||||
for (ItemStack itemStack : _itemMaps)
|
||||
{
|
||||
player.getInventory().setItem(slot++, itemStack);
|
||||
}
|
||||
|
||||
//FIXME
|
||||
int slot = 8;
|
||||
for (ItemStack itemStack : _itemMaps)
|
||||
{
|
||||
player.getInventory().setItem(slot++, itemStack);
|
||||
UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5);
|
||||
}
|
||||
|
||||
UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5);
|
||||
|
||||
for (int i = 0; i < _itemMaps.size(); i++)
|
||||
{
|
||||
ItemFrame itemFrame = _itemFrames.get(i);
|
||||
@ -70,14 +66,4 @@ public class PlayerMapImage extends MapImage
|
||||
_itemFramesManager.setItem(player, itemFrame, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeViewer(Player player)
|
||||
{
|
||||
_viewers.remove(player);
|
||||
}
|
||||
|
||||
public List<Player> getViewers()
|
||||
{
|
||||
return _viewers;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,6 +20,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.common.Constants;
|
||||
@ -36,6 +36,7 @@ import mineplex.core.punish.Command.PunishCommand;
|
||||
import mineplex.core.punish.Command.RulesCommand;
|
||||
import mineplex.core.punish.Tokens.PunishClientToken;
|
||||
import mineplex.core.punish.Tokens.PunishmentToken;
|
||||
import mineplex.core.punish.clans.ClansBanManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.serverdata.commands.AddPunishCommand;
|
||||
@ -47,18 +48,30 @@ public class Punish extends MiniPlugin
|
||||
private HashMap<String, PunishClient> _punishClients;
|
||||
private PunishRepository _repository;
|
||||
private CoreClientManager _clientManager;
|
||||
private ClansBanManager _clansPunish;
|
||||
|
||||
public Punish(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
this(plugin, clientManager, false);
|
||||
}
|
||||
|
||||
public Punish(JavaPlugin plugin, CoreClientManager clientManager, boolean clansServer)
|
||||
{
|
||||
super("Punish", plugin);
|
||||
|
||||
|
||||
_punishClients = new HashMap<String, PunishClient>();
|
||||
_clientManager = clientManager;
|
||||
_repository = new PunishRepository();
|
||||
_clansPunish = new ClansBanManager(plugin, clientManager, clansServer);
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.commands.PunishCommand.class, new PunishmentHandler(this));
|
||||
}
|
||||
|
||||
public ClansBanManager getClansPunish()
|
||||
{
|
||||
return _clansPunish;
|
||||
}
|
||||
|
||||
public PunishRepository GetRepository()
|
||||
{
|
||||
return _repository;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
package mineplex.core.punish.clans;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.UUID;
|
||||
@ -7,7 +7,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
/**
|
||||
* Stores the information about a ban in Clans.
|
||||
* Stores the information about a blacklist in Clans.
|
||||
*/
|
||||
public class ClansBan
|
||||
{
|
||||
@ -98,4 +98,4 @@ public class ClansBan
|
||||
{
|
||||
_removed = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
package mineplex.core.punish.clans;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
/**
|
||||
* Signifies a player on clans, and a Set of their current clan bans.
|
||||
* A client representing a player and a List of their Clans blacklists
|
||||
*/
|
||||
public class ClansBanClient
|
||||
{
|
@ -0,0 +1,160 @@
|
||||
package mineplex.core.punish.clans;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.punish.clans.command.ClansBanCommand;
|
||||
import mineplex.core.punish.clans.redis.ClansBanNotification;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
public class ClansBanManager extends MiniPlugin
|
||||
{
|
||||
private final CoreClientManager _clientManager;
|
||||
private final ClansBanRepository _repository;
|
||||
private final boolean _fullOperation;
|
||||
|
||||
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, boolean fullOperation)
|
||||
{
|
||||
super("Clans Blacklist", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
_repository = new ClansBanRepository(plugin);
|
||||
|
||||
_fullOperation = fullOperation;
|
||||
|
||||
if (_fullOperation)
|
||||
{
|
||||
ServerCommandManager.getInstance().registerCommandType(ClansBanNotification.class, notification ->
|
||||
{
|
||||
runSync(() ->
|
||||
{
|
||||
if (Bukkit.getPlayer(notification.getTarget()) != null)
|
||||
{
|
||||
Bukkit.getPlayer(notification.getTarget()).kickPlayer(C.cRedB + "You have been banned from Clans " + notification.getBanTimeFormatted() + ".");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new ClansBanCommand(this));
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public ClansBanRepository getRepository()
|
||||
{
|
||||
return _repository;
|
||||
}
|
||||
|
||||
public void loadClient(String name, Consumer<Optional<ClansBanClient>> callback)
|
||||
{
|
||||
_repository.loadClient(name).thenAccept(client -> runSync(() -> callback.accept(client)));
|
||||
}
|
||||
|
||||
public void loadClient(UUID uuid, Consumer<ClansBanClient> callback)
|
||||
{
|
||||
_repository.loadClient(uuid).thenAccept(client -> runSync(() -> callback.accept(client)));
|
||||
}
|
||||
|
||||
public void ban(ClansBanClient target, String targetName, String admin, long duration, String reason, Player caller, Consumer<Optional<ClansBan>> callback)
|
||||
{
|
||||
_repository.ban(target._uuid, admin, duration, reason).thenAccept(ban -> runSync(() ->
|
||||
{
|
||||
if (ban.isPresent())
|
||||
{
|
||||
target._bans.add(ban.get());
|
||||
String banTimeFormatted = target.getBanTimeFormatted();
|
||||
|
||||
if (targetName != null)
|
||||
{
|
||||
for (Player notify : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (_clientManager.Get(notify).GetRank().has(notify, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, false))
|
||||
{
|
||||
UtilPlayer.message(notify, F.main(getName(), F.elem(targetName) + " is now banned " + banTimeFormatted + "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_fullOperation && Bukkit.getPlayer(target._uuid) != null)
|
||||
{
|
||||
Bukkit.getPlayer(target._uuid).kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + ".");
|
||||
}
|
||||
new ClansBanNotification(target._uuid, banTimeFormatted).publish();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (caller != null && targetName != null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), C.cRed + "An issue occurred when trying to ban " + F.elem(targetName)));
|
||||
}
|
||||
}
|
||||
callback.accept(ban);
|
||||
}));
|
||||
}
|
||||
|
||||
public void unban(ClansBanClient target, ClansBan ban, Runnable callback)
|
||||
{
|
||||
if (!target._uuid.equals(ban.getUUID()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ban.remove();
|
||||
_repository.removeBan(ban);
|
||||
|
||||
callback.run();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onLogin(AsyncPlayerPreLoginEvent event)
|
||||
{
|
||||
if (!_fullOperation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
ClansBanClient client = _repository.loadClient(event.getUniqueId()).get();
|
||||
|
||||
if (client.isBanned())
|
||||
{
|
||||
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
|
||||
|
||||
if (client.getLongestBan().isPermanent())
|
||||
{
|
||||
time = "Permanent";
|
||||
}
|
||||
|
||||
String reason = C.cRedB + "You are banned from Clans for " + time +
|
||||
"\n" + C.cWhite + client.getLongestBan().getReason();
|
||||
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason);
|
||||
}
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
}
|
@ -1,20 +1,24 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
package mineplex.core.punish.clans;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
|
||||
public class ClansBanRepository extends RepositoryBase
|
||||
{
|
||||
private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);";
|
||||
@ -50,18 +54,22 @@ public class ClansBanRepository extends RepositoryBase
|
||||
{
|
||||
int id = resultSet.getInt(1);
|
||||
return Optional.of(new ClansBan(id, uuid, admin, reason, banTime, unbanTime, time == -1, false));
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return Optional.empty();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<ClansBanClient> loadClient(UUID uuid) {
|
||||
public CompletableFuture<ClansBanClient> loadClient(UUID uuid)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
try (Connection conn = DBPool.getAccount().getConnection())
|
||||
@ -87,7 +95,9 @@ public class ClansBanRepository extends RepositoryBase
|
||||
}
|
||||
|
||||
return new ClansBanClient(uuid, bans);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return new ClansBanClient(uuid, new ArrayList<>());
|
||||
}
|
||||
@ -106,7 +116,9 @@ public class ClansBanRepository extends RepositoryBase
|
||||
CompletableFuture<Optional<ClansBanClient>> future = new CompletableFuture<>();
|
||||
future.complete(Optional.empty());
|
||||
return future;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return loadClient(uuid).thenApply(Optional::of);
|
||||
}
|
||||
});
|
||||
@ -116,4 +128,4 @@ public class ClansBanRepository extends RepositoryBase
|
||||
{
|
||||
executeUpdate(REMOVE_BAN, new ColumnInt("id", ban.getId()));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package mineplex.game.clans.clans.ban.commands;
|
||||
package mineplex.core.punish.clans.command;
|
||||
|
||||
import mineplex.game.clans.clans.ban.ui.ClansBanShop;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.core.punish.clans.ClansBanManager;
|
||||
import mineplex.core.punish.clans.ui.ClansBanShop;
|
||||
|
||||
public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
{
|
||||
@ -35,23 +35,22 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
}
|
||||
|
||||
final String finalReason = reason;
|
||||
|
||||
Plugin.getRepository().loadClient(playerName)
|
||||
.thenAccept(maybeClient ->
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (!maybeClient.isPresent())
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName);
|
||||
} else
|
||||
{
|
||||
new ClansBanShop(Plugin, playerName, maybeClient.get(), finalReason).attemptShopOpen(caller);
|
||||
}
|
||||
}));
|
||||
|
||||
Plugin.loadClient(playerName, client ->
|
||||
{
|
||||
if (client.isPresent())
|
||||
{
|
||||
new ClansBanShop(Plugin, playerName, client.get(), finalReason).attemptShopOpen(caller);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, C.cRed + "Could not find player with name " + C.cYellow + playerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, C.cBlue + "/cb <username> <reason>" + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view their past bans.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package mineplex.core.punish.clans.redis;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class ClansBanNotification extends ServerCommand
|
||||
{
|
||||
private final UUID _target;
|
||||
private final String _banTimeFormatted;
|
||||
|
||||
public ClansBanNotification(UUID target, String banTimeFormatted)
|
||||
{
|
||||
_target = target;
|
||||
_banTimeFormatted = banTimeFormatted;
|
||||
}
|
||||
|
||||
public UUID getTarget()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
public String getBanTimeFormatted()
|
||||
{
|
||||
return _banTimeFormatted;
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
package mineplex.core.punish.clans.ui;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.punish.clans.ClansBan;
|
||||
import mineplex.core.punish.clans.ClansBanClient;
|
||||
import mineplex.core.punish.clans.ClansBanManager;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
||||
{
|
||||
private long _time;
|
||||
private boolean _permanent;
|
||||
|
||||
private String _victimName;
|
||||
private ClansBanClient _victimClient;
|
||||
|
||||
private String _reason;
|
||||
|
||||
public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final String name, final Player player, String victimName, ClansBanClient client, String reason)
|
||||
{
|
||||
super(banManager, shop, banManager.getClientManager(), Managers.get(DonationManager.class), name, player);
|
||||
|
||||
_reason = reason;
|
||||
|
||||
_victimName = victimName;
|
||||
_victimClient = client;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
protected void buildPage()
|
||||
{
|
||||
_time = Math.max(0, _time);
|
||||
|
||||
int slot = 27;
|
||||
|
||||
// Middle of first row
|
||||
addButton(4, new ItemBuilder(Material.SKULL_ITEM)
|
||||
.setData((short) 3)
|
||||
.setPlayerHead(_victimName)
|
||||
.setTitle(C.cDGreenB + _victimName)
|
||||
.addLore(" ")
|
||||
.addLore(C.cYellow + _reason).build(), (player, click) -> {});
|
||||
|
||||
addTimeAdjuster((9 * 1 + 2), -(1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 1), -(1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 0), -(1000l * 60l * 60l * 24l * 30l));
|
||||
addTimeAdjuster((9 * 1 + 6), (1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 7), (1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 8), (1000l * 60l * 60l * 24l * 30l));
|
||||
|
||||
addButton((9 * 1) + 4,
|
||||
new ItemBuilder(Material.RECORD_5)
|
||||
.setTitle(C.cRedB + "Ban Player")
|
||||
.setLore(
|
||||
" ",
|
||||
C.cGray + "Player: " + F.elem(_victimName),
|
||||
C.cGray + "Reason: " + F.elem(_reason),
|
||||
C.cGray + "Time: " + F.elem(_permanent ? "Permanent" : UtilTime.MakeStr(_time)),
|
||||
"",
|
||||
C.cRed + C.Italics + "Left-Click to BAN PLAYER",
|
||||
C.cGray + C.Italics + "Right-Click to toggle permanent ban setting"
|
||||
).build(),
|
||||
(player, click) ->
|
||||
{
|
||||
if (click == ClickType.RIGHT)
|
||||
{
|
||||
_permanent = !_permanent;
|
||||
refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
performBan();
|
||||
}
|
||||
});
|
||||
|
||||
for (ClansBan ban : _victimClient._bans)
|
||||
{
|
||||
ItemStack item;
|
||||
if (ban.isPermanent())
|
||||
{
|
||||
item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
|
||||
.setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive")
|
||||
.addLore(" ")
|
||||
.addLore(C.cGray + "Date Banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
|
||||
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
|
||||
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
||||
.addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||
.addLore(ban.isActive() ? " " : null)
|
||||
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null)
|
||||
.setGlow(ban.isActive())
|
||||
.build();
|
||||
}
|
||||
else
|
||||
{
|
||||
item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
|
||||
.setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive")
|
||||
.addLore(" ")
|
||||
.addLore(C.cGray + "Date Banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
|
||||
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
|
||||
.addLore(C.cGray + "Time Left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
||||
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
||||
.addLore(C.cGray + "Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||
.addLore(ban.isActive() ? " " : null)
|
||||
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null)
|
||||
.setGlow(ban.isActive())
|
||||
.build();
|
||||
}
|
||||
|
||||
addButton(slot++, item, (player, click) ->
|
||||
{
|
||||
if (ban.isActive())
|
||||
{
|
||||
getPlugin().runAsync(() ->
|
||||
{
|
||||
getPlugin().unban(_victimClient, ban, () ->
|
||||
{
|
||||
refresh();
|
||||
playAcceptSound(player);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void performBan()
|
||||
{
|
||||
getPlugin().ban(_victimClient, _victimName, getPlayer().getName(), _permanent ? -1 : _time, _reason, getPlayer(), ban ->
|
||||
{
|
||||
if (ban.isPresent())
|
||||
{
|
||||
playAcceptSound(getPlayer());
|
||||
refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
playDenySound(getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addTimeAdjuster(int index, long time)
|
||||
{
|
||||
addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(),
|
||||
(player, click) ->
|
||||
{
|
||||
_time += time;
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package mineplex.game.clans.clans.ban.ui;
|
||||
package mineplex.core.punish.clans.ui;
|
||||
|
||||
import mineplex.game.clans.clans.ban.ClansBanClient;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.punish.clans.ClansBanClient;
|
||||
import mineplex.core.punish.clans.ClansBanManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
public class ClansBanShop extends ShopBase<ClansBanManager>
|
||||
{
|
||||
@ -15,7 +17,7 @@ public class ClansBanShop extends ShopBase<ClansBanManager>
|
||||
|
||||
public ClansBanShop(final ClansBanManager plugin, String victimName, ClansBanClient client, String reason)
|
||||
{
|
||||
super(plugin, plugin.getClientManager(), plugin.getDonationManager(), "Clans Punish");
|
||||
super(plugin, plugin.getClientManager(), Managers.get(DonationManager.class), "Clans Punish");
|
||||
_clientName = victimName;
|
||||
_client = client;
|
||||
_reason = reason;
|
||||
@ -25,6 +27,5 @@ public class ClansBanShop extends ShopBase<ClansBanManager>
|
||||
protected ShopPageBase<ClansBanManager, ? extends ShopBase<ClansBanManager>> buildPagesFor(final Player player)
|
||||
{
|
||||
return new ClansBanPage(getPlugin(), this, "Clans Punish", player, _clientName, _client, _reason);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -66,7 +66,7 @@ import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.freeze.ClansFreezeManager;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.shop.building.BuildingShop;
|
||||
import mineplex.game.clans.shop.farming.FarmingShop;
|
||||
@ -143,9 +143,9 @@ public class Clans extends JavaPlugin
|
||||
Portal portal = new Portal();
|
||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.CLANS_HUB);
|
||||
|
||||
ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
|
||||
ClansFreezeManager clansFreeze = new ClansFreezeManager(this, _clientManager);
|
||||
|
||||
Punish punish = new Punish(this, _clientManager);
|
||||
Punish punish = new Punish(this, _clientManager, true);
|
||||
|
||||
DisguiseManager disguiseManager = require(DisguiseManager.class);
|
||||
Creature creature = new Creature(this);
|
||||
@ -187,7 +187,7 @@ public class Clans extends JavaPlugin
|
||||
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
|
||||
|
||||
HologramManager hologram = new HologramManager(this, packetHandler);
|
||||
_clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory);
|
||||
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory);
|
||||
new Recipes(this);
|
||||
new Farming(this);
|
||||
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
||||
@ -243,4 +243,4 @@ public class Clans extends JavaPlugin
|
||||
{
|
||||
return MAP;
|
||||
}
|
||||
}
|
||||
}
|
@ -759,6 +759,13 @@ public class ClansGame extends MiniPlugin
|
||||
ClanInfo clan = _clans.getClan(event.getPlayer());
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (UtilEvent.isAction(event, ActionType.R_BLOCK) && block.getType() == Material.BED_BLOCK)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (clan == null)
|
||||
|
@ -90,7 +90,6 @@ import mineplex.game.clans.Clans;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.amplifiers.AmplifierManager;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.banners.BannerManager;
|
||||
import mineplex.game.clans.clans.boxes.BoxManager;
|
||||
import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
@ -98,7 +97,6 @@ import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansCommand;
|
||||
import mineplex.game.clans.clans.commands.KillCommand;
|
||||
import mineplex.game.clans.clans.commands.MapCommand;
|
||||
import mineplex.game.clans.clans.commands.RegionsCommand;
|
||||
import mineplex.game.clans.clans.commands.SpeedCommand;
|
||||
import mineplex.game.clans.clans.data.PlayerClan;
|
||||
@ -106,7 +104,6 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
|
||||
import mineplex.game.clans.clans.gui.ClanShop;
|
||||
import mineplex.game.clans.clans.invsee.InvseeManager;
|
||||
import mineplex.game.clans.clans.loot.LootManager;
|
||||
import mineplex.game.clans.clans.map.ItemMapManager;
|
||||
import mineplex.game.clans.clans.mounts.MountManager;
|
||||
import mineplex.game.clans.clans.nameblacklist.ClansBlacklist;
|
||||
import mineplex.game.clans.clans.nether.NetherManager;
|
||||
@ -115,7 +112,6 @@ import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.clans.potato.PotatoManager;
|
||||
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
|
||||
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
|
||||
import mineplex.game.clans.core.ClaimLocation;
|
||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
||||
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
@ -124,6 +120,7 @@ import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
|
||||
import mineplex.game.clans.clans.war.WarManager;
|
||||
import mineplex.game.clans.clans.warpoints.WarPointEvasion;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.core.ClaimLocation;
|
||||
import mineplex.game.clans.core.ClanDeleteCommand;
|
||||
import mineplex.game.clans.core.ClanLoadCommand;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
@ -257,7 +254,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
// Spawn area
|
||||
|
||||
public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager)
|
||||
public ClansManager(JavaPlugin plugin, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, InventoryManager inventoryManager)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
@ -288,7 +285,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_npcManager = new NpcManager(plugin, Managers.get(Creature.class));
|
||||
_condition = new SkillConditionManager(plugin);
|
||||
_damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
|
||||
_damageManager.addCommand(new KillCommand(_damageManager));
|
||||
_condition.setDamageManager(_damageManager);
|
||||
|
||||
_worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null);
|
||||
@ -494,6 +490,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
addCommand(new ClanManagementCommand(this));
|
||||
// addCommand(new MapCommand(this));
|
||||
addCommand(new SpeedCommand(this));
|
||||
addCommand(new KillCommand(this));
|
||||
}
|
||||
|
||||
public void loadClan(ClanToken clanToken, boolean loadBanner)
|
||||
@ -515,7 +512,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
}
|
||||
|
||||
if (loadBanner)
|
||||
{
|
||||
_bannerManager.loadBanner(clan);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadClan(ClanToken clanToken)
|
||||
@ -793,10 +792,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
player.setOp(true);
|
||||
}
|
||||
if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug
|
||||
if (player.getInventory().getHelmet() != null) //Reset helmet to fix 1 damage bug
|
||||
{
|
||||
ItemStack helmet = player.getInventory().getHelmet().clone();
|
||||
player.getInventory().setHelmet(null);
|
||||
runSyncLater(() -> {
|
||||
runSyncLater(() ->
|
||||
{
|
||||
player.getInventory().setHelmet(helmet);
|
||||
}, 20L);
|
||||
}
|
||||
@ -807,7 +808,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
// happens 20 ticks later because player channels don't
|
||||
// seem to work immediately after joining.
|
||||
runSyncLater(() -> {
|
||||
runSyncLater(() ->
|
||||
{
|
||||
ByteArrayDataOutput bado = ByteStreams.newDataOutput();
|
||||
|
||||
bado.writeUTF("no_xray");
|
||||
@ -845,7 +847,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
for (String message : messages)
|
||||
{
|
||||
if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().startsWith("/" + message + " "))
|
||||
if (!event.getMessage().equalsIgnoreCase("/" + message) && !event.getMessage().toLowerCase().startsWith("/" + message + " "))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -904,7 +906,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
for (Player other : event.getRecipients())
|
||||
{
|
||||
if (_tutorial.inTutorial(other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
UtilPlayer.message(other, String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage()));
|
||||
}
|
||||
@ -918,7 +922,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
for (Player other : event.getRecipients())
|
||||
{
|
||||
if (_tutorial.inTutorial(other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ClanInfo otherClan = _clanUtility.getClanByPlayer(other);
|
||||
|
||||
@ -941,7 +947,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void disableObsidian(BlockBreakEvent event)
|
||||
{
|
||||
if(event.getBlock().getType().equals(Material.OBSIDIAN))
|
||||
if (event.getBlock().getType().equals(Material.OBSIDIAN))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR);
|
||||
@ -977,7 +983,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " ";
|
||||
|
||||
if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH))
|
||||
{
|
||||
rank = "";
|
||||
}
|
||||
|
||||
if (client.isClanChat() && clan != null)
|
||||
{
|
||||
@ -1029,7 +1037,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " ";
|
||||
|
||||
if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH))
|
||||
{
|
||||
rank = "";
|
||||
}
|
||||
|
||||
handleClanChat(caller, message, clan, rank);
|
||||
}
|
||||
@ -1039,7 +1049,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " ";
|
||||
|
||||
if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH))
|
||||
{
|
||||
rank = "";
|
||||
}
|
||||
|
||||
handleAllyChat(caller, message, clan, rank);
|
||||
}
|
||||
@ -1317,7 +1329,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
public void updateBedStatus(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TWOSEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (String name : getClanNameSet())
|
||||
{
|
||||
@ -1392,7 +1406,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
_clanMemberLeftMap.remove(uuid);
|
||||
_warPointEvasion.resetCooldown(uuid);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -1406,7 +1419,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
if (event.getEntered() instanceof Player && event.getVehicle() instanceof Horse)
|
||||
{
|
||||
if(!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false))
|
||||
if (!Recharge.Instance.use((Player) event.getEntered(), "Ride Horse", 2 * 20L, true, false))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ public class ClansUtility
|
||||
|
||||
public boolean isSafe(Player player)
|
||||
{
|
||||
if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) return false;
|
||||
if (!UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION)) return false;
|
||||
|
||||
return isSafe(player.getLocation());
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
/**
|
||||
* Stores the data provided through the /cban (Clans ban) command for use further in the plugin.
|
||||
*/
|
||||
public class ClansBanCache
|
||||
{
|
||||
private String _victim;
|
||||
private String _reason;
|
||||
|
||||
public ClansBanCache(String victim, String reason)
|
||||
{
|
||||
_victim = victim;
|
||||
_reason = reason;
|
||||
}
|
||||
|
||||
public String getVictim()
|
||||
{
|
||||
return _victim;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return _reason;
|
||||
}
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
package mineplex.game.clans.clans.ban.ui;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ban.ClansBan;
|
||||
import mineplex.game.clans.clans.ban.ClansBanClient;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
||||
{
|
||||
private long _time;
|
||||
private boolean _permanent;
|
||||
|
||||
private String _victimName;
|
||||
private ClansBanClient _victimClient;
|
||||
|
||||
private String _reason;
|
||||
|
||||
public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final String name, final Player player, String victimName, ClansBanClient client, String reason)
|
||||
{
|
||||
super(banManager, shop, banManager.getClientManager(), banManager.getDonationManager(), name, player);
|
||||
|
||||
_reason = reason;
|
||||
|
||||
_victimName = victimName;
|
||||
_victimClient = client;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
protected void buildPage()
|
||||
{
|
||||
_time = Math.max(0, _time);
|
||||
|
||||
int slot = 27;
|
||||
|
||||
// Middle of first row
|
||||
addButton(4, new ItemBuilder(Material.SKULL_ITEM)
|
||||
.setData((short) 3)
|
||||
.setPlayerHead(_victimName)
|
||||
.setTitle(C.cDGreenB + _victimName)
|
||||
.addLore(" ")
|
||||
.addLore(C.cYellow + _reason).build(), (player, click) -> {});
|
||||
|
||||
addTimeAdjuster((9 * 1 + 2), -(1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 1), -(1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 0), -(1000l * 60l * 60l * 24l * 30l));
|
||||
addTimeAdjuster((9 * 1 + 6), (1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 7), (1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 8), (1000l * 60l * 60l * 24l * 30l));
|
||||
|
||||
addButton((9 * 1) + 4,
|
||||
new ItemBuilder(Material.RECORD_5)
|
||||
.setTitle(C.cRedB + "Ban Player")
|
||||
.setLore(
|
||||
" ",
|
||||
C.cGray + "Player: " + F.elem(_victimName),
|
||||
C.cGray + "Reason: " + F.elem(_reason),
|
||||
C.cGray + "Time: " + F.elem(_permanent ? "Permanent" : UtilTime.MakeStr(_time)),
|
||||
"",
|
||||
C.cRed + C.Italics + "Left-Click to BAN PLAYER",
|
||||
C.cGray + C.Italics + "Right-Click to toggle permanent ban setting"
|
||||
).build(),
|
||||
(player, click) -> {
|
||||
if (click == ClickType.RIGHT)
|
||||
{
|
||||
_permanent = !_permanent;
|
||||
refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
performBan();
|
||||
}
|
||||
});
|
||||
|
||||
for (ClansBan ban : _victimClient._bans)
|
||||
{
|
||||
ItemStack item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
|
||||
.setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive")
|
||||
.addLore(" ")
|
||||
.addLore(C.cGray + "Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
|
||||
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
|
||||
.addLore(C.cGray + "Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
||||
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
||||
.addLore(C.cGray + "Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||
.addLore(ban.isActive() ? " " : null)
|
||||
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null)
|
||||
.setGlow(ban.isActive())
|
||||
.build();
|
||||
|
||||
addButton(slot++, item, (player, click) -> {
|
||||
if (ban.isActive())
|
||||
{
|
||||
getPlugin().runAsync(() -> {
|
||||
getPlugin().unban(_victimClient, ban, client -> {
|
||||
refresh();
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void performBan()
|
||||
{
|
||||
getPlugin().getRepository().ban(_victimClient._uuid, getPlayer().getName(), _permanent ? -1 : _time, _reason)
|
||||
.thenAccept(maybeBan -> getPlugin().runSync(() ->
|
||||
{
|
||||
if (maybeBan.isPresent())
|
||||
{
|
||||
_victimClient._bans.add(maybeBan.get());
|
||||
|
||||
String banTimeFormatted = _victimClient.getBanTimeFormatted();
|
||||
UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(_victimName) + " is now banned " + banTimeFormatted + "."));
|
||||
|
||||
Player target = Bukkit.getPlayer(_victimClient._uuid);
|
||||
target.kickPlayer(C.cRedB + "You have been banned from Clans " + banTimeFormatted + ".");
|
||||
refresh();
|
||||
} else
|
||||
{
|
||||
F.main("Clans", C.cRed + "An issue occurred when trying to ban " + F.elem(_victimName));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void addTimeAdjuster(int index, long time)
|
||||
{
|
||||
addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(),
|
||||
(player, click) -> {
|
||||
_time += time;
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,17 +1,19 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillCommand extends CommandBase<DamageManager>
|
||||
public class KillCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
public KillCommand(DamageManager plugin)
|
||||
public KillCommand(ClansManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "suicide", "kill");
|
||||
}
|
||||
@ -19,26 +21,26 @@ public class KillCommand extends CommandBase<DamageManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if ((System.currentTimeMillis() - Plugin.GetCombatManager().Get(caller).GetLastCombat()) <= 20000)
|
||||
if (!UtilTime.elapsed(Plugin.getCombatManager().Get(caller).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat."));
|
||||
return;
|
||||
}
|
||||
if(ClansManager.getInstance().getTutorial().inTutorial(caller))
|
||||
if (Plugin.getTutorial().inTutorial(caller))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in the tutorial."));
|
||||
return;
|
||||
}
|
||||
if (mineplex.core.recharge.Recharge.Instance.use(caller, "Suicide", 5000, false, false))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Please wait a bit before suiciding"));
|
||||
return;
|
||||
}
|
||||
if (ClansManager.getInstance().getClanUtility().isSafe(caller.getLocation()) || (ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn")))
|
||||
if (Plugin.getClanUtility().isSafe(caller.getLocation()) || (Plugin.getClanUtility().getClaim(caller.getLocation()) != null && Plugin.getClanUtility().getClaim(caller.getLocation()).Owner.equalsIgnoreCase("Spawn")))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in a safezone!"));
|
||||
return;
|
||||
}
|
||||
if (Recharge.Instance.use(caller, "Suicide", 5000, false, false))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Run the command again to confirm."));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Clans", "You have imploded."));
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
package mineplex.game.clans.clans.freeze;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -12,7 +12,6 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -23,89 +22,38 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
|
||||
import mineplex.game.clans.clans.ban.commands.FreezeCommand;
|
||||
import mineplex.game.clans.clans.ban.commands.UnfreezeCommand;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.clans.freeze.commands.FreezeCommand;
|
||||
import mineplex.game.clans.clans.freeze.commands.UnfreezeCommand;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class ClansBanManager extends MiniPlugin
|
||||
public class ClansFreezeManager extends MiniPlugin
|
||||
{
|
||||
private static final long FREEZE_MESSAGE_INTERVAL = 10000;
|
||||
private final CoreClientManager _clientManager;
|
||||
private final DonationManager _donationManager;
|
||||
private final ClansBanRepository _repository;
|
||||
private final Map<UUID, Float> _frozen = new HashMap<>();
|
||||
|
||||
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
public ClansFreezeManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
super("Blacklist", plugin);
|
||||
super("Freeze", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
_repository = new ClansBanRepository(plugin);
|
||||
|
||||
_donationManager = donationManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new ClansBanCommand(this));
|
||||
addCommand(new FreezeCommand(this));
|
||||
addCommand(new UnfreezeCommand(this));
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public DonationManager getDonationManager()
|
||||
{
|
||||
return _donationManager;
|
||||
}
|
||||
|
||||
public ClansBanRepository getRepository()
|
||||
{
|
||||
return _repository;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onLogin(AsyncPlayerPreLoginEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ClansBanClient client = _repository.loadClient(event.getUniqueId()).get();
|
||||
|
||||
if (client.isBanned())
|
||||
{
|
||||
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
|
||||
|
||||
if (client.getLongestBan().isPermanent())
|
||||
{
|
||||
time = "Permanent";
|
||||
}
|
||||
|
||||
String reason = C.cRedB + "You are banned from Clans for " + time +
|
||||
"\n" + C.cWhite + client.getLongestBan().getReason();
|
||||
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, reason);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
@ -131,7 +79,7 @@ public class ClansBanManager extends MiniPlugin
|
||||
if (isFrozen(event.getPlayer()) && UtilMath.offset2d(event.getFrom().getBlock().getLocation(), event.getTo().getBlock().getLocation()) >= 1)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 1, 0));
|
||||
event.getPlayer().teleport(event.getFrom().getBlock().getLocation().add(0, 0.5, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,17 +247,4 @@ public class ClansBanManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unban(ClansBanClient target, ClansBan ban, Callback<ClansBanClient> callback)
|
||||
{
|
||||
if (!target._uuid.equals(ban.getUUID()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ban.remove();
|
||||
_repository.removeBan(ban);
|
||||
|
||||
callback.run(target);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,20 @@
|
||||
package mineplex.game.clans.clans.ban.commands;
|
||||
package mineplex.game.clans.clans.freeze.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.freeze.ClansFreezeManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Command to freeze players
|
||||
*/
|
||||
public class FreezeCommand extends CommandBase<ClansBanManager>
|
||||
public class FreezeCommand extends CommandBase<ClansFreezeManager>
|
||||
{
|
||||
public FreezeCommand(ClansBanManager plugin)
|
||||
public FreezeCommand(ClansFreezeManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "freeze");
|
||||
}
|
@ -1,20 +1,20 @@
|
||||
package mineplex.game.clans.clans.ban.commands;
|
||||
package mineplex.game.clans.clans.freeze.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.freeze.ClansFreezeManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Command to unfreeze players
|
||||
*/
|
||||
public class UnfreezeCommand extends CommandBase<ClansBanManager>
|
||||
public class UnfreezeCommand extends CommandBase<ClansFreezeManager>
|
||||
{
|
||||
public UnfreezeCommand(ClansBanManager plugin)
|
||||
public UnfreezeCommand(ClansFreezeManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.CMOD, Rank.CMA}, "unfreeze");
|
||||
}
|
@ -20,6 +20,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.inventory.HorseInventory;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -34,6 +35,7 @@ import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -396,7 +398,7 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void handleHorseHits(CustomDamageEvent event)
|
||||
public void redirectHorseDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageeEntity() == null || !(event.GetDamageeEntity() instanceof Horse))
|
||||
{
|
||||
@ -413,14 +415,16 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
|
||||
mount.despawn(false);
|
||||
return;
|
||||
}
|
||||
event.setDamagee(mount.getOwner());
|
||||
if (event.GetCause() != DamageCause.FALL)
|
||||
if (mount.getEntity().getPassenger() == null)
|
||||
{
|
||||
mount.handleHit();
|
||||
event.SetCancelled("Killing riderless mount");
|
||||
mount.despawn(true);
|
||||
return;
|
||||
}
|
||||
event.setDamagee(mount.getOwner());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void handleRiderHits(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageePlayer() == null || event.GetDamageePlayer().getVehicle() == null || !(event.GetDamageePlayer().getVehicle() instanceof Horse))
|
||||
@ -479,6 +483,18 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "This is not your Mount!"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event)
|
||||
{
|
||||
_spawnedMounts.entrySet().forEach(entry ->
|
||||
{
|
||||
if (UtilWorld.isInChunk(entry.getKey().getLocation(), event.getChunk()))
|
||||
{
|
||||
entry.getValue().despawn(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
|
@ -40,7 +40,6 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.clans.worldevent.capturepoint;
|
||||
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.clans.worldevent.api.WorldEvent;
|
||||
|
||||
public class CapturePointEvent extends WorldEvent
|
||||
{
|
||||
public CapturePointEvent(WorldEventManager manager)
|
||||
{
|
||||
super("Capture Point", CapturePointLocation.getRandomLocation().toLocation(UtilWorld.getWorld("world")), 5, true, manager.getDisguiseManager(), manager.getClans().getProjectile(), manager.getDamage(), manager.getBlockRestore(), manager.getClans().getCondition());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customTick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customCleanup(boolean onDisable)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package mineplex.game.clans.clans.worldevent.capturepoint;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public enum CapturePointLocation
|
||||
{
|
||||
;
|
||||
|
||||
private final double _x, _y, _z;
|
||||
|
||||
private CapturePointLocation(double x, double y, double z)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public Location toLocation(World world)
|
||||
{
|
||||
return new Location(world, _x, _y, _z);
|
||||
}
|
||||
|
||||
public static CapturePointLocation getRandomLocation()
|
||||
{
|
||||
return CapturePointLocation.values()[ThreadLocalRandom.current().nextInt(CapturePointLocation.values().length)];
|
||||
}
|
||||
}
|
@ -251,7 +251,8 @@ public abstract class RaidWorldEvent extends WorldEvent
|
||||
}
|
||||
if (_players.remove(event.getPlayer()))
|
||||
{
|
||||
event.getPlayer().teleport(Spawn.getNorthSpawn());
|
||||
event.getPlayer().setHealth(0);
|
||||
event.getPlayer().spigot().respawn();
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,13 +265,7 @@ public abstract class RaidWorldEvent extends WorldEvent
|
||||
}
|
||||
if (_players.remove(event.getEntity()))
|
||||
{
|
||||
event.getEntity().setHealth(event.getEntity().getMaxHealth());
|
||||
getCondition().Clean(event.getEntity());
|
||||
event.getEntity().getActivePotionEffects().forEach(pe -> event.getEntity().removePotionEffect(pe.getType()));
|
||||
event.getEntity().setExp(0);
|
||||
event.getEntity().setLevel(0);
|
||||
event.getEntity().setFireTicks(-1);
|
||||
event.getEntity().teleport(Spawn.getNorthSpawn());
|
||||
Manager.runSyncLater(() -> event.getEntity().spigot().respawn(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class HeatingUp extends Cataclysm
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = true;
|
||||
Magmus.HeatingRoom = true;
|
||||
_center = Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C1S").get(0);
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
@ -50,17 +50,14 @@ public class HeatingUp extends Cataclysm
|
||||
_center.getBlock().getRelative(x, -1, z).setType(Material.STONE);
|
||||
}
|
||||
}
|
||||
if (Magmus.Abilities.size() > 1 && Magmus.Abilities.get(2) instanceof MagmusMeteor)
|
||||
{
|
||||
((MagmusMeteor)Magmus.Abilities.get(2)).Disabled = false;
|
||||
}
|
||||
Magmus.HeatingRoom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
_ticks++;
|
||||
if (_ticks > (20 * 10))
|
||||
if (_ticks > (20 * 10) && _ticks <= (20 * 30))
|
||||
{
|
||||
for (Player player : Challenge.getRaid().getPlayers())
|
||||
{
|
||||
@ -71,7 +68,7 @@ public class HeatingUp extends Cataclysm
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_ticks > (20 * 30))
|
||||
if (_ticks > (20 * 33))
|
||||
{
|
||||
end();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ public class Magmus extends RaidCreature<MagmaCube>
|
||||
protected List<BossPassive<Magmus, MagmaCube>> Abilities = new ArrayList<>();
|
||||
|
||||
protected boolean TeleportBackASAP = true;
|
||||
protected boolean HeatingRoom = false;
|
||||
|
||||
public Magmus(ChallengeSix challenge, Location location)
|
||||
{
|
||||
|
@ -40,6 +40,10 @@ public class MagmusCataclysm extends BossPassive<Magmus, MagmaCube>
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (getBoss().HeatingRoom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (UtilTime.elapsed(_lastUse, getCooldown() * 1000))
|
||||
{
|
||||
_lastUse = System.currentTimeMillis();
|
||||
|
@ -39,7 +39,7 @@ public class MagmusEat extends BossPassive<Magmus, MagmaCube>
|
||||
|
||||
private void eat()
|
||||
{
|
||||
if (_ticks < 20 * 10)
|
||||
if (_ticks < 20 * 10 && !getBoss().HeatingRoom)
|
||||
{
|
||||
_eating.setFireTicks(40);
|
||||
_eating.teleport(getEntity());
|
||||
@ -73,6 +73,10 @@ public class MagmusEat extends BossPassive<Magmus, MagmaCube>
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (getBoss().HeatingRoom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_eating != null)
|
||||
{
|
||||
eat();
|
||||
|
@ -28,8 +28,6 @@ public class MagmusMeteor extends BossPassive<Magmus, MagmaCube>
|
||||
private long _lastUse;
|
||||
private List<LargeFireball> _shot = new ArrayList<>();
|
||||
|
||||
protected boolean Disabled = false;
|
||||
|
||||
public MagmusMeteor(Magmus creature)
|
||||
{
|
||||
super(creature);
|
||||
@ -38,7 +36,7 @@ public class MagmusMeteor extends BossPassive<Magmus, MagmaCube>
|
||||
|
||||
private void newBall()
|
||||
{
|
||||
if (Disabled)
|
||||
if (getBoss().HeatingRoom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -72,7 +70,7 @@ public class MagmusMeteor extends BossPassive<Magmus, MagmaCube>
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (Disabled)
|
||||
if (getBoss().HeatingRoom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ public class MagmusSmash extends BossPassive<Magmus, MagmaCube>
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (getBoss().HeatingRoom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (UtilTime.elapsed(_lastUse, getCooldown() * 1000))
|
||||
{
|
||||
_lastUse = System.currentTimeMillis();
|
||||
|
@ -61,7 +61,6 @@ public class DurabilityManager implements Listener
|
||||
_itemDurabilities.put(Material.LEATHER_CHESTPLATE, 900);
|
||||
_itemDurabilities.put(Material.LEATHER_LEGGINGS, 900);
|
||||
_itemDurabilities.put(Material.LEATHER_BOOTS, 900);
|
||||
_itemDurabilities.put(Material.BOW, 900);
|
||||
}
|
||||
|
||||
private boolean canRepair(ItemStack item)
|
||||
|
@ -610,15 +610,13 @@ public class Gameplay extends MiniPlugin
|
||||
|
||||
final byte data = block.getData();
|
||||
|
||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
||||
public void run()
|
||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), () ->
|
||||
{
|
||||
Material mat = block.getRelative(BlockFace.DOWN).getType();
|
||||
if (mat == Material.DIRT || mat == Material.GRASS)
|
||||
{
|
||||
Material mat = block.getRelative(BlockFace.DOWN).getType();
|
||||
if (mat == Material.DIRT || mat == Material.GRASS)
|
||||
{
|
||||
block.setType(Material.SAPLING);
|
||||
block.setData(data);
|
||||
}
|
||||
block.setType(Material.SAPLING);
|
||||
block.setData(data);
|
||||
}
|
||||
}, 20 * 10);
|
||||
}
|
||||
@ -637,7 +635,9 @@ public class Gameplay extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int y = -1; y <= 1; y++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
// Self
|
||||
@ -659,6 +659,8 @@ public class Gameplay extends MiniPlugin
|
||||
|
||||
if (block.getTypeId() == 0) block.setType(Material.FIRE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -756,4 +758,4 @@ public class Gameplay extends MiniPlugin
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", message));
|
||||
}
|
||||
}
|
||||
}
|
@ -23,8 +23,8 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.freeze.ClansFreezeManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.worldevent.raid.RaidManager;
|
||||
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
|
||||
import mineplex.game.clans.restart.RestartManager;
|
||||
@ -66,7 +66,7 @@ public class SafeLog extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (Managers.get(ClansBanManager.class).isFrozen(player))
|
||||
if (Managers.get(ClansFreezeManager.class).isFrozen(player))
|
||||
{
|
||||
isSafeLog = true;
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
|
||||
// Weightings for randomly selecting item type (legendary/weapon/armor/bow)
|
||||
private static final WeightSet<ItemType> TYPE_WEIGHTS = new WeightSet<ItemType>(
|
||||
new Weight<>(6, ItemType.LEGENDARY),
|
||||
new Weight<>(9, ItemType.LEGENDARY),
|
||||
new Weight<>(9, ItemType.RARE),
|
||||
new Weight<>(46 - 9, ItemType.ARMOR),
|
||||
new Weight<>(34, ItemType.ARMOR),
|
||||
new Weight<>(25, ItemType.WEAPON),
|
||||
new Weight<>(23, ItemType.BOW)
|
||||
);
|
||||
|
@ -10,7 +10,8 @@ public class DemonicScythe extends LegendaryItem
|
||||
{
|
||||
public DemonicScythe()
|
||||
{
|
||||
super("Scythe of the Fallen Lord", new String[]{
|
||||
super("Scythe of the Fallen Lord", new String[]
|
||||
{
|
||||
C.cWhite + "An old blade fashioned of nothing more",
|
||||
C.cWhite + "than bones and cloth which served no",
|
||||
C.cWhite + "purpose. Brave adventurers however have",
|
||||
@ -24,7 +25,10 @@ public class DemonicScythe extends LegendaryItem
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event, Player wielder)
|
||||
{
|
||||
event.AddMod("Scythe of the Fallen Lord", 8);
|
||||
wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2));
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
event.AddMod("Scythe of the Fallen Lord", 8);
|
||||
wielder.setHealth(Math.min(wielder.getMaxHealth(), wielder.getHealth() + 2));
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.event.WebTossEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -24,7 +23,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -51,7 +49,6 @@ public class Spawn extends MiniPlugin
|
||||
{
|
||||
public static final int SPAWN_RADIUS = 32;
|
||||
public static final int SHOP_RADIUS = 48;
|
||||
public static final String COMBAT_TAG_NAME = "Unsafe";
|
||||
public static final long COMBAT_TAG_DURATION = 15000;
|
||||
public static final Location ORIGIN = new Location(getSpawnWorld(), 0, 0, 0);
|
||||
|
||||
@ -201,7 +198,6 @@ public class Spawn extends MiniPlugin
|
||||
+ ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT));
|
||||
|
||||
UtilTextMiddle.display(null, message, 0, 20, 0, cur);
|
||||
_clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1.d, 0, false, Material.FIRE, (byte)0, true);
|
||||
playUnsafeParticles(cur);
|
||||
}
|
||||
else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600))
|
||||
@ -277,6 +273,7 @@ public class Spawn extends MiniPlugin
|
||||
public void onRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
event.setRespawnLocation(getSpawnLocation());
|
||||
_clansManager.getCombatManager().Get(event.getPlayer()).SetLastCombatEngaged(System.currentTimeMillis() - Spawn.COMBAT_TAG_DURATION);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -490,16 +487,14 @@ public class Spawn extends MiniPlugin
|
||||
|
||||
public boolean isCombatTagged(Player player)
|
||||
{
|
||||
return _clansManager.getCondition().HasCondition(player, ConditionType.CUSTOM, COMBAT_TAG_NAME);
|
||||
return !UtilTime.elapsed(_clansManager.getCombatManager().Get(player).GetLastCombatEngaged(), Spawn.COMBAT_TAG_DURATION);
|
||||
}
|
||||
|
||||
public void teleport(final Player player, final Location location, int delay)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(location);
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () ->
|
||||
{
|
||||
player.teleport(location);
|
||||
}, delay);
|
||||
}
|
||||
|
||||
@ -521,7 +516,9 @@ public class Spawn extends MiniPlugin
|
||||
public void playDatMusicALLDAYLONG(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilTime.elapsed(_songEastLast, _songEastLength))
|
||||
{
|
||||
@ -542,4 +539,4 @@ public class Spawn extends MiniPlugin
|
||||
{
|
||||
return _clansManager;
|
||||
}
|
||||
}
|
||||
}
|
@ -154,7 +154,7 @@ public class ClansHub extends JavaPlugin
|
||||
ConditionManager condition = new ConditionManager(this);
|
||||
ThankManager thankManager = new ThankManager(this, clientManager, donationManager);
|
||||
BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager, thankManager);
|
||||
HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager);
|
||||
HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager, castleManager);
|
||||
|
||||
ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager);
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
|
||||
|
||||
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
|
||||
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager)
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, ThankManager thankManager, BoosterManager boosterManager, CastleManager castleManager)
|
||||
{
|
||||
super("Hub Manager", plugin);
|
||||
|
||||
@ -195,7 +195,6 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
|
||||
_inventoryManager = inventoryManager;
|
||||
new BenefitManager(plugin, clientManager, _inventoryManager);
|
||||
|
||||
CastleManager castleManager = new CastleManager(_plugin, _clientManager, hologramManager, false);
|
||||
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager, incognito, castleManager);
|
||||
|
||||
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
|
||||
|
@ -12,12 +12,12 @@ import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
public class SalesAnnouncementData
|
||||
{
|
||||
private final int _id;
|
||||
private final Integer _id;
|
||||
private final Rank[] _displayTo;
|
||||
private final String _message;
|
||||
private boolean _enabled;
|
||||
|
||||
public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled)
|
||||
public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled)
|
||||
{
|
||||
_id = id;
|
||||
_displayTo = displayTo;
|
||||
@ -25,7 +25,7 @@ public class SalesAnnouncementData
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
public Integer getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
@ -4,16 +4,17 @@ import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementDeleteCommand extends ServerCommand
|
||||
{
|
||||
private String _id;
|
||||
private Integer _id;
|
||||
private String _from;
|
||||
private boolean _clans;
|
||||
|
||||
public SalesAnnouncementDeleteCommand(String id, String from)
|
||||
public SalesAnnouncementDeleteCommand(Integer id, String from, boolean clans)
|
||||
{
|
||||
_id = id;
|
||||
_from = from;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
public Integer getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
@ -22,4 +23,9 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand
|
||||
{
|
||||
return _from;
|
||||
}
|
||||
|
||||
public boolean isClans()
|
||||
{
|
||||
return _clans;
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package mineplex.clanshub.salesannouncements;
|
||||
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementDeleteHandler implements CommandCallback
|
||||
public class SalesAnnouncementDeleteHandler implements CommandCallback<SalesAnnouncementDeleteCommand>
|
||||
{
|
||||
private final SalesAnnouncementManager _manager;
|
||||
|
||||
@ -13,16 +12,16 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
public void run(SalesAnnouncementDeleteCommand command)
|
||||
{
|
||||
if (!(command instanceof SalesAnnouncementDeleteCommand))
|
||||
if (_manager.getServer().equalsIgnoreCase(command.getFrom()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom()))
|
||||
if (_manager.CLANS != command.isClans())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId()));
|
||||
_manager.handleRemoteDeletion(command.getId());
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
package mineplex.clanshub.salesannouncements;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -22,22 +21,23 @@ import mineplex.serverdata.commands.ServerCommandManager;
|
||||
public class SalesAnnouncementManager extends MiniPlugin
|
||||
{
|
||||
private static final String LINE = C.cDGreenB + C.Strike + "=============================================";
|
||||
private final List<SalesAnnouncementData> _data = Lists.newArrayList();
|
||||
private final Map<Integer, SalesAnnouncementData> _data = new HashMap<>();
|
||||
private final SalesAnnouncementRepository _repo;
|
||||
public final boolean CLANS = true;
|
||||
|
||||
public SalesAnnouncementManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Sales", plugin);
|
||||
_repo = new SalesAnnouncementRepository(plugin);
|
||||
_repo = new SalesAnnouncementRepository(plugin, CLANS);
|
||||
_repo.loadAnnouncements(_data);
|
||||
|
||||
addCommand(new SalesAnnouncementCommand(this));
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this));
|
||||
}
|
||||
|
||||
public List<SalesAnnouncementData> getLoadedAnnouncements()
|
||||
public Map<Integer, SalesAnnouncementData> getLoadedAnnouncements()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
@ -57,8 +57,8 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
_repo.createAnnouncement(displayTo, message, data ->
|
||||
{
|
||||
UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!"));
|
||||
_data.add(data);
|
||||
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
|
||||
_data.put(data.getId(), data);
|
||||
new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish();
|
||||
});
|
||||
}
|
||||
|
||||
@ -73,9 +73,9 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!"));
|
||||
if (!forceRemoveFromList)
|
||||
{
|
||||
_data.remove(data);
|
||||
_data.remove(data.getId());
|
||||
}
|
||||
new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish();
|
||||
new SalesAnnouncementDeleteCommand(data.getId(), getServer(), CLANS).publish();
|
||||
});
|
||||
}
|
||||
|
||||
@ -85,40 +85,46 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
_repo.updateAnnouncementStatus(data, () ->
|
||||
{
|
||||
UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!"));
|
||||
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
|
||||
new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish();
|
||||
});
|
||||
}
|
||||
|
||||
public void handleRemoteDeletion(int id)
|
||||
{
|
||||
_data.removeIf(data -> data.getId() == id);
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
runSync(() ->
|
||||
{
|
||||
_data.remove(Integer.valueOf(id));
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
|
||||
public void handleRemoteUpdate(int id)
|
||||
{
|
||||
if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0)
|
||||
runSync(() ->
|
||||
{
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
if (_data.containsKey(Integer.valueOf(id)))
|
||||
{
|
||||
_data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled()));
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
{
|
||||
_data.get(data.getId()).setEnabled(data.isEnabled());
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.add(data);
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
{
|
||||
_data.put(data.getId(), data);
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0)
|
||||
if (_data.isEmpty() || !_data.values().stream().filter(data -> data.isEnabled()).findAny().isPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -127,7 +133,7 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
|
||||
runSyncLater(() ->
|
||||
{
|
||||
_data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data ->
|
||||
_data.values().stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data ->
|
||||
{
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(LINE);
|
||||
|
@ -36,10 +36,11 @@ public class SalesAnnouncementPage implements Listener
|
||||
private void setup()
|
||||
{
|
||||
_buttons.clear();
|
||||
for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++)
|
||||
int i = 0;
|
||||
for (SalesAnnouncementData data : _manager.getLoadedAnnouncements().values())
|
||||
{
|
||||
SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i);
|
||||
_buttons.put(i, new SalesAnnouncementButton(data, this));
|
||||
i++;
|
||||
}
|
||||
updateButtons(false);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.clanshub.salesannouncements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -9,7 +11,6 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
@ -18,20 +19,22 @@ import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class SalesAnnouncementRepository extends RepositoryBase
|
||||
{
|
||||
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));";
|
||||
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, clans BOOL, PRIMARY KEY (id), INDEX typeIndex (clans));";
|
||||
|
||||
private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;";
|
||||
private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements WHERE clans=?;";
|
||||
private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;";
|
||||
private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;";
|
||||
private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);";
|
||||
private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled, clans) VALUES(?, ?, ?, ?);";
|
||||
private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;";
|
||||
|
||||
private final JavaPlugin _plugin;
|
||||
private final boolean _clans;
|
||||
|
||||
public SalesAnnouncementRepository(JavaPlugin plugin)
|
||||
public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans)
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
_plugin = plugin;
|
||||
_clans = clans;
|
||||
}
|
||||
|
||||
private void runAsync(Runnable runnable)
|
||||
@ -44,13 +47,13 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
Bukkit.getScheduler().runTask(_plugin, runnable);
|
||||
}
|
||||
|
||||
public void loadAnnouncements(final List<SalesAnnouncementData> announcementList)
|
||||
public void loadAnnouncements(final Map<Integer, SalesAnnouncementData> map)
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
executeQuery(GET_ANNOUNCEMENTS, resultSet ->
|
||||
{
|
||||
final List<SalesAnnouncementData> data = Lists.newArrayList();
|
||||
final List<SalesAnnouncementData> data = new ArrayList<>();
|
||||
while (resultSet.next())
|
||||
{
|
||||
int id = resultSet.getInt("id");
|
||||
@ -71,15 +74,15 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
String message = resultSet.getString("message");
|
||||
boolean enabled = resultSet.getBoolean("enabled");
|
||||
|
||||
data.add(new SalesAnnouncementData(id, displayTo, message, enabled));
|
||||
data.add(new SalesAnnouncementData(Integer.valueOf(id), displayTo, message, enabled));
|
||||
}
|
||||
|
||||
runSync(() ->
|
||||
{
|
||||
announcementList.clear();
|
||||
data.forEach(sData -> announcementList.add(sData));
|
||||
map.clear();
|
||||
data.forEach(sData -> map.put(sData.getId(), sData));
|
||||
});
|
||||
});
|
||||
}, new ColumnBoolean("clans", _clans));
|
||||
});
|
||||
}
|
||||
|
||||
@ -109,7 +112,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
String message = resultSet.getString("message");
|
||||
boolean enabled = resultSet.getBoolean("enabled");
|
||||
|
||||
final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled);
|
||||
final SalesAnnouncementData data = new SalesAnnouncementData(Integer.valueOf(aId), displayTo, message, enabled);
|
||||
runSync(() ->
|
||||
{
|
||||
callback.run(data);
|
||||
@ -139,7 +142,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
runSync(() -> callback.run(data));
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true));
|
||||
}, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans));
|
||||
});
|
||||
}
|
||||
|
||||
@ -147,7 +150,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId()));
|
||||
executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId().intValue()));
|
||||
if (after != null)
|
||||
{
|
||||
runSync(after);
|
||||
@ -159,7 +162,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId()));
|
||||
executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId().intValue()));
|
||||
if (after != null)
|
||||
{
|
||||
runSync(after);
|
||||
|
@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementUpdateCommand extends ServerCommand
|
||||
{
|
||||
private String _id;
|
||||
private Integer _id;
|
||||
private String _from;
|
||||
private boolean _clans;
|
||||
|
||||
public SalesAnnouncementUpdateCommand(String id, String from)
|
||||
public SalesAnnouncementUpdateCommand(Integer id, String from, boolean clans)
|
||||
{
|
||||
_id = id;
|
||||
_from = from;
|
||||
_clans = clans;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
public Integer getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
@ -22,4 +24,9 @@ public class SalesAnnouncementUpdateCommand extends ServerCommand
|
||||
{
|
||||
return _from;
|
||||
}
|
||||
|
||||
public boolean isClans()
|
||||
{
|
||||
return _clans;
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package mineplex.clanshub.salesannouncements;
|
||||
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementUpdateHandler implements CommandCallback
|
||||
public class SalesAnnouncementUpdateHandler implements CommandCallback<SalesAnnouncementUpdateCommand>
|
||||
{
|
||||
private final SalesAnnouncementManager _manager;
|
||||
|
||||
@ -13,16 +12,16 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
public void run(SalesAnnouncementUpdateCommand command)
|
||||
{
|
||||
if (!(command instanceof SalesAnnouncementUpdateCommand))
|
||||
if (_manager.getServer().equalsIgnoreCase(command.getFrom()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom()))
|
||||
if (_manager.CLANS != command.isClans())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId()));
|
||||
_manager.handleRemoteUpdate(command.getId());
|
||||
}
|
||||
}
|
@ -34,14 +34,12 @@ public class HubVisibilityManager extends MiniPlugin
|
||||
public HubVisibilityManager(HubManager manager)
|
||||
{
|
||||
super("Visibility Manager", manager.getPlugin());
|
||||
|
||||
Manager = manager;
|
||||
}
|
||||
|
||||
public void addHiddenPlayer(Player player)
|
||||
{
|
||||
_hiddenPlayers.add(player);
|
||||
|
||||
}
|
||||
|
||||
public void removeHiddenPlayer(Player player)
|
||||
@ -64,30 +62,30 @@ public class HubVisibilityManager extends MiniPlugin
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
Rank rank = Manager.GetClients().Get(player).GetRank();
|
||||
boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 ||
|
||||
(Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) ||
|
||||
_hiddenPlayers.contains(player);
|
||||
boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0
|
||||
|| (Manager.getPreferences().get(player).isActive(Preference.INVISIBILITY) &&
|
||||
(rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH))
|
||||
|| _hiddenPlayers.contains(player);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
boolean localHideMe = hideMe;
|
||||
if (player.equals(other))
|
||||
continue;
|
||||
|
||||
if(Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR))
|
||||
localHideMe = false;
|
||||
|
||||
|
||||
if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR))
|
||||
localHideMe = UtilMath.offset2d(other.getLocation(), Manager.GetSpawn()) == 0;
|
||||
|
||||
if (localHideMe || !Manager.getPreferences().get(other).isActive(Preference.SHOW_PLAYERS))
|
||||
{
|
||||
VisibilityManager.Instance.setVisibility(player, false, other);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
VisibilityManager.Instance.setVisibility(player, true, other);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ParticleSwap(PlayerInteractEvent event)
|
||||
@ -128,10 +126,9 @@ public class HubVisibilityManager extends MiniPlugin
|
||||
|
||||
for (Player player : _particle.keySet())
|
||||
{
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)], player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1,
|
||||
UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)],
|
||||
player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1,
|
||||
ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
public class SalesAnnouncementData
|
||||
{
|
||||
private final int _id;
|
||||
private final Integer _id;
|
||||
private final Rank[] _displayTo;
|
||||
private final String _message;
|
||||
private boolean _enabled;
|
||||
|
||||
public SalesAnnouncementData(int id, Rank[] displayTo, String message, boolean enabled)
|
||||
public SalesAnnouncementData(Integer id, Rank[] displayTo, String message, boolean enabled)
|
||||
{
|
||||
_id = id;
|
||||
_displayTo = displayTo;
|
||||
@ -25,7 +25,7 @@ public class SalesAnnouncementData
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
public Integer getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
@ -4,16 +4,17 @@ import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementDeleteCommand extends ServerCommand
|
||||
{
|
||||
private String _id;
|
||||
private Integer _id;
|
||||
private String _from;
|
||||
private boolean _clans;
|
||||
|
||||
public SalesAnnouncementDeleteCommand(String id, String from)
|
||||
public SalesAnnouncementDeleteCommand(Integer id, String from, boolean clans)
|
||||
{
|
||||
_id = id;
|
||||
_from = from;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
public Integer getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
@ -22,4 +23,9 @@ public class SalesAnnouncementDeleteCommand extends ServerCommand
|
||||
{
|
||||
return _from;
|
||||
}
|
||||
|
||||
public boolean isClans()
|
||||
{
|
||||
return _clans;
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package mineplex.hub.modules.salesannouncements;
|
||||
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementDeleteHandler implements CommandCallback
|
||||
public class SalesAnnouncementDeleteHandler implements CommandCallback<SalesAnnouncementDeleteCommand>
|
||||
{
|
||||
private final SalesAnnouncementManager _manager;
|
||||
|
||||
@ -13,16 +12,16 @@ public class SalesAnnouncementDeleteHandler implements CommandCallback
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
public void run(SalesAnnouncementDeleteCommand command)
|
||||
{
|
||||
if (!(command instanceof SalesAnnouncementDeleteCommand))
|
||||
if (_manager.getServer().equalsIgnoreCase(command.getFrom()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementDeleteCommand) command).getFrom()))
|
||||
if (_manager.CLANS != command.isClans())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_manager.handleRemoteDeletion(Integer.parseInt(((SalesAnnouncementDeleteCommand)command).getId()));
|
||||
_manager.handleRemoteDeletion(command.getId());
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
package mineplex.hub.modules.salesannouncements;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -22,22 +21,23 @@ import mineplex.serverdata.commands.ServerCommandManager;
|
||||
public class SalesAnnouncementManager extends MiniPlugin
|
||||
{
|
||||
private static final String LINE = C.cDGreenB + C.Strike + "=============================================";
|
||||
private final List<SalesAnnouncementData> _data = Lists.newArrayList();
|
||||
private final Map<Integer, SalesAnnouncementData> _data = new HashMap<>();
|
||||
private final SalesAnnouncementRepository _repo;
|
||||
public final boolean CLANS = false;
|
||||
|
||||
public SalesAnnouncementManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Sales", plugin);
|
||||
_repo = new SalesAnnouncementRepository(plugin);
|
||||
_repo = new SalesAnnouncementRepository(plugin, CLANS);
|
||||
_repo.loadAnnouncements(_data);
|
||||
|
||||
addCommand(new SalesAnnouncementCommand(this));
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementUpdate", SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType("SalesAnnouncementDelete", SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementUpdateCommand.class, new SalesAnnouncementUpdateHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType(SalesAnnouncementDeleteCommand.class, new SalesAnnouncementDeleteHandler(this));
|
||||
}
|
||||
|
||||
public List<SalesAnnouncementData> getLoadedAnnouncements()
|
||||
public Map<Integer, SalesAnnouncementData> getLoadedAnnouncements()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
@ -57,8 +57,8 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
_repo.createAnnouncement(displayTo, message, data ->
|
||||
{
|
||||
UtilPlayer.message(creator, F.main(getName(), "Announcement successfully created!"));
|
||||
_data.add(data);
|
||||
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
|
||||
_data.put(data.getId(), data);
|
||||
new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish();
|
||||
});
|
||||
}
|
||||
|
||||
@ -73,9 +73,9 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
UtilPlayer.message(deletor, F.main(getName(), "Successfully deleted announcement!"));
|
||||
if (!forceRemoveFromList)
|
||||
{
|
||||
_data.remove(data);
|
||||
_data.remove(data.getId());
|
||||
}
|
||||
new SalesAnnouncementDeleteCommand(data.getId() + "", getServer()).publish();
|
||||
new SalesAnnouncementDeleteCommand(data.getId(), getServer(), CLANS).publish();
|
||||
});
|
||||
}
|
||||
|
||||
@ -85,40 +85,46 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
_repo.updateAnnouncementStatus(data, () ->
|
||||
{
|
||||
UtilPlayer.message(toggler, F.main(getName(), "Successfully toggled announcement!"));
|
||||
new SalesAnnouncementUpdateCommand(data.getId() + "", getServer()).publish();
|
||||
new SalesAnnouncementUpdateCommand(data.getId(), getServer(), CLANS).publish();
|
||||
});
|
||||
}
|
||||
|
||||
public void handleRemoteDeletion(int id)
|
||||
{
|
||||
_data.removeIf(data -> data.getId() == id);
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
runSync(() ->
|
||||
{
|
||||
_data.remove(Integer.valueOf(id));
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
|
||||
public void handleRemoteUpdate(int id)
|
||||
{
|
||||
if (_data.stream().filter(data -> data.getId() == id).toArray().length > 0)
|
||||
runSync(() ->
|
||||
{
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
if (_data.containsKey(Integer.valueOf(id)))
|
||||
{
|
||||
_data.stream().filter(existing -> existing.getId() == data.getId()).forEach(existing -> existing.setEnabled(data.isEnabled()));
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
{
|
||||
_data.get(data.getId()).setEnabled(data.isEnabled());
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.add(data);
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
_repo.loadAnnouncement(id, data ->
|
||||
{
|
||||
_data.put(data.getId(), data);
|
||||
UtilServer.CallEvent(new SalesAnnouncementRemoteListUpdateEvent());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_data.isEmpty() || _data.stream().filter(data -> data.isEnabled()).toArray().length == 0)
|
||||
if (_data.isEmpty() || !_data.values().stream().filter(data -> data.isEnabled()).findAny().isPresent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -127,7 +133,7 @@ public class SalesAnnouncementManager extends MiniPlugin
|
||||
|
||||
runSyncLater(() ->
|
||||
{
|
||||
_data.stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data ->
|
||||
_data.values().stream().filter(data -> data.isEnabled() && data.shouldDisplayTo(rank)).forEach(data ->
|
||||
{
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage(LINE);
|
||||
|
@ -36,10 +36,11 @@ public class SalesAnnouncementPage implements Listener
|
||||
private void setup()
|
||||
{
|
||||
_buttons.clear();
|
||||
for (int i = 0; i < _manager.getLoadedAnnouncements().size(); i++)
|
||||
int i = 0;
|
||||
for (SalesAnnouncementData data : _manager.getLoadedAnnouncements().values())
|
||||
{
|
||||
SalesAnnouncementData data = _manager.getLoadedAnnouncements().get(i);
|
||||
_buttons.put(i, new SalesAnnouncementButton(data, this));
|
||||
i++;
|
||||
}
|
||||
updateButtons(false);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.hub.modules.salesannouncements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -9,7 +11,6 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
@ -18,20 +19,22 @@ import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class SalesAnnouncementRepository extends RepositoryBase
|
||||
{
|
||||
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, PRIMARY KEY (id));";
|
||||
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS salesAnnouncements (id INT NOT NULL AUTO_INCREMENT, ranks VARCHAR(250), message VARCHAR(256), enabled BOOL, clans BOOL, PRIMARY KEY (id), INDEX typeIndex (clans));";
|
||||
|
||||
private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements;";
|
||||
private static final String GET_ANNOUNCEMENTS = "SELECT * FROM salesAnnouncements WHERE clans=?;";
|
||||
private static final String GET_ANNOUNCEMENT = "SELECT * FROM salesAnnouncements WHERE id=?;";
|
||||
private static final String UPDATE_ANNOUNCEMENT_STATUS = "UPDATE salesAnnouncements SET enabled=? WHERE id=?;";
|
||||
private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled) VALUES(?, ?, ?);";
|
||||
private static final String INSERT_ANNOUNCEMENT = "INSERT INTO salesAnnouncements (ranks, message, enabled, clans) VALUES(?, ?, ?, ?);";
|
||||
private static final String DELETE_ANNOUNCEMENT = "DELETE FROM salesAnnouncements WHERE id=?;";
|
||||
|
||||
private final JavaPlugin _plugin;
|
||||
private final boolean _clans;
|
||||
|
||||
public SalesAnnouncementRepository(JavaPlugin plugin)
|
||||
public SalesAnnouncementRepository(JavaPlugin plugin, boolean clans)
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
_plugin = plugin;
|
||||
_clans = clans;
|
||||
}
|
||||
|
||||
private void runAsync(Runnable runnable)
|
||||
@ -44,13 +47,13 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
Bukkit.getScheduler().runTask(_plugin, runnable);
|
||||
}
|
||||
|
||||
public void loadAnnouncements(final List<SalesAnnouncementData> announcementList)
|
||||
public void loadAnnouncements(final Map<Integer, SalesAnnouncementData> map)
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
executeQuery(GET_ANNOUNCEMENTS, resultSet ->
|
||||
{
|
||||
final List<SalesAnnouncementData> data = Lists.newArrayList();
|
||||
final List<SalesAnnouncementData> data = new ArrayList<>();
|
||||
while (resultSet.next())
|
||||
{
|
||||
int id = resultSet.getInt("id");
|
||||
@ -71,15 +74,15 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
String message = resultSet.getString("message");
|
||||
boolean enabled = resultSet.getBoolean("enabled");
|
||||
|
||||
data.add(new SalesAnnouncementData(id, displayTo, message, enabled));
|
||||
data.add(new SalesAnnouncementData(Integer.valueOf(id), displayTo, message, enabled));
|
||||
}
|
||||
|
||||
runSync(() ->
|
||||
{
|
||||
announcementList.clear();
|
||||
data.forEach(sData -> announcementList.add(sData));
|
||||
map.clear();
|
||||
data.forEach(sData -> map.put(sData.getId(), sData));
|
||||
});
|
||||
});
|
||||
}, new ColumnBoolean("clans", _clans));
|
||||
});
|
||||
}
|
||||
|
||||
@ -109,7 +112,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
String message = resultSet.getString("message");
|
||||
boolean enabled = resultSet.getBoolean("enabled");
|
||||
|
||||
final SalesAnnouncementData data = new SalesAnnouncementData(aId, displayTo, message, enabled);
|
||||
final SalesAnnouncementData data = new SalesAnnouncementData(Integer.valueOf(aId), displayTo, message, enabled);
|
||||
runSync(() ->
|
||||
{
|
||||
callback.run(data);
|
||||
@ -139,7 +142,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
runSync(() -> callback.run(data));
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true));
|
||||
}, new ColumnVarChar("ranks", 250, rankStr), new ColumnVarChar("message", 256, message), new ColumnBoolean("enabled", true), new ColumnBoolean("clans", _clans));
|
||||
});
|
||||
}
|
||||
|
||||
@ -147,7 +150,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId()));
|
||||
executeUpdate(UPDATE_ANNOUNCEMENT_STATUS, new ColumnBoolean("enabled", data.isEnabled()), new ColumnInt("id", data.getId().intValue()));
|
||||
if (after != null)
|
||||
{
|
||||
runSync(after);
|
||||
@ -159,7 +162,7 @@ public class SalesAnnouncementRepository extends RepositoryBase
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId()));
|
||||
executeUpdate(DELETE_ANNOUNCEMENT, new ColumnInt("id", data.getId().intValue()));
|
||||
if (after != null)
|
||||
{
|
||||
runSync(after);
|
||||
|
@ -4,16 +4,18 @@ import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementUpdateCommand extends ServerCommand
|
||||
{
|
||||
private String _id;
|
||||
private Integer _id;
|
||||
private String _from;
|
||||
private boolean _clans;
|
||||
|
||||
public SalesAnnouncementUpdateCommand(String id, String from)
|
||||
public SalesAnnouncementUpdateCommand(Integer id, String from, boolean clans)
|
||||
{
|
||||
_id = id;
|
||||
_from = from;
|
||||
_clans = clans;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
public Integer getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
@ -22,4 +24,9 @@ public class SalesAnnouncementUpdateCommand extends ServerCommand
|
||||
{
|
||||
return _from;
|
||||
}
|
||||
|
||||
public boolean isClans()
|
||||
{
|
||||
return _clans;
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package mineplex.hub.modules.salesannouncements;
|
||||
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class SalesAnnouncementUpdateHandler implements CommandCallback
|
||||
public class SalesAnnouncementUpdateHandler implements CommandCallback<SalesAnnouncementUpdateCommand>
|
||||
{
|
||||
private final SalesAnnouncementManager _manager;
|
||||
|
||||
@ -13,16 +12,16 @@ public class SalesAnnouncementUpdateHandler implements CommandCallback
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
public void run(SalesAnnouncementUpdateCommand command)
|
||||
{
|
||||
if (!(command instanceof SalesAnnouncementUpdateCommand))
|
||||
if (_manager.getServer().equalsIgnoreCase(command.getFrom()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_manager.getServer().equalsIgnoreCase(((SalesAnnouncementUpdateCommand) command).getFrom()))
|
||||
if (_manager.CLANS != command.isClans())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_manager.handleRemoteUpdate(Integer.parseInt(((SalesAnnouncementUpdateCommand)command).getId()));
|
||||
_manager.handleRemoteUpdate(command.getId());
|
||||
}
|
||||
}
|
@ -865,6 +865,11 @@ public class ServerManager extends MiniPlugin
|
||||
return _serverNpcShopMap.get("Bawk Bawk Battles");
|
||||
}
|
||||
|
||||
public ServerNpcShop getMobaShop()
|
||||
{
|
||||
return _serverNpcShopMap.get("Heroes of GWEN");
|
||||
}
|
||||
|
||||
public BoosterManager getBoosterManager()
|
||||
{
|
||||
return _boosterManager;
|
||||
|
@ -26,14 +26,14 @@ public class MOBAServerTypePage extends ShopPageBase<ServerManager, ServerNpcSho
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cGold + "Play " + C.cYellow + "Heroes of GWEN")
|
||||
setItem(12, new ItemBuilder(Material.PRISMARINE_SHARD).setTitle(C.Reset + C.cGold + "Play " + C.cYellow + "Heroes of GWEN")
|
||||
.addLore(new String[]
|
||||
{
|
||||
C.Reset + "",
|
||||
C.Reset + C.cGreen + "Click to Play",
|
||||
}).build());
|
||||
|
||||
setItem(14, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "Heroes of GWEN " + C.cGold + "Training")
|
||||
setItem(14, new ItemBuilder(Material.SKULL_ITEM, (byte) 3).setTitle(C.Reset + C.cYellow + "Heroes of GWEN " + C.cGold + "Training")
|
||||
.addLore(new String[]
|
||||
{
|
||||
C.Reset + "",
|
||||
|
@ -3,6 +3,7 @@ package mineplex.hub.server.ui;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.hub.server.ui.button.SelectMOBAButton;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
@ -80,14 +81,14 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
C.Reset + "at all costs!",
|
||||
}, "CA", "Castle_Assault", new SelectCAButton(this));
|
||||
|
||||
add(4, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Assault TDM " + C.cGray + "Team PvP", new String[]
|
||||
add(4, Material.PRISMARINE_SHARD, C.cYellowB + "Heroes of GWEN " + C.cGray + "Team Game", new String[]
|
||||
{
|
||||
(_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME",
|
||||
(_extraValue ? C.cAquaB : C.cWhiteB) + "FULL RELEASE",
|
||||
C.Reset + "",
|
||||
C.Reset + "Combatants must battle to",
|
||||
C.Reset + "win glory for their team",
|
||||
C.Reset + "by slaying the enemy!",
|
||||
}, "CATDM", "Castle_Assault_TDM", new SelectCATDMButton(this));
|
||||
C.Reset + "Face off in a crazy 4v4",
|
||||
C.Reset + "battle with many different",
|
||||
C.Reset + "Heroes and Abilities!",
|
||||
}, "MOBA", "Heroes_of_GWEN", new SelectMOBAButton(this));
|
||||
|
||||
add(6, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[]
|
||||
{
|
||||
@ -761,6 +762,11 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
getPlugin().getBawkShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
public void openMoba(Player player)
|
||||
{
|
||||
getPlugin().getMobaShop().attemptShopOpen(player);
|
||||
}
|
||||
|
||||
/*
|
||||
ADDITIONAL LORES;
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package mineplex.hub.server.ui.button;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.hub.server.ui.ServerGameMenu;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class SelectMOBAButton implements IButton
|
||||
{
|
||||
private ServerGameMenu _menu;
|
||||
|
||||
public SelectMOBAButton(ServerGameMenu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_menu.openMoba(player);
|
||||
}
|
||||
}
|
@ -236,7 +236,5 @@ public class CombatLog
|
||||
public void SetKillerColor(String color)
|
||||
{
|
||||
_killerColor = color;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package mineplex.serverdata.commands;
|
||||
|
||||
|
||||
public interface CommandCallback<T extends ServerCommand>
|
||||
{
|
||||
|
||||
void run(T command);
|
||||
}
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
package mineplex.serverdata.commands;
|
||||
|
||||
|
||||
public class CommandType
|
||||
{
|
||||
|
||||
private Class<? extends ServerCommand> _commandClazz;
|
||||
public Class<? extends ServerCommand> getCommandType() { return _commandClazz; }
|
||||
|
||||
private CommandCallback _commandCallback;
|
||||
public CommandCallback getCallback() { return _commandCallback; }
|
||||
private CommandCallback<? extends ServerCommand> _commandCallback;
|
||||
public CommandCallback<? extends ServerCommand> getCallback() { return _commandCallback; }
|
||||
|
||||
public CommandType(Class<? extends ServerCommand> commandClazz, CommandCallback commandCallback)
|
||||
public CommandType(Class<? extends ServerCommand> commandClazz, CommandCallback<? extends ServerCommand> commandCallback)
|
||||
{
|
||||
_commandClazz = commandClazz;
|
||||
_commandCallback = commandCallback;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,8 +9,6 @@ import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
|
||||
public class ServerCommandManager
|
||||
{
|
||||
@ -35,7 +33,7 @@ public class ServerCommandManager
|
||||
public boolean isServerInitialized() { return _localServerName != null; }
|
||||
public String getServerName()
|
||||
{
|
||||
return this._localServerName;
|
||||
return _localServerName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +44,7 @@ public class ServerCommandManager
|
||||
_writePool = Utility.generatePool(ServerManager.getMasterConnection()); // Publish to master instance
|
||||
_readPool = Utility.generatePool(ServerManager.getSlaveConnection()); // Read from slave instance
|
||||
|
||||
_commandTypes = new HashMap<String, CommandType>();
|
||||
_commandTypes = new HashMap<>();
|
||||
|
||||
initialize();
|
||||
}
|
||||
@ -98,6 +96,7 @@ public class ServerCommandManager
|
||||
* @param commandType - the type of command being received
|
||||
* @param serializedCommand - the serialized {@link ServerCommand} data.
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void handleCommand(final String commandType, String serializedCommand)
|
||||
{
|
||||
if (!isServerInitialized())
|
||||
@ -163,4 +162,4 @@ public class ServerCommandManager
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ import mineplex.core.imagemap.objects.PlayerMapBoard;
|
||||
import mineplex.core.leaderboard.Leaderboard;
|
||||
import mineplex.core.leaderboard.LeaderboardManager;
|
||||
import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType;
|
||||
import mineplex.core.stats.event.StatChangeEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
|
@ -25,6 +25,7 @@ import nautilus.game.arcade.kit.Perk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
@ -217,27 +218,6 @@ public class HeroKit extends Kit
|
||||
{
|
||||
inventory.setBoots(itemstack);
|
||||
}
|
||||
|
||||
// Give consumable items
|
||||
else if (!UtilItem.isSword(itemstack) && !UtilGear.isBow(itemstack))
|
||||
{
|
||||
// Keep moving left from the ammo slot until a free slot is available
|
||||
for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--)
|
||||
{
|
||||
ItemStack consumable = inventory.getItem(i);
|
||||
|
||||
if (consumable == null)
|
||||
{
|
||||
inventory.setItem(i, itemstack);
|
||||
break;
|
||||
}
|
||||
else if (consumable.isSimilar(itemstack))
|
||||
{
|
||||
consumable.setAmount(consumable.getAmount() + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Give all skill related items
|
||||
@ -267,6 +247,40 @@ public class HeroKit extends Kit
|
||||
super.GiveItemsCall(player);
|
||||
|
||||
disguise(player);
|
||||
giveConsumables(player);
|
||||
}
|
||||
|
||||
public void giveConsumables(Player player)
|
||||
{
|
||||
Inventory inventory = player.getInventory();
|
||||
Moba game = (Moba) Manager.GetGame();
|
||||
List<MobaItem> items = game.getShop().getOwnedItems(player);
|
||||
|
||||
for (MobaItem item : items)
|
||||
{
|
||||
ItemStack itemStack = item.getItem();
|
||||
|
||||
// Give consumable items
|
||||
if (itemStack.getType() == Material.POTION || itemStack.getType() == Material.ENDER_PEARL)
|
||||
{
|
||||
// Keep moving left from the ammo slot until a free slot is available
|
||||
for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--)
|
||||
{
|
||||
ItemStack consumable = inventory.getItem(i);
|
||||
|
||||
if (consumable == null)
|
||||
{
|
||||
inventory.setItem(i, itemStack);
|
||||
break;
|
||||
}
|
||||
else if (consumable.isSimilar(itemStack))
|
||||
{
|
||||
consumable.setAmount(consumable.getAmount() + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disguise(Player player)
|
||||
|
@ -9,6 +9,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.PlayerKitGiveEvent;
|
||||
@ -185,8 +186,17 @@ public class HeroSkill extends Perk
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemStack.isSimilar(_item);
|
||||
if (itemStack.isSimilar(_item))
|
||||
{
|
||||
if (_dropItemActivate && !Recharge.Instance.use(player, "Ultimate", _cooldown, false, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isSkillSneak(PlayerToggleSneakEvent event)
|
||||
@ -248,7 +258,7 @@ public class HeroSkill extends Perk
|
||||
}
|
||||
|
||||
game.Announce(team.GetColor() + C.Bold + player.getName() + " " + kit.getRole().getChatColor() + kit.GetName() + C.cWhiteB + " activated their " + team.GetColor() + C.Bold + GetName() + C.cWhiteB + ".", false);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0.5F);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.5F);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -386,7 +396,6 @@ public class HeroSkill extends Perk
|
||||
GameTeam team = Manager.GetGame().GetTeam((Player) damager);
|
||||
|
||||
return team != null && MobaUtil.isTeamEntity(damagee, team);
|
||||
|
||||
}
|
||||
|
||||
public int getSlot()
|
||||
|
@ -41,16 +41,18 @@ public class MobaProgression implements Listener
|
||||
{
|
||||
|
||||
private static final int[] EXP_LEVELS;
|
||||
private static final int EXP_PER_LEVEL = 500;
|
||||
private static final int EXP_FACTOR = 3;
|
||||
public static final DecimalFormat FORMAT = new DecimalFormat("0.0");
|
||||
|
||||
static
|
||||
{
|
||||
EXP_LEVELS = new int[100];
|
||||
int expRequired = 2000;
|
||||
int expRequired = EXP_PER_LEVEL;
|
||||
|
||||
for (int level = 0; level < 100; level++)
|
||||
{
|
||||
EXP_LEVELS[level] = expRequired += 2000;
|
||||
EXP_LEVELS[level] = expRequired += EXP_PER_LEVEL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,6 +201,7 @@ public class MobaProgression implements Listener
|
||||
int level = getLevel(player, role);
|
||||
return getExperience(level) - getExperience(level - 1);
|
||||
}
|
||||
|
||||
public int getLevel(Player player, HeroKit kit)
|
||||
{
|
||||
return getLevel(player, kit.getRole());
|
||||
@ -238,6 +241,8 @@ public class MobaProgression implements Listener
|
||||
earnedExp.getAndAdd((int) data.Gems);
|
||||
}
|
||||
|
||||
earnedExp.getAndAdd(earnedExp.get() * EXP_FACTOR);
|
||||
|
||||
int level = getLevel(currentExp);
|
||||
int newLevel = getLevel(currentExp + earnedExp.get());
|
||||
long expForThisLevel = getExperienceCurrentLevel(player, role);
|
||||
|
@ -19,12 +19,14 @@ import nautilus.game.arcade.game.games.moba.MobaPlayer;
|
||||
import nautilus.game.arcade.game.games.moba.MobaRole;
|
||||
import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent;
|
||||
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
|
||||
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
|
||||
import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent;
|
||||
import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop;
|
||||
import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop;
|
||||
import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop;
|
||||
import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop;
|
||||
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
@ -210,10 +212,11 @@ public class MobaShop implements Listener
|
||||
|
||||
// The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn,
|
||||
// Prevents infinite speed
|
||||
double currentHealth = player.getHealth();
|
||||
player.setWalkSpeed(0.2F);
|
||||
player.setMaxHealth(20);
|
||||
|
||||
PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player);
|
||||
PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(_host, player);
|
||||
|
||||
for (MobaItem ownedItem : owned)
|
||||
{
|
||||
@ -223,13 +226,20 @@ public class MobaShop implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
_host.GetKit(player).GiveItems(player);
|
||||
HeroKit kit = (HeroKit) _host.GetKit(player);
|
||||
|
||||
// If we aren't tracking purchases then after we give the item remove it.
|
||||
if (!category.isTrackingPurchases())
|
||||
if (category.isTrackingPurchases())
|
||||
{
|
||||
kit.GiveItems(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
kit.giveConsumables(player);
|
||||
owned.remove(item);
|
||||
}
|
||||
|
||||
player.setHealth(Math.min(currentHealth, player.getMaxHealth()));
|
||||
}
|
||||
|
||||
public boolean ownsItem(Player player, MobaItem item)
|
||||
|
@ -80,10 +80,7 @@ public class Tower
|
||||
_guardian = new DisguiseGuardian(_stand);
|
||||
_host.getArcadeManager().GetDisguise().disguise(_guardian);
|
||||
|
||||
if (!_firstTower)
|
||||
{
|
||||
_guardian.setElder(true);
|
||||
}
|
||||
//_guardian.setElder(!_firstTower);
|
||||
|
||||
_guardian.setCustomNameVisible(true);
|
||||
|
||||
|
@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.training;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -522,4 +523,15 @@ public class MobaTraining extends Moba
|
||||
SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true);
|
||||
SetKit(player, kit, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void informLobbyPlayers(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC_20 || InProgress())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Announce(F.main("Game", "Waiting for more players before starting the training area."), false);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.managers;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -22,6 +23,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -40,14 +42,17 @@ import mineplex.core.portal.GenericServer;
|
||||
import mineplex.core.portal.Intent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
|
||||
import nautilus.game.arcade.gui.privateServer.page.GameVotingPage;
|
||||
|
||||
public class GameHostManager implements Listener
|
||||
{
|
||||
private final AntiHack _antiHack;
|
||||
private ArrayList<GameType> ultraGames = new ArrayList<GameType>();
|
||||
private ArrayList<GameType> heroGames = new ArrayList<GameType>();
|
||||
private ArrayList<GameType> legendGames = new ArrayList<GameType>();
|
||||
@ -79,6 +84,7 @@ public class GameHostManager implements Listener
|
||||
|
||||
public GameHostManager(ArcadeManager manager)
|
||||
{
|
||||
_antiHack = Managers.require(AntiHack.class);
|
||||
Manager = manager;
|
||||
_shop = new PrivateServerShop(manager, manager.GetClients(), manager.GetDonation());
|
||||
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
@ -123,7 +129,6 @@ public class GameHostManager implements Listener
|
||||
legendGames.add(GameType.Skywars);
|
||||
legendGames.add(GameType.SpeedBuilders);
|
||||
legendGames.add(GameType.TypeWars);
|
||||
legendGames.add(GameType.MOBA);
|
||||
// Team variants - Currently being remade.
|
||||
/*
|
||||
legendGames.add(GameType.DragonEscapeTeams);
|
||||
@ -161,6 +166,18 @@ public class GameHostManager implements Listener
|
||||
return games;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if (!isEventServer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable all checks in event servers
|
||||
Stream.concat(AntiHack.ACTIONS.keySet().stream(), AntiHack.CHECKS.keySet().stream()).distinct().forEach(_antiHack::addIgnoredCheck);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateHost(UpdateEvent event)
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ public class GameChatManager implements Listener
|
||||
event.setFormat(dead + levelStr + rankStr + _manager.GetColor(sender) + senderName + " " + C.cWhite + "%2$s");
|
||||
|
||||
//Public/Private (Not If Player Dead)
|
||||
if (_manager.GetGame() != null && _manager.GetGame().GetState() == GameState.Live)
|
||||
if (_manager.GetGame() != null && _manager.GetGame().InProgress())
|
||||
{
|
||||
boolean globalMessage = false;
|
||||
|
||||
|
@ -1,19 +1,5 @@
|
||||
package mineplex.gemhunters.death.quitnpc;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
@ -26,6 +12,19 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilGameProfile;
|
||||
import mineplex.gemhunters.death.event.QuitNPCDespawnEvent;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuitNPC implements Listener
|
||||
{
|
||||
@ -94,7 +93,6 @@ public class QuitNPC implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
_disguise.undisguise(_disguise.getActiveDisguise(_entity));
|
||||
_entity.remove();
|
||||
_hologram.remove();
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
package mineplex.gemhunters.join;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
@ -23,8 +16,14 @@ import mineplex.gemhunters.persistence.PersistenceModule;
|
||||
import mineplex.gemhunters.persistence.PersistenceRepository;
|
||||
import mineplex.gemhunters.quest.QuestModule;
|
||||
import mineplex.gemhunters.spawn.SpawnModule;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class JoinModule extends MiniPlugin
|
||||
{
|
||||
@ -88,6 +87,7 @@ public class JoinModule extends MiniPlugin
|
||||
}
|
||||
|
||||
_inventory.resetSlots(player);
|
||||
_spawn.teleportToSpawn(player);
|
||||
|
||||
runAsync(() ->
|
||||
{
|
||||
@ -97,7 +97,7 @@ public class JoinModule extends MiniPlugin
|
||||
{
|
||||
runSync(() -> _spawn.teleportToSpawn(player));
|
||||
}
|
||||
});
|
||||
}, 40);
|
||||
}
|
||||
|
||||
private void loseDurability(ItemStack[] items, long time)
|
||||
|
Loading…
Reference in New Issue
Block a user