Merge remote-tracking branch 'refs/remotes/origin/develop' into update/skywars-finalised
This commit is contained in:
commit
2c37af32ca
@ -16,9 +16,11 @@ public class Mineplexer extends Plugin
|
||||
{
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
getProxy().getScheduler().runAsync(this, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
public void run()
|
||||
{
|
||||
// Sentry setup
|
||||
Handler sentry = new SentryHandler(new DefaultRavenFactory().createRavenInstance(
|
||||
new Dsn("https://470f12378af3453ba089e0c0a0c9aae6:292516b722594784807aebb06db8ec38@app.getsentry.com/66323"
|
||||
@ -30,10 +32,9 @@ public class Mineplexer extends Plugin
|
||||
|
||||
new MotdManager(this);
|
||||
new LobbyBalancer(this);
|
||||
PlayerCount playerCount = new PlayerCount(this);
|
||||
new PlayerCount(this);
|
||||
new FileUpdater(this);
|
||||
new PlayerStats(this);
|
||||
//new InternetStatus(this);
|
||||
new PlayerTracker(this);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package mineplex.bungee.lobbyBalancer;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -12,21 +11,24 @@ import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class LobbyBalancer implements Listener, Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private ServerRepository _repository;
|
||||
|
||||
private List<MinecraftServer> _sortedLobbies = new ArrayList<MinecraftServer>();
|
||||
private List<MinecraftServer> _sortedLobbies = Lists.newArrayList();
|
||||
private List<MinecraftServer> _sortedClans = Lists.newArrayList();
|
||||
private static Object _serverLock = new Object();
|
||||
|
||||
private int _lobbyIndex = 0;
|
||||
private int _clansIndex = 0;
|
||||
|
||||
public LobbyBalancer(Plugin plugin)
|
||||
{
|
||||
@ -35,7 +37,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
Region region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||
_repository = ServerManager.getServerRepository(region);
|
||||
|
||||
loadLobbyServers();
|
||||
run();
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS);
|
||||
@ -44,9 +46,8 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
@EventHandler
|
||||
public void playerConnect(ServerConnectEvent event)
|
||||
{
|
||||
if (!event.getTarget().getName().equalsIgnoreCase("Lobby"))
|
||||
return;
|
||||
|
||||
if (event.getTarget().getName().equalsIgnoreCase("Lobby"))
|
||||
{
|
||||
synchronized (_serverLock)
|
||||
{
|
||||
if (_lobbyIndex >= _sortedLobbies.size() || _sortedLobbies.get(_lobbyIndex).getPlayerCount() >= _sortedLobbies.get(_lobbyIndex).getMaxPlayerCount())
|
||||
@ -58,13 +59,36 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
_lobbyIndex++;
|
||||
}
|
||||
}
|
||||
if (event.getTarget().getName().equalsIgnoreCase("ClansHub"))
|
||||
{
|
||||
synchronized (_serverLock)
|
||||
{
|
||||
if (_clansIndex >= _sortedClans.size() || _sortedClans.get(_clansIndex).getPlayerCount() >= _sortedClans.get(_clansIndex).getMaxPlayerCount())
|
||||
_clansIndex = 0;
|
||||
|
||||
event.setTarget(_plugin.getProxy().getServerInfo(_sortedClans.get(_clansIndex).getName()));
|
||||
_sortedClans.get(_clansIndex).incrementPlayerCount(1);
|
||||
System.out.println("Sending " + event.getPlayer().getName() + " to " + _sortedClans.get(_clansIndex).getName() + "(" + _sortedClans.get(_clansIndex).getPublicAddress() + ")");
|
||||
_clansIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
loadLobbyServers();
|
||||
loadServers();
|
||||
|
||||
if (!_plugin.getProxy().getServers().containsKey("ClansHub"))
|
||||
{
|
||||
_plugin.getProxy().getServers().put("ClansHub", _plugin.getProxy().constructServerInfo("ClansHub", new InetSocketAddress("lobby.mineplex.com", 25565), "LobbyBalancer", false));
|
||||
}
|
||||
if (!_plugin.getProxy().getServers().containsKey("Lobby"))
|
||||
{
|
||||
_plugin.getProxy().getServers().put("Lobby", _plugin.getProxy().constructServerInfo("Lobby", new InetSocketAddress("lobby.mineplex.com", 25565), "LobbyBalancer", false));
|
||||
}
|
||||
}
|
||||
|
||||
public void loadLobbyServers()
|
||||
public void loadServers()
|
||||
{
|
||||
Collection<MinecraftServer> servers = _repository.getServerStatuses();
|
||||
|
||||
@ -72,6 +96,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
_sortedLobbies.clear();
|
||||
_sortedClans.clear();
|
||||
|
||||
for (MinecraftServer server : servers)
|
||||
{
|
||||
@ -88,9 +113,17 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
_sortedLobbies.add(server);
|
||||
}
|
||||
}
|
||||
if (server.getName().toUpperCase().startsWith("CLANSHUB"))
|
||||
{
|
||||
if (server.getMotd() == null || !server.getMotd().contains("Restarting"))
|
||||
{
|
||||
_sortedClans.add(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(_sortedLobbies, new LobbySorter());
|
||||
Collections.sort(_sortedClans, new LobbySorter());
|
||||
|
||||
long timeSpentInLock = System.currentTimeMillis() - startTime;
|
||||
|
||||
|
@ -1,20 +1,18 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ConnectionData;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
@ -31,6 +29,8 @@ public class MotdManager implements Listener, Runnable
|
||||
private Random _random = new Random();
|
||||
private String _firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r";
|
||||
private List<String> _motdLines;
|
||||
private String _firstCLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r";
|
||||
private List<String> _motdCLines;
|
||||
|
||||
public MotdManager(Plugin plugin)
|
||||
{
|
||||
@ -70,18 +70,29 @@ public class MotdManager implements Listener, Runnable
|
||||
public void serverPing(ProxyPingEvent event)
|
||||
{
|
||||
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
|
||||
|
||||
if (event.getConnection().getListener() != null && event.getConnection().getListener().getDefaultServer().equalsIgnoreCase("ClansHub"))
|
||||
{
|
||||
String motd = _firstCLine;
|
||||
if (_motdCLines != null && _motdCLines.size() > 0)
|
||||
{
|
||||
motd += "\n" + _motdCLines.get(_random.nextInt(_motdCLines.size()));
|
||||
}
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject()));
|
||||
}
|
||||
else
|
||||
{
|
||||
String motd = _firstLine;
|
||||
if (_motdLines != null && _motdLines.size() > 0)
|
||||
{
|
||||
motd += "\n" + _motdLines.get(_random.nextInt(_motdLines.size()));
|
||||
}
|
||||
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
{
|
||||
GlobalMotd motd = _repository.getElement("MainMotd");
|
||||
|
||||
@ -91,6 +102,20 @@ public class MotdManager implements Listener, Runnable
|
||||
_firstLine = motd.getHeadline();
|
||||
}
|
||||
}
|
||||
{
|
||||
GlobalMotd motd = _repository.getElement("ClansMotd");
|
||||
|
||||
if (motd != null)
|
||||
{
|
||||
_motdCLines = motd.getMotd();
|
||||
_firstCLine = motd.getHeadline();
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.addElement(new GlobalMotd("ClansMotd", "§4§lMineplex Clans§r", Arrays.asList("Default MOTD")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the main {@link GlobalMotd} determining the MOTD for Bungee instances.
|
||||
|
@ -1,7 +1,6 @@
|
||||
package mineplex.bungee.playerCount;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.bungee.status.InternetStatus;
|
||||
@ -12,7 +11,6 @@ import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ConnectionData;
|
||||
import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
import net.md_5.bungee.api.ServerPing.Players;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
@ -39,7 +37,13 @@ public class PlayerCount implements Listener, Runnable
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 4L, 4L, TimeUnit.SECONDS);
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
_listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next();
|
||||
for (ListenerInfo info : _plugin.getProxy().getConfigurationAdapter().getListeners())
|
||||
{
|
||||
if (info.getDefaultServer().equalsIgnoreCase("Lobby"))
|
||||
{
|
||||
_listenerInfo = info;
|
||||
}
|
||||
}
|
||||
|
||||
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL),
|
||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||
@ -55,7 +59,10 @@ public class PlayerCount implements Listener, Runnable
|
||||
public void run()
|
||||
{
|
||||
BungeeServer snapshot = generateSnapshot();
|
||||
if (snapshot != null)
|
||||
{
|
||||
_repository.addElement(snapshot, 15); // Update with a 15 second expiry on session
|
||||
}
|
||||
|
||||
_totalPlayers = fetchPlayerCount();
|
||||
}
|
||||
@ -84,6 +91,10 @@ public class PlayerCount implements Listener, Runnable
|
||||
*/
|
||||
private BungeeServer generateSnapshot()
|
||||
{
|
||||
if (_listenerInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String name = _listenerInfo.getHost().getAddress().getHostAddress();
|
||||
String host = _listenerInfo.getHost().getAddress().getHostAddress();
|
||||
int port = _listenerInfo.getHost().getPort();
|
||||
|
@ -1,41 +0,0 @@
|
||||
package mineplex.core.common;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum CurrencyType
|
||||
{
|
||||
TOKEN("Tokens", "Token", C.cWhite, Material.EMERALD),
|
||||
TREASURE_SHARD("Treasure Shards", "Treasure Shard", C.cAqua, Material.PRISMARINE_SHARD),
|
||||
GEM("Gems", "Gem", C.cGreen, Material.EMERALD),
|
||||
GOLD("Gold", "Gold", C.cGold, Material.GOLD_NUGGET);
|
||||
|
||||
private String _plural;
|
||||
private String _single;
|
||||
private String _color;
|
||||
private Material _displayMaterial;
|
||||
|
||||
CurrencyType(String plural, String single, String color, Material displayMaterial)
|
||||
{
|
||||
_plural = plural;
|
||||
_single = single;
|
||||
_color = color;
|
||||
_displayMaterial = displayMaterial;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getPrefix()
|
||||
{
|
||||
return _plural;
|
||||
}
|
||||
|
||||
public String getString(int amount)
|
||||
{
|
||||
return _color + amount + " " + (amount == 1 ? _single : _plural);
|
||||
}
|
||||
|
||||
public Material getDisplayMaterial()
|
||||
{
|
||||
return _displayMaterial;
|
||||
}
|
||||
}
|
@ -190,13 +190,29 @@ public class Schematic
|
||||
return index < _blocks.length;
|
||||
}
|
||||
|
||||
public short getBlock(int x, int y, int z)
|
||||
public Short getBlock(int x, int y, int z)
|
||||
{
|
||||
if (getIndex(x, y, z) >= _blocks.length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (getIndex(x, y, z) < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _blocks[getIndex(x, y, z)];
|
||||
}
|
||||
|
||||
public byte getData(int x, int y, int z)
|
||||
public Byte getData(int x, int y, int z)
|
||||
{
|
||||
if (getIndex(x, y, z) >= _blocks.length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (getIndex(x, y, z) < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _blockData[getIndex(x, y, z)];
|
||||
}
|
||||
|
||||
|
@ -99,10 +99,13 @@ public class SchematicRunnable implements Runnable
|
||||
|
||||
private void setBlock(Block block, int x, int y, int z)
|
||||
{
|
||||
Short materialId = _schematic.getBlock(x, y, z);
|
||||
Byte data = _schematic.getData(x, y, z);
|
||||
|
||||
int materialId = _schematic.getBlock(x, y, z);
|
||||
byte data = _schematic.getData(x, y, z);
|
||||
|
||||
if (materialId == null || data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Material material = Material.getMaterial(materialId);
|
||||
if (material == null)
|
||||
{
|
||||
|
@ -0,0 +1,41 @@
|
||||
package mineplex.core.common.currency;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Currency is the base class for all currency types in mineplex:
|
||||
* - Global currencies, found in {@link GlobalCurrency}, e.g., treasure shards
|
||||
* - Clans gold, found in the Mineplex.Game.Clans project
|
||||
*/
|
||||
public class Currency
|
||||
{
|
||||
private final String _plural;
|
||||
private final String _singular;
|
||||
private final String _color;
|
||||
private final Material _displayMaterial;
|
||||
|
||||
public Currency(String plural, String singular, String color, Material displayMaterial)
|
||||
{
|
||||
this._plural = plural;
|
||||
this._singular = singular;
|
||||
this._color = color;
|
||||
this._displayMaterial = displayMaterial;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getPrefix()
|
||||
{
|
||||
return _plural;
|
||||
}
|
||||
|
||||
public String getString(int amount)
|
||||
{
|
||||
return _color + amount + " " + (amount == 1 ? _singular : _plural);
|
||||
}
|
||||
|
||||
public Material getDisplayMaterial()
|
||||
{
|
||||
return _displayMaterial;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package mineplex.core.common.currency;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* A GlobalCurrency is one whose state is shared between all Mineplex servers.
|
||||
* GlobalCurrencies can be retrieved and modified through DonationManager/Donor in Mineplex.Core
|
||||
*/
|
||||
public class GlobalCurrency extends Currency {
|
||||
public static final GlobalCurrency TREASURE_SHARD = new GlobalCurrency("Treasure Shards", "Treasure Shard", C.cAqua, Material.PRISMARINE_SHARD);
|
||||
public static final GlobalCurrency GEM = new GlobalCurrency("Gems", "Gem", C.cGreen, Material.EMERALD);
|
||||
|
||||
public GlobalCurrency(String plural, String singular, String color, Material displayMaterial) {
|
||||
super(plural, singular, color, displayMaterial);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package mineplex.core.common.events;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Called just before UtilAction#velocity changes an entity's velocity.
|
||||
*/
|
||||
public class EntityVelocityChangeEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Entity _ent;
|
||||
private Vector _vel;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public EntityVelocityChangeEvent(Entity entity, Vector velocity)
|
||||
{
|
||||
_ent = entity;
|
||||
_vel = velocity;
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
return _ent;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public Vector getVelocity()
|
||||
{
|
||||
return _vel;
|
||||
}
|
||||
|
||||
public void setVelocity(Vector velocity)
|
||||
{
|
||||
_vel = velocity;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import mineplex.core.common.currency.Currency;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class F
|
||||
@ -201,7 +198,7 @@ public class F
|
||||
return out;
|
||||
}
|
||||
|
||||
public static String currency(CurrencyType type, int amount)
|
||||
public static String currency(Currency type, int amount)
|
||||
{
|
||||
return type.getString(amount) + ChatColor.RESET + C.mBody;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import mineplex.core.common.events.EntityVelocityChangeEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -50,6 +53,15 @@ public class UtilAction
|
||||
if (UtilEnt.isGrounded(ent))
|
||||
vec.setY(vec.getY() + 0.2);
|
||||
|
||||
EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
vec = event.getVelocity();
|
||||
|
||||
//Velocity
|
||||
ent.setFallDistance(0);
|
||||
|
||||
@ -65,6 +77,16 @@ public class UtilAction
|
||||
public static void zeroVelocity(Entity ent)
|
||||
{
|
||||
Vector vec = new Vector(0,0,0);
|
||||
|
||||
EntityVelocityChangeEvent event = new EntityVelocityChangeEvent(ent, vec);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
vec = event.getVelocity();
|
||||
|
||||
ent.setFallDistance(0);
|
||||
|
||||
//Store It!
|
||||
|
@ -1617,4 +1617,35 @@ public class UtilBlock
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean water(Material type)
|
||||
{
|
||||
return type == Material.WATER || type == Material.STATIONARY_WATER;
|
||||
}
|
||||
|
||||
public static boolean lava(Material type)
|
||||
{
|
||||
return type == Material.LAVA || type == Material.STATIONARY_LAVA;
|
||||
}
|
||||
|
||||
public static boolean liquid(Material type)
|
||||
{
|
||||
return water(type) || lava(type);
|
||||
}
|
||||
|
||||
public static boolean water(Block block)
|
||||
{
|
||||
return water(block.getType());
|
||||
}
|
||||
|
||||
public static boolean lava(Block block)
|
||||
{
|
||||
return lava(block.getType());
|
||||
}
|
||||
|
||||
public static boolean liquid(Block block)
|
||||
{
|
||||
return liquid(block.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -7,13 +11,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
|
||||
public class UtilText
|
||||
{
|
||||
private static HashMap<Character, Integer> _characters = new HashMap<>();
|
||||
@ -25,7 +22,7 @@ public class UtilText
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream inputStream = CurrencyType.class.getResourceAsStream("/ascii.png");
|
||||
InputStream inputStream = UtilText.class.getResourceAsStream("/ascii.png");
|
||||
BufferedImage image = ImageIO.read(inputStream);
|
||||
|
||||
char[] text = new char[]
|
||||
|
@ -160,7 +160,13 @@ public class BlockRestore extends MiniPlugin
|
||||
public void add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime, boolean restoreOnBreak)
|
||||
{
|
||||
if (!contains(block)) getBlocks().put(block, new BlockRestoreData(block, toID, toData, fromID, fromData, expireTime, 0, restoreOnBreak));
|
||||
else getData(block).update(toID, toData, expireTime);
|
||||
else
|
||||
{
|
||||
if (getData(block) != null)
|
||||
{
|
||||
getData(block).update(toID, toData, expireTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void snow(Block block, byte heightAdd, byte heightMax, long expireTime, long meltDelay, int heightJumps)
|
||||
@ -168,6 +174,7 @@ public class BlockRestore extends MiniPlugin
|
||||
//Fill Above
|
||||
if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && getData(block) != null)
|
||||
{
|
||||
if (getData(block) != null)
|
||||
getData(block).update(78, heightAdd, expireTime, meltDelay);
|
||||
|
||||
if (heightJumps > 0) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, heightJumps - 1);
|
||||
@ -214,8 +221,11 @@ public class BlockRestore extends MiniPlugin
|
||||
if (!contains(block))
|
||||
getBlocks().put(block, new BlockRestoreData(block, 78, (byte) Math.max(0, heightAdd - 1), block.getTypeId(), block.getData(), expireTime, meltDelay, false));
|
||||
else
|
||||
{
|
||||
if (getData(block) != null)
|
||||
getData(block).update(78, heightAdd, expireTime, meltDelay);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(Block block)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
public class BlockRestoreData
|
||||
{
|
||||
@ -23,6 +24,8 @@ public class BlockRestoreData
|
||||
protected long _meltDelay = 0;
|
||||
protected long _meltLast = 0;
|
||||
|
||||
protected BlockState _fromState;
|
||||
|
||||
protected HashMap<Location, Byte> _pad = new HashMap<Location, Byte>();
|
||||
|
||||
protected boolean _restoreOnBreak;
|
||||
@ -30,6 +33,7 @@ public class BlockRestoreData
|
||||
public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay, boolean restoreOnBreak)
|
||||
{
|
||||
_block = block;
|
||||
_fromState = block.getState();
|
||||
|
||||
_fromID = fromID;
|
||||
_fromData = fromData;
|
||||
@ -163,6 +167,8 @@ public class BlockRestoreData
|
||||
public void restore()
|
||||
{
|
||||
_block.setTypeIdAndData(_fromID, _fromData, true);
|
||||
_fromState.update();
|
||||
|
||||
handleLilypad(true);
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,13 @@ public class BlockRestoreMap
|
||||
{
|
||||
Block block = blockData.Block;
|
||||
|
||||
if (block.getY() > 0 && block.getY() < _blocks.length)
|
||||
{
|
||||
if (!_blocks[block.getY()].containsKey(block))
|
||||
{
|
||||
_blocks[block.getY()].put(block, blockData);
|
||||
}
|
||||
}
|
||||
|
||||
_changedBlocks.add(blockData.Block);
|
||||
}
|
||||
|
@ -1,41 +1,27 @@
|
||||
package mineplex.core.bonuses.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
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.gui.GuiItem;
|
||||
import mineplex.core.gui.ItemRefresher;
|
||||
import mineplex.core.gui.pages.LoadingWindow;
|
||||
import mineplex.core.gui.pages.TimedMessageWindow;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.StreakRecord;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ClaimTipsButton implements GuiItem, Listener
|
||||
{
|
||||
private ItemStack _item;
|
||||
@ -87,7 +73,7 @@ public class ClaimTipsButton implements GuiItem, Listener
|
||||
new TimedMessageWindow(getPlugin(), getPlayer(), ItemStackFactory.Instance.CreateStack(Material.STAINED_GLASS_PANE, DyeColor.LIME.getData(), 1, ChatColor.GREEN + "Amplifier Thanks Collected"), "Thanks Collected", 6*9, 20*3, getGui()).openInventory();
|
||||
}
|
||||
|
||||
UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(CurrencyType.TREASURE_SHARD, claimed) + " from Amplifiers!"));
|
||||
UtilPlayer.message(getPlayer(), F.main("Carl", "You collected " + F.currency(GlobalCurrency.TREASURE_SHARD, claimed) + " from Amplifiers!"));
|
||||
// Pending explosions are strange.. Not sure why we are using strings. Either way, lets display a rank reward effect
|
||||
_bonusManager.addPendingExplosion(getPlayer(), "RANK");
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
|
||||
|
@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
||||
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -21,6 +22,9 @@ public class BoosterProcessor implements ConfirmationProcessor
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Inventory inventory) {}
|
||||
|
||||
@Override
|
||||
public void process(ConfirmationCallback callback)
|
||||
{
|
||||
|
@ -5,8 +5,8 @@ import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.boosters.tips.BoosterTipManager;
|
||||
import mineplex.core.boosters.tips.TipAddResult;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -60,8 +60,8 @@ public class ThankCommand extends CommandBase<BoosterManager>
|
||||
{
|
||||
if (result == TipAddResult.SUCCESS)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got "
|
||||
+ F.currency(CurrencyType.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!");
|
||||
UtilPlayer.message(caller, F.main("Tip", "You thanked " + F.name(booster.getPlayerName()) + ". They earned " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_SPONSOR) + " and you got "
|
||||
+ F.currency(GlobalCurrency.TREASURE_SHARD, BoosterTipManager.TIP_FOR_TIPPER)) + " in return!");
|
||||
caller.playSound(caller.getLocation(), Sound.LEVEL_UP, 1f, 1f);
|
||||
}
|
||||
else if (result.getFriendlyMessage() != null)
|
||||
|
@ -4,7 +4,6 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.boosters.Booster;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.boosters.BoosterProcessor;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
@ -115,8 +114,7 @@ public class BoosterPage extends ShopPageBase<BoosterManager, BoosterShop>
|
||||
ShopItem booster = new ShopItem(Material.SUGAR, "Game Amplifier", lore.toArray(new String[0]), 0, false, false);
|
||||
|
||||
BoosterProcessor processor = new BoosterProcessor(getPlugin(), getPlayer());
|
||||
ConfirmationPage<BoosterManager, BoosterShop> page = new ConfirmationPage<>(getPlugin(), getShop(),
|
||||
getClientManager(), getDonationManager(), getPlayer(), this, processor, booster);
|
||||
ConfirmationPage<BoosterManager, BoosterShop> page = new ConfirmationPage<>(getPlayer(), this, processor, booster);
|
||||
getShop().openPageForPlayer(getPlayer(), page);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
package mineplex.core.brawl.fountain;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
@ -14,14 +13,8 @@ public class GemFountainSalesPackage extends SalesPackageBase
|
||||
{
|
||||
super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1);
|
||||
|
||||
CurrencyCostMap.put(CurrencyType.GEM, gems);
|
||||
CurrencyCostMap.put(GlobalCurrency.GEM, gems);
|
||||
KnownPackage = false;
|
||||
OneTimePurchaseOnly = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package mineplex.core.brawl.fountain.command;
|
||||
|
||||
import mineplex.core.brawl.fountain.FountainManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -53,7 +53,7 @@ public class AddCommand extends CommandBase<FountainManager>
|
||||
UtilPlayer.message(caller, F.main("Fountain", "There was an error processing your request!"));
|
||||
}
|
||||
}
|
||||
}, caller, "GemFountain.Add", CurrencyType.GEM, amount, false);
|
||||
}, caller, "GemFountain.Add", GlobalCurrency.GEM, amount, false);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
|
@ -4,8 +4,8 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.brawl.fountain.Fountain;
|
||||
import mineplex.core.brawl.fountain.FountainManager;
|
||||
import mineplex.core.brawl.fountain.gui.button.FountainAddButton;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.MaterialData;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
@ -77,7 +77,7 @@ public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
|
||||
|
||||
if (canAdd)
|
||||
{
|
||||
int playerGems = getDonationManager().Get(getPlayer()).GetGems();
|
||||
int playerGems = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.GEM);
|
||||
ShopItem add1 = new ShopItem(Material.EMERALD, "Add 100 Gems", new String[]{}, 1, playerGems < 100, false);
|
||||
ShopItem add2 = new ShopItem(Material.EMERALD, "Add 1,000 Gems", new String[]{}, 64, playerGems < 1000, false);
|
||||
ShopItem add3 = new ShopItem(Material.EMERALD_BLOCK, "Add 10,000 Gems", new String[]{}, 1, playerGems < 10000, false);
|
||||
|
@ -1,13 +1,12 @@
|
||||
package mineplex.core.brawl.fountain.gui.button;
|
||||
|
||||
import mineplex.core.brawl.fountain.FountainManager;
|
||||
import mineplex.core.brawl.fountain.GemFountainSalesPackage;
|
||||
import mineplex.core.brawl.fountain.gui.FountainPage;
|
||||
import mineplex.core.brawl.fountain.gui.FountainShop;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -30,13 +29,10 @@ public class FountainAddButton implements IButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<FountainManager, FountainShop>(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.GEM, _salesPackage, _page.getDonationManager(), () ->
|
||||
{
|
||||
_page.getPlugin().getGemFountain().increment(player, _gems, null);
|
||||
_page.refresh();
|
||||
}
|
||||
}, _page, _salesPackage, CurrencyType.GEM, player));
|
||||
}), _salesPackage.buildIcon()));
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,5 @@
|
||||
package mineplex.core.chat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
@ -53,6 +18,39 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Chat extends MiniPlugin
|
||||
{
|
||||
@ -69,7 +67,6 @@ public class Chat extends MiniPlugin
|
||||
|
||||
private int _chatSlow = 0;
|
||||
private long _silenced = 0;
|
||||
private boolean _threeSecondDelay = true;
|
||||
|
||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
|
||||
private List<Function<AsyncPlayerChatEvent, Boolean>> _lowPriorityFilters = new ArrayList<>();
|
||||
@ -349,15 +346,6 @@ public class Chat extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else if (_threeSecondDelay &&
|
||||
_clientManager.Get(sender).GetRank() == Rank.ALL &&
|
||||
_achievements.getMineplexLevelNumber(sender, Rank.ALL) < 25 &&
|
||||
!Recharge.Instance.use(sender, "All Chat Message", 3000, false, false))
|
||||
{
|
||||
UtilPlayer.message(sender, C.cYellow + "You can only chat once every 3 seconds to prevent spam.");
|
||||
UtilPlayer.message(sender, C.cYellow + "Buy a Rank at " + C.cGreen + "www.mineplex.com/shop" + C.cYellow + " to remove this limit!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (!_clientManager.Get(sender).GetRank().has(Rank.MODERATOR) &&
|
||||
!Recharge.Instance.use(sender, "Chat Message", 400, false, false))
|
||||
{
|
||||
@ -645,11 +633,6 @@ public class Chat extends MiniPlugin
|
||||
_playerLastMessage.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
public void setThreeSecondDelay(boolean b)
|
||||
{
|
||||
_threeSecondDelay = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the function returns Boolean.TRUE then the message will be CANCELLED.
|
||||
*/
|
||||
|
@ -1,25 +1,23 @@
|
||||
package mineplex.core.cosmetic.ui;
|
||||
|
||||
import mineplex.core.cosmetic.ui.page.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||
import mineplex.core.cosmetic.ui.page.Menu;
|
||||
import mineplex.core.cosmetic.ui.page.PetTagPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
public class CosmeticShop extends ShopBase<CosmeticManager> implements PluginMessageListener
|
||||
{
|
||||
public CosmeticShop(CosmeticManager plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, name, CurrencyType.GEM, CurrencyType.TREASURE_SHARD);
|
||||
super(plugin, clientManager, donationManager, name);
|
||||
|
||||
plugin.getPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.getPlugin(), "MC|ItemName", this);
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package mineplex.core.cosmetic.ui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.cosmetic.ui.page.MountPage;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class MountButton implements IButton
|
||||
{
|
||||
@ -25,13 +23,10 @@ public class MountButton implements IButton
|
||||
@Override
|
||||
public void onClick(final Player player, ClickType clickType)
|
||||
{
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<CosmeticManager, CosmeticShop>(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, _mount, _page.getDonationManager(), () ->
|
||||
{
|
||||
_page.getPlugin().getInventoryManager().addItemToInventory(null, player, _mount.getName(), 1);
|
||||
_page.refresh();
|
||||
}
|
||||
}, _page, _mount, CurrencyType.TREASURE_SHARD, player));
|
||||
}), _mount.buildIcon()));
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,7 @@
|
||||
package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
@ -19,6 +14,10 @@ import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.gadget.types.OutfitGadget;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-15.
|
||||
@ -38,7 +37,7 @@ public class CostumePage extends GadgetPage
|
||||
|
||||
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.COSTUME))
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
|
||||
continue;
|
||||
|
||||
OutfitGadget outfitGadget = ((OutfitGadget) gadget);
|
||||
|
@ -1,12 +1,29 @@
|
||||
package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.banner.CountryFlag;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.button.GadgetButton;
|
||||
import mineplex.core.cosmetic.ui.button.activate.ActivateGadgetButton;
|
||||
import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.event.GadgetChangeEvent;
|
||||
import mineplex.core.gadget.gadgets.morph.MorphBlock;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.gadget.types.HatGadget;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -14,26 +31,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.button.activate.ActivateGadgetButton;
|
||||
import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton;
|
||||
import mineplex.core.cosmetic.ui.button.GadgetButton;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.gadgets.morph.MorphBlock;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.gadget.types.HatGadget;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
@ -50,7 +50,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM))
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -3)
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -3)
|
||||
continue;
|
||||
|
||||
addGadget(gadget, slot);
|
||||
@ -105,64 +105,64 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
if (!gadget.ownsGadget(getPlayer()))
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
|
||||
{
|
||||
//Nothing
|
||||
}
|
||||
//Chest Unlocks
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -2 || gadget.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Treasure Chests");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -3)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -3)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Winter Holiday Treasure");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -4)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -4)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -5)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -5)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -6)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -6)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Valentines Gifts");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -7)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -7)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Purchased from shop.mineplex.com");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Freedom Chests");
|
||||
}
|
||||
|
||||
//Rank Unlocks
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -10)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cAqua + "Unlocked with Ultra Rank");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -11)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -11)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cPurple + "Unlocked with Hero Rank");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -12)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -12)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Unlocked with Legend Rank");
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -13)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -13)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
||||
@ -178,12 +178,12 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
itemLore.add(C.cWhite + "You own " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.getName()));
|
||||
|
||||
// boolean canAffordAmmo = true;
|
||||
// if (itemGadget.getAmmo().getCost(CurrencyType.Coins) > 0)
|
||||
// if (itemGadget.getAmmo().getCost(GlobalCurrency.Coins) > 0)
|
||||
// {
|
||||
// itemLore.add(C.cBlack);
|
||||
// itemLore.add(C.cWhite + ((ItemGadget)gadget).getAmmo().getDisplayName() + " for " + C.cYellow + ((ItemGadget)gadget).getAmmo().getCost(CurrencyType.Coins) + " Coins");
|
||||
// itemLore.add(C.cWhite + ((ItemGadget)gadget).getAmmo().getDisplayName() + " for " + C.cYellow + ((ItemGadget)gadget).getAmmo().getCost(GlobalCurrency.Coins) + " Coins");
|
||||
//
|
||||
// if (getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.Coins) >= itemGadget.getAmmo().getCost(CurrencyType.Coins))
|
||||
// if (getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.Coins) >= itemGadget.getAmmo().getCost(GlobalCurrency.Coins))
|
||||
// {
|
||||
// itemLore.add(C.cGreen + "Right-Click To Purchase");
|
||||
// }
|
||||
@ -239,26 +239,26 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards");
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards");
|
||||
}
|
||||
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD))
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD))
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards");
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards");
|
||||
}
|
||||
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD))
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD))
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Click to Purchase");
|
||||
|
||||
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this));
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||
@ -291,7 +291,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH
|
||||
|| gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP)
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8)
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8)
|
||||
{
|
||||
gadgetItemStack = CountryFlag.USA.getBanner();
|
||||
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
||||
@ -314,7 +314,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
if (gadget.getGadgetType() == GadgetType.ARROW_TRAIL || gadget.getGadgetType() == GadgetType.DEATH
|
||||
|| gadget.getGadgetType() == GadgetType.PARTICLE || gadget.getGadgetType() == GadgetType.DOUBLE_JUMP)
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8)
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -8)
|
||||
{
|
||||
gadgetItemStack = CountryFlag.USA.getBanner();
|
||||
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
|
||||
@ -329,20 +329,20 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards");
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + gadget.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards");
|
||||
}
|
||||
|
||||
if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= gadget.getCost(CurrencyType.TREASURE_SHARD))
|
||||
if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= gadget.getCost(GlobalCurrency.TREASURE_SHARD))
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Click to Purchase");
|
||||
|
||||
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, gadget.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).hideInfo(), new GadgetButton(gadget, this));
|
||||
}
|
||||
else if (gadget.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||
@ -363,7 +363,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
ItemGadget itemGadget = (ItemGadget)gadget;
|
||||
|
||||
if (itemGadget.getAmmo().getCost(CurrencyType.TREASURE_SHARD) < 0)
|
||||
if (itemGadget.getAmmo().getCost(GlobalCurrency.TREASURE_SHARD) < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -372,14 +372,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
||||
return;
|
||||
}
|
||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(player, this, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, gadget, getDonationManager(), () ->
|
||||
{
|
||||
getPlugin().getInventoryManager().addItemToInventory(getPlayer(), gadget.getName(), (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo().getQuantity() : gadget.getQuantity()));
|
||||
refresh();
|
||||
}
|
||||
}, this, (gadget instanceof ItemGadget ? ((ItemGadget) gadget).getAmmo() : gadget), CurrencyType.TREASURE_SHARD, getPlayer()));
|
||||
}), gadget.buildIcon()));
|
||||
}
|
||||
|
||||
public void activateGadget(Player player, Gadget gadget)
|
||||
|
@ -1,24 +1,11 @@
|
||||
package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.cosmetic.ui.button.open.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.button.open.*;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
@ -27,6 +14,15 @@ import mineplex.core.pet.Pet;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
@ -41,7 +37,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
protected void buildPage()
|
||||
{
|
||||
// Treasure Shards
|
||||
int treasureShards = getDonationManager().Get(getPlayer()).getCoins();
|
||||
int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD);
|
||||
|
||||
List<String> shardLore = new ArrayList<String>();
|
||||
shardLore.add(" ");
|
||||
|
@ -1,26 +1,25 @@
|
||||
package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.button.MountButton;
|
||||
import mineplex.core.cosmetic.ui.button.activate.ActivateMountButton;
|
||||
import mineplex.core.cosmetic.ui.button.deactivate.DeactivateMountButton;
|
||||
import mineplex.core.cosmetic.ui.button.MountButton;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
@ -62,58 +61,58 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
if (!getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName()))
|
||||
{
|
||||
if (mount.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
||||
if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
|
||||
{
|
||||
//Nothing
|
||||
}
|
||||
//Chest Unlocks
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -2 || mount.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Treasure Chests");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -3)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -3)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Winter Holiday Treasure");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -4)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -4)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -5)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -5)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -6)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -6)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Valentines Holiday Treasure");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -7)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -7)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Freedom Chests");
|
||||
}
|
||||
//Rank Unlocks
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -10)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -10)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cAqua + "Unlocked with Ultra Rank");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -11)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -11)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cPurple + "Unlocked with Hero Rank");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -12)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -12)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Unlocked with Legend Rank");
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) == -13)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -13)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
||||
@ -139,20 +138,20 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + mount.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards");
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + mount.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards");
|
||||
}
|
||||
|
||||
if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= mount.getCost(CurrencyType.TREASURE_SHARD))
|
||||
if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= mount.getCost(GlobalCurrency.TREASURE_SHARD))
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Click to Purchase");
|
||||
|
||||
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, mount.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new MountButton(mount, this));
|
||||
}
|
||||
else if (mount.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||
|
@ -1,33 +1,16 @@
|
||||
package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Blocks;
|
||||
import net.minecraft.server.v1_8_R3.ChatMessage;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.Items;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.PetSorter;
|
||||
import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton;
|
||||
import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton;
|
||||
import mineplex.core.cosmetic.ui.button.PetButton;
|
||||
import mineplex.core.cosmetic.ui.button.RenamePetButton;
|
||||
import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton;
|
||||
import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.pet.Pet;
|
||||
import mineplex.core.pet.PetExtra;
|
||||
@ -35,6 +18,16 @@ import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.AnvilContainer;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
@ -63,49 +56,49 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
//Chest Unlocks
|
||||
if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
|
||||
{
|
||||
if (pet.getCost(CurrencyType.TREASURE_SHARD) == -1)
|
||||
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
|
||||
{
|
||||
//Nothing
|
||||
}
|
||||
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -2 || pet.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Treasure Chests");
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -3)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -3)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Winter Holiday Treasure");
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -4)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -4)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Halloween Pumpkin Treasure");
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -5)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -5)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
|
||||
}
|
||||
|
||||
//Rank Unlocks
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -10)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -10)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cAqua + "Unlocked with Ultra Rank");
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -11)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -11)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cPurple + "Unlocked with Hero Rank");
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -12)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -12)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Unlocked with Legend Rank");
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) == -13)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -13)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Unlocked with Titan Rank");
|
||||
@ -145,20 +138,20 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
//Not Owned
|
||||
else
|
||||
{
|
||||
if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(CurrencyType.TREASURE_SHARD) + " Treasure Shards");
|
||||
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards");
|
||||
}
|
||||
|
||||
if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).GetBalance(CurrencyType.TREASURE_SHARD) >= pet.getCost(CurrencyType.TREASURE_SHARD))
|
||||
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer().getName()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD))
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cGreen + "Click to Purchase");
|
||||
|
||||
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this));
|
||||
}
|
||||
else if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0)
|
||||
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
|
||||
{
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cRed + "Not enough Treasure Shards.");
|
||||
@ -194,7 +187,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|| getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER
|
||||
|| getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.ZOMBIE)
|
||||
{
|
||||
addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(CurrencyType.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this));
|
||||
addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(GlobalCurrency.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this));
|
||||
}
|
||||
|
||||
slot++;
|
||||
|
@ -2,7 +2,7 @@ package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import mineplex.cache.player.PlayerCache;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -15,11 +15,12 @@ import mineplex.core.pet.Pet;
|
||||
import mineplex.core.pet.PetExtra;
|
||||
import mineplex.core.pet.repository.token.PetChangeToken;
|
||||
import mineplex.core.pet.repository.token.PetToken;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||
import net.minecraft.server.v1_8_R3.Items;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -93,12 +94,11 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
}
|
||||
|
||||
PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100);
|
||||
final SalesPackageBase salesPackage = _petPurchase ? _pet : tag;
|
||||
|
||||
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
|
||||
|
||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<CosmeticManager, CosmeticShop>(getPlugin(), getShop(), getClientManager(), getDonationManager(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(_player, this, new SalesPackageProcessor(_player, GlobalCurrency.TREASURE_SHARD, salesPackage, _donationManager, () ->
|
||||
{
|
||||
PetChangeToken token = new PetChangeToken();
|
||||
|
||||
@ -129,8 +129,7 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName);
|
||||
|
||||
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer()));
|
||||
}
|
||||
}, null, _petPurchase ? _pet : tag, CurrencyType.TREASURE_SHARD, getPlayer()));
|
||||
}), salesPackage.buildIcon()));
|
||||
}
|
||||
|
||||
public void SetTagName(String tagName)
|
||||
|
@ -40,6 +40,8 @@ import java.util.Map.Entry;
|
||||
|
||||
public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
public static DisguiseManager INSTANCE;
|
||||
|
||||
private NautHashMap<Integer, DisguiseBase> _spawnPacketMap = new NautHashMap<Integer, DisguiseBase>();
|
||||
private NautHashMap<Integer, PacketPlayOutEntityVelocity> _movePacketMap = new NautHashMap<Integer, PacketPlayOutEntityVelocity>();
|
||||
private NautHashMap<Integer, PacketPlayOutEntityVelocity> _moveTempMap = new NautHashMap<Integer, PacketPlayOutEntityVelocity>();
|
||||
@ -71,6 +73,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
PacketPlayOutEntityTeleport.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntityLiving.class,
|
||||
PacketPlayOutUpdateAttributes.class, PacketPlayOutEntityEquipment.class, PacketPlayOutNamedSoundEffect.class);
|
||||
|
||||
INSTANCE = this;
|
||||
|
||||
try
|
||||
{
|
||||
_bedChunk = new Chunk(((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(), 0, 0);
|
||||
|
@ -1,36 +1,30 @@
|
||||
package mineplex.core.donation;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import mineplex.cache.player.PlayerCache;
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.ClientWebResponseEvent;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.command.ShardCommand;
|
||||
import mineplex.core.donation.command.GemCommand;
|
||||
import mineplex.core.donation.command.GoldCommand;
|
||||
import mineplex.core.donation.command.SetGoldCommand;
|
||||
import mineplex.core.donation.command.ShardCommand;
|
||||
import mineplex.core.donation.repository.DonationRepository;
|
||||
import mineplex.core.donation.repository.token.DonorTokenWrapper;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DonationManager extends MiniClientPlugin<Donor>
|
||||
{
|
||||
private final int MAX_GIVE_ATTEMPTS = 10;
|
||||
|
||||
@ -38,17 +32,24 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
|
||||
private NautHashMap<Player, NautHashMap<String, Integer>> _gemQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
||||
private NautHashMap<Player, NautHashMap<String, Integer>> _coinQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
||||
private NautHashMap<Player, NautHashMap<String, Integer>> _goldQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
||||
|
||||
private Queue<GiveDonorData> _coinAttemptQueue;
|
||||
private final CoreClientManager _clientManager;
|
||||
|
||||
public DonationManager(JavaPlugin plugin, CoreClientManager clientManager, String webAddress)
|
||||
{
|
||||
super("Donation", plugin, clientManager);
|
||||
super("Donation", plugin);
|
||||
|
||||
_repository = new DonationRepository(plugin, webAddress);
|
||||
|
||||
_coinAttemptQueue = new LinkedList<>();
|
||||
|
||||
_clientManager = clientManager;
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,8 +58,6 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
// TODO: Re-add commands? Where are command implementations, seen as missing at the moment.
|
||||
addCommand(new GemCommand(this));
|
||||
addCommand(new ShardCommand(this));
|
||||
addCommand(new GoldCommand(this));
|
||||
addCommand(new SetGoldCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -74,12 +73,12 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
//_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
||||
}
|
||||
|
||||
public void purchaseUnknownSalesPackage(Callback<TransactionResponse> callback, Player player, String packageName, CurrencyType currencyType, int cost, boolean oneTimePurchase)
|
||||
public void purchaseUnknownSalesPackage(Callback<TransactionResponse> callback, Player player, String packageName, GlobalCurrency currencyType, int cost, boolean oneTimePurchase)
|
||||
{
|
||||
PurchaseUnknownSalesPackage(callback, player.getName(), getClientManager().getAccountId(player), packageName, currencyType, cost, oneTimePurchase);
|
||||
PurchaseUnknownSalesPackage(callback, player.getName(), _clientManager.getAccountId(player), packageName, currencyType, cost, oneTimePurchase);
|
||||
}
|
||||
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost, boolean oneTimePurchase)
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final GlobalCurrency currencyType, final int cost, boolean oneTimePurchase)
|
||||
{
|
||||
final Donor donor = Bukkit.getPlayerExact(name) != null ? Get(name) : null;
|
||||
|
||||
@ -154,7 +153,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
|
||||
if (donor != null)
|
||||
{
|
||||
donor.AddGems(amount);
|
||||
donor.addBalance(GlobalCurrency.GEM, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,7 +180,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
Donor donor = Get(player.getName());
|
||||
|
||||
if (donor != null)
|
||||
donor.AddGems(amount);
|
||||
donor.addBalance(GlobalCurrency.GEM, amount);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -241,7 +240,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
|
||||
if (donor != null)
|
||||
{
|
||||
donor.addCoins(amount);
|
||||
donor.addBalance(GlobalCurrency.TREASURE_SHARD, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -268,7 +267,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
Donor donor = Get(player.getName());
|
||||
|
||||
if (donor != null)
|
||||
donor.addCoins(amount);
|
||||
donor.addBalance(GlobalCurrency.TREASURE_SHARD, amount);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -295,7 +294,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
continue;
|
||||
|
||||
if (player.isOnline() && player.isValid())
|
||||
RewardCoins(null, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
|
||||
RewardCoins(null, caller, player.getName(), _clientManager.Get(player).getAccountId(), total, false);
|
||||
else
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
@ -338,7 +337,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
|
||||
if (donor != null)
|
||||
{
|
||||
donor.addCoins(data.getGiveAmount());
|
||||
donor.addBalance(GlobalCurrency.TREASURE_SHARD, data.getGiveAmount());
|
||||
}
|
||||
|
||||
if (data.getCallback() != null) data.getCallback().run(true);
|
||||
@ -368,164 +367,14 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
||||
|
||||
}
|
||||
|
||||
public void rewardGold(Callback<Boolean> callback, String caller, Player player, int amount)
|
||||
{
|
||||
rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), amount);
|
||||
}
|
||||
|
||||
public void rewardGold(Callback<Boolean> callback, String caller, String name, int accountId, int amount)
|
||||
{
|
||||
rewardGold(callback, caller, name, accountId, amount, true);
|
||||
}
|
||||
|
||||
public void rewardGold(final Callback<Boolean> callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal)
|
||||
{
|
||||
_repository.rewardGold(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
if (updateTotal)
|
||||
{
|
||||
Donor donor = Get(name);
|
||||
|
||||
if (donor != null)
|
||||
{
|
||||
donor.addGold(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("REWARD GOLD FAILED...");
|
||||
}
|
||||
|
||||
if (callback != null)
|
||||
callback.run(success);
|
||||
}
|
||||
}, caller, name, accountId, amount);
|
||||
}
|
||||
|
||||
public void setGold(final Callback<Boolean> callback, final String caller, final String name, final int accountId, final int amount, final boolean updateTotal)
|
||||
{
|
||||
_repository.setGold(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
if (updateTotal)
|
||||
{
|
||||
Donor donor = Get(name);
|
||||
|
||||
if (donor != null)
|
||||
{
|
||||
donor.setGold(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("SET GOLD FAILED...");
|
||||
}
|
||||
|
||||
if (callback != null)
|
||||
callback.run(success);
|
||||
}
|
||||
}, caller, name, accountId, amount);
|
||||
}
|
||||
|
||||
public void RewardGoldLater(final String caller, final Player player, final int amount)
|
||||
{
|
||||
if (!_goldQueue.containsKey(player))
|
||||
_goldQueue.put(player, new NautHashMap<String, Integer>());
|
||||
|
||||
int totalAmount = amount;
|
||||
|
||||
if (_goldQueue.get(player).containsKey(caller))
|
||||
totalAmount += _goldQueue.get(player).get(caller);
|
||||
|
||||
_goldQueue.get(player).put(caller, totalAmount);
|
||||
|
||||
//Do Temp Change
|
||||
Donor donor = Get(player.getName());
|
||||
|
||||
if (donor != null)
|
||||
donor.addGold(amount);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateGoldQueue(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOWER)
|
||||
return;
|
||||
|
||||
for (Player player : _goldQueue.keySet())
|
||||
{
|
||||
updateGoldQueue(null, player);
|
||||
}
|
||||
|
||||
//Clean
|
||||
_goldQueue.clear();
|
||||
}
|
||||
|
||||
public void updateGoldQueue(final Callback<Boolean> callback, final Player player)
|
||||
{
|
||||
String tempCaller = null;
|
||||
int tempTotal = 0;
|
||||
|
||||
for (String curCaller : _goldQueue.get(player).keySet())
|
||||
{
|
||||
tempCaller = curCaller;
|
||||
tempTotal += _goldQueue.get(player).get(curCaller);
|
||||
}
|
||||
|
||||
final String caller = tempCaller;
|
||||
final int total = tempTotal;
|
||||
|
||||
if (caller == null)
|
||||
return;
|
||||
|
||||
if (player.isOnline() && player.isValid())
|
||||
rewardGold(callback, caller, player.getName(), ClientManager.Get(player).getAccountId(), total, false);
|
||||
else
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
rewardGold(callback, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
System.out.println("Queue Added [" + player + "] with Gold [" + total + "] for [" + caller + "]");
|
||||
|
||||
//Clean
|
||||
_goldQueue.get(player).clear();
|
||||
}
|
||||
|
||||
public void applyKits(String playerName)
|
||||
{
|
||||
_repository.applyKits(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
Get(playerName).setGold(_repository.retrieveDonorInfo(resultSet).getGold());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Donor addPlayer(String player)
|
||||
{
|
||||
return new Donor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT gold FROM accounts WHERE id = '" + accountId + "';";
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package mineplex.core.donation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.donation.repository.token.CoinTransactionToken;
|
||||
import mineplex.core.donation.repository.token.DonorToken;
|
||||
import mineplex.core.donation.repository.token.TransactionToken;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Donor
|
||||
{
|
||||
private int _gems;
|
||||
private int _coins;
|
||||
private int _gold;
|
||||
private final Map<GlobalCurrency, Integer> _balances = new HashMap<>();
|
||||
private boolean _donated;
|
||||
private List<Integer> _salesPackagesOwned = new ArrayList<Integer>();
|
||||
private List<String> _unknownSalesPackagesOwned = new ArrayList<String>();
|
||||
@ -25,8 +25,8 @@ public class Donor
|
||||
|
||||
public void loadToken(DonorToken token)
|
||||
{
|
||||
_gems = token.Gems;
|
||||
_coins = token.Coins;
|
||||
_balances.put(GlobalCurrency.GEM, token.Gems);
|
||||
_balances.put(GlobalCurrency.TREASURE_SHARD, token.Coins);
|
||||
_donated = token.Donated;
|
||||
|
||||
_salesPackagesOwned = token.SalesPackages;
|
||||
@ -35,11 +35,6 @@ public class Donor
|
||||
_coinTransactions = token.CoinRewards;
|
||||
}
|
||||
|
||||
public int GetGems()
|
||||
{
|
||||
return _gems;
|
||||
}
|
||||
|
||||
public List<Integer> GetSalesPackagesOwned()
|
||||
{
|
||||
return _salesPackagesOwned;
|
||||
@ -65,47 +60,19 @@ public class Donor
|
||||
return _donated;
|
||||
}
|
||||
|
||||
public void DeductCost(int cost, CurrencyType currencyType)
|
||||
public void DeductCost(int cost, GlobalCurrency currencyType)
|
||||
{
|
||||
switch (currencyType)
|
||||
{
|
||||
case GEM:
|
||||
_gems -= cost;
|
||||
_update = true;
|
||||
break;
|
||||
case TREASURE_SHARD:
|
||||
_coins -= cost;
|
||||
_update = true;
|
||||
break;
|
||||
case GOLD:
|
||||
_gold -= cost;
|
||||
_update = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
addBalance(currencyType, -cost);
|
||||
}
|
||||
|
||||
public int GetBalance(CurrencyType currencyType)
|
||||
public int getBalance(GlobalCurrency currencyType)
|
||||
{
|
||||
switch (currencyType)
|
||||
{
|
||||
case GEM:
|
||||
return _gems;
|
||||
case TREASURE_SHARD:
|
||||
return _coins;
|
||||
case GOLD:
|
||||
return _gold;
|
||||
case TOKEN:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return _balances.getOrDefault(currencyType, 0);
|
||||
}
|
||||
|
||||
public void AddGems(int gems)
|
||||
public void addBalance(GlobalCurrency currencyType, int amount)
|
||||
{
|
||||
_gems += gems;
|
||||
_balances.merge(currencyType, amount, Integer::sum);
|
||||
}
|
||||
|
||||
public boolean OwnsUnknownPackage(String packageName)
|
||||
@ -144,33 +111,9 @@ public class Donor
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getCoins()
|
||||
{
|
||||
return _coins;
|
||||
}
|
||||
|
||||
public void addCoins(int amount)
|
||||
{
|
||||
_coins += amount;
|
||||
}
|
||||
|
||||
public void addGold(int amount)
|
||||
{
|
||||
_gold = Math.max(0, _gold + amount);
|
||||
}
|
||||
|
||||
public void setGold(int amount)
|
||||
{
|
||||
_gold = Math.max(0, amount);
|
||||
}
|
||||
|
||||
public List<CoinTransactionToken> getCoinTransactions()
|
||||
{
|
||||
return _coinTransactions;
|
||||
}
|
||||
|
||||
public int getGold()
|
||||
{
|
||||
return _gold;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,20 @@
|
||||
package mineplex.core.donation.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.Currency;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.DatabaseRunnable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.core.donation.repository.token.GemRewardToken;
|
||||
import mineplex.core.donation.repository.token.PurchaseToken;
|
||||
import mineplex.core.donation.repository.token.UnknownPurchaseToken;
|
||||
import mineplex.core.server.remotecall.AsyncJsonWebCall;
|
||||
import mineplex.core.server.remotecall.JsonWebCall;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.DatabaseRunnable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class DonationRepository extends MinecraftRepository
|
||||
{
|
||||
@ -26,8 +22,6 @@ public class DonationRepository extends MinecraftRepository
|
||||
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);";
|
||||
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;";
|
||||
private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ? && gold >= ?;";
|
||||
private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;";
|
||||
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;";
|
||||
|
||||
private String _webAddress;
|
||||
@ -70,12 +64,12 @@ public class DonationRepository extends MinecraftRepository
|
||||
}), "Error purchasing known sales package in DonationRepository : ");
|
||||
}
|
||||
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost)
|
||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final Currency currencyType, final int cost)
|
||||
{
|
||||
final UnknownPurchaseToken token = new UnknownPurchaseToken();
|
||||
token.AccountName = name;
|
||||
token.SalesPackageName = packageName;
|
||||
token.CoinPurchase = currencyType == CurrencyType.TREASURE_SHARD;
|
||||
token.CoinPurchase = currencyType == GlobalCurrency.TREASURE_SHARD;
|
||||
token.Cost = cost;
|
||||
token.Premium = false;
|
||||
|
||||
@ -85,15 +79,11 @@ public class DonationRepository extends MinecraftRepository
|
||||
{
|
||||
if (response == TransactionResponse.Success)
|
||||
{
|
||||
if (currencyType == CurrencyType.TREASURE_SHARD)
|
||||
if (currencyType == GlobalCurrency.TREASURE_SHARD)
|
||||
{
|
||||
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnInt("id", accountId));
|
||||
//executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost));
|
||||
}
|
||||
else if (currencyType == CurrencyType.GOLD)
|
||||
{
|
||||
executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", -cost), new ColumnInt("id", accountId));
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
@ -184,35 +174,6 @@ public class DonationRepository extends MinecraftRepository
|
||||
}), "Error updating player coin amount in DonationRepository : ");
|
||||
}
|
||||
|
||||
public void rewardGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold)
|
||||
{
|
||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
ColumnInt min = new ColumnInt("gold", gold < 0 ? -gold : 0);
|
||||
boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId), min) > 0;
|
||||
callback.run(success);
|
||||
}
|
||||
}), "Error updating player gold amount in DonationRepository : ");
|
||||
}
|
||||
|
||||
public void setGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold)
|
||||
{
|
||||
if (gold < 0)
|
||||
{
|
||||
throw new IllegalArgumentException("gold cannot be negative");
|
||||
}
|
||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
boolean success = executeUpdate(SET_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0;
|
||||
callback.run(success);
|
||||
}
|
||||
}), "Error updating player gold amount in DonationRepository : ");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
@ -240,16 +201,4 @@ public class DonationRepository extends MinecraftRepository
|
||||
{
|
||||
new AsyncJsonWebCall(_webAddress + "PlayerAccount/ApplyKits").Execute(playerName);
|
||||
}
|
||||
|
||||
public Donor retrieveDonorInfo(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
Donor donor = new Donor();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
donor.setGold(resultSet.getInt(1));
|
||||
}
|
||||
|
||||
return donor;
|
||||
}
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
package mineplex.core.gadget.gadgets;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class Ammo extends SalesPackageBase
|
||||
{
|
||||
@ -16,9 +13,4 @@ public class Ammo extends SalesPackageBase
|
||||
KnownPackage = false;
|
||||
OneTimePurchaseOnly = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
package mineplex.core.gadget.gadgets.morph;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.disguise.disguises.DisguiseRabbit;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,28 +25,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.disguises.DisguiseRabbit;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class MorphBunny extends MorphGadget
|
||||
{
|
||||
@ -151,7 +136,7 @@ public class MorphBunny extends MorphGadget
|
||||
if (!UtilEvent.isAction(event, ActionType.L))
|
||||
return;
|
||||
|
||||
if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.TREASURE_SHARD) < 500)
|
||||
if (Manager.getDonationManager().Get(player.getName()).getBalance(GlobalCurrency.TREASURE_SHARD) < 500)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards."));
|
||||
return;
|
||||
|
@ -1,8 +1,16 @@
|
||||
package mineplex.core.gadget.gadgets.morph;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.disguise.disguises.DisguiseVillager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Material;
|
||||
@ -12,27 +20,12 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.disguise.disguises.DisguiseVillager;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class MorphVillager extends MorphGadget implements IThrown
|
||||
{
|
||||
@ -81,7 +74,7 @@ public class MorphVillager extends MorphGadget implements IThrown
|
||||
if (!UtilEvent.isAction(event, ActionType.L))
|
||||
return;
|
||||
|
||||
if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.GEM) < 20)
|
||||
if (Manager.getDonationManager().Get(player.getName()).getBalance(GlobalCurrency.GEM) < 20)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Gems."));
|
||||
return;
|
||||
|
@ -1,17 +1,13 @@
|
||||
package mineplex.core.gadget.types;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.GadgetAppliedEvent;
|
||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||
import mineplex.core.gadget.event.GadgetDisableEvent;
|
||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,6 +15,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public abstract class Gadget extends SalesPackageBase implements Listener
|
||||
{
|
||||
public GadgetManager Manager;
|
||||
@ -152,12 +150,6 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
||||
UtilPlayer.message(player, F.main("Gadget", "You disabled " + F.elem(getName()) + "."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean ownsGadget(Player player)
|
||||
{
|
||||
if(isFree() || _free) return true;
|
||||
|
@ -215,12 +215,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
Get(from).LastToTime = System.currentTimeMillis();
|
||||
|
||||
// Chiss or defek7
|
||||
if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("AlexTheCoder"))
|
||||
{
|
||||
UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development.");
|
||||
UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
|
||||
}
|
||||
if (to.getName().equals("xXVevzZXx"))
|
||||
if (GetClientManager().Get(to).GetRank() == Rank.DEVELOPER)
|
||||
{
|
||||
UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development.");
|
||||
UtilPlayer.message(from, C.cPurple + "Please be patient if she does not reply instantly.");
|
||||
|
@ -1,8 +1,10 @@
|
||||
package mineplex.core.mount;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -12,12 +14,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public abstract class Mount<T extends MountData> extends SalesPackageBase implements Listener
|
||||
{
|
||||
@ -35,12 +33,6 @@ public abstract class Mount<T extends MountData> extends SalesPackageBase implem
|
||||
Manager.getPlugin().getServer().getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public final void enable(Player player)
|
||||
{
|
||||
MountActivateEvent gadgetEvent = new MountActivateEvent(player, this);
|
||||
|
@ -17,6 +17,7 @@ import net.md_5.bungee.api.chat.ClickEvent.Action;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -124,6 +125,7 @@ public class PartyInviteManager
|
||||
inviteTo(player.getUniqueId(), sender, sender, serverFrom);
|
||||
Lang.INVITE_RECEIVED.send(player, sender);
|
||||
sendAcceptOrDeny(player, sender);
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,12 +139,7 @@ public class PartyRedisManager
|
||||
|
||||
case PLAYER_FIND_RESPONSE:
|
||||
UUID uuid = UUID.fromString(third);
|
||||
BukkitTask task = TASKS.remove(second);
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
task.cancel();
|
||||
}
|
||||
cancelTask(second);
|
||||
|
||||
Player inviter = Bukkit.getPlayerExact(contents[3]);
|
||||
if (_plugin.getInviteManager().isInvitedTo(uuid, inviter.getName()))
|
||||
@ -177,12 +172,7 @@ public class PartyRedisManager
|
||||
|
||||
private void handleNotAccepting(String second, String[] contents)
|
||||
{
|
||||
BukkitTask task = TASKS.remove(second);
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
task.cancel();
|
||||
}
|
||||
cancelTask(second);
|
||||
|
||||
Player inviter = Bukkit.getPlayerExact(contents[3]);
|
||||
inviter.sendMessage(F.main("Party", F.name(second) + " is not accepting invites at this time."));
|
||||
@ -190,13 +180,7 @@ public class PartyRedisManager
|
||||
|
||||
private void handleAlreadyIn(String second, String[] contents)
|
||||
{
|
||||
BukkitTask task = TASKS.remove(second);
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
cancelTask(second);
|
||||
Player inviter = Bukkit.getPlayerExact(contents[3]);
|
||||
Lang.ALREADY_IN.send(inviter, second);
|
||||
}
|
||||
@ -215,6 +199,11 @@ public class PartyRedisManager
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(!TASKS.containsKey(player))
|
||||
{
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
TASKS.remove(player);
|
||||
Player senderPlayer = Bukkit.getPlayerExact(sender);
|
||||
if (senderPlayer == null)
|
||||
@ -293,4 +282,14 @@ public class PartyRedisManager
|
||||
{
|
||||
return FIND_PLAYERS_CHANNEL;
|
||||
}
|
||||
|
||||
public void cancelTask(String player)
|
||||
{
|
||||
BukkitTask task = TASKS.remove(player);
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
package mineplex.core.pet;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.pet.repository.token.PetSalesToken;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Pet extends SalesPackageBase
|
||||
{
|
||||
@ -19,7 +17,7 @@ public class Pet extends SalesPackageBase
|
||||
|
||||
_name = name;
|
||||
_petType = petType;
|
||||
CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, cost);
|
||||
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost);
|
||||
|
||||
KnownPackage = false;
|
||||
}
|
||||
@ -38,10 +36,4 @@ public class Pet extends SalesPackageBase
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
package mineplex.core.pet;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.pet.repository.token.PetExtraToken;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PetExtra extends SalesPackageBase
|
||||
{
|
||||
@ -18,7 +16,7 @@ public class PetExtra extends SalesPackageBase
|
||||
|
||||
_name = name;
|
||||
_material = material;
|
||||
CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, cost);
|
||||
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost);
|
||||
|
||||
KnownPackage = false;
|
||||
OneTimePurchaseOnly = false;
|
||||
@ -38,9 +36,4 @@ public class PetExtra extends SalesPackageBase
|
||||
{
|
||||
return _material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTabTitle;
|
||||
import mineplex.core.party.Lang;
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.event.PartySendToServerEvent;
|
||||
import mineplex.core.portal.Commands.SendCommand;
|
||||
@ -95,16 +96,27 @@ public class Portal extends MiniPlugin
|
||||
ServerTransferEvent event = new ServerTransferEvent(player, serverName, draggedByParty);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
final boolean override = serverName.equalsIgnoreCase("Lobby");
|
||||
final boolean override = serverName.equalsIgnoreCase("Lobby") || serverName.equalsIgnoreCase("ClansHub");
|
||||
final Rank playerRank = _clientManager.Get(player).GetRank();
|
||||
|
||||
if (event.getParty() != null && override)
|
||||
{
|
||||
Party party = event.getParty();
|
||||
if(!party.getOwner().equalsIgnoreCase(player.getName()))
|
||||
{
|
||||
Lang.NOT_OWNER_SERVER.send(player);
|
||||
return;
|
||||
}
|
||||
sendParty(party);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getParty() != null && serverName.toUpperCase().startsWith("CLANS-"))
|
||||
{
|
||||
event.getParty().sendMessage(F.main(getName(), "You cannot join Clans while in a party!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (override)
|
||||
{
|
||||
sendPlayer(player, serverName);
|
||||
|
@ -88,6 +88,15 @@ public class ProjectileManager extends MiniPlugin
|
||||
sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult));
|
||||
}
|
||||
|
||||
public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback,
|
||||
long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle,
|
||||
Sound sound, float soundVolume, float soundPitch, ParticleType particle, UpdateType effectRate, float hitboxMult, double charge)
|
||||
{
|
||||
_thrown.put(thrown, new ProjectileUser(this, thrown, thrower, callback,
|
||||
expireTime, hitPlayer, hitNonPlayerEntity, hitBlock, idle, false,
|
||||
sound, soundVolume, soundPitch, null, 0, effectRate, particle, 0F, 0F, 0F, 0F, 1, hitboxMult, charge));
|
||||
}
|
||||
|
||||
public void AddThrow(Entity thrown, LivingEntity thrower, IThrown callback,
|
||||
long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle,
|
||||
Sound sound, float soundVolume, float soundPitch, ParticleType particle, float pX, float pY, float pZ, float pS, int pC, UpdateType effectRate, float hitboxMult)
|
||||
|
@ -63,6 +63,8 @@ public class ProjectileUser
|
||||
|
||||
private double _hitboxGrow;
|
||||
|
||||
private double _charge;
|
||||
|
||||
private List<Player> _canHit;
|
||||
|
||||
public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback,
|
||||
@ -104,6 +106,47 @@ public class ProjectileUser
|
||||
_canHit = null;
|
||||
}
|
||||
|
||||
public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback,
|
||||
long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup,
|
||||
Sound sound, float soundVolume, float soundPitch,
|
||||
Effect effect, int effectData, UpdateType effectRate,
|
||||
ParticleType particle, float particleX, float particleY,
|
||||
float particleZ, float particleS, int particleC, double hitboxMult, double charge)
|
||||
{
|
||||
Throw = throwInput;
|
||||
|
||||
_thrown = thrown;
|
||||
_thrower = thrower;
|
||||
_callback = callback;
|
||||
|
||||
_expireTime = expireTime;
|
||||
_startTime = System.currentTimeMillis();
|
||||
|
||||
_hitPlayer = hitPlayer;
|
||||
_hitNonPlayerEntity = hitNonPlayerEntity;
|
||||
_hitBlock = hitBlock;
|
||||
_idle = idle;
|
||||
_pickup = pickup;
|
||||
|
||||
_sound = sound;
|
||||
_soundVolume = soundVolume;
|
||||
_soundPitch = soundPitch;
|
||||
_particle = particle;
|
||||
_particleX = particleX;
|
||||
_particleY = particleY;
|
||||
_particleZ = particleZ;
|
||||
_particleS = particleS;
|
||||
_particleC = particleC;
|
||||
_effect = effect;
|
||||
_effectData = effectData;
|
||||
_effectRate = effectRate;
|
||||
|
||||
_hitboxGrow = hitboxMult;
|
||||
_canHit = null;
|
||||
|
||||
_charge = charge;
|
||||
}
|
||||
|
||||
public ProjectileUser(ProjectileManager throwInput, Entity thrown, LivingEntity thrower, IThrown callback,
|
||||
long expireTime, boolean hitPlayer, boolean hitNonPlayerEntity, boolean hitBlock, boolean idle, boolean pickup,
|
||||
Sound sound, float soundVolume, float soundPitch,
|
||||
@ -143,6 +186,7 @@ public class ProjectileUser
|
||||
_canHit = canHit;
|
||||
}
|
||||
|
||||
|
||||
public void effect(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != _effectRate)
|
||||
@ -312,6 +356,11 @@ public class ProjectileUser
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getCharge()
|
||||
{
|
||||
return _charge;
|
||||
}
|
||||
|
||||
public IThrown getIThrown()
|
||||
{
|
||||
return _callback;
|
||||
|
@ -1,14 +1,13 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.reward.RewardType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
@ -34,7 +33,7 @@ public class UnknownPackageReward extends Reward
|
||||
@Override
|
||||
protected RewardData giveRewardCustom(Player player, RewardType type)
|
||||
{
|
||||
_donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, CurrencyType.TREASURE_SHARD, 0, true);
|
||||
_donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, GlobalCurrency.TREASURE_SHARD, 0, true);
|
||||
|
||||
return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + _name, _itemStack, getRarity());
|
||||
}
|
||||
|
@ -95,6 +95,8 @@ public class PlayerScoreboard
|
||||
ArrayList<String> lines = data.getLines(manager, player);
|
||||
|
||||
for (int i=0 ; i<lines.size() ; i++)
|
||||
{
|
||||
if ((15-i) >= 0)
|
||||
{
|
||||
//Get New Line
|
||||
String newLine = lines.get(i);
|
||||
@ -127,6 +129,7 @@ public class PlayerScoreboard
|
||||
//Line
|
||||
_sideObjective.getScore(_teamNames[i]).setScore(15-i);
|
||||
}
|
||||
}
|
||||
|
||||
//Hide Old Unused
|
||||
if (_currentLines.size() > lines.size())
|
||||
|
@ -1,12 +1,11 @@
|
||||
package mineplex.core.scoreboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.scoreboard.elements.*;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ScoreboardData
|
||||
{
|
||||
private ArrayList<ScoreboardElement> _elements = new ArrayList<ScoreboardElement>();
|
||||
@ -96,11 +95,6 @@ public class ScoreboardData
|
||||
_elements.add(new ScoreboardElementText(" "));
|
||||
}
|
||||
|
||||
public void writePlayerGold()
|
||||
{
|
||||
_elements.add(new ScoreboardElementGoldCount());
|
||||
}
|
||||
|
||||
public void writePlayerGems()
|
||||
{
|
||||
_elements.add(new ScoreboardElementGemCount());
|
||||
|
@ -1,20 +1,19 @@
|
||||
package mineplex.core.scoreboard.elements;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
|
||||
public class ScoreboardElementCoinCount implements ScoreboardElement
|
||||
{
|
||||
@Override
|
||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||
{
|
||||
List<String> output = new ArrayList<String>();
|
||||
output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.TREASURE_SHARD) + "");
|
||||
output.add(manager.getDonation().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) + "");
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
package mineplex.core.scoreboard.elements;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
|
||||
public class ScoreboardElementGemCount implements ScoreboardElement
|
||||
{
|
||||
@Override
|
||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||
{
|
||||
List<String> output = new ArrayList<String>();
|
||||
output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.GEM) + "");
|
||||
output.add(manager.getDonation().Get(player).getBalance(GlobalCurrency.GEM) + "");
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
package mineplex.core.scoreboard.elements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
|
||||
public class ScoreboardElementGoldCount implements ScoreboardElement
|
||||
{
|
||||
@Override
|
||||
public List<String> getLines(ScoreboardManager manager, Player player, List<String> out)
|
||||
{
|
||||
List<String> output = new ArrayList<String>();
|
||||
output.add(manager.getDonation().Get(player).GetBalance(CurrencyType.GOLD) + "");
|
||||
return output;
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package mineplex.core.shop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
||||
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
|
||||
@ -22,22 +23,13 @@ import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
||||
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import java.util.HashSet;
|
||||
|
||||
public abstract class ShopBase<PluginType extends MiniPlugin> implements Listener
|
||||
{
|
||||
private NautHashMap<String, Long> _errorThrottling;
|
||||
private NautHashMap<String, Long> _purchaseBlock;
|
||||
|
||||
private List<CurrencyType> _availableCurrencyTypes = new ArrayList<CurrencyType>();
|
||||
|
||||
private PluginType _plugin;
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
@ -46,7 +38,7 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
|
||||
private HashSet<String> _openedShop = new HashSet<String>();
|
||||
|
||||
public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes)
|
||||
public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_clientManager = clientManager;
|
||||
@ -57,17 +49,9 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
_errorThrottling = new NautHashMap<String, Long>();
|
||||
_purchaseBlock = new NautHashMap<String, Long>();
|
||||
|
||||
if (currencyTypes != null && currencyTypes.length > 0)
|
||||
_availableCurrencyTypes.addAll(Arrays.asList(currencyTypes));
|
||||
|
||||
_plugin.registerEvents(this);
|
||||
}
|
||||
|
||||
public List<CurrencyType> getAvailableCurrencyTypes()
|
||||
{
|
||||
return _availableCurrencyTypes;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerDamageEntity(NpcDamageByEntityEvent event)
|
||||
{
|
||||
|
@ -31,11 +31,21 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
||||
private ConfirmationProcessor _processor;
|
||||
private boolean _processing;
|
||||
|
||||
public ConfirmationPage(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, Player player, ShopPageBase<PluginType, ShopType> returnPage, ConfirmationProcessor processor, ItemStack displayItem)
|
||||
public ConfirmationPage(Player player, ShopPageBase<PluginType, ShopType> returnPage, ConfirmationProcessor processor, ItemStack displayItem)
|
||||
{
|
||||
super(returnPage.getPlugin(), returnPage.getShop(), returnPage.getClientManager(), returnPage.getDonationManager(), "Confirmation", player);
|
||||
|
||||
_returnPage = returnPage;
|
||||
_displayItem = displayItem;
|
||||
_processor = processor;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
public ConfirmationPage(Player player, PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, ConfirmationProcessor processor, ItemStack displayItem)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "Confirmation", player);
|
||||
|
||||
_returnPage = returnPage;
|
||||
_displayItem = displayItem;
|
||||
_processor = processor;
|
||||
|
||||
@ -49,6 +59,8 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
||||
|
||||
buildSquareAt(_okSquareSlotStart, new ShopItem(Material.EMERALD_BLOCK, (byte) 0, ChatColor.GREEN + "OK", null, 1, false, true), this::okClicked);
|
||||
buildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.REDSTONE_BLOCK, (byte) 0, ChatColor.RED + "CANCEL", null, 1, false, true), this::cancelClicked);
|
||||
|
||||
_processor.init(this);
|
||||
}
|
||||
|
||||
protected void okClicked(Player player, ClickType clickType)
|
||||
|
@ -1,9 +1,12 @@
|
||||
package mineplex.core.shop.confirmation;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
*/
|
||||
public interface ConfirmationProcessor
|
||||
{
|
||||
public void init(Inventory inventory);
|
||||
public void process(ConfirmationCallback callback);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package mineplex.core.shop.item;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.donation.repository.GameSalesPackageToken;
|
||||
|
||||
public interface ICurrencyPackage
|
||||
{
|
||||
int getSalesPackageId();
|
||||
int getCost(CurrencyType currencytype);
|
||||
int getCost(GlobalCurrency currencytype);
|
||||
boolean isFree();
|
||||
void update(GameSalesPackageToken token);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package mineplex.core.shop.item;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.repository.GameSalesPackageToken;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPackage
|
||||
{
|
||||
@ -20,7 +20,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
||||
|
||||
protected int SalesPackageId;
|
||||
protected boolean Free;
|
||||
protected NautHashMap<CurrencyType, Integer> CurrencyCostMap;
|
||||
protected NautHashMap<GlobalCurrency, Integer> CurrencyCostMap;
|
||||
protected boolean KnownPackage = true;
|
||||
protected boolean OneTimePurchaseOnly = true;
|
||||
|
||||
@ -41,7 +41,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
||||
|
||||
public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins, int quantity)
|
||||
{
|
||||
CurrencyCostMap = new NautHashMap<CurrencyType, Integer>();
|
||||
CurrencyCostMap = new NautHashMap<>();
|
||||
|
||||
Name = name;
|
||||
DisplayName = name;
|
||||
@ -49,12 +49,10 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
||||
_displayMaterial = material;
|
||||
_displayData = displayData;
|
||||
|
||||
CurrencyCostMap.put(CurrencyType.TREASURE_SHARD, coins);
|
||||
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, coins);
|
||||
Quantity = quantity;
|
||||
}
|
||||
|
||||
public abstract void sold(Player player, CurrencyType currencyType);
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
@ -68,7 +66,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost(CurrencyType currencyType)
|
||||
public int getCost(GlobalCurrency currencyType)
|
||||
{
|
||||
return CurrencyCostMap.containsKey(currencyType) ? CurrencyCostMap.get(currencyType) : 0;
|
||||
}
|
||||
@ -105,7 +103,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
||||
|
||||
if (token.Gems > 0)
|
||||
{
|
||||
CurrencyCostMap.put(CurrencyType.GEM, token.Gems);
|
||||
CurrencyCostMap.put(GlobalCurrency.GEM, token.Gems);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,4 +131,9 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
||||
{
|
||||
DisplayName = name;
|
||||
}
|
||||
|
||||
public ItemStack buildIcon()
|
||||
{
|
||||
return new ItemBuilder(_displayMaterial).setData(_displayData).setTitle(DisplayName).addLore(Description).build();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
package mineplex.core.shop.item;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
||||
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class SalesPackageProcessor implements ConfirmationProcessor {
|
||||
private final GlobalCurrency _currencyType;
|
||||
private final SalesPackageBase _salesItem;
|
||||
private final DonationManager _donationManager;
|
||||
private final Player _player;
|
||||
private final Runnable _runAfterPurchase;
|
||||
|
||||
public SalesPackageProcessor(Player player, GlobalCurrency currencyType, SalesPackageBase salesItem, DonationManager donationManager, Runnable runAfterPurchase)
|
||||
{
|
||||
_currencyType = currencyType;
|
||||
_salesItem = salesItem;
|
||||
_donationManager = donationManager;
|
||||
_player = player;
|
||||
_runAfterPurchase = runAfterPurchase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Inventory inventory)
|
||||
{
|
||||
inventory.setItem(4, new ItemBuilder(_currencyType.getDisplayMaterial()).setTitle(_currencyType.getPrefix()).addLore(C.cGray + _salesItem.getCost(_currencyType) + " " + _currencyType.getPrefix() + " will be", C.cGray + "deducted from your account balance").build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ConfirmationCallback callback)
|
||||
{
|
||||
if (_salesItem.isKnown())
|
||||
{
|
||||
_donationManager.PurchaseKnownSalesPackage(response -> showResults(callback, response), _player.getName(), _player.getUniqueId(), _salesItem.getCost(_currencyType), _salesItem.getSalesPackageId());
|
||||
}
|
||||
else
|
||||
{
|
||||
_donationManager.PurchaseUnknownSalesPackage(response -> showResults(callback, response), _player.getName(), _donationManager.getClientManager().Get(_player).getAccountId(), _salesItem.getName(), _currencyType, _salesItem.getCost(_currencyType), _salesItem.oneTimePurchase());
|
||||
}
|
||||
}
|
||||
|
||||
private void showResults(ConfirmationCallback callback, TransactionResponse response)
|
||||
{
|
||||
switch (response)
|
||||
{
|
||||
case Failed:
|
||||
callback.reject("There was an error processing your request.");
|
||||
break;
|
||||
case AlreadyOwns:
|
||||
callback.reject("You already own this package.");
|
||||
break;
|
||||
case InsufficientFunds:
|
||||
callback.reject("Your account has insufficient funds.");
|
||||
break;
|
||||
case Success:
|
||||
callback.resolve("Your purchase was successful.");
|
||||
|
||||
if (_runAfterPurchase != null)
|
||||
_runAfterPurchase.run();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,328 +0,0 @@
|
||||
package mineplex.core.shop.page;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
|
||||
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends ShopPageBase<PluginType, ShopType> implements Runnable
|
||||
{
|
||||
private Runnable _runnable;
|
||||
private ShopPageBase<PluginType, ShopType> _returnPage;
|
||||
private SalesPackageBase _salesItem;
|
||||
private int _okSquareSlotStart;
|
||||
private boolean _processing;
|
||||
private int _progressCount;
|
||||
private ShopItem _progressItem;
|
||||
private int _taskId;
|
||||
|
||||
public ConfirmationPage(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, Runnable runnable, ShopPageBase<PluginType, ShopType> returnPage, SalesPackageBase salesItem, CurrencyType currencyType, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, " Confirmation", player);
|
||||
|
||||
_runnable = runnable;
|
||||
_returnPage = returnPage;
|
||||
_salesItem = salesItem;
|
||||
setCurrencyType(currencyType);
|
||||
_progressItem = new ShopItem(Material.LAPIS_BLOCK, (byte)11, ChatColor.BLUE + "Processing", null, 1, false, true);
|
||||
_okSquareSlotStart = 27;
|
||||
|
||||
if (getShop().canPlayerAttemptPurchase(player))
|
||||
{
|
||||
buildPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
buildErrorPage(new String[]{ChatColor.RED + "You have attempted too many invalid transactions.", ChatColor.RED + "Please wait 10 seconds before retrying."});
|
||||
_taskId = plugin.getScheduler().scheduleSyncRepeatingTask(plugin.getPlugin(), this, 2L, 2L);
|
||||
}
|
||||
}
|
||||
|
||||
protected void buildPage()
|
||||
{
|
||||
this.getInventory().setItem(22, new ShopItem(_salesItem.getDisplayMaterial(), (byte)0, _salesItem.getDisplayName(), _salesItem.getDescription(), 1, false, true).getHandle());
|
||||
|
||||
IButton okClicked = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
okClicked(player);
|
||||
}
|
||||
};
|
||||
|
||||
IButton cancelClicked = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
cancelClicked(player);
|
||||
}
|
||||
};
|
||||
|
||||
buildSquareAt(_okSquareSlotStart, new ShopItem(Material.EMERALD_BLOCK, (byte) 0, ChatColor.GREEN + "OK", null, 1, false, true), okClicked);
|
||||
buildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.REDSTONE_BLOCK, (byte) 0, ChatColor.RED + "CANCEL", null, 1, false, true), cancelClicked);
|
||||
|
||||
this.getInventory().setItem(4, new ShopItem(getCurrencyType().getDisplayMaterial(), (byte)0, getCurrencyType().getPrefix(), new String[] { C.cGray + _salesItem.getCost(getCurrencyType()) + " " + getCurrencyType().getPrefix() + " will be", C.cGray + "deducted from your account balance." }, 1, false, true).getHandle());
|
||||
}
|
||||
|
||||
protected void okClicked(Player player)
|
||||
{
|
||||
processTransaction();
|
||||
}
|
||||
|
||||
protected void cancelClicked(Player player)
|
||||
{
|
||||
getPlugin().getScheduler().cancelTask(_taskId);
|
||||
|
||||
if (_returnPage != null)
|
||||
getShop().openPageForPlayer(player, _returnPage);
|
||||
else
|
||||
{
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buildSquareAt(int slot, ShopItem item, IButton button)
|
||||
{
|
||||
addButton(slot, item, button);
|
||||
addButton(slot + 1, item, button);
|
||||
addButton(slot + 2, item, button);
|
||||
|
||||
slot += 9;
|
||||
|
||||
addButton(slot, item, button);
|
||||
addButton(slot + 1, item, button);
|
||||
addButton(slot + 2, item, button);
|
||||
|
||||
slot += 9;
|
||||
|
||||
addButton(slot, item, button);
|
||||
addButton(slot + 1, item, button);
|
||||
addButton(slot + 2, item, button);
|
||||
}
|
||||
|
||||
private void processTransaction()
|
||||
{
|
||||
for (int i=_okSquareSlotStart; i < 54; i++)
|
||||
{
|
||||
getButtonMap().remove(i);
|
||||
clear(i);
|
||||
}
|
||||
|
||||
_processing = true;
|
||||
|
||||
if (getCurrencyType() == CurrencyType.GOLD)
|
||||
{
|
||||
int goldCount = getDonationManager().Get(getPlayer()).getGold();
|
||||
int cost = _salesItem.getCost(getCurrencyType());
|
||||
|
||||
if (cost > goldCount)
|
||||
showResultsPage(TransactionResponse.InsufficientFunds);
|
||||
else
|
||||
{
|
||||
getDonationManager().rewardGold(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
showResultsPage(TransactionResponse.Success);
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
showResultsPage(TransactionResponse.Failed);
|
||||
}
|
||||
}
|
||||
}, "Energy Purchase", getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), -cost);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_salesItem.isKnown())
|
||||
{
|
||||
getDonationManager().PurchaseKnownSalesPackage(new Callback<TransactionResponse>()
|
||||
{
|
||||
public void run(TransactionResponse response)
|
||||
{
|
||||
showResultsPage(response);
|
||||
}
|
||||
}, getPlayer().getName(), getPlayer().getUniqueId(), _salesItem.getCost(getCurrencyType()), _salesItem.getSalesPackageId());
|
||||
}
|
||||
else
|
||||
{
|
||||
getDonationManager().PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
|
||||
{
|
||||
public void run(TransactionResponse response)
|
||||
{
|
||||
showResultsPage(response);
|
||||
}
|
||||
}, getPlayer().getName(), getClientManager().Get(getPlayer()).getAccountId(), _salesItem.getName(), getCurrencyType(), _salesItem.getCost(getCurrencyType()), _salesItem.oneTimePurchase());
|
||||
}
|
||||
}
|
||||
|
||||
_taskId = getPlugin().getScheduler().scheduleSyncRepeatingTask(getPlugin().getPlugin(), this, 2L, 2L);
|
||||
}
|
||||
|
||||
private void showResultsPage(TransactionResponse response)
|
||||
{
|
||||
_processing = false;
|
||||
|
||||
switch (response)
|
||||
{
|
||||
case Failed:
|
||||
buildErrorPage(ChatColor.RED + "There was an error processing your request.");
|
||||
getShop().addPlayerProcessError(getPlayer());
|
||||
break;
|
||||
case AlreadyOwns:
|
||||
buildErrorPage(ChatColor.RED + "You already own this package.");
|
||||
getShop().addPlayerProcessError(getPlayer());
|
||||
break;
|
||||
case InsufficientFunds:
|
||||
buildErrorPage(ChatColor.RED + "Your account has insufficient funds.");
|
||||
getShop().addPlayerProcessError(getPlayer());
|
||||
break;
|
||||
case Success:
|
||||
_salesItem.sold(getPlayer(), getCurrencyType());
|
||||
|
||||
buildSuccessPage("Your purchase was successful.");
|
||||
|
||||
if (_runnable != null)
|
||||
_runnable.run();
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_progressCount = 0;
|
||||
}
|
||||
|
||||
private void buildErrorPage(String... message)
|
||||
{
|
||||
IButton returnButton = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
cancelClicked(player);
|
||||
}
|
||||
};
|
||||
|
||||
ShopItem item = new ShopItem(Material.REDSTONE_BLOCK, (byte)0, ChatColor.RED + "" + ChatColor.UNDERLINE + "ERROR", message, 1, false, true);
|
||||
for (int i = 0; i < this.getSize(); i++)
|
||||
{
|
||||
addButton(i, item, returnButton);
|
||||
}
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.BLAZE_DEATH, 1, .1f);
|
||||
}
|
||||
|
||||
private void buildSuccessPage(String message)
|
||||
{
|
||||
IButton returnButton = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
cancelClicked(player);
|
||||
}
|
||||
};
|
||||
|
||||
ShopItem item = new ShopItem(Material.EMERALD_BLOCK, (byte)0, ChatColor.GREEN + message, null, 1, false, true);
|
||||
for (int i = 0; i < this.getSize(); i++)
|
||||
{
|
||||
addButton(i, item, returnButton);
|
||||
}
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, .9f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerClosed()
|
||||
{
|
||||
super.playerClosed();
|
||||
|
||||
Bukkit.getScheduler().cancelTask(_taskId);
|
||||
|
||||
if (_returnPage != null && getShop() != null)
|
||||
getShop().setCurrentPageForPlayer(getPlayer(), _returnPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_processing)
|
||||
{
|
||||
if (_progressCount == 9)
|
||||
{
|
||||
for (int i=45; i < 54; i++)
|
||||
{
|
||||
clear(i);
|
||||
}
|
||||
|
||||
_progressCount = 0;
|
||||
}
|
||||
|
||||
setItem(45 + _progressCount, _progressItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_progressCount >= 20)
|
||||
{
|
||||
try
|
||||
{
|
||||
Bukkit.getScheduler().cancelTask(_taskId);
|
||||
|
||||
if (_returnPage != null && getShop() != null)
|
||||
{
|
||||
getShop().openPageForPlayer(getPlayer(), _returnPage);
|
||||
}
|
||||
else if (getPlayer() != null)
|
||||
{
|
||||
getPlayer().closeInventory();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_progressCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
|
||||
Bukkit.getScheduler().cancelTask(_taskId);
|
||||
}
|
||||
}
|
@ -1,5 +1,13 @@
|
||||
package mineplex.core.shop.page;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom;
|
||||
@ -11,16 +19,6 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
|
||||
public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends CraftInventoryCustom implements Listener
|
||||
{
|
||||
protected PluginType _plugin;
|
||||
@ -29,7 +27,6 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
protected ShopType _shop;
|
||||
protected Player _player;
|
||||
protected CoreClient _client;
|
||||
protected CurrencyType _currencyType;
|
||||
protected NautHashMap<Integer, IButton> _buttonMap;
|
||||
protected boolean _showCurrency = false;
|
||||
|
||||
@ -52,27 +49,6 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
_buttonMap = new NautHashMap<Integer, IButton>();
|
||||
|
||||
_client = _clientManager.Get(player);
|
||||
|
||||
if (shop.getAvailableCurrencyTypes().size() > 0)
|
||||
{
|
||||
_currencyType = shop.getAvailableCurrencyTypes().get(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void changeCurrency(Player player)
|
||||
{
|
||||
playAcceptSound(player);
|
||||
|
||||
int currentIndex = _shop.getAvailableCurrencyTypes().indexOf(_currencyType);
|
||||
|
||||
if (currentIndex + 1 < _shop.getAvailableCurrencyTypes().size())
|
||||
{
|
||||
_currencyType = _shop.getAvailableCurrencyTypes().get(currentIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currencyType = _shop.getAvailableCurrencyTypes().get(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void buildPage();
|
||||
@ -237,16 +213,6 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
return _client;
|
||||
}
|
||||
|
||||
protected CurrencyType getCurrencyType()
|
||||
{
|
||||
return _currencyType;
|
||||
}
|
||||
|
||||
protected void setCurrencyType(CurrencyType type)
|
||||
{
|
||||
_currencyType = type;
|
||||
}
|
||||
|
||||
protected NautHashMap<Integer, IButton> getButtonMap()
|
||||
{
|
||||
return _buttonMap;
|
||||
|
@ -1,20 +1,18 @@
|
||||
package mineplex.core.tournament.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.tournament.TournamentManager;
|
||||
import mineplex.core.tournament.ui.page.MainMenu;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TournamentShop extends ShopBase<TournamentManager>
|
||||
{
|
||||
public TournamentShop(TournamentManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Tournaments", CurrencyType.GEM);
|
||||
super(plugin, clientManager, donationManager, "Tournaments");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,7 @@
|
||||
package mineplex.core.treasure;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class ChestPackage extends SalesPackageBase
|
||||
{
|
||||
@ -15,10 +12,4 @@ public class ChestPackage extends SalesPackageBase
|
||||
KnownPackage = false;
|
||||
OneTimePurchaseOnly = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package mineplex.core.treasure;
|
||||
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-18.
|
||||
@ -19,10 +16,4 @@ public class TreasureKey extends SalesPackageBase
|
||||
KnownPackage = false;
|
||||
OneTimePurchaseOnly = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -121,7 +123,9 @@ public class TreasureManager extends MiniPlugin
|
||||
for (TreasureLocation treasureLocation : _treasureLocations)
|
||||
{
|
||||
treasureLocation.cleanup();
|
||||
HandlerList.unregisterAll(treasureLocation);
|
||||
}
|
||||
_treasureLocations.clear();
|
||||
}
|
||||
|
||||
public void addOpenStat(Player player, TreasureType treasureType)
|
||||
@ -129,6 +133,12 @@ public class TreasureManager extends MiniPlugin
|
||||
_statsManager.incrementStat(player, "Global.Treasure." + treasureType.getStatName(), 1);
|
||||
}
|
||||
|
||||
public void addTreasureLocation(TreasureLocation loc)
|
||||
{
|
||||
_treasureLocations.add(loc);
|
||||
_plugin.getServer().getPluginManager().registerEvents(loc, _plugin);
|
||||
}
|
||||
|
||||
public Reward[] getRewards(Player player, RewardPool.Type pool, RewardType rewardType)
|
||||
{
|
||||
return _rewardManager.getRewards(player, pool, rewardType);
|
||||
|
@ -1,18 +1,19 @@
|
||||
package mineplex.core.treasure.gui;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.shop.item.SalesPackageProcessor;
|
||||
import mineplex.core.treasure.ChestPackage;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import mineplex.core.treasure.ChestPackage;
|
||||
|
||||
public class BuyChestButton implements IButton
|
||||
{
|
||||
private InventoryManager _inventoryManager;
|
||||
@ -64,10 +65,11 @@ public class BuyChestButton implements IButton
|
||||
UtilPlayer.message(player, F.main("Disguise", "You cant buy things while you are disguised!"));
|
||||
return;
|
||||
}
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(
|
||||
_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), () -> {
|
||||
SalesPackageBase salesPackage = new ChestPackage(_chestName, _chestMat, _chestCost);
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () ->
|
||||
{
|
||||
_inventoryManager.addItemToInventory(player, _chestName, 1);
|
||||
_page.refresh();
|
||||
}, _page, new ChestPackage(_chestName, _chestMat, _chestCost), CurrencyType.TREASURE_SHARD, player));
|
||||
}), salesPackage.buildIcon()));
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package mineplex.core.treasure.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
|
||||
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom;
|
||||
@ -11,24 +14,21 @@ import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
|
||||
import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.treasure.TreasureLocation;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.core.treasure.TreasureLocation;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
|
||||
{
|
||||
@ -50,7 +50,7 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int treasureShards = getDonationManager().Get(getPlayer()).getCoins();
|
||||
int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD);
|
||||
|
||||
int basicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OLD.getItemName());
|
||||
int heroicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ANCIENT.getItemName());
|
||||
|
@ -1,24 +1,10 @@
|
||||
package mineplex.enjinTranslator;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
@ -28,6 +14,19 @@ import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.enjinTranslator.purchase.PurchaseManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
{
|
||||
@ -121,6 +120,8 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
|
||||
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
|
||||
|
||||
if (!checkForClansPurchase(args, name, client))
|
||||
{
|
||||
if (!checkForBoosterPurchase(args, name, playerUUID, client))
|
||||
{
|
||||
if (!checkForCoinPurchase(args, name, playerUUID, client))
|
||||
@ -143,6 +144,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -243,7 +245,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
_purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, amount, data == TransactionResponse.Success);
|
||||
}
|
||||
}
|
||||
}, name, client.getAccountId(), amount == 1 ? packageName : packageName + " " + amount, CurrencyType.GEM, 0, false);
|
||||
}, name, client.getAccountId(), amount == 1 ? packageName : packageName + " " + amount, GlobalCurrency.GEM, 0, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -293,4 +295,71 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean checkForClansPurchase(String[] args, final String name, final CoreClient client)
|
||||
{
|
||||
if (args.length >= 3 && args[0].equalsIgnoreCase("clansBanner"))
|
||||
{
|
||||
String purchase = "Clan Banner Usage";
|
||||
if (args[2].equalsIgnoreCase("true"))
|
||||
{
|
||||
purchase = "Clan Banner Editor";
|
||||
}
|
||||
final String packageName = purchase;
|
||||
|
||||
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
|
||||
{
|
||||
public void run(TransactionResponse data)
|
||||
{
|
||||
if (data == TransactionResponse.Success)
|
||||
{
|
||||
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
_purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, true);
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received their " + packageName + " access.");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + packageName + ". Queuing for run later.");
|
||||
_purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, false);
|
||||
}
|
||||
}
|
||||
}, client.getAccountId(), packageName, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " 1" + ". Queuing for run later.");
|
||||
_purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), packageName, 1, data == TransactionResponse.Success);
|
||||
}
|
||||
}
|
||||
}, name, client.getAccountId(), packageName, GlobalCurrency.GEM, 0, false);
|
||||
//enjin_mineplex clansBanner AlexTheCoder true
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 4 && args[0].equalsIgnoreCase("clansAmplifier"))
|
||||
{
|
||||
//enjin_mineplex clansAmplifier AlexTheCoder 20 1
|
||||
final String item = "Rune Amplifier " + args[2];
|
||||
final int amount = Integer.parseInt(args[3]);
|
||||
|
||||
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||
{
|
||||
public void run (Boolean response)
|
||||
{
|
||||
if (response)
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " rune amplifiers.");
|
||||
else
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " rune amplifiers. Queuing for run later.");
|
||||
|
||||
_purchaseManager.addAccountPurchaseToQueue(client.getAccountId(), item, amount, response);
|
||||
}
|
||||
}, client.getAccountId(), item, amount);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
name: Clans
|
||||
main: mineplex.game.clans.Clans
|
||||
version: 0.1
|
||||
version: 1.0
|
@ -58,7 +58,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class Clans extends JavaPlugin
|
||||
{
|
||||
public static final String VERSION = "Beta 1.0";
|
||||
public static final String MAP = "Map 1";
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
// Modules
|
||||
@ -132,7 +132,7 @@ public class Clans extends JavaPlugin
|
||||
new MemoryFix(this);
|
||||
new FoodDupeFix(this);
|
||||
new Explosion(this, blockRestore);
|
||||
new InventoryManager(this, _clientManager);
|
||||
InventoryManager inventory = new InventoryManager(this, _clientManager);
|
||||
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
|
||||
resourcePackManager.setResourcePack(new Pair[]
|
||||
{
|
||||
@ -149,7 +149,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, webServerAddress);
|
||||
_clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, inventory, webServerAddress);
|
||||
new Recipes(this);
|
||||
new Farming(this);
|
||||
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
||||
@ -196,8 +196,8 @@ public class Clans extends JavaPlugin
|
||||
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
|
||||
}
|
||||
|
||||
public static String version()
|
||||
public static String getMap()
|
||||
{
|
||||
return VERSION;
|
||||
return MAP;
|
||||
}
|
||||
}
|
||||
|
@ -363,9 +363,6 @@ public class ClanInfo
|
||||
}
|
||||
stringList.add(F.value("Members", members));
|
||||
|
||||
// Protected
|
||||
stringList.add(F.value("TNT Protection", getProtected()));
|
||||
|
||||
return stringList;
|
||||
}
|
||||
|
||||
@ -506,25 +503,6 @@ public class ClanInfo
|
||||
return isOnlineNow();
|
||||
}
|
||||
|
||||
public String getProtected()
|
||||
{
|
||||
for (ClansPlayer cur : getMembers().values())
|
||||
if (cur.isOnline())
|
||||
return C.cRed + "No - Clan Members are Online";
|
||||
|
||||
if (UtilTime.elapsed(_lastOnline.getTime(), Clans.getOnlineTime()))
|
||||
return C.cGreen + "Yes - Clan Members are Offline";
|
||||
|
||||
return C.cGold
|
||||
+ "No, "
|
||||
+ UtilTime.convertString(Clans.getOnlineTime() - (System.currentTimeMillis() - _lastOnline.getTime()), 1,
|
||||
TimeUnit.FIT) + " to Protection";
|
||||
}
|
||||
|
||||
public boolean isProtected() {
|
||||
return getProtected().startsWith(C.cGreen + "Yes");
|
||||
}
|
||||
|
||||
public TntGenerator getGenerator()
|
||||
{
|
||||
return _generator;
|
||||
|
@ -191,14 +191,14 @@ public class ClanTips extends MiniPlugin
|
||||
new String[] {
|
||||
C.cDAquaB + "Lost War Point",
|
||||
C.cAqua + "You were killed by another Clan and they have gained 1 War Point against you.",
|
||||
C.cAqua + "If your War Points with them reaches -20, they will get to invade your Territory, giving them full access for 15 minutes."
|
||||
C.cAqua + "If your War Points with them reaches -25, they will get to besiege your Territory, giving them access to cannon it for 30 minutes."
|
||||
}),
|
||||
|
||||
DOMINANCE_NOOICE(
|
||||
new String[] {
|
||||
C.cDAquaB + "Gained War Point",
|
||||
C.cAqua + "You killed someone in another Clan and you have gained 1 War Point against them.",
|
||||
C.cAqua + "If your War Points with them reaches +20, you will get to invade their Territory, giving you full access for 15 minutes."
|
||||
C.cAqua + "If your War Points with them reaches +25, you will get to besiege their Territory, giving you access to cannon it for 30 minutes."
|
||||
}),
|
||||
|
||||
ENERGY(
|
||||
@ -226,8 +226,8 @@ public class ClanTips extends MiniPlugin
|
||||
}),
|
||||
ENTER_NETHER(
|
||||
new String[] {
|
||||
C.cDAqua + "The Nether",
|
||||
C.cAqua + "Welcome to the Nether. This is a very scary place full of fire and is a place for people to battle to the death! TODO: Write something better about the nether here"
|
||||
C.cDRedB + "The Nether",
|
||||
C.cRed + "The Nether is a dangerous place full of powerful mobs and hazardous terrain! However, the mobs here drop powerful Ancient Runes, which can be used to strengthen your gear, making your clan even more fearsome than before!"
|
||||
}),
|
||||
;
|
||||
|
||||
@ -242,7 +242,7 @@ public class ClanTips extends MiniPlugin
|
||||
|
||||
TipType(String[] messages, boolean ignorePreferences)
|
||||
{
|
||||
_messages = new LinkedList();
|
||||
_messages = new LinkedList<>();
|
||||
|
||||
for (String message : messages)
|
||||
{
|
||||
|
@ -1,12 +1,7 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -17,7 +12,9 @@ import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanToken;
|
||||
import mineplex.game.clans.core.war.ClanWarData;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ClansAdmin
|
||||
{
|
||||
@ -341,19 +338,80 @@ public class ClansAdmin
|
||||
{
|
||||
ClanWarData war = clan.getWarData(clanAgainst);
|
||||
|
||||
// war.set
|
||||
//
|
||||
// Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success -> {
|
||||
// UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB())));
|
||||
// });
|
||||
if (war != null)
|
||||
{
|
||||
war.set(clan.getName(), war.getClanAPoints() - value);
|
||||
|
||||
Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB())));
|
||||
Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "There is no war between those two clans!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (operation.equalsIgnoreCase("set"))
|
||||
{
|
||||
ClanWarData war = clan.getWarData(clanAgainst);
|
||||
|
||||
if (war != null)
|
||||
{
|
||||
war.set(clanAgainst.getName(), value);
|
||||
|
||||
Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB())));
|
||||
Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback<ClanWarData>()
|
||||
{
|
||||
@Override
|
||||
public void run(ClanWarData data)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB())));
|
||||
Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (operation.equalsIgnoreCase("add"))
|
||||
{
|
||||
ClanWarData war = clan.getWarData(clanAgainst);
|
||||
|
||||
if (war != null)
|
||||
{
|
||||
war.set(clanAgainst.getName(), war.getClanAPoints() + value);
|
||||
|
||||
Clans.getClanDataAccess().updateWar(clan, clanAgainst, war, success ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(war.getClanB())));
|
||||
Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Clans.getClanDataAccess().war(clan, clanAgainst, value, new Callback<ClanWarData>()
|
||||
{
|
||||
@Override
|
||||
public void run(ClanWarData data)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "Updated war points against " + F.elem(data.getClanB())));
|
||||
Clans.messageClan(clan, F.main("Clans", "Your war points with " + F.elem(clanAgainst.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
Clans.messageClan(clanAgainst, F.main("Clans", "Your war points with " + F.elem(clan.getName()) + " have been edited by " + F.elem(caller.getName()) + "!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,27 +0,0 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.game.clans.Clans;
|
||||
|
||||
public class ClansBetaManager extends MiniPlugin
|
||||
{
|
||||
public ClansBetaManager(ClansManager manager, TaskManager taskManager)
|
||||
{
|
||||
super("Clans Beta", manager.getPlugin());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans " + Clans.VERSION);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +1,10 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.blockrestore.BlockRestoreData;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
@ -52,6 +23,36 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ClansGame extends MiniPlugin
|
||||
{
|
||||
private ClansManager _clans;
|
||||
@ -63,6 +64,25 @@ public class ClansGame extends MiniPlugin
|
||||
_clans = clans;
|
||||
}
|
||||
|
||||
public static boolean isDupedFromClassShop(ItemStack item)
|
||||
{
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).toUpperCase();
|
||||
if (name.contains("APPLY DEFAULT BUILD") || name.contains("APPLY BUILD") || name.contains("EDIT BUILD") || name.contains("DELETE BUILD"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void openClanShop(PlayerInteractEvent event)
|
||||
{
|
||||
@ -78,6 +98,11 @@ public class ClansGame extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEnchant(EnchantItemEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void BlockBurn(BlockBurnEvent event)
|
||||
@ -98,6 +123,26 @@ public class ClansGame extends MiniPlugin
|
||||
|
||||
if (event.getBlock().getType() != Material.LADDER) return;
|
||||
|
||||
if (isDupedFromClassShop(event.getItemInHand()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (ClansManager.getInstance().getClientManager().hasRank(p, Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(p, F.elem("[" + C.cRedB + "!" + C.cGray + "] ") + event.getPlayer().getName() + " just tried to use a duped item/block!");
|
||||
}
|
||||
}
|
||||
final int slot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(slot, new ItemStack(Material.AIR));
|
||||
event.getPlayer().updateInventory();
|
||||
}, 1L);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) return;
|
||||
|
||||
final Block block = event.getBlock();
|
||||
@ -230,12 +275,6 @@ public class ClansGame extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clans.getWarManager().allowFromInvade(event.getBlock().getLocation(), event.getPlayer()))
|
||||
{
|
||||
// Allow because of invasion
|
||||
return;
|
||||
}
|
||||
|
||||
// Disallow
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -287,12 +326,6 @@ public class ClansGame extends MiniPlugin
|
||||
Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation();
|
||||
if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation();
|
||||
|
||||
if (_clans.getWarManager().allowFromInvade(loc, event.getPlayer()))
|
||||
{
|
||||
// Allow because of invasion
|
||||
return;
|
||||
}
|
||||
|
||||
// Borderlands
|
||||
if (player.getGameMode() != GameMode.CREATIVE && player.getItemInHand() != null && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) && _clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation()))
|
||||
{
|
||||
@ -565,15 +598,6 @@ public class ClansGame extends MiniPlugin
|
||||
ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation());
|
||||
if (clan == null) return;
|
||||
|
||||
if (_clans.getWarManager().isBeingInvaded(clan))
|
||||
{
|
||||
// Allow because of invasion
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clan.isProtected())
|
||||
event.setCancelled(true);
|
||||
else
|
||||
clan.inform(C.cRed + "Your Territory is under attack!", null);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,14 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
@ -10,7 +17,13 @@ import mineplex.core.chat.Chat;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.events.PlayerMessageEvent;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
@ -22,6 +35,7 @@ import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
@ -36,11 +50,19 @@ import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
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.commands.*;
|
||||
import mineplex.game.clans.clans.banners.BannerManager;
|
||||
import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
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;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
|
||||
import mineplex.game.clans.clans.gui.ClanShop;
|
||||
@ -82,8 +104,8 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
||||
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.ItemFactory;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||
@ -96,7 +118,7 @@ import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
import mineplex.minecraft.game.core.mechanics.Weapon;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -113,13 +135,18 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelation
|
||||
{
|
||||
@ -153,6 +180,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
private GearManager _gearManager;
|
||||
private LootManager _lootManager;
|
||||
private DonationManager _donationManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private NetherManager _netherManager;
|
||||
private DamageManager _damageManager;
|
||||
private SiegeManager _siegeManager;
|
||||
@ -166,6 +194,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
private mineplex.game.clans.legacytutorial.TutorialManager _legacyTutorial;
|
||||
|
||||
private ClassManager _classManager;
|
||||
private BannerManager _bannerManager;
|
||||
private AmplifierManager _amplifierManager;
|
||||
|
||||
public ClassManager getClassManager()
|
||||
{
|
||||
@ -206,21 +236,21 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator;
|
||||
|
||||
private ClansBanManager _clansBans;
|
||||
private PacketHandler _packetHandler;
|
||||
|
||||
public ClanTips ClanTips;
|
||||
|
||||
// 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, String webServerAddress)
|
||||
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, String webServerAddress)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
_instance = this;
|
||||
|
||||
_clansBans = clansBans;
|
||||
_punish = punish;
|
||||
|
||||
_packetHandler = packetHandler;
|
||||
|
||||
_incognitoManager = incognitoManager;
|
||||
_serverName = serverName;
|
||||
_clientManager = clientManager;
|
||||
@ -233,10 +263,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_warManager = new WarManager(plugin, this);
|
||||
|
||||
_donationManager = donationManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
|
||||
_blacklist = new ClansBlacklist(plugin);
|
||||
|
||||
_goldManager = new GoldManager(this, _clientManager, donationManager);
|
||||
_gearManager = gearManager;
|
||||
_lootManager = new LootManager(gearManager, _goldManager);
|
||||
_disguiseManager = new DisguiseManager(plugin, packetHandler);
|
||||
@ -289,8 +319,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
new ClanEnergyTracker(plugin, this);
|
||||
// new StuckManager(this);
|
||||
|
||||
new ClansBetaManager(this, _taskManager);
|
||||
|
||||
new PotatoManager(plugin, this);
|
||||
|
||||
new Weapon(plugin, energy);
|
||||
@ -355,11 +383,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
_playTracker = new Playtime(this, statsManager);
|
||||
|
||||
_legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler);
|
||||
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, _tutorial, clientManager, donationManager);
|
||||
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
|
||||
|
||||
_bannerManager = new BannerManager(plugin);
|
||||
|
||||
_goldManager = new GoldManager(this, _clientManager, donationManager, _clanDataAccess);
|
||||
|
||||
_legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler);
|
||||
|
||||
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
||||
{
|
||||
loadClan(token);
|
||||
@ -413,8 +445,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
for (Location location : welcomeHolograms)
|
||||
{
|
||||
Hologram hologram = new Hologram(hologramManager, location,
|
||||
C.cGreenB + "Welcome to Clans Beta",
|
||||
C.cWhite + "Please be aware there may be bugs",
|
||||
C.cGreenB + "Welcome to Clans!",
|
||||
C.cWhite + "Type " + C.cYellow + "/clan" + C.cWhite + " to get started!"
|
||||
);
|
||||
hologram.start();
|
||||
@ -422,7 +453,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
|
||||
_siegeManager = new SiegeManager(this);
|
||||
// _netherManager = new NetherManager(this);
|
||||
_netherManager = new NetherManager(this);
|
||||
_amplifierManager = new AmplifierManager(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -450,6 +482,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
for (ClanTerritoryToken territoryToken : clanToken.Territories)
|
||||
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
|
||||
|
||||
_bannerManager.loadBanner(clan);
|
||||
}
|
||||
|
||||
public DisguiseManager getDisguiseManager()
|
||||
@ -482,6 +516,16 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return _donationManager;
|
||||
}
|
||||
|
||||
public GoldManager getGoldManager()
|
||||
{
|
||||
return _goldManager;
|
||||
}
|
||||
|
||||
public InventoryManager getInventoryManager()
|
||||
{
|
||||
return _inventoryManager;
|
||||
}
|
||||
|
||||
public ItemMapManager getItemMapManager()
|
||||
{
|
||||
return _itemMapManager;
|
||||
@ -492,6 +536,21 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return _explosion;
|
||||
}
|
||||
|
||||
public PacketHandler getPacketHandler()
|
||||
{
|
||||
return _packetHandler;
|
||||
}
|
||||
|
||||
public BannerManager getBannerManager()
|
||||
{
|
||||
return _bannerManager;
|
||||
}
|
||||
|
||||
public AmplifierManager getAmplifierManager()
|
||||
{
|
||||
return _amplifierManager;
|
||||
}
|
||||
|
||||
public int getInviteExpire()
|
||||
{
|
||||
return _inviteExpire;
|
||||
@ -602,6 +661,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
public void Join(PlayerJoinEvent event)
|
||||
{
|
||||
event.setJoinMessage(null);
|
||||
UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans!");
|
||||
|
||||
if (_incognitoManager.Get(event.getPlayer()).Status)
|
||||
{
|
||||
@ -740,7 +800,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
continue;
|
||||
}
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is on version: " + F.elem(Clans.version())));
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Server is running Mineplex Clans version " + _plugin.getDescription().getVersion() + "!"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -1160,8 +1220,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon");
|
||||
event.setKickMessage("Clans Beta is full! Try again soon");
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon");
|
||||
event.setKickMessage("This Clans server is full! Try again soon");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1184,7 +1244,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
if (event.getMessage().toLowerCase().equals("/lobby") || event.getMessage().toLowerCase().equals("/hub") || event.getMessage().toLowerCase().equals("/leave"))
|
||||
{
|
||||
Portal.getInstance().sendPlayerToServer(event.getPlayer(), "Lobby");
|
||||
Portal.getInstance().sendPlayerToServer(event.getPlayer(), "ClansHub");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package mineplex.game.clans.clans.amplifiers;
|
||||
|
||||
import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Data class for active amplifiers
|
||||
*/
|
||||
public class Amplifier
|
||||
{
|
||||
private Player _owner;
|
||||
private long _end;
|
||||
|
||||
public Amplifier(Player owner, AmplifierType type)
|
||||
{
|
||||
_owner = owner;
|
||||
_end = System.currentTimeMillis() + type.getDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the owner of the amplifier
|
||||
* @return This amplifier's owner
|
||||
*/
|
||||
public Player getOwner()
|
||||
{
|
||||
return _owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remaining duration of this amplifier
|
||||
* @return How much time is left before this amplifier expires
|
||||
*/
|
||||
public long getRemainingTime()
|
||||
{
|
||||
return Math.max(0, _end - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this amplifier has run out of time
|
||||
* @return Whether this amplifier has run out of time
|
||||
*/
|
||||
public boolean isEnded()
|
||||
{
|
||||
return System.currentTimeMillis() >= _end;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package mineplex.game.clans.clans.amplifiers;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Main amplifier command
|
||||
*/
|
||||
public class AmplifierCommand extends CommandBase<AmplifierManager>
|
||||
{
|
||||
public AmplifierCommand(AmplifierManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "amplifier", "runeamplifier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
new AmplifierGUI(caller, Plugin);
|
||||
}
|
||||
}
|
@ -0,0 +1,197 @@
|
||||
package mineplex.game.clans.clans.amplifiers;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.amplifiers.AmplifierManager.AmplifierType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* GUI manager for amplifiers
|
||||
*/
|
||||
public class AmplifierGUI implements Listener
|
||||
{
|
||||
private Player _viewer;
|
||||
private AmplifierManager _manager;
|
||||
private Inventory _inventory;
|
||||
private final HashMap<Integer, ItemStack> _items = new HashMap<>();
|
||||
private final HashMap<Integer, AmplifierType> _boundSlots = new HashMap<>();
|
||||
private AmplifierType _selected;
|
||||
|
||||
public AmplifierGUI(Player viewer, AmplifierManager manager)
|
||||
{
|
||||
_viewer = viewer;
|
||||
_manager = manager;
|
||||
_inventory = Bukkit.createInventory(viewer, 9, C.cClansNether + "Rune Amplifiers");
|
||||
Bukkit.getPluginManager().registerEvents(this, manager.getPlugin());
|
||||
|
||||
propagate();
|
||||
open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the owner of this specific inventory
|
||||
* @return The owner of this inventory
|
||||
*/
|
||||
public Player getViewer()
|
||||
{
|
||||
return _viewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches all the items registered as buttons in this inventory gui
|
||||
* @return A list of the items registered as buttons in this inventory gui
|
||||
*/
|
||||
public HashMap<Integer, ItemStack> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the gui with buttons
|
||||
*/
|
||||
public void propagate()
|
||||
{
|
||||
getItems().clear();
|
||||
Integer slot = 0;
|
||||
for (AmplifierType type : AmplifierType.values())
|
||||
{
|
||||
int owned = _manager.getAmountOwned(getViewer(), type);
|
||||
owned = Math.max(owned, 0);
|
||||
getItems().put(slot, new ItemBuilder(Material.NETHER_STAR).setAmount(Math.min(owned, 1)).setTitle(type.getDisplayName()).setLore(F.elem(owned) + " Owned").build());
|
||||
_boundSlots.put(slot, type);
|
||||
slot++;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fils the confirmation menu with buttons
|
||||
*/
|
||||
public void propagateConfirmation()
|
||||
{
|
||||
getItems().clear();
|
||||
_boundSlots.clear();
|
||||
getItems().put(3, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 5).setTitle(C.cGreen + "Confirm").build());
|
||||
getItems().put(5, new ItemBuilder(Material.STAINED_GLASS_PANE).setData((short) 14).setTitle(C.cRed + "Cancel").build());
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles players clicking on buttons
|
||||
* @param slot The slot clicked on
|
||||
* @param type The type of click
|
||||
*/
|
||||
public void onClick(Integer slot, ClickType type)
|
||||
{
|
||||
if (_boundSlots.containsKey(slot))
|
||||
{
|
||||
if (_manager.hasActiveAmplifier())
|
||||
{
|
||||
UtilPlayer.message(getViewer(), F.main(_manager.getName(), "An amplifier is already active!"));
|
||||
_manager.runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
}
|
||||
else
|
||||
{
|
||||
_selected = _boundSlots.get(slot);
|
||||
if (_manager.getAmountOwned(getViewer(), _selected) > 0)
|
||||
{
|
||||
propagateConfirmation();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(getViewer(), F.main(_manager.getName(), "You do not have enough of that amplifier! Purchase some at http://www.mineplex.com/shop!"));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot == 3)
|
||||
{
|
||||
_manager.runSyncLater(() ->
|
||||
{
|
||||
_manager.useAmplifier(getViewer(), _selected);
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
}
|
||||
if (slot == 5)
|
||||
{
|
||||
_selected = null;
|
||||
propagate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens this inventory to its viewer
|
||||
*/
|
||||
public void open()
|
||||
{
|
||||
_viewer.openInventory(_inventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the GUI's visuals to match registered button items
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
_inventory.clear();
|
||||
for (Integer slot : _items.keySet())
|
||||
{
|
||||
_inventory.setItem(slot, _items.get(slot));
|
||||
}
|
||||
for (Integer slot = 0; slot < _inventory.getSize(); slot++)
|
||||
{
|
||||
if (!_items.containsKey(slot))
|
||||
{
|
||||
_inventory.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(C.cGray).setData((short)7).build());
|
||||
}
|
||||
}
|
||||
_viewer.updateInventory();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleClick(InventoryClickEvent event)
|
||||
{
|
||||
if (event.getClickedInventory() == null || !event.getClickedInventory().equals(_inventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_viewer.getName().equals(event.getWhoClicked().getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
Integer slot = event.getSlot();
|
||||
if (!_items.containsKey(slot))
|
||||
{
|
||||
return;
|
||||
}
|
||||
onClick(slot, event.getClick());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event)
|
||||
{
|
||||
if (event.getPlayer().getUniqueId().equals(_viewer.getUniqueId()))
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package mineplex.game.clans.clans.amplifiers;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Manager for using amplifiers in clans
|
||||
*/
|
||||
public class AmplifierManager extends MiniPlugin
|
||||
{
|
||||
public static final double AMPLIFIER_RUNE_DROP_MULTIPLIER = 2;
|
||||
private static final String AMPLIFIER_NAME = "Rune Amplifier";
|
||||
private Amplifier _active;
|
||||
|
||||
public AmplifierManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Rune Amplifiers", plugin);
|
||||
|
||||
addCommand(new AmplifierCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether there is an amplifier active on this server
|
||||
* @return Whether there is an amplifier active on this server
|
||||
*/
|
||||
public boolean hasActiveAmplifier()
|
||||
{
|
||||
return _active != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks how many of a certain amplifier type a player owns
|
||||
* @param player The player to check
|
||||
* @param type The type of amplifier to check for
|
||||
* @return The amount of amplifiers of that type owned
|
||||
*/
|
||||
public int getAmountOwned(Player player, AmplifierType type)
|
||||
{
|
||||
return ClansManager.getInstance().getInventoryManager().Get(player).getItemCount(type.getFullItemName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a player use an amplifier
|
||||
* @param user The player to use the amplifier
|
||||
* @param type The type of amplifier to use
|
||||
*/
|
||||
public void useAmplifier(Player user, AmplifierType type)
|
||||
{
|
||||
if (getAmountOwned(user, type) < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (hasActiveAmplifier())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClansManager.getInstance().getInventoryManager().addItemToInventory(user, type.getFullItemName(), -1);
|
||||
UtilTextMiddle.display(C.cClansNether + AMPLIFIER_NAME, "Has been activated by " + F.elem(user.getName()));
|
||||
Bukkit.broadcastMessage(F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " has been activated on this server by " + F.elem(user.getName()) + " for " + F.elem(UtilTime.MakeStr(type.getDuration())) + "!"));
|
||||
_active = new Amplifier(user, type);
|
||||
runSyncLater(() ->
|
||||
{
|
||||
ClansManager.getInstance().getNetherManager().spawnPortal(type.getDuration());
|
||||
}, 60L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_active != null && _active.isEnded())
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main(getName(), "The " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner()) + " has run out! You can purchase another at http://www.mineplex.com/shop!"));
|
||||
_active = null;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_active != null)
|
||||
{
|
||||
runSyncLater(() ->
|
||||
{
|
||||
if (_active != null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "A " + F.clansNether(AMPLIFIER_NAME) + " owned by " + F.elem(_active.getOwner().getName()) + " is active on this server with " + F.elem(UtilTime.MakeStr(_active.getRemainingTime())) + " remaining!"));
|
||||
}
|
||||
}, 40L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum containing different types of amplifiers recognized by code
|
||||
*/
|
||||
public static enum AmplifierType
|
||||
{
|
||||
TWENTY("20", "Twenty Minute Amplifier", UtilTime.convert(20, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)),
|
||||
SIXTY("60", "One Hour Amplifier", UtilTime.convert(60, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
|
||||
|
||||
private String _extension, _display;
|
||||
private long _duration;
|
||||
|
||||
private AmplifierType(String extension, String displayName, long duration)
|
||||
{
|
||||
_extension = extension;
|
||||
_display = C.cClansNether + displayName;
|
||||
_duration = duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full name of this amplifier as recognized by the inventory database
|
||||
* @return The full name of this amplifier as recognized by the inventory database
|
||||
*/
|
||||
public String getFullItemName()
|
||||
{
|
||||
return AMPLIFIER_NAME + " " + _extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name for this amplifier in this GUI
|
||||
* @return The display name for this amplifier in this GUI
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return _display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total duration for this type of amplifier
|
||||
* @return The total duration for this type of amplifier
|
||||
*/
|
||||
public long getDuration()
|
||||
{
|
||||
return _duration;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +1,52 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
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.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
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;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class ClansBanManager extends MiniPlugin
|
||||
{
|
||||
private static final long FREEZE_MESSAGE_INTERVAL = 10000;
|
||||
private final CoreClientManager _clientManager;
|
||||
private final DonationManager _donationManager;
|
||||
private final ClansBanRepository _repository;
|
||||
private final HashMap<UUID, Float> _frozen = new HashMap<>();
|
||||
|
||||
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
@ -34,6 +63,8 @@ public class ClansBanManager extends MiniPlugin
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new ClansBanCommand(this));
|
||||
addCommand(new FreezeCommand(this));
|
||||
addCommand(new UnfreezeCommand(this));
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
@ -75,6 +106,202 @@ public class ClansBanManager extends MiniPlugin
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Float walkSpeed = _frozen.remove(event.getPlayer().getUniqueId());
|
||||
if (walkSpeed != null)
|
||||
{
|
||||
event.getPlayer().setWalkSpeed(walkSpeed);
|
||||
event.getPlayer().removePotionEffect(PotionEffectType.JUMP);
|
||||
for (Player staff : UtilServer.GetPlayers())
|
||||
{
|
||||
if (_clientManager.hasRank(staff, Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisplayFreezeMessage(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (UUID frozenUUID : _frozen.keySet())
|
||||
{
|
||||
Player frozen = Bukkit.getPlayer(frozenUUID);
|
||||
if (Recharge.Instance.use(frozen, "Freeze Message", FREEZE_MESSAGE_INTERVAL, false, false))
|
||||
{
|
||||
String border = C.cGray + C.Strike + "-----------------------------------------------------";
|
||||
String sq = "\u2589";
|
||||
|
||||
UtilPlayer.message(frozen, border);
|
||||
UtilPlayer.message(frozen, C.Reset + "");
|
||||
UtilPlayer.message(frozen, C.cWhite + sq + sq + sq + sq + C.cRed + sq + C.cWhite + sq + sq + sq + sq);
|
||||
UtilPlayer.message(frozen, C.cWhite + sq + sq + sq + C.cRed + sq + C.cBlack + sq + C.cRed + sq + C.cWhite + sq + sq + sq);
|
||||
UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq);
|
||||
UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq);
|
||||
UtilPlayer.message(frozen, C.cWhite + sq + sq + C.cRed + sq + C.cGold + sq + C.cBlack + sq + C.cGold + sq + C.cRed + sq + C.cWhite + sq + sq);
|
||||
UtilPlayer.message(frozen, C.cWhite + sq + C.cRed + sq + C.cGold + sq + sq + sq + C.cGold + sq + sq + C.cRed + sq + C.cWhite + sq);
|
||||
UtilPlayer.message(frozen, C.cRed + sq + C.cGold + sq + sq + sq + C.cBlack + sq + C.cGold + sq + sq + sq + C.cRed + sq);
|
||||
UtilPlayer.message(frozen, C.cRed + sq + sq + sq + sq + sq + sq + sq + sq + sq);
|
||||
UtilPlayer.message(frozen, C.Reset + "");
|
||||
UtilPlayer.message(frozen, C.cRed + "You have been frozen by a staff member!");
|
||||
UtilPlayer.message(frozen, C.cRed + "Do not log out or you will be banned!");
|
||||
UtilPlayer.message(frozen, C.Reset + "");
|
||||
UtilPlayer.message(frozen, border);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleMobs(EntityTargetLivingEntityEvent event)
|
||||
{
|
||||
if (event.getTarget() instanceof Player)
|
||||
{
|
||||
Player player = (Player) event.getTarget();
|
||||
if (isFrozen(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(event.GetCause() == DamageCause.PROJECTILE);
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
|
||||
if (damager != null && isFrozen(damager))
|
||||
{
|
||||
event.SetCancelled("Frozen Attacker");
|
||||
UtilPlayer.message(damager, F.main(getName(), "You cannot attack others while frozen!"));
|
||||
}
|
||||
if (damagee != null && isFrozen(damagee))
|
||||
{
|
||||
event.SetCancelled("Frozen Damagee");
|
||||
if (damager != null)
|
||||
{
|
||||
UtilPlayer.message(damager, F.main(getName(), "You cannot attack " + F.elem(damagee.getName()) + " while they are frozen!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUseSkill(SkillTriggerEvent event)
|
||||
{
|
||||
if (isFrozen(event.GetPlayer()))
|
||||
{
|
||||
event.SetCancelled(true);
|
||||
UtilPlayer.message(event.GetPlayer(), F.main(getName(), "You cannot use " + F.skill(event.GetSkillName()) + " while frozen!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot break blocks while frozen!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot place blocks while frozen!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTpHome(ClansCommandExecutedEvent event)
|
||||
{
|
||||
if (event.getCommand().equalsIgnoreCase("tphome"))
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while frozen!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is frozen
|
||||
* @param player The player to check
|
||||
* @return Whether the player is frozen
|
||||
*/
|
||||
public boolean isFrozen(Player player)
|
||||
{
|
||||
return _frozen.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Freezes a player
|
||||
* @param player The player to freeze
|
||||
* @param staff The staff member who froze them
|
||||
*/
|
||||
public void freeze(Player player, Player staff)
|
||||
{
|
||||
_frozen.put(player.getUniqueId(), player.getWalkSpeed());
|
||||
player.setWalkSpeed(0);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10));
|
||||
for (Player alert : UtilServer.GetPlayers())
|
||||
{
|
||||
if (_clientManager.hasRank(alert, Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unfreezes a player
|
||||
* @param player The player to unfreeze
|
||||
* @param staff The staff member who unfroze them
|
||||
*/
|
||||
public void unfreeze(Player player, Player staff)
|
||||
{
|
||||
Float walkSpeed = _frozen.remove(player.getUniqueId());
|
||||
if (walkSpeed != null)
|
||||
{
|
||||
player.setWalkSpeed(walkSpeed);
|
||||
player.removePotionEffect(PotionEffectType.JUMP);
|
||||
for (Player alert : UtilServer.GetPlayers())
|
||||
{
|
||||
if (_clientManager.hasRank(alert, Rank.HELPER))
|
||||
{
|
||||
UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!"));
|
||||
continue;
|
||||
}
|
||||
if (alert.getName().equals(player.getName()))
|
||||
{
|
||||
UtilPlayer.message(alert, F.main(getName(), "You have been unfrozen!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unban(ClansBanClient target, ClansBan ban, Callback<ClansBanClient> callback)
|
||||
{
|
||||
if (!target._uuid.equals(ban.getUUID()))
|
||||
|
@ -22,7 +22,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
{
|
||||
if (args == null || args.length < 1)
|
||||
{
|
||||
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 thier past bans.");
|
||||
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.");
|
||||
}
|
||||
else if (args.length > 1)
|
||||
{
|
||||
@ -52,7 +52,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
}
|
||||
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 thier past bans.");
|
||||
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,44 @@
|
||||
package mineplex.game.clans.clans.ban.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 org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Command to freeze players
|
||||
*/
|
||||
public class FreezeCommand extends CommandBase<ClansBanManager>
|
||||
{
|
||||
public FreezeCommand(ClansBanManager plugin)
|
||||
{
|
||||
super(plugin, Rank.CMOD, "freeze");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cBlue + "/freeze <username>" + C.cGray + " - " + C.cYellow + "Freezes a player, restricting their movement and ability to interact with the game.");
|
||||
}
|
||||
else if (args.length > 0)
|
||||
{
|
||||
Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Plugin.isFrozen(target))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(args[0]) + " is already frozen!"));
|
||||
return;
|
||||
}
|
||||
Plugin.freeze(target, caller);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package mineplex.game.clans.clans.ban.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 org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Command to unfreeze players
|
||||
*/
|
||||
public class UnfreezeCommand extends CommandBase<ClansBanManager>
|
||||
{
|
||||
public UnfreezeCommand(ClansBanManager plugin)
|
||||
{
|
||||
super(plugin, Rank.CMOD, "unfreeze");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cBlue + "/unfreeze <username>" + C.cGray + " - " + C.cYellow + "Unfreezes a player, restoring their movement and ability to interact with the game.");
|
||||
}
|
||||
else if (args.length > 0)
|
||||
{
|
||||
Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Plugin.isFrozen(target))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(args[0]) + " is not frozen!"));
|
||||
return;
|
||||
}
|
||||
Plugin.unfreeze(target, caller);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package mineplex.game.clans.clans.banners;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.banners.command.BannerCommand;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Manager class for cosmetic clans banners
|
||||
*/
|
||||
public class BannerManager extends MiniPlugin
|
||||
{
|
||||
private static final long BANNER_PLACE_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.MILLISECONDS);
|
||||
public final HashMap<String, ClanBanner> LoadedBanners = new HashMap<>();
|
||||
private final HashMap<Block, Long> _placedBanners = new HashMap<>();
|
||||
private BannerRepository _repo;
|
||||
|
||||
public BannerManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Clan Banners", plugin);
|
||||
_repo = new BannerRepository(plugin, this);
|
||||
|
||||
new BannerPacketManager();
|
||||
addCommand(new BannerCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all placed banners to air
|
||||
*/
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
for (Block changed : _placedBanners.keySet())
|
||||
{
|
||||
changed.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks what type of banner unlock a player has
|
||||
* @param player The player to check
|
||||
* @return The type of banner unlock a player has
|
||||
*/
|
||||
public int getBannerUnlockLevel(Player player)
|
||||
{
|
||||
int level = 0;
|
||||
if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("Clan Banner Usage"))
|
||||
{
|
||||
level = 1;
|
||||
}
|
||||
if (ClansManager.getInstance().getDonationManager().Get(player).OwnsUnknownPackage("Clan Banner Editor"))
|
||||
{
|
||||
level = 2;
|
||||
}
|
||||
if (ClansManager.getInstance().getClientManager().hasRank(player, Rank.ADMIN))
|
||||
{
|
||||
level = 2;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a banner for a clan
|
||||
* @param clan The clan whose banner to load
|
||||
*/
|
||||
public void loadBanner(ClanInfo clan)
|
||||
{
|
||||
_repo.loadBanner(LoadedBanners, clan);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a banner to the database
|
||||
* @param banner The banner to save
|
||||
*/
|
||||
public void saveBanner(ClanBanner banner)
|
||||
{
|
||||
_repo.saveBanner(banner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a clan's banner
|
||||
* @param clan The clan whose banner to delete
|
||||
*/
|
||||
public void deleteBanner(ClanInfo clan)
|
||||
{
|
||||
_repo.deleteBanner(clan);
|
||||
LoadedBanners.remove(clan.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a clan banner
|
||||
* @param banner The banner to delete
|
||||
*/
|
||||
public void deleteBanner(ClanBanner banner)
|
||||
{
|
||||
deleteBanner(banner.getClan());
|
||||
}
|
||||
|
||||
/**
|
||||
* Places a clans banner for a player
|
||||
* @param placing The player who placed the banner
|
||||
* @param banner The banner to place
|
||||
*/
|
||||
public void placeBanner(Player placing, ClanBanner banner)
|
||||
{
|
||||
if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Block block = placing.getLocation().getBlock();
|
||||
BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
ClanTerritory claim = ClansManager.getInstance().getClanUtility().getClaim(block.getLocation());
|
||||
if (claim != null && !claim.Owner.equals(banner.getClan().getName()))
|
||||
{
|
||||
UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there."));
|
||||
return;
|
||||
}
|
||||
ClansManager.getInstance().getBlockRestore().restore(block);
|
||||
if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)))
|
||||
{
|
||||
block.setType(Material.STANDING_BANNER);
|
||||
Banner state = (Banner) block.getState();
|
||||
state.setBaseColor(banner.getBaseColor());
|
||||
state.setPatterns(((BannerMeta)banner.getBanner().getItemMeta()).getPatterns());
|
||||
state.update();
|
||||
_placedBanners.put(block, System.currentTimeMillis());
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(placing, F.main("Clans", "You cannot place your Clan Banner there."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (_placedBanners.containsKey(event.getBlock()))
|
||||
{
|
||||
_placedBanners.remove(event.getBlock());
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.FAST)
|
||||
{
|
||||
for (Block reset : _placedBanners.keySet())
|
||||
{
|
||||
if (UtilTime.elapsed(_placedBanners.get(reset), BANNER_PLACE_DURATION))
|
||||
{
|
||||
reset.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package mineplex.game.clans.clans.banners;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Handler for banner wearing packets
|
||||
*/
|
||||
public class BannerPacketManager implements Listener
|
||||
{
|
||||
private Field _itemField;
|
||||
private static BannerPacketManager Instance;
|
||||
private final HashMap<Player, IPacketHandler> _wearing = new HashMap<>();
|
||||
|
||||
public BannerPacketManager()
|
||||
{
|
||||
try
|
||||
{
|
||||
_itemField = PacketPlayOutSetSlot.class.getDeclaredField("c");
|
||||
_itemField.setAccessible(true);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the registered loaded instance of this class
|
||||
* @return The loaded instance of this class
|
||||
*/
|
||||
public static BannerPacketManager getInstance()
|
||||
{
|
||||
return Instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles a player wearing their clan's banner
|
||||
* @param player The player to toggle for
|
||||
* @param banner The banner to toggle
|
||||
*/
|
||||
public void toggleBanner(Player player, ItemStack banner)
|
||||
{
|
||||
if (_wearing.containsKey(player))
|
||||
{
|
||||
IPacketHandler bannerHandler = _wearing.remove(player);
|
||||
ClansManager.getInstance().getPacketHandler().removePacketHandler(bannerHandler);
|
||||
for (Player refresh : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
ItemStack helmet = new ItemStack(Material.AIR);
|
||||
if (player.getInventory().getHelmet() != null)
|
||||
{
|
||||
helmet = player.getInventory().getHelmet();
|
||||
}
|
||||
UtilPlayer.sendPacket(refresh, new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(helmet)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IPacketHandler bannerHandler = new IPacketHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
if (packetInfo.getPacket() instanceof PacketPlayOutEntityEquipment)
|
||||
{
|
||||
PacketPlayOutEntityEquipment equip = (PacketPlayOutEntityEquipment) packetInfo.getPacket();
|
||||
|
||||
if (equip.a == player.getEntityId() && equip.b == 4)
|
||||
{
|
||||
equip.c = CraftItemStack.asNMSCopy(banner);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
_wearing.put(player, bannerHandler);
|
||||
ClansManager.getInstance().getPacketHandler().addPacketHandler(bannerHandler, PacketPlayOutEntityEquipment.class);
|
||||
for (Player refresh : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
UtilPlayer.sendPacket(refresh, new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(banner)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (_wearing.containsKey(event.getPlayer()))
|
||||
{
|
||||
ClansManager.getInstance().getPacketHandler().removePacketHandler(_wearing.remove(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package mineplex.game.clans.clans.banners;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
|
||||
/**
|
||||
* Data class for clans banner patterns
|
||||
*/
|
||||
public class BannerPattern
|
||||
{
|
||||
private int _layer;
|
||||
private DyeColor _color;
|
||||
private PatternType _type;
|
||||
|
||||
public BannerPattern(int layer, DyeColor color, PatternType type)
|
||||
{
|
||||
_layer = layer;
|
||||
_color = color;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public BannerPattern(int layer)
|
||||
{
|
||||
_layer = layer;
|
||||
_color = null;
|
||||
_type = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the layer this pattern occupies on the clan's banner
|
||||
* @return The layer this pattern occupies on the clan's banner
|
||||
*/
|
||||
public int getLayer()
|
||||
{
|
||||
return _layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Bukkit version of this banner pattern
|
||||
* @return The Bukkit version of this banner pattern, or null if this is not a fully configured pattern
|
||||
*/
|
||||
public Pattern getBukkitPattern()
|
||||
{
|
||||
if (_color == null || _type == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Pattern(_color, _type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the form this banner pattern will take in the database
|
||||
* @return The form this banner pattern will take in the database
|
||||
*/
|
||||
public String getDatabaseForm()
|
||||
{
|
||||
if (_color == null || _type == null)
|
||||
{
|
||||
return "Blank";
|
||||
}
|
||||
|
||||
return _color.toString() + "," + _type.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color of this banner pattern
|
||||
* @param color The color to set this pattern to
|
||||
*/
|
||||
public void setColor(DyeColor color)
|
||||
{
|
||||
_color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the design of this banner pattern
|
||||
* @param color The design to set this pattern to
|
||||
*/
|
||||
public void setPatternType(PatternType type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package mineplex.game.clans.clans.banners;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Database repository class for banners
|
||||
*/
|
||||
public class BannerRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String CREATE = "CREATE TABLE IF NOT EXISTS clanBanners (clanId INT NOT NULL,"
|
||||
+ "baseColor VARCHAR(15),"
|
||||
+ "patterns VARCHAR(300),"
|
||||
+ "PRIMARY KEY (clanId));";
|
||||
|
||||
private static final String GET_BANNER_BY_CLAN = "SELECT * FROM clanBanners WHERE clanId=? LIMIT 1;";
|
||||
private static final String INSERT_BANNER = "INSERT INTO clanBanners (clanId, baseColor, patterns) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE baseColor=VALUES(baseColor), patterns=VALUES(patterns);";
|
||||
private static final String DELETE_BANNER = "DELETE FROM clanBanners WHERE clanId=?;";
|
||||
|
||||
private BannerManager _bannerManager;
|
||||
|
||||
public BannerRepository(JavaPlugin plugin, BannerManager bannerManager)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
_bannerManager = bannerManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a banner for a certain clan into a given hashmap
|
||||
* @param map The hashmap to load the banner into
|
||||
* @param clan The clan whose banner to fetch
|
||||
*/
|
||||
public void loadBanner(final HashMap<String, ClanBanner> map, ClanInfo clan)
|
||||
{
|
||||
_bannerManager.runAsync(() ->
|
||||
{
|
||||
executeQuery(GET_BANNER_BY_CLAN, resultSet ->
|
||||
{
|
||||
while(resultSet.next())
|
||||
{
|
||||
DyeColor baseColor = DyeColor.valueOf(resultSet.getString("baseColor"));
|
||||
List<String> patternStrs = Arrays.asList(resultSet.getString("patterns").split("/"));
|
||||
LinkedList<BannerPattern> patterns = new LinkedList<>();
|
||||
int layer = 1;
|
||||
for (String patternStr : patternStrs)
|
||||
{
|
||||
if (patternStr.equalsIgnoreCase("Blank"))
|
||||
{
|
||||
patterns.add(new BannerPattern(layer));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
DyeColor patternColor = DyeColor.valueOf(patternStr.split(",")[0]);
|
||||
PatternType patternType = PatternType.valueOf(patternStr.split(",")[1]);
|
||||
patterns.add(new BannerPattern(layer, patternColor, patternType));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
patterns.add(new BannerPattern(layer));
|
||||
}
|
||||
}
|
||||
layer++;
|
||||
}
|
||||
map.put(clan.getName(), new ClanBanner(_bannerManager, clan, baseColor, patterns));
|
||||
}
|
||||
}, new ColumnInt("clanId", clan.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a banner into the database
|
||||
* @param banner The banner to save
|
||||
*/
|
||||
public void saveBanner(ClanBanner banner)
|
||||
{
|
||||
_bannerManager.runAsync(() ->
|
||||
{
|
||||
String patternStr = "";
|
||||
for (BannerPattern pattern : banner.getPatterns())
|
||||
{
|
||||
if (!patternStr.equalsIgnoreCase(""))
|
||||
{
|
||||
patternStr = patternStr + "/";
|
||||
}
|
||||
patternStr = patternStr + pattern.getDatabaseForm();
|
||||
}
|
||||
executeUpdate(INSERT_BANNER, new ColumnInt("clanId", banner.getClan().getId()), new ColumnVarChar("baseColor", 15, banner.getBaseColor().toString()), new ColumnVarChar("patterns", 300, patternStr));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a banner from the database
|
||||
* @param clan The clan whose banner to delete
|
||||
*/
|
||||
public void deleteBanner(ClanInfo clan)
|
||||
{
|
||||
_bannerManager.runAsync(() ->
|
||||
{
|
||||
executeUpdate(DELETE_BANNER, new ColumnInt("clanId", clan.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
executeUpdate(CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update() {}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package mineplex.game.clans.clans.banners;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Data class for clan banners
|
||||
*/
|
||||
public class ClanBanner
|
||||
{
|
||||
private BannerManager _manager;
|
||||
private ClanInfo _clan;
|
||||
private DyeColor _baseColor;
|
||||
private LinkedList<BannerPattern> _patterns;
|
||||
|
||||
public ClanBanner(BannerManager manager, ClanInfo clan, DyeColor baseColor, LinkedList<BannerPattern> patterns)
|
||||
{
|
||||
_manager = manager;
|
||||
_clan = clan;
|
||||
_baseColor = baseColor;
|
||||
_patterns = patterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the clan that owns this banner
|
||||
* @return The clan that owns this banner
|
||||
*/
|
||||
public ClanInfo getClan()
|
||||
{
|
||||
return _clan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base color for this banner
|
||||
* @return The base color for this banner
|
||||
*/
|
||||
public DyeColor getBaseColor()
|
||||
{
|
||||
return _baseColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this banner's patterns
|
||||
* @return This banner's patterns
|
||||
*/
|
||||
public LinkedList<BannerPattern> getPatterns()
|
||||
{
|
||||
return _patterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ItemStack representation of this banner
|
||||
* @return The ItemStack representation of this banner
|
||||
*/
|
||||
public ItemStack getBanner()
|
||||
{
|
||||
ItemStack banner = new ItemStack(Material.BANNER);
|
||||
BannerMeta im = (BannerMeta) banner.getItemMeta();
|
||||
|
||||
im.setDisplayName(C.cGray + _clan.getName() + "'s Banner");
|
||||
im.setBaseColor(_baseColor);
|
||||
List<Pattern> patterns = Lists.newArrayList();
|
||||
for (BannerPattern bp : _patterns)
|
||||
{
|
||||
if (bp.getBukkitPattern() != null)
|
||||
{
|
||||
patterns.add(bp.getBukkitPattern());
|
||||
}
|
||||
}
|
||||
im.setPatterns(patterns);
|
||||
banner.setItemMeta(im);
|
||||
|
||||
return banner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base color of this banner
|
||||
* @param color The color to set
|
||||
*/
|
||||
public void setBaseColor(DyeColor color)
|
||||
{
|
||||
_baseColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this banner to the database
|
||||
*/
|
||||
public void save()
|
||||
{
|
||||
_manager.saveBanner(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Places this banner on the ground
|
||||
* @param player The player to place the banner for
|
||||
*/
|
||||
public void place(Player player)
|
||||
{
|
||||
_manager.placeBanner(player, this);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package mineplex.game.clans.clans.banners.command;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.banners.BannerManager;
|
||||
import mineplex.game.clans.clans.banners.BannerPattern;
|
||||
import mineplex.game.clans.clans.banners.ClanBanner;
|
||||
import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Main banner usage command
|
||||
*/
|
||||
public class BannerCommand extends CommandBase<BannerManager>
|
||||
{
|
||||
public BannerCommand(BannerManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "banner");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (ClansManager.getInstance().getClan(caller) == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not in a Clan!"));
|
||||
return;
|
||||
}
|
||||
ClanInfo clan = ClansManager.getInstance().getClan(caller);
|
||||
|
||||
if (Plugin.getBannerUnlockLevel(caller) < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not purchased the ability to use Clan banners! Buy it at http://www.mineplex.com/shop!"));
|
||||
return;
|
||||
}
|
||||
if (!Plugin.LoadedBanners.containsKey(clan.getName()))
|
||||
{
|
||||
if (Plugin.getBannerUnlockLevel(caller) >= 2 && clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER)
|
||||
{
|
||||
LinkedList<BannerPattern> patterns = new LinkedList<>();
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
patterns.add(new BannerPattern(i + 1));
|
||||
}
|
||||
ClanBanner banner = new ClanBanner(Plugin, clan, DyeColor.WHITE, patterns);
|
||||
Plugin.LoadedBanners.put(clan.getName(), banner);
|
||||
banner.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Your Clan does not have a set banner!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
new NonEditOverviewGUI(caller, Plugin.LoadedBanners.get(clan.getName()));
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
package mineplex.game.clans.clans.banners.gui;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Base class to manage banner guis
|
||||
*/
|
||||
public abstract class BannerGUI implements Listener
|
||||
{
|
||||
private Player _viewer;
|
||||
private Inventory _inventory;
|
||||
private final HashMap<Integer, ItemStack> _items = new HashMap<>();
|
||||
|
||||
public BannerGUI(Player viewer, String pageName, int slots)
|
||||
{
|
||||
_viewer = viewer;
|
||||
_inventory = Bukkit.createInventory(viewer, slots, pageName);
|
||||
Bukkit.getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the owner of this specific inventory
|
||||
* @return The owner of this inventory
|
||||
*/
|
||||
public Player getViewer()
|
||||
{
|
||||
return _viewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches all the items registered as buttons in this inventory gui
|
||||
* @return A list of the items registered as buttons in this inventory gui
|
||||
*/
|
||||
public HashMap<Integer, ItemStack> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the gui with buttons
|
||||
*/
|
||||
public abstract void propagate();
|
||||
|
||||
/**
|
||||
* Handles players clicking on buttons
|
||||
* @param slot The slot clicked on
|
||||
* @param type The type of click
|
||||
*/
|
||||
public abstract void onClick(Integer slot, ClickType type);
|
||||
|
||||
/**
|
||||
* Opens this inventory to its viewer
|
||||
*/
|
||||
public void open()
|
||||
{
|
||||
_viewer.openInventory(_inventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the GUI's visuals to match registered button items
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
_inventory.clear();
|
||||
for (Integer slot : _items.keySet())
|
||||
{
|
||||
_inventory.setItem(slot, _items.get(slot));
|
||||
}
|
||||
for (Integer slot = 0; slot < _inventory.getSize(); slot++)
|
||||
{
|
||||
if (!_items.containsKey(slot))
|
||||
{
|
||||
_inventory.setItem(slot, new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(C.cGray).setData((short)7).build());
|
||||
}
|
||||
}
|
||||
_viewer.updateInventory();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleClick(InventoryClickEvent event)
|
||||
{
|
||||
if (event.getClickedInventory() == null || !event.getClickedInventory().equals(_inventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_viewer.getName().equals(event.getWhoClicked().getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
Integer slot = event.getSlot();
|
||||
if (!_items.containsKey(slot))
|
||||
{
|
||||
return;
|
||||
}
|
||||
onClick(slot, event.getClick());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event)
|
||||
{
|
||||
if (event.getPlayer().getUniqueId().equals(_viewer.getUniqueId()))
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package mineplex.game.clans.clans.banners.gui.creation;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.banners.ClanBanner;
|
||||
import mineplex.game.clans.clans.banners.gui.BannerGUI;
|
||||
import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
/**
|
||||
* GUI manager for selecting a banner's base color
|
||||
*/
|
||||
public class BaseColorSelectionGUI extends BannerGUI
|
||||
{
|
||||
private ClanBanner _banner;
|
||||
|
||||
public BaseColorSelectionGUI(Player viewer, ClanBanner banner)
|
||||
{
|
||||
super(viewer, "Background Color", 27);
|
||||
_banner = banner;
|
||||
|
||||
propagate();
|
||||
open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propagate()
|
||||
{
|
||||
Integer slot = 1;
|
||||
for (short data = 0; data <= 15; data++)
|
||||
{
|
||||
getItems().put(slot, new ItemBuilder(Material.INK_SACK).setData(data).setTitle(C.cGray).build());
|
||||
if ((slot + 1) == 8)
|
||||
{
|
||||
slot = 10;
|
||||
}
|
||||
else if ((slot + 1) == 17)
|
||||
{
|
||||
slot = 21;
|
||||
}
|
||||
else if ((slot + 1) == 22)
|
||||
{
|
||||
slot = 23;
|
||||
}
|
||||
else
|
||||
{
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onClick(Integer slot, ClickType type)
|
||||
{
|
||||
if (getItems().get(slot).getType() == Material.INK_SACK)
|
||||
{
|
||||
DyeColor color = DyeColor.getByDyeData(getItems().get(slot).getData().getData());
|
||||
_banner.setBaseColor(color);
|
||||
_banner.save();
|
||||
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
new OverviewGUI(getViewer(), _banner);
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package mineplex.game.clans.clans.banners.gui.creation;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.banners.BannerPattern;
|
||||
import mineplex.game.clans.clans.banners.ClanBanner;
|
||||
import mineplex.game.clans.clans.banners.gui.BannerGUI;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
/**
|
||||
* GUI manager for selecting a banner pattern's base color
|
||||
*/
|
||||
public class PatternColorSelectionGUI extends BannerGUI
|
||||
{
|
||||
private ClanBanner _banner;
|
||||
private int _bannerPos;
|
||||
|
||||
public PatternColorSelectionGUI(Player viewer, ClanBanner banner, int bannerPosition)
|
||||
{
|
||||
super(viewer, "Pattern Color", 27);
|
||||
_banner = banner;
|
||||
_bannerPos = bannerPosition;
|
||||
|
||||
propagate();
|
||||
open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propagate()
|
||||
{
|
||||
Integer slot = 1;
|
||||
for (short data = 0; data <= 15; data++)
|
||||
{
|
||||
getItems().put(slot, new ItemBuilder(Material.INK_SACK).setData(data).setTitle(C.cGray).build());
|
||||
if ((slot + 1) == 8)
|
||||
{
|
||||
slot = 10;
|
||||
}
|
||||
else if ((slot + 1) == 17)
|
||||
{
|
||||
slot = 21;
|
||||
}
|
||||
else if ((slot + 1) == 22)
|
||||
{
|
||||
slot = 23;
|
||||
}
|
||||
else
|
||||
{
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onClick(Integer slot, ClickType type)
|
||||
{
|
||||
if (getItems().get(slot).getType() == Material.INK_SACK)
|
||||
{
|
||||
DyeColor color = DyeColor.getByDyeData(getItems().get(slot).getData().getData());
|
||||
BannerPattern pattern = _banner.getPatterns().get(_bannerPos);
|
||||
pattern.setColor(color);
|
||||
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
new PatternTypeSelectionGUI(getViewer(), _banner, _bannerPos, color);
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package mineplex.game.clans.clans.banners.gui.creation;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.banners.BannerPattern;
|
||||
import mineplex.game.clans.clans.banners.ClanBanner;
|
||||
import mineplex.game.clans.clans.banners.gui.BannerGUI;
|
||||
import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
|
||||
/**
|
||||
* GUI manager for selecting a banner pattern's design
|
||||
*/
|
||||
public class PatternTypeSelectionGUI extends BannerGUI
|
||||
{
|
||||
private ClanBanner _banner;
|
||||
private int _bannerPos;
|
||||
private DyeColor _color;
|
||||
|
||||
public PatternTypeSelectionGUI(Player viewer, ClanBanner banner, int bannerPosition, DyeColor patternColor)
|
||||
{
|
||||
super(viewer, "Pattern Color", 45);
|
||||
_banner = banner;
|
||||
_bannerPos = bannerPosition;
|
||||
_color = patternColor;
|
||||
|
||||
propagate();
|
||||
open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propagate()
|
||||
{
|
||||
for (int i = 0; i < PatternType.values().length; i++)
|
||||
{
|
||||
ItemStack item = new ItemStack(Material.BANNER);
|
||||
BannerMeta im = (BannerMeta) item.getItemMeta();
|
||||
im.setBaseColor(_banner.getBaseColor());
|
||||
LinkedList<Pattern> patterns = new LinkedList<>();
|
||||
for (int patternId = 0; patternId < _bannerPos; patternId++)
|
||||
{
|
||||
BannerPattern show = _banner.getPatterns().get(patternId);
|
||||
if (show.getBukkitPattern() != null)
|
||||
{
|
||||
patterns.add(show.getBukkitPattern());
|
||||
}
|
||||
}
|
||||
patterns.add(new Pattern(_color, PatternType.values()[i]));
|
||||
im.setPatterns(patterns);
|
||||
im.setDisplayName(C.cGray);
|
||||
item.setItemMeta(im);
|
||||
getItems().put(i, item);
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Integer slot, ClickType ctype)
|
||||
{
|
||||
if (getItems().get(slot).getType() == Material.BANNER)
|
||||
{
|
||||
PatternType type = ((BannerMeta)getItems().get(slot).getItemMeta()).getPatterns().get(Math.min(_bannerPos, ((BannerMeta)getItems().get(slot).getItemMeta()).getPatterns().size() - 1)).getPattern();
|
||||
BannerPattern pattern = _banner.getPatterns().get(_bannerPos);
|
||||
pattern.setPatternType(type);
|
||||
_banner.save();
|
||||
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
new OverviewGUI(getViewer(), _banner);
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package mineplex.game.clans.clans.banners.gui.nonedit;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.banners.BannerPacketManager;
|
||||
import mineplex.game.clans.clans.banners.ClanBanner;
|
||||
import mineplex.game.clans.clans.banners.gui.BannerGUI;
|
||||
import mineplex.game.clans.clans.banners.gui.overview.OverviewGUI;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
/**
|
||||
* GUI manager for viewing a banner usage overview
|
||||
*/
|
||||
public class NonEditOverviewGUI extends BannerGUI
|
||||
{
|
||||
private ClanBanner _banner;
|
||||
|
||||
public NonEditOverviewGUI(Player viewer, ClanBanner banner)
|
||||
{
|
||||
super(viewer, "Clan Banner", 9);
|
||||
_banner = banner;
|
||||
|
||||
propagate();
|
||||
open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propagate()
|
||||
{
|
||||
ItemStack banner = _banner.getBanner().clone();
|
||||
ItemMeta im = banner.getItemMeta();
|
||||
im.setDisplayName(C.cGreen + "Clan Banner");
|
||||
im.setLore(Arrays.asList(new String[] {F.elem("Left Click") + " to toggle wearing your banner", F.elem("Right Click") + " to place down your banner"}));
|
||||
banner.setItemMeta(im);
|
||||
getItems().put(4, banner);
|
||||
|
||||
if (_banner.getClan().getMembers().get(getViewer().getUniqueId()).getRole() == ClanRole.LEADER && ClansManager.getInstance().getBannerManager().getBannerUnlockLevel(getViewer()) >= 2)
|
||||
{
|
||||
getItems().put(8, new ItemBuilder(Material.ANVIL).setTitle(C.cGold + "Edit Your Banner").build());
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Integer slot, ClickType type)
|
||||
{
|
||||
if (slot == 4)
|
||||
{
|
||||
if (type == ClickType.LEFT)
|
||||
{
|
||||
BannerPacketManager.getInstance().toggleBanner(getViewer(), _banner.getBanner());
|
||||
UtilPlayer.message(getViewer(), F.main("Clan Banners", "You have toggled your banner!"));
|
||||
}
|
||||
else if (type == ClickType.RIGHT)
|
||||
{
|
||||
_banner.place(getViewer());
|
||||
}
|
||||
}
|
||||
if (slot == 8)
|
||||
{
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
new OverviewGUI(getViewer(), _banner);
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package mineplex.game.clans.clans.banners.gui.overview;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.banners.BannerPattern;
|
||||
import mineplex.game.clans.clans.banners.ClanBanner;
|
||||
import mineplex.game.clans.clans.banners.gui.BannerGUI;
|
||||
import mineplex.game.clans.clans.banners.gui.creation.BaseColorSelectionGUI;
|
||||
import mineplex.game.clans.clans.banners.gui.creation.PatternColorSelectionGUI;
|
||||
import mineplex.game.clans.clans.banners.gui.nonedit.NonEditOverviewGUI;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
/**
|
||||
* GUI manager for overviewing a banner's design
|
||||
*/
|
||||
public class OverviewGUI extends BannerGUI
|
||||
{
|
||||
private static final int MAX_BANNER_LAYERS = 12;
|
||||
private static final int PATTERN_DISPLAY_START_SLOT = 27;
|
||||
private final ClanBanner _banner;
|
||||
|
||||
public OverviewGUI(Player viewer, ClanBanner banner)
|
||||
{
|
||||
super(viewer, "Clan Banner", 45);
|
||||
_banner = banner;
|
||||
|
||||
propagate();
|
||||
open();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void propagate()
|
||||
{
|
||||
getItems().put(4, _banner.getBanner());
|
||||
ItemStack color = new MaterialData(Material.INK_SACK, _banner.getBaseColor().getDyeData()).toItemStack(1);
|
||||
ItemMeta colorMeta = color.getItemMeta();
|
||||
colorMeta.setDisplayName(C.cGray);
|
||||
color.setItemMeta(colorMeta);
|
||||
getItems().put(22, color);
|
||||
Integer slot = PATTERN_DISPLAY_START_SLOT;
|
||||
for (int i = 0; i < MAX_BANNER_LAYERS; i++)
|
||||
{
|
||||
ItemStack item = new ItemStack(Material.INK_SACK, 1, (short)8);
|
||||
if (i < _banner.getPatterns().size())
|
||||
{
|
||||
BannerPattern pattern = _banner.getPatterns().get(i);
|
||||
if (pattern.getBukkitPattern() != null)
|
||||
{
|
||||
ItemStack representation = new ItemStack(Material.BANNER);
|
||||
BannerMeta im = (BannerMeta) representation.getItemMeta();
|
||||
im.setBaseColor(_banner.getBaseColor());
|
||||
im.setDisplayName(C.cGray);
|
||||
im.setPatterns(Arrays.asList(pattern.getBukkitPattern()));
|
||||
representation.setItemMeta(im);
|
||||
item = representation;
|
||||
}
|
||||
}
|
||||
getItems().put(slot, item);
|
||||
slot++;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Integer slot, ClickType type)
|
||||
{
|
||||
if (slot == 4)
|
||||
{
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
new NonEditOverviewGUI(getViewer(), _banner);
|
||||
}, 2L);
|
||||
}
|
||||
if (slot == 22)
|
||||
{
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
new BaseColorSelectionGUI(getViewer(), _banner);
|
||||
}, 2L);
|
||||
}
|
||||
if (slot >= PATTERN_DISPLAY_START_SLOT)
|
||||
{
|
||||
if (type == ClickType.RIGHT)
|
||||
{
|
||||
_banner.getPatterns().get(slot - PATTERN_DISPLAY_START_SLOT).setColor(null);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getItems().clear();
|
||||
propagate();
|
||||
refresh();
|
||||
}, 1L);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
getViewer().closeInventory();
|
||||
}, 1L);
|
||||
ClansManager.getInstance().runSyncLater(() ->
|
||||
{
|
||||
new PatternColorSelectionGUI(getViewer(), _banner, slot - PATTERN_DISPLAY_START_SLOT);
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user