Merge branch 'clans/beta' of github.com:Mineplex-LLC/Minecraft-PC into clans/beta

This commit is contained in:
phobia 2016-04-12 09:48:59 +10:00
commit 11d92c49ec
60 changed files with 1134 additions and 710 deletions

View File

@ -56,12 +56,12 @@ public class MotdManager implements Listener, Runnable
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f"; // String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
String motdLine = " §f❄ §2§lMerry Christmas §f❄ §2§lElf Presents §f❄"; String motdLine = " §f> §4§lCLANS BETA §f- §c§lOpen to Everyone §f<";
// String motdLine = " §f❄ §2§lServer Maintenance §f❄ §2§lBe Back Soon §f❄"; // String motdLine = " §f❄ §2§lServer Maintenance §f❄ §2§lBe Back Soon §f❄";
//String motdLine = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §d§lRank Sale §a§l40% Off");
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine); updateMainMotd(" §f§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§f§m §r", motdLine);
System.out.println("Updated Bungee MOTD"); System.out.println("Updated Bungee MOTD");
} }
} }

View File

@ -216,6 +216,24 @@ public class UtilAlg
return true; return true;
} }
public static boolean inBoundingBox(Location loc, Vector cornerA, Vector cornerB)
{
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
if (cornerA.getY() != cornerB.getY())
{
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
}
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
return true;
}
public static Vector cross(Vector a, Vector b) public static Vector cross(Vector a, Vector b)
{ {
double x = a.getY()*b.getZ() - a.getZ()*b.getY(); double x = a.getY()*b.getZ() - a.getZ()*b.getY();

View File

@ -2,18 +2,20 @@ package mineplex.core.common.util;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class UtilWorld public class UtilWorld
{ {
public static World getWorld(String world) public static World getWorld(String world)
@ -210,4 +212,81 @@ public class UtilWorld
origin.getBlock().getRelative(BlockFace.WEST)); origin.getBlock().getRelative(BlockFace.WEST));
} }
/**
* This method will use the World provided by the given Location.<p>
* @return <b>true</b> if the specified location is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean inWorldBorder(Location location)
{
WorldBorder border = location.getWorld().getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ;
}
/**
* This method will use the World specified by the second argument, and the
* x, y, and z provided by the given Location.<p>
* @return <b>true</b> if the specified location is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean inWorldBorder(World world, Location location)
{
WorldBorder border = world.getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
return location.getX() >= minX && location.getX() <= maxX && location.getZ() >= minZ && location.getZ() <= maxZ;
}
/**
* @return <b>true</b> if the specified bounding box is within the bounds of the
* world's set border, or <b>false</b> if {@link World#getWorldBorder()} returns null.
*/
public static boolean isBoxInWorldBorder(World world, Location min, Location max)
{
WorldBorder border = world.getWorldBorder();
if (border == null)
{
return false;
}
double size = border.getSize() / 2;
double maxX = size;
double maxZ = size;
double minX = -size;
double minZ = -size;
double startX = Math.min(min.getX(), max.getX());
double startZ = Math.min(min.getZ(), max.getZ());
double endX = Math.max(min.getX(), max.getX());
double endZ = Math.max(min.getZ(), max.getZ());
return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ;
}
} }

View File

@ -58,6 +58,7 @@ public class Chat extends MiniPlugin
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private PreferencesManager _preferences; private PreferencesManager _preferences;
private AchievementManager _achievements; private AchievementManager _achievements;
private IncognitoManager _incognitoManager;
private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"}; private String[] _hackusations = {"hack", "hax", "hacker", "hacking", "cheat", "cheater", "cheating", "forcefield", "flyhack", "flyhacking", "autoclick", "aimbot"};
private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate"; private String _filterUrl = "https://chat.mineplex.com:8003/content/item/moderate";
@ -74,10 +75,11 @@ public class Chat extends MiniPlugin
private HashMap<UUID, MessageData> _playerLastMessage = new HashMap<UUID, MessageData>(); private HashMap<UUID, MessageData> _playerLastMessage = new HashMap<UUID, MessageData>();
public Chat(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName) public Chat(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName)
{ {
super("Chat", plugin); super("Chat", plugin);
_incognitoManager = incognitoManager;
_clientManager = clientManager; _clientManager = clientManager;
_serverName = serverName; _serverName = serverName;
_preferences = preferences; _preferences = preferences;
@ -308,7 +310,7 @@ public class Chat extends MiniPlugin
Player sender = event.getPlayer(); Player sender = event.getPlayer();
if (IncognitoManager.Instance.Get(sender).Status) if (_incognitoManager != null && _incognitoManager.Get(sender).Status)
{ {
UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito."); UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito.");
event.setCancelled(true); event.setCancelled(true);

View File

@ -27,7 +27,7 @@ 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 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 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_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;";
private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? 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 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 static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;";
@ -191,7 +191,8 @@ public class DonationRepository extends MinecraftRepository
{ {
public void run() public void run()
{ {
boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0; 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); callback.run(success);
} }
}), "Error updating player gold amount in DonationRepository : "); }), "Error updating player gold amount in DonationRepository : ");
@ -199,6 +200,10 @@ public class DonationRepository extends MinecraftRepository
public void setGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold) 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() handleDatabaseCall(new DatabaseRunnable(new Runnable()
{ {
public void run() public void run()

View File

@ -6,24 +6,24 @@ import java.sql.SQLException;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.incognito.commands.IncognitoToggleCommand; import mineplex.core.incognito.commands.IncognitoToggleCommand;
import mineplex.core.incognito.events.IncognitoHidePlayerEvent;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.incognito.repository.IncognitoClient; import mineplex.core.incognito.repository.IncognitoClient;
import mineplex.core.incognito.repository.IncognitoRepository; import mineplex.core.incognito.repository.IncognitoRepository;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -31,8 +31,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private IncognitoRepository _repository; private IncognitoRepository _repository;
private PreferencesManager _preferencesManager;
public static IncognitoManager Instance;
public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler) public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler)
{ {
@ -40,8 +39,6 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
_repository = new IncognitoRepository(this); _repository = new IncognitoRepository(this);
_clientManager = clientManager; _clientManager = clientManager;
Instance = this;
} }
public void addCommands() public void addCommands()
@ -63,59 +60,109 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
Get(caller).Status = enabled; Get(caller).Status = enabled;
if (!enabled) if (!enabled)
{
if (event.doShow())
{ {
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
other.showPlayer(caller); other.showPlayer(caller);
} }
} }
}
else
{
IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(caller));
if (!customEvent.isCancelled())
{
UtilServer.getPlayersCollection().forEach(player -> {
player.hidePlayer(caller);
});
}
}
runAsync(() -> _repository.setStatus(_clientManager.getAccountId(caller), enabled)); runAsync(() -> _repository.setStatus(_clientManager.getAccountId(caller), enabled));
return enabled; return enabled;
} }
@EventHandler(priority = EventPriority.LOWEST)
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
UtilServer.getPlayersCollection().forEach(player ->
{
UtilServer.getPlayersCollection().forEach(other ->
{
if (Get(other).Status && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
player.hidePlayer(other);
if (Get(player).Status)
{
if (!_clientManager.hasRank(other, _clientManager.Get(player).GetRank()))
other.hidePlayer(player);
}
});
});
}
}
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void Join(PlayerJoinEvent event) public void Join(PlayerJoinEvent event)
{ {
Player player = event.getPlayer();
if (Get(event.getPlayer()).Status && !_clientManager.hasRank(event.getPlayer(), Rank.HELPER))
{
Get(event.getPlayer()).Status = false;
runAsync(() -> _repository.setStatus(_clientManager.getAccountId(player), false));
return;
}
if (Get(event.getPlayer()).Status) if (Get(event.getPlayer()).Status)
{ {
event.setJoinMessage(null); event.setJoinMessage(null);
informIncognito(event.getPlayer()); informIncognito(player);
} }
UtilServer.getPlayersCollection().forEach(player -> { IncognitoHidePlayerEvent customEvent = null;
if (Get(event.getPlayer()).Status && !_clientManager.hasRank(player, _clientManager.Get(event.getPlayer()).GetRank()))
player.hidePlayer(event.getPlayer());
if (Get(event.getPlayer()).Status)
{
customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player));
}
for (Player other : UtilServer.getPlayers())
{
if (customEvent != null && !customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank()))
{
other.hidePlayer(player);
}
if (Get(other).Status)
{
IncognitoHidePlayerEvent customEvent2 = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other));
if (!customEvent2.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
{
player.hidePlayer(other);
}
}
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
for (Player other : UtilServer.getPlayers())
{
if (Get(player).Status) if (Get(player).Status)
{ {
if (!_clientManager.hasRank(event.getPlayer(), _clientManager.Get(player).GetRank())) IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(player));
event.getPlayer().hidePlayer(player);
if (!customEvent.isCancelled() && !_clientManager.hasRank(other, _clientManager.Get(player).GetRank()))
{
other.hidePlayer(player);
}
}
if (Get(other).Status)
{
IncognitoHidePlayerEvent customEvent = UtilServer.CallEvent(new IncognitoHidePlayerEvent(other));
if (!customEvent.isCancelled() && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
{
player.hidePlayer(other);
}
}
}
} }
});
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -168,4 +215,14 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
Get(playerName).Status = resultSet.getInt("status") == 1; Get(playerName).Status = resultSet.getInt("status") == 1;
} }
} }
public PreferencesManager getPreferences()
{
return _preferencesManager;
}
public void setPreferencesManager(PreferencesManager preferencesManager)
{
_preferencesManager = preferencesManager;
}
} }

View File

@ -18,6 +18,12 @@ public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (Plugin.getPreferences().Get(caller).Invisibility)
{
UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled."));
return;
}
if (Plugin.toggle(caller)) if (Plugin.toggle(caller))
{ {
UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again.")); UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem(AliasUsed) + " again."));

View File

@ -0,0 +1,47 @@
package mineplex.core.incognito.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when an Incognito player is getting hidden from all other players.
*/
public class IncognitoHidePlayerEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private boolean _cancelled;
public IncognitoHidePlayerEvent(Player player)
{
_player = player;
}
public Player getPlayer()
{
return _player;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -13,6 +13,8 @@ public class IncognitoStatusChangeEvent extends Event
private boolean _cancelled; private boolean _cancelled;
private boolean _show = true;
public IncognitoStatusChangeEvent(Player player, boolean newState) public IncognitoStatusChangeEvent(Player player, boolean newState)
{ {
_player = player; _player = player;
@ -49,4 +51,14 @@ public class IncognitoStatusChangeEvent extends Event
return handlers; return handlers;
} }
public void show(boolean show)
{
_show = show;
}
public boolean doShow()
{
return _show;
}
} }

View File

@ -27,7 +27,12 @@ import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendStatus; import mineplex.core.friend.data.FriendStatus;
import mineplex.core.ignore.IgnoreManager; import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.IncognitoManager;
import mineplex.core.message.commands.*; import mineplex.core.message.commands.AdminCommand;
import mineplex.core.message.commands.AnnounceCommand;
import mineplex.core.message.commands.MessageAdminCommand;
import mineplex.core.message.commands.MessageCommand;
import mineplex.core.message.commands.ResendAdminCommand;
import mineplex.core.message.commands.ResendCommand;
import mineplex.core.message.redis.AnnouncementHandler; import mineplex.core.message.redis.AnnouncementHandler;
import mineplex.core.message.redis.MessageHandler; import mineplex.core.message.redis.MessageHandler;
import mineplex.core.message.redis.RedisMessage; import mineplex.core.message.redis.RedisMessage;
@ -45,6 +50,8 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private FriendManager _friendsManager; private FriendManager _friendsManager;
private IgnoreManager _ignoreManager; private IgnoreManager _ignoreManager;
private IncognitoManager _incognitoManager;
private HashMap<UUID, BukkitRunnable> _messageTimeouts = new HashMap<UUID, BukkitRunnable>(); private HashMap<UUID, BukkitRunnable> _messageTimeouts = new HashMap<UUID, BukkitRunnable>();
private PreferencesManager _preferences; private PreferencesManager _preferences;
private Punish _punish; private Punish _punish;
@ -52,11 +59,12 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
private ArrayList<String> _randomMessage; private ArrayList<String> _randomMessage;
private String _serverName; private String _serverName;
public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, public MessageManager(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences,
IgnoreManager ignoreManager, Punish punish, FriendManager friendManager, Chat chat) IgnoreManager ignoreManager, Punish punish, FriendManager friendManager, Chat chat)
{ {
super("Message", plugin); super("Message", plugin);
_incognitoManager = incognitoManager;
_clientManager = clientManager; _clientManager = clientManager;
_preferences = preferences; _preferences = preferences;
_ignoreManager = ignoreManager; _ignoreManager = ignoreManager;
@ -86,7 +94,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
addCommand(new AnnounceCommand(this)); addCommand(new AnnounceCommand(this));
//addCommand(new GlobalCommand(this)); //addCommand(new GlobalCommand(this));
addCommand(new AdminCommand(this)); addCommand(new AdminCommand(this, _incognitoManager));
} }
@Override @Override
@ -523,7 +531,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
// If this is a message inside the server // If this is a message inside the server
if (to != null) if (to != null)
{ {
if (IncognitoManager.Instance.Get(to).Status) if (_incognitoManager.Get(to).Status)
{ {
UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "].")); UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "]."));
return; return;

View File

@ -9,14 +9,18 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.message.MessageManager; import mineplex.core.message.MessageManager;
import mineplex.core.visibility.VisibilityManager;
public class AdminCommand extends CommandBase<MessageManager> public class AdminCommand extends CommandBase<MessageManager>
{ {
public AdminCommand(MessageManager plugin) private IncognitoManager _incognitoManager;
public AdminCommand(MessageManager plugin, IncognitoManager incognitoManager)
{ {
super(plugin, Rank.ALL, "a","admin"); super(plugin, Rank.ALL, "a","admin");
_incognitoManager = incognitoManager;
} }
@Override @Override
@ -51,6 +55,11 @@ public class AdminCommand extends CommandBase<MessageManager>
{ {
if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER)) if (Plugin.GetClientManager().Get(to).GetRank().has(Rank.HELPER))
{ {
if (_incognitoManager.Get(to).Status)
{
continue;
}
if (!to.equals(caller)) if (!to.equals(caller))
UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message); UtilPlayer.message(to, F.rank(Plugin.GetClientManager().Get(caller).GetRank()) + " " + caller.getName() + " " + C.cPurple + message);

View File

@ -4,20 +4,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,17 +15,35 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences> public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{ {
private PreferencesRepository _repository; private PreferencesRepository _repository;
private PreferencesShop _shop; private PreferencesShop _shop;
private ExclusivePreferencesShop _exclusiveShop; private ExclusivePreferencesShop _exclusiveShop;
private IncognitoManager _incognitoManager;
private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>(); private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>();
public boolean GiveItem; public boolean GiveItem;
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager) public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager)
{ {
super("Preferences", plugin, clientManager); super("Preferences", plugin, clientManager);
@ -47,6 +51,8 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
_exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager); _exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager);
_shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop); _shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop);
_incognitoManager = incognito;
_exclusiveShop.setPreferencesShop(_shop); _exclusiveShop.setPreferencesShop(_shop);
addCommand(new PreferencesCommand(this)); addCommand(new PreferencesCommand(this));
@ -138,4 +144,9 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
{ {
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;"; return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
} }
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
} }

View File

@ -8,6 +8,8 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilUI; import mineplex.core.common.util.UtilUI;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
@ -149,6 +151,12 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
private void toggleHubInvisibility(org.bukkit.entity.Player player) private void toggleHubInvisibility(org.bukkit.entity.Player player)
{ {
if (getPlugin().getIncognitoManager() != null && getPlugin().getIncognitoManager().Get(player).Status)
{
UtilPlayer.message(player, F.main("Incognito", "You are not allowed to use Hub Visibility whilst in incognito mode."));
return;
}
getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility; getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility;
// Dont save for Mod/SnrMod - prevents them just being invis 24/7 // Dont save for Mod/SnrMod - prevents them just being invis 24/7

View File

@ -97,7 +97,11 @@ public class Clans extends JavaPlugin
new ServerConfiguration(this, _clientManager); new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); PacketHandler packetHandler = new PacketHandler(this);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
incognito.setPreferencesManager(preferenceManager);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
@ -109,9 +113,8 @@ public class Clans extends JavaPlugin
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
// new ClansBanManager(this, _clientManager, _donationManager); // ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
PacketHandler packetHandler = new PacketHandler(this);
Punish punish = new Punish(this, webServerAddress, _clientManager); Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false); AntiHack.Instance.setKick(false);
@ -120,12 +123,10 @@ public class Clans extends JavaPlugin
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
new IncognitoManager(this, _clientManager, packetHandler);
StatsManager statsManager = new StatsManager(this, _clientManager); StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
new MemoryFix(this); new MemoryFix(this);
new FoodDupeFix(this); new FoodDupeFix(this);
@ -143,7 +144,7 @@ public class Clans extends JavaPlugin
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
HologramManager hologram = new HologramManager(this, packetHandler); HologramManager hologram = new HologramManager(this, packetHandler);
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), 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, webServerAddress);
new Recipes(this); new Recipes(this);
new Farming(this); new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager); new BuildingShop(_clansManager, _clientManager, _donationManager);

View File

@ -103,8 +103,6 @@ import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.regions.ClansRegions;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
import mineplex.game.clans.clans.staff.SilentChestOpen;
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.war.WarManager;
@ -176,6 +174,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private NetherManager _netherManager; private NetherManager _netherManager;
private DamageManager _damageManager; private DamageManager _damageManager;
private SiegeManager _siegeManager; private SiegeManager _siegeManager;
private IncognitoManager _incognitoManager;
private ClansBlacklist _blacklist; private ClansBlacklist _blacklist;
@ -225,18 +224,22 @@ 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; public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator;
/*private ClansBanManager _clansBans;*/
public ClanTips ClanTips; public ClanTips ClanTips;
// Spawn area // Spawn area
public ClansManager(JavaPlugin plugin, String serverName, 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, String webServerAddress)
{ {
super("Clans Manager", plugin); super("Clans Manager", plugin);
_instance = this; _instance = this;
/*_clansBans = clansBans;*/
_punish = punish; _punish = punish;
_incognitoManager = incognitoManager;
_serverName = serverName; _serverName = serverName;
_clientManager = clientManager; _clientManager = clientManager;
_combatManager = new CombatManager(plugin); _combatManager = new CombatManager(plugin);
@ -276,7 +279,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_clanDisplay = new ClansDisplay(plugin, this); _clanDisplay = new ClansDisplay(plugin, this);
_clanGame = new ClansGame(plugin, this); _clanGame = new ClansGame(plugin, this);
_clanUtility = new ClansUtility(this); _clanUtility = new ClansUtility(this);
_tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, _npcManager, _taskManager); _tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, this, _npcManager, _taskManager);
_itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent); _itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent);
new TntGeneratorManager(plugin, this); new TntGeneratorManager(plugin, this);
new SupplyDropManager(plugin, this); new SupplyDropManager(plugin, this);
@ -296,8 +299,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new Field(plugin, creature, _condition, this, energy, serverName); new Field(plugin, creature, _condition, this, energy, serverName);
new SilentChestOpen(this);
// Required managers to be initialized // Required managers to be initialized
new Spawn(plugin, this); new Spawn(plugin, this);
new NPCManager(this, _hologramManager); new NPCManager(this, _hologramManager);
@ -599,11 +600,21 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{ {
event.setJoinMessage(null); event.setJoinMessage(null);
if (IncognitoManager.Instance.Get(event.getPlayer()).Status) /*if (_clansBans.willBeKicked(event.getPlayer()))
{
return;
}*/
if (_incognitoManager.Get(event.getPlayer()).Status)
{ {
return; return;
} }
/*_clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
if (_clansBans.Get(event.getPlayer().getName()).isBanned())
{
return;
}*/
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
@ -615,6 +626,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
other.sendMessage(F.sys("Join", event.getPlayer().getName())); other.sendMessage(F.sys("Join", event.getPlayer().getName()));
} }
/*});*/
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -622,11 +634,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{ {
event.setQuitMessage(null); event.setQuitMessage(null);
if (IncognitoManager.Instance.Get(event.getPlayer()).Status) if (_incognitoManager.Get(event.getPlayer()).Status)
{ {
return; return;
} }
/*if (_clansBans.willBeKicked(event.getPlayer()))
{
return;
}*/
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
@ -643,12 +659,22 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void Kick(PlayerKickEvent event) public void Kick(PlayerKickEvent event)
{ {
if (IncognitoManager.Instance.Get(event.getPlayer()).Status) if (_incognitoManager.Get(event.getPlayer()).Status)
{ {
event.setLeaveMessage(null); event.setLeaveMessage(null);
return; return;
} }
/*if (_clansBans.willBeKicked(event.getPlayer()))
{
return;
}*/
if (event.getReason().contains("You are banned from Clans"))
{
return;
}
if (event.getLeaveMessage() != null) if (event.getLeaveMessage() != null)
{ {
event.setLeaveMessage(null); event.setLeaveMessage(null);
@ -1178,17 +1204,35 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{ {
Rank rank = _clientManager.Get(event.getPlayer()).GetRank(); Rank rank = _clientManager.Get(event.getPlayer()).GetRank();
if (rank.has(Rank.MODERATOR)) if (rank.has(Rank.HELPER))
{ {
event.allow(); event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED); event.setResult(PlayerLoginEvent.Result.ALLOWED);
return;
} }
if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) int online = 0;
for (Player player : UtilServer.getPlayers())
{
if (_clientManager.hasRank(player, Rank.HELPER))
{
continue;
}
online++;
}
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.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon");
event.setKickMessage("Clans Beta is full! Try again soon"); event.setKickMessage("Clans Beta is full! Try again soon");
} }
else
{
event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
}
} }
@EventHandler @EventHandler
@ -1381,4 +1425,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{ {
return _siegeManager; return _siegeManager;
} }
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
} }

View File

@ -2,6 +2,7 @@ package mineplex.game.clans.clans.ban;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -12,8 +13,6 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -23,6 +22,7 @@ import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor; import mineplex.core.account.ILoginProcessor;
import mineplex.core.common.DefaultHashMap;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
@ -32,6 +32,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ban.commands.ClansBanCommand; import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
import mineplex.game.clans.clans.ban.ui.ClansBanShop; import mineplex.game.clans.clans.ban.ui.ClansBanShop;
@ -41,6 +42,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
private ClansBanRepository _repository; private ClansBanRepository _repository;
private Map<String, ClansBanClient> _clients; private Map<String, ClansBanClient> _clients;
private Map<String, Pair<String, String>> _cache; private Map<String, Pair<String, String>> _cache;
private DefaultHashMap<String, List<Runnable>> _runAfterLoad;
private ClansBanShop _shop; private ClansBanShop _shop;
private Map<String, String> _toKick = new HashMap<>(); private Map<String, String> _toKick = new HashMap<>();
@ -57,7 +59,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
_clients = new HashMap<>(); _clients = new HashMap<>();
_cache = new HashMap<>(); _cache = new HashMap<>();
_runAfterLoad = new DefaultHashMap<>(name -> new ArrayList<>());
_shop = new ClansBanShop(this, clientManager, donationManager); _shop = new ClansBanShop(this, clientManager, donationManager);
clientManager.addStoredProcedureLoginProcessor(this); clientManager.addStoredProcedureLoginProcessor(this);
@ -232,6 +234,11 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
LoadClient(name, callback); LoadClient(name, callback);
} }
public boolean willBeKicked(Player player)
{
return _toKick.containsKey(player.getName());
}
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{ {
_repository.loadBans(playerName, client -> { _repository.loadBans(playerName, client -> {
@ -246,6 +253,19 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
"\n" + C.cWhite + client.getLongestBan().getReason(); "\n" + C.cWhite + client.getLongestBan().getReason();
_toKick.put(playerName, reason); _toKick.put(playerName, reason);
ClansManager.getInstance().runSyncLater(() -> {
if (Bukkit.getPlayer(playerName) != null)
{
Bukkit.getPlayer(playerName).kickPlayer(_toKick.remove(playerName));
}
else
{
_runAfterLoad.get(playerName).forEach(Runnable::run);
_runAfterLoad.get(playerName).clear();
}
}, 5L);
} }
}); });
} }
@ -254,4 +274,9 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
{ {
return "SELECT * FROM clanBans WHERE uuid = '" + uuid + "';"; return "SELECT * FROM clanBans WHERE uuid = '" + uuid + "';";
} }
public void runAfterLoad(String playerName, Runnable run)
{
_runAfterLoad.get(playerName).add(run);
}
} }

View File

@ -357,7 +357,7 @@ public class ClansCommand extends CommandBase<ClansManager>
} }
Player target = UtilPlayer.searchOnline(caller, args[1], true); Player target = UtilPlayer.searchOnline(caller, args[1], true);
if (target == null || IncognitoManager.Instance.Get(target).Status) return; if (target == null || _clansManager.getIncognitoManager().Get(target).Status) return;
Plugin.getClanUtility().invite(caller, clan, target); Plugin.getClanUtility().invite(caller, clan, target);
} }

View File

@ -0,0 +1,58 @@
package mineplex.game.clans.clans.event;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called before an iron door is opened by right clicking.
*
* (Custom mechanic in Clans)
*/
public class IronDoorOpenEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private Block _block;
private boolean _cancelled;
public IronDoorOpenEvent(Player player, Block block)
{
_player = player;
_block = block;
}
public Player getPlayer()
{
return _player;
}
public Block getBlock()
{
return _block;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -210,6 +210,7 @@ public class NetherManager extends MiniPlugin
_clansManager.getItemMapManager().removeMap(player); _clansManager.getItemMapManager().removeMap(player);
}); });
} }
if (event.getType() == UpdateType.SLOW) if (event.getType() == UpdateType.SLOW)
{ {
_portals.forEach(portal -> { _portals.forEach(portal -> {

View File

@ -39,10 +39,10 @@ public class Portal
if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock())) if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock()))
{ {
if (!isValidPortalBlock(from.getBlock())) if (!isValidPortalBlock(from.getBlock()))
from = UtilBlock.getInRadius(from.getBlock(), 12).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); from = UtilBlock.getInRadius(from.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation();
if (!isValidPortalBlock(to.getBlock())) if (!isValidPortalBlock(to.getBlock()))
to = UtilBlock.getInRadius(to.getBlock(), 9).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation(); to = UtilBlock.getInRadius(to.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation();
if (to == null || from == null) if (to == null || from == null)
{ {
@ -54,7 +54,7 @@ public class Portal
} }
} }
for (Block other : UtilBlock.getInRadius(from, 7.5d).keySet()) for (Block other : UtilBlock.getInRadius(from, 25).keySet())
{ {
if (other.getType() == Material.OBSIDIAN) if (other.getType() == Material.OBSIDIAN)
{ {

View File

@ -1,7 +1,5 @@
package mineplex.game.clans.clans.siege; package mineplex.game.clans.clans.siege;
import java.util.Stack;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -23,7 +21,6 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.commands.CommandSiegeSupplies;
import mineplex.game.clans.clans.siege.outpost.OutpostManager; import mineplex.game.clans.clans.siege.outpost.OutpostManager;
import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository; import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken; import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
@ -36,11 +33,8 @@ import net.minecraft.server.v1_8_R3.Material;
public class SiegeManager extends MiniPlugin public class SiegeManager extends MiniPlugin
{ {
private ClansManager _clansManager; private ClansManager _clansManager;
private OutpostManager _outpostManager; private OutpostManager _outpostManager;
public static SiegeManager Instance;
public NautHashMap<Integer, SiegeWeapon> LiveSiegeWeapons = new NautHashMap<>(); public NautHashMap<Integer, SiegeWeapon> LiveSiegeWeapons = new NautHashMap<>();
public NautHashMap<Integer, SiegeWeapon> UnsyncedSiegeWeapons = new NautHashMap<>(); public NautHashMap<Integer, SiegeWeapon> UnsyncedSiegeWeapons = new NautHashMap<>();
@ -58,11 +52,7 @@ public class SiegeManager extends MiniPlugin
_outpostManager = new OutpostManager(clans, this); _outpostManager = new OutpostManager(clans, this);
addCommand(new CommandSiegeSupplies(_outpostManager)); _repository = new SiegeWeaponRepository(clans.getPlugin(), this);
Instance = this;
_repository = new SiegeWeaponRepository(clans.getPlugin());
_outpostManager.loadOutposts(); _outpostManager.loadOutposts();
@ -122,6 +112,7 @@ public class SiegeManager extends MiniPlugin
if (!part) if (!part)
{ {
System.out.println("Removing slime...");
slime.remove(); slime.remove();
} }
else else
@ -172,11 +163,13 @@ public class SiegeManager extends MiniPlugin
{ {
if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().getType().equals(Material.SPONGE)) if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().getType().equals(Material.SPONGE))
{ {
System.out.println("Removing armor stand");
entity.remove(); entity.remove();
} }
if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime) if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime)
{ {
System.out.println("Removing armostand + children");
entity.getPassenger().getPassenger().remove(); entity.getPassenger().getPassenger().remove();
entity.getPassenger().remove(); entity.getPassenger().remove();
entity.remove(); entity.remove();
@ -188,8 +181,6 @@ public class SiegeManager extends MiniPlugin
private void saveSiegeWeapons() private void saveSiegeWeapons()
{ {
final Stack<Runnable> queue = new Stack<>();
for (final SiegeWeapon weapon : LiveSiegeWeapons.values()) for (final SiegeWeapon weapon : LiveSiegeWeapons.values())
{ {
final SiegeWeaponToken token = weapon.toToken(); final SiegeWeaponToken token = weapon.toToken();
@ -197,28 +188,10 @@ public class SiegeManager extends MiniPlugin
if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId))) if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
continue; continue;
queue.push(() -> { runAsync(() -> {
_repository.updateWeapon(token); _repository.updateWeapon(token);
}); });
} }
runAsync(() -> {
while (!queue.isEmpty())
{
queue.pop().run();
}
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens -> {
tokens.forEach(token -> {
if (!LiveSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)) && !UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
{
System.out.println("LiveSiegeWeapons no longer contains old weapon " + token.UniqueId + ", deleting.");
_repository.deleteWeapon(token.UniqueId);
}
});
});
});
} }
@EventHandler @EventHandler

View File

@ -1,35 +0,0 @@
package mineplex.game.clans.clans.siege.commands;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.siege.outpost.Outpost;
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
import mineplex.game.clans.clans.siege.weapon.Cannon;
public class CommandSiegeSupplies extends CommandBase<OutpostManager>
{
public CommandSiegeSupplies(OutpostManager plugin)
{
super(plugin, Rank.MODERATOR, "siege");
}
@Override
public void Execute(Player caller, String[] args)
{
ItemStack outpost = new ItemStack(Outpost.OUTPOST_ITEM);
ItemStack cannons = new ItemStack(Cannon.CANNON_ITEM);
outpost.setAmount(64);
cannons.setAmount(64);
caller.getInventory().addItem(outpost);
caller.getInventory().addItem(cannons);
UtilPlayer.message(caller, F.main("Clans", "Received supplies for a siege."));
}
}

View File

@ -53,6 +53,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; import mineplex.game.clans.clans.event.ClansWaterPlaceEvent;
import mineplex.game.clans.clans.event.IronDoorOpenEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent; import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock; import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock;
@ -83,7 +84,7 @@ public class Outpost implements Listener
private Location _core; private Location _core;
private LinkedHashMap<String, OutpostBlock> _blocks; private LinkedHashMap<String, OutpostBlock> _blocks;
private LinkedHashMap<String, OutpostBlock> _buildQueue; private LinkedHashMap<String, OutpostBlock> _buildQueue = new LinkedHashMap<>();
protected OutpostType _type; protected OutpostType _type;
private OutpostState _state; private OutpostState _state;
@ -561,6 +562,22 @@ public class Outpost implements Listener
_ownerClan.inform("Your Clan's Outpost has been destroyed.", null); _ownerClan.inform("Your Clan's Outpost has been destroyed.", null);
} }
@EventHandler
public void doorOpen(IronDoorOpenEvent event)
{
if (!UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner))
{
return;
}
if (_ownerClan.isMember(event.getPlayer()))
{
return;
}
event.setCancelled(true);
}
@EventHandler @EventHandler
public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event) public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event)
{ {

View File

@ -44,23 +44,27 @@ public class SiegeWeaponRepository extends MinecraftRepository
private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;"; private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;";
public SiegeWeaponRepository(JavaPlugin plugin) private SiegeManager _siegeManager;
public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager siegeManager)
{ {
super(plugin, DBPool.getAccount()); super(plugin, DBPool.getAccount());
_siegeManager = siegeManager;
} }
public void deleteWeapon(final int uniqueId) public void deleteWeapon(final int uniqueId)
{ {
System.out.println("Siege Repo> Deleting weapon " + uniqueId); System.out.println("Siege Repo> Deleting weapon " + uniqueId);
SiegeManager.Instance.runAsync(() -> _siegeManager.runAsync(() ->
executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId)) executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId))
); );
} }
public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback) public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback)
{ {
SiegeManager.Instance.runAsync(() -> _siegeManager.runAsync(() ->
executeQuery(GET_WEAPON_BY_ID, resultSet -> { executeQuery(GET_WEAPON_BY_ID, resultSet -> {
SiegeWeaponToken token = new SiegeWeaponToken(); SiegeWeaponToken token = new SiegeWeaponToken();
@ -75,7 +79,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback) public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback)
{ {
SiegeManager.Instance.runAsync(() -> _siegeManager.runAsync(() ->
executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> { executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList(); List<SiegeWeaponToken> tokens = Lists.newArrayList();
@ -95,7 +99,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
public void getWeaponsByClan(final ClanInfo clan, final Callback<List<SiegeWeaponToken>> callback) public void getWeaponsByClan(final ClanInfo clan, final Callback<List<SiegeWeaponToken>> callback)
{ {
SiegeManager.Instance.runAsync(() -> _siegeManager.runAsync(() ->
executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> { executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList(); List<SiegeWeaponToken> tokens = Lists.newArrayList();
@ -117,12 +121,11 @@ public class SiegeWeaponRepository extends MinecraftRepository
{ {
token.UniqueId = columns.getInt("uniqueId"); token.UniqueId = columns.getInt("uniqueId");
token.Location = UtilWorld.strToLoc(columns.getString("location")); token.Location = UtilWorld.strToLoc(columns.getString("location"));
token.OwnerClan = SiegeManager.Instance.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan")); token.OwnerClan = _siegeManager.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan"));
token.WeaponType = columns.getByte("weaponType"); token.WeaponType = columns.getByte("weaponType");
token.Health = columns.getShort("health"); token.Health = columns.getShort("health");
token.Yaw = columns.getShort("yaw"); token.Yaw = columns.getShort("yaw");
token.LastFired = columns.getTimestamp("lastFired").getTime(); token.LastFired = columns.getTimestamp("lastFired").getTime();
token.Entities = decodeEntities(columns.getString("entities"));
System.out.println("Siege Repo> Loaded weapon " + token.UniqueId); System.out.println("Siege Repo> Loaded weapon " + token.UniqueId);
} }
@ -131,7 +134,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
{ {
System.out.println("Siege Repo> Updating weapon " + token.UniqueId); System.out.println("Siege Repo> Updating weapon " + token.UniqueId);
SiegeManager.Instance.runAsync(() -> _siegeManager.runAsync(() ->
executeUpdate(UPDATE_WEAPON, executeUpdate(UPDATE_WEAPON,
new ColumnInt("health", token.Health), new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw), new ColumnInt("yaw", token.Yaw),
@ -144,57 +147,24 @@ public class SiegeWeaponRepository extends MinecraftRepository
{ {
System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId); System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId);
SiegeManager.Instance.runAsync(() -> _siegeManager.runAsync(() ->
executeUpdate(INSERT_WEAPON, executeUpdate(INSERT_WEAPON,
new ColumnInt("uniqueId", token.UniqueId), new ColumnInt("uniqueId", token.UniqueId),
new ColumnInt("serverId", SiegeManager.Instance.getClansManager().getServerId()), new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()),
new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)), new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
new ColumnInt("ownerClan", token.OwnerClan.getId()), new ColumnInt("ownerClan", token.OwnerClan.getId()),
new ColumnInt("weaponType", token.WeaponType), new ColumnInt("weaponType", token.WeaponType),
new ColumnInt("health", token.Health), new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw), new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)), new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnVarChar("entities", 100, encodeEntities(token.Entities))) new ColumnVarChar("entities", 100, ""))
); );
} }
private String encodeEntities(Map<String, String> entities)
{
StringBuilder builder = new StringBuilder();
int l = 0;
for (String name : entities.keySet())
{
if (l != 0)
{
builder.append(",");
}
builder.append(name + ":" + entities.get(name));
l++;
}
return builder.toString();
}
private Map<String, String> decodeEntities(String data)
{
Map<String, String> map = new HashMap<>();
for (String entries : data.split(","))
{
map.put(entries.split(":")[0], entries.split(":")[1]);
}
return map;
}
@Override @Override
protected void initialize() protected void initialize()
{ {
SiegeManager.Instance.runAsync(() -> executeUpdate(CREATE);
executeUpdate(CREATE)
);
} }
@Override @Override

View File

@ -16,6 +16,5 @@ public class SiegeWeaponToken
public int Health; public int Health;
public int Yaw; public int Yaw;
public long LastFired; public long LastFired;
public Map<String, String> Entities;
} }

View File

@ -55,6 +55,13 @@ public class Cannon extends SiegeWeapon
{ {
super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager); super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager);
if (_ownerClan == null)
{
System.out.println("[cannon] owner clan null, killing");
kill();
return;
}
System.out.println("Siege> Loading Cannon from token " + token.UniqueId); System.out.println("Siege> Loading Cannon from token " + token.UniqueId);
setBoundingBox(1); setBoundingBox(1);
@ -77,11 +84,11 @@ public class Cannon extends SiegeWeapon
return false; return false;
} }
if (!_ownerClan.isMember(player)) // if (!_ownerClan.isMember(player))
{ // {
UtilPlayer.message(player, F.main("Clans", "This cannon is not owned by your Clan.")); // UtilPlayer.message(player, F.main("Clans", "This cannon is not owned by your Clan."));
return false; // return false;
} // }
if(_clans.hasTimer(player)) if(_clans.hasTimer(player))
{ {
@ -140,7 +147,7 @@ public class Cannon extends SiegeWeapon
setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1)); setStateInfo("Unloaded", new WeaponStateInfo(Material.SPONGE, (byte) 1));
setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0)); setStateInfo("Loaded", new WeaponStateInfo(Material.SPONGE, (byte) 0));
loadEntities(); loadEntities(true);
setFirepowerType(Material.SULPHUR); setFirepowerType(Material.SULPHUR);
setAmmunitionType(Material.TNT); setAmmunitionType(Material.TNT);
@ -161,11 +168,11 @@ public class Cannon extends SiegeWeapon
return false; return false;
} }
if (!_ownerClan.isMember(player)) // if (!_ownerClan.isMember(player))
{ // {
UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan.")); // UtilPlayer.message(player, F.main("Clans", "This Cannon is not owned by your Clan."));
return false; // return false;
} // }
if (_clans.hasTimer(player)) if (_clans.hasTimer(player))
{ {
@ -179,9 +186,9 @@ public class Cannon extends SiegeWeapon
return false; return false;
} }
if (System.currentTimeMillis() - _lastFired < 20000) if (System.currentTimeMillis() - _lastFired < 30000)
{ {
UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(20000 - (System.currentTimeMillis() - _lastFired))) + ")")); UtilPlayer.message(player, F.main("Clans", "Cannon is cooling down (" + F.time(UtilTime.MakeStr(30000 - (System.currentTimeMillis() - _lastFired))) + ")"));
return false; return false;
} }
@ -298,7 +305,7 @@ public class Cannon extends SiegeWeapon
return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2; return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2;
} }
private void loadEntities() private void loadEntities(boolean insert)
{ {
Slime filler = _location.getWorld().spawn(_location.clone(), Slime.class); Slime filler = _location.getWorld().spawn(_location.clone(), Slime.class);
@ -332,29 +339,24 @@ public class Cannon extends SiegeWeapon
addEntity(weapon, "WEAPON"); addEntity(weapon, "WEAPON");
if (insert)
{
insert(); insert();
} }
}
@Override @Override
public void FindEntities() public void FindEntities()
{ {
Lists.newArrayList(_location.getWorld().getEntities()) Lists.newArrayList(_location.getWorld().getEntities())
.forEach(entity -> { .forEach(entity -> {
for (Entry<String, String> entry : _loadedToken.Entities.entrySet()) if (Integer.toString(_uniqueId).equals(entity.getCustomName()))
{ {
if (entity.getUniqueId().toString().equals(entry.getValue())) entity.remove();
{
addEntity(entity, entry.getKey());
}
} }
}); });
if (getEntity("WEAPON") == null || getEntity("Filler_1") == null || getEntity("PLAYERMOUNT") == null) loadEntities(false);
{
System.out.println("[Cannon] Could not find all entities, killing.");
kill();
}
} }
@Override @Override
@ -428,12 +430,12 @@ public class Cannon extends SiegeWeapon
@EventHandler @EventHandler
public void explosionEffects(SiegeWeaponExplodeEvent event) public void explosionEffects(SiegeWeaponExplodeEvent event)
{ {
for (int i = 0; i < 8; i++) // for (int i = 0; i < 8; i++)
{ // {
// Explosion particle effects. // // Explosion particle effects.
Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5); // Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX); // UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX);
} // }
// Block explosion. // Block explosion.
ArrayList<Block> blocks = new ArrayList<>(); ArrayList<Block> blocks = new ArrayList<>();
@ -449,7 +451,7 @@ public class Cannon extends SiegeWeapon
attempts++; attempts++;
} }
_siegeManager.getClansManager().getExplosion().BlockExplosion( _clans.getExplosion().BlockExplosion(
blocks, blocks,
event.getProjectile().getLocation(), event.getProjectile().getLocation(),
false false

View File

@ -162,15 +162,16 @@ public abstract class SiegeWeapon implements Listener
_infoHologram = new Hologram(ClansManager.getInstance().getHologramManager(), _location.clone().add(.5, 3, .5), _name + " Health", getDisplayHealth()); _infoHologram = new Hologram(ClansManager.getInstance().getHologramManager(), _location.clone().add(.5, 3, .5), _name + " Health", getDisplayHealth());
_infoHologram.start(); _infoHologram.start();
// _infoHologram.setInteraction((player, type) -> { _infoHologram.setInteraction((player, type) -> {
// if (player.equals(_rider)) if (type.equals(ClickType.LEFT))
// { {
// if (type.equals(ClickType.LEFT)) handleLeftClick(player);
// { }
// handleLeftClick(player); else if (type.equals(ClickType.RIGHT))
// } {
// } handleRightClick(player);
// }); }
});
UtilServer.RegisterEvents(this); UtilServer.RegisterEvents(this);
@ -535,6 +536,9 @@ public abstract class SiegeWeapon implements Listener
protected final void addEntity(Entity entity, String uniqueName) protected final void addEntity(Entity entity, String uniqueName)
{ {
entity.setCustomName(Integer.toString(_uniqueId));
entity.setCustomNameVisible(false);
_comprisedOf.add(entity); _comprisedOf.add(entity);
_entityMapping.put(uniqueName, entity); _entityMapping.put(uniqueName, entity);
@ -941,18 +945,11 @@ public abstract class SiegeWeapon implements Listener
token.Location = _location; token.Location = _location;
token.Health = _health; token.Health = _health;
token.Yaw = (int) _yaw; token.Yaw = (int) _yaw;
token.Entities = new HashMap<>();
_entityMapping.entrySet().forEach(entry ->
token.Entities.put(entry.getKey(), entry.getValue().getUniqueId().toString())
);
return token; return token;
} }
public boolean isPartOf(UUID uniqueId) public boolean isPartOf(UUID uniqueId)
{
if (_loadedToken == null)
{ {
for (Entity entity : _comprisedOf) for (Entity entity : _comprisedOf)
{ {
@ -963,9 +960,6 @@ public abstract class SiegeWeapon implements Listener
return false; return false;
} }
return _loadedToken.Entities.values().contains(uniqueId.toString());
}
public void setInvincible(boolean invincible) public void setInvincible(boolean invincible)
{ {
_invincible = invincible; _invincible = invincible;

View File

@ -26,9 +26,9 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.nameblacklist.ClansBlacklist;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon; import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.Explosion;
public class Crater implements Listener public class Crater implements Listener
{ {
@ -108,124 +108,52 @@ public class Crater implements Listener
return; return;
} }
_blocks.add(new CraterBlock(_origin, 0, Material.AIR)); boolean explosion = _origin.getWorld().createExplosion(_origin, 2.6f);
HashMap<Block, Double> blockList = new HashMap<Block, Double>(); boolean floating = _origin.distance(UtilBlock.nearestFloor(_origin)) > 0.6;
int iR = (int) _size + 1;
for (int x = -iR; x <= iR; x++) if (explosion)
{ {
for (int z = -iR; z <= iR; z++) for (Block block : UtilBlock.getInRadius(_origin.getBlock(), 2.6f).keySet())
{ {
for (int y = -iR; y <= iR; y++) boolean charred = false;
double dist = block.getLocation().distance(_origin);
if (floating)
{ {
Block curBlock = _origin.getBlock().getRelative(x, y, z); if (!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
&& !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
double offset = UtilMath.offset(_origin, curBlock.getLocation()); && Math.random() > 0.79)
if (offset <= _size)
{ {
blockList.put(curBlock, Double.valueOf(offset)); charred = true;
} }
} }
} else
}
for (Entry<Block, Double> entry : blockList.entrySet())
{ {
Block block = entry.getKey(); if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR)
&& !block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE)
ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation()); && !block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR)
&& Math.random() > 0.79)
if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner))
{ {
continue; charred = true;
}
} }
double distance = entry.getValue().doubleValue(); if (block.getType().equals(Material.SMOOTH_BRICK))
boolean air = distance <= _airChance || (Math.random() > (distance) / 3.65d);
if (block.getState() instanceof Chest) continue;
if (block.getType() == Material.AIR) continue;
if (air)
{ {
_blocks.add(new CraterBlock(block.getLocation(), distance, Material.AIR)); charred = false;
}
Block above = block; if (charred)
while (!UtilItem.isBoundless((above = above.getRelative(BlockFace.UP)).getType()))
{ {
_blocks.add(new CraterBlock(above.getLocation(), distance, Material.AIR)); CraterBlock charredBlock = new CraterBlock(block.getLocation(), dist, CHARRED_TYPE, (byte) 0);
}
if (!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType())) charredBlock.set();
{
if (_fire && Math.random() >= .5) _blocks.add(charredBlock);
{
_blocks.add(new CraterBlock(block.getLocation(), distance, Material.FIRE));
} }
} }
} }
} }
_blocks.forEach(CraterBlock::set);
for (Entry<Block, Double> entry : blockList.entrySet())
{
Block block = entry.getKey();
ClanTerritory territory = _weapon.getClans().getClanUtility().getClaim(block.getLocation());
if (territory != null && !ClansManager.getInstance().getBlacklist().allowed(territory.Owner))
{
continue;
}
double distance = entry.getValue().doubleValue();
if (block.getType() == Material.AIR) continue;
if (block.getState() instanceof Chest)
{
Chest chest = (Chest) block.getState();
for (ItemStack item : chest.getBlockInventory().getContents())
{
if (item == null)
{
continue;
}
if (item.getType() == Material.AIR)
{
continue;
}
_origin.getWorld().dropItemNaturally(_origin, item);
}
}
if (
distance > _airChance &&
Math.random() > .75 &&
UtilItem.isBoundless(block.getRelative(BlockFace.UP).getType()) &&
!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()) &&
!block.getRelative(BlockFace.UP).getType().equals(CHARRED_TYPE) &&
!block.getRelative(BlockFace.DOWN).getType().equals(CHARRED_TYPE))
{
_blocks.add(new CraterBlock(block.getLocation(), distance, CHARRED_TYPE));
if (_fire)
{
_blocks.add(new CraterBlock(block.getRelative(BlockFace.UP).getLocation(), distance, Material.FIRE));
}
}
}
_blocks.forEach(CraterBlock::set);
}
} }

View File

@ -110,7 +110,7 @@ public class WeaponProjectile implements Listener
if (!newEvent.isCancelled()) if (!newEvent.isCancelled())
{ {
new Crater(_weapon, this, UtilBlock.nearestFloor(_projectileEntity.getLocation()), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire); new Crater(_weapon, this, _projectileEntity.getLocation(), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire);
} }
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f)); UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f));

View File

@ -1,37 +0,0 @@
package mineplex.game.clans.clans.staff;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import mineplex.core.common.util.UtilServer;
public class SilentChestInventory implements Listener
{
private Chest _chest;
private Inventory _inventory;
private Player _viewer;
public SilentChestInventory(Chest chest, Player viewer)
{
_chest = chest;
viewer.openInventory(_chest.getBlockInventory());
UtilServer.RegisterEvents(this);
}
@EventHandler
public void closeInventory(InventoryCloseEvent event)
{
if (event.getInventory().equals(_inventory) && event.getPlayer().equals(_viewer))
{
UtilServer.Unregister(this);
}
}
}

View File

@ -1,49 +0,0 @@
package mineplex.game.clans.clans.staff;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilServer;
import mineplex.core.incognito.IncognitoManager;
import mineplex.game.clans.clans.ClansManager;
public class SilentChestOpen extends MiniPlugin
{
private ClansManager _clansManager;
public SilentChestOpen(ClansManager clansManager)
{
super("Silent Chest", clansManager.getPlugin());
_clansManager = clansManager;
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (!IncognitoManager.Instance.Get(event.getPlayer()).Status)
return;
if (!ClansManager.getInstance().getClientManager().hasRank(event.getPlayer(), Rank.CMOD))
return;
if (event.getClickedBlock() == null)
return;
BlockState block = event.getClickedBlock().getState();
if (!(block instanceof Chest))
return;
Chest chest = (Chest) block;
UtilServer.RegisterEvents(new SilentChestInventory(chest, event.getPlayer()));
event.setCancelled(true);
}
}

View File

@ -12,7 +12,7 @@ import mineplex.game.clans.clans.ClansManager;
public class TntGeneratorManager extends MiniPlugin public class TntGeneratorManager extends MiniPlugin
{ {
public static final int SECONDS_PER_TNT = 30;//60 * 60 * 10; // 10 Hours public static final int SECONDS_PER_TNT = 60 * 60 * 12; // 12 Hours
public static final int MAX_GENERATOR_STOCK = 3; public static final int MAX_GENERATOR_STOCK = 3;
private ClansManager _clansManager; private ClansManager _clansManager;

View File

@ -52,9 +52,15 @@ public class EventTerrainFinder
loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation()); loc.Set(UtilBlock.getHighest(chunk.getWorld(), chunk.getBlock(0, 0, 0)).getLocation());
}); });
if (!UtilWorld.isBoxInWorldBorder(world, loc.Get().clone().subtract(size * 2, vert, size * 2), loc.Get().clone().add(size * 2, vert, size * 2)))
{
continue;
}
if (loc.Get() == null) if (loc.Get() == null)
{
continue; continue;
}
System.out.println("Done finding area... [success]"); System.out.println("Done finding area... [success]");
@ -62,7 +68,7 @@ public class EventTerrainFinder
return loc.Get(); return loc.Get();
} }
System.out.println("Done finding area..."); System.out.println("Failed to find area...");
return null; return null;
} }

View File

@ -77,6 +77,19 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
} }
} }
public boolean isInEvent(Location location)
{
for (WorldEvent event : _runningEvents)
{
if (event.isInBounds(location))
{
return true;
}
}
return false;
}
@EventHandler @EventHandler
public void update(UpdateEvent event) public void update(UpdateEvent event)
{ {
@ -124,6 +137,17 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
} }
} }
public void randomEvent()
{
if (_runningEvents.size() == 0)
{
if (UtilServer.getPlayers().length > 0)
{
tryStartEvent();
}
}
}
private void tryStartEvent() private void tryStartEvent()
{ {
WorldEventType[] types = WorldEventType.values(); WorldEventType[] types = WorldEventType.values();

View File

@ -0,0 +1,28 @@
package mineplex.game.clans.clans.worldevent.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.clans.worldevent.WorldEventType;
import mineplex.minecraft.game.core.boss.WorldEvent;
/**
* Command for spawning a random world event in the world.
*/
public class RandomCommand extends CommandBase<WorldEventManager>
{
public RandomCommand(WorldEventManager plugin)
{
super(plugin, Rank.JNR_DEV, "random", "rand");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.randomEvent();
}
}

View File

@ -14,6 +14,7 @@ public class WorldEventCommand extends MultiCommandBase<WorldEventManager>
AddCommand(new StartCommand(Plugin)); AddCommand(new StartCommand(Plugin));
AddCommand(new ClearCommand(Plugin)); AddCommand(new ClearCommand(Plugin));
AddCommand(new RandomCommand(Plugin));
} }
@Override @Override

View File

@ -41,7 +41,7 @@ import mineplex.game.clans.shop.bank.BankShop;
public class GoldManager extends MiniPlugin public class GoldManager extends MiniPlugin
{ {
public static final double GEM_CONVERSION_RATE = 32; // The number of gold coins when converted from a single gem public static final double GEM_CONVERSION_RATE = 16; // The number of gold coins when converted from a single gem
public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death
public static final String META_STRING = "clans.goldAmount"; public static final String META_STRING = "clans.goldAmount";

View File

@ -59,6 +59,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.weight.Weight; import mineplex.core.common.weight.Weight;
import mineplex.core.common.weight.WeightSet; import mineplex.core.common.weight.WeightSet;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
@ -68,6 +69,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansWaterPlaceEvent; import mineplex.game.clans.clans.event.ClansWaterPlaceEvent;
import mineplex.game.clans.clans.event.IronDoorOpenEvent;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
@ -303,6 +305,60 @@ public class Gameplay extends MiniPlugin
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void disableEnderChest(PlayerInteractEvent event)
{
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (event.getClickedBlock() == null)
{
return;
}
if (_clansManager.getWorldEvent().isInEvent(event.getClickedBlock().getLocation()))
{
return;
}
if (event.getClickedBlock().getType().equals(Material.ENDER_CHEST))
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not permitted to use Ender Chests."));
return;
}
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status)
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (event.getClickedBlock() == null)
{
return;
}
if (!event.getClickedBlock().getType().equals(Material.CHEST)
&& !event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST))
{
return;
}
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not allowed to use this whilst incognito."));
event.setCancelled(true);
}
/** /**
* Disable all Piston related events in Clans * Disable all Piston related events in Clans
* *
@ -449,6 +505,13 @@ public class Gameplay extends MiniPlugin
// Open // Open
else else
{ {
IronDoorOpenEvent customEvent = UtilServer.CallEvent(new IronDoorOpenEvent(event.getPlayer(), block));
if (customEvent.isCancelled())
{
return;
}
if (block.getData() >= 8) block = block.getRelative(BlockFace.DOWN); if (block.getData() >= 8) block = block.getRelative(BlockFace.DOWN);
if (block.getData() < 4) if (block.getData() < 4)

View File

@ -60,6 +60,6 @@ public class GiantsBroadsword extends LegendaryItem
private void buffPlayer(Player player) private void buffPlayer(Player player)
{ {
grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER); grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER);
grantPotionEffect(player, PotionEffectType.REGENERATION, 40, REGEN_AMPLIFIER); //Regen grantPotionEffect(player, PotionEffectType.REGENERATION, 2, REGEN_AMPLIFIER); //Regen
} }
} }

View File

@ -20,6 +20,7 @@ import mineplex.core.common.util.RGBData;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilCollections; import mineplex.core.common.util.UtilCollections;
import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
@ -38,6 +39,8 @@ public class MeridianScepter extends LegendaryItem
private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() }; private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() };
private int _witherDamageTimes = 5;
public MeridianScepter() public MeridianScepter()
{ {
super("Meridian Scepter", UtilText.splitLinesToArray(new String[] { super("Meridian Scepter", UtilText.splitLinesToArray(new String[] {
@ -80,7 +83,6 @@ public class MeridianScepter extends LegendaryItem
final Vector direction = shooter.getEyeLocation().getDirection().normalize().multiply(0.25); final Vector direction = shooter.getEyeLocation().getDirection().normalize().multiply(0.25);
final int maxRange = 50; final int maxRange = 50;
final int maxDings = maxRange * 4; final int maxDings = maxRange * 4;
final int damage = 6;
UtilServer.repeat(new BukkitRunnable() UtilServer.repeat(new BukkitRunnable()
{ {
@ -96,16 +98,21 @@ public class MeridianScepter extends LegendaryItem
Player player = (Player) cur; Player player = (Player) cur;
Location eLoc = player.getLocation();
// If they are less than 0.5 blocks away // If they are less than 0.5 blocks away
if (eLoc.clone().add(0, player.getEyeHeight() / 2, 0).distance(projectile) <= 0.7) if (player.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2)
{ {
ClansManager.getInstance().getDamageManager().NewDamageEvent(player, player, null, player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * _witherDamageTimes, 0));
DamageCause.CUSTOM, damage, true, true, false,
player.getName(), "Meridian Scepter");
player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * 4, 0)); int time = 0;
for (int i = 0; i < _witherDamageTimes; i++)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> {
ClansManager.getInstance().getDamageManager().NewDamageEvent(player, shooter, null,
DamageCause.CUSTOM, 1.75, false, true, true,
shooter.getName(), "Meridian Scepter");
}, ++time * 20);
}
UtilPlayer.message(player, F.main("Clans", F.elem(player.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + ".")); UtilPlayer.message(player, F.main("Clans", F.elem(player.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + "."));
UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + ".")); UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + "."));
@ -142,7 +149,7 @@ public class MeridianScepter extends LegendaryItem
continue; continue;
} }
if (ClansManager.getInstance().getClan(shooter) == ClansManager.getInstance().getClan(closest)) if (ClansManager.getInstance().isInClan(shooter) && ClansManager.getInstance().getClan(shooter).isMember(closest))
{ {
continue; continue;
} }
@ -152,12 +159,17 @@ public class MeridianScepter extends LegendaryItem
continue; continue;
} }
if (IncognitoManager.Instance.Get(closest).Status) if (closest.getGameMode().equals(GameMode.CREATIVE) || closest.getGameMode().equals(GameMode.SPECTATOR))
{ {
continue; continue;
} }
if (ClansManager.getInstance().getClan(shooter) != null && ClansManager.getInstance().getClan(shooter).isAlly(ClansManager.getInstance().getClan(closest))) if (ClansManager.getInstance().getIncognitoManager().Get(closest).Status)
{
continue;
}
if (ClansManager.getInstance().isInClan(shooter) && ClansManager.getInstance().getClan(shooter).isAlly(ClansManager.getInstance().getClan(closest)))
{ {
continue; continue;
} }

View File

@ -23,6 +23,8 @@ import mineplex.core.npc.NpcManager;
import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement; import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.command.TutorialCommand; import mineplex.game.clans.tutorial.command.TutorialCommand;
import mineplex.game.clans.tutorial.gui.TutorialShop; import mineplex.game.clans.tutorial.gui.TutorialShop;
@ -37,7 +39,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
private EnumMap<TutorialType, Tutorial> _tutorialMap; private EnumMap<TutorialType, Tutorial> _tutorialMap;
private EnumMap<TutorialType, TutorialShop> _shopMap; // Don't need to do anything with shops currently private EnumMap<TutorialType, TutorialShop> _shopMap; // Don't need to do anything with shops currently
public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat, HologramManager hologram, NpcManager npcManager, TaskManager taskManager) public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat, HologramManager hologram, ClansManager clansManager, NpcManager npcManager, TaskManager taskManager)
{ {
super("Clans Tutorial", plugin); super("Clans Tutorial", plugin);
@ -48,7 +50,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class); _tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
_shopMap = new EnumMap<TutorialType, TutorialShop>(TutorialType.class); _shopMap = new EnumMap<TutorialType, TutorialShop>(TutorialType.class);
addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, _clansMessageManager, hologram, npcManager, taskManager)); addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager));
chat.AddFilter(event -> { chat.AddFilter(event -> {
if (inTutorial(event.getPlayer())) if (inTutorial(event.getPlayer()))

View File

@ -10,7 +10,7 @@ public class FinishCommand extends CommandBase<TutorialManager>
{ {
public FinishCommand(TutorialManager plugin) public FinishCommand(TutorialManager plugin)
{ {
super(plugin, Rank.DEVELOPER, "finish", "end"); super(plugin, Rank.JNR_DEV, "finish", "end");
} }
@Override @Override

View File

@ -13,7 +13,7 @@ public class TutorialCommand extends MultiCommandBase<TutorialManager>
{ {
public TutorialCommand(TutorialManager plugin) public TutorialCommand(TutorialManager plugin)
{ {
super(plugin, Rank.DEVELOPER, "tutorial", "tut"); super(plugin, Rank.JNR_DEV, "tutorial", "tut");
AddCommand(new StartCommand(plugin)); AddCommand(new StartCommand(plugin));
AddCommand(new FinishCommand(plugin)); AddCommand(new FinishCommand(plugin));

View File

@ -277,6 +277,11 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
public void displayChatMessages(Player player) public void displayChatMessages(Player player)
{ {
if (getPlugin().getTutorialSession(player) == null)
{
return;
}
for (int i = 0; i < 1; i++) for (int i = 0; i < 1; i++)
{ {
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");

View File

@ -46,7 +46,7 @@ public abstract class OrderedObjective<Plugin extends Tutorial> extends Objectiv
OrderedObjectiveData data = getData(player); OrderedObjectiveData data = getData(player);
assert index == data.getIndex(); assert index == data.getIndex();
if (data.getIndex() + 1 >= _goals.size()) if (data == null || data.getIndex() + 1 >= _goals.size())
{ {
finish(player); finish(player);
} }

View File

@ -3,19 +3,14 @@ package mineplex.game.clans.tutorial.tutorials.clans;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.UUID;
import com.google.common.collect.Lists; import org.bukkit.Bukkit;
import mineplex.core.hologram.Hologram; import org.bukkit.DyeColor;
import mineplex.core.common.util.*; import org.bukkit.Effect;
import mineplex.core.task.TaskManager; import org.bukkit.GameMode;
import mineplex.game.clans.clans.ClanInfo; import org.bukkit.Location;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; import org.bukkit.Material;
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; import org.bukkit.Sound;
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -30,17 +25,30 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.npc.NpcManager; import mineplex.core.npc.NpcManager;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent; import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.spawn.Spawn;
@ -57,8 +65,6 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
//import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
public class ClansMainTutorial extends Tutorial public class ClansMainTutorial extends Tutorial
{ {
@ -79,7 +85,7 @@ public class ClansMainTutorial extends Tutorial
); );
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message, HologramManager hologram, NpcManager npcManager, TaskManager taskManager) public ClansMainTutorial(JavaPlugin plugin, ClansManager clansManager, ClansMessageManager message, HologramManager hologram, NpcManager npcManager, TaskManager taskManager)
{ {
super(plugin, message, hologram, "Clans Tutorial", "main", Material.DIAMOND_SWORD, (byte) 0); super(plugin, message, hologram, "Clans Tutorial", "main", Material.DIAMOND_SWORD, (byte) 0);
@ -100,7 +106,7 @@ public class ClansMainTutorial extends Tutorial
// _repository = new TutorialRepository(ClansManager.getInstance().getClientManager()); // _repository = new TutorialRepository(ClansManager.getInstance().getClientManager());
addObjective(new ClanObjective(this, plugin)); addObjective(new ClanObjective(this, plugin));
addObjective(new AttackEnemyObjective(this, plugin)); addObjective(new AttackEnemyObjective(this, clansManager, plugin));
addObjective(new ShopsObjective(this, npcManager, plugin)); addObjective(new ShopsObjective(this, npcManager, plugin));
addObjective(new PurchaseItemsObjective(this, plugin)); addObjective(new PurchaseItemsObjective(this, plugin));
addObjective(new ClassesObjective(this, plugin)); addObjective(new ClassesObjective(this, plugin));

View File

@ -30,6 +30,8 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.weapon.Cannon; import mineplex.game.clans.clans.siege.weapon.Cannon;
import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.TutorialSession; import mineplex.game.clans.tutorial.TutorialSession;
@ -49,7 +51,7 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
private DefaultHashMap<String, List<Zombie>> _shooters; private DefaultHashMap<String, List<Zombie>> _shooters;
public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin) public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, ClansManager clansManager, JavaPlugin javaPlugin)
{ {
super(clansMainTutorial, javaPlugin, "Enemy Clans Tutorial", "Attack and raid this enemy!"); super(clansMainTutorial, javaPlugin, "Enemy Clans Tutorial", "Attack and raid this enemy!");
@ -66,7 +68,7 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
40 40
)); ));
addGoal(new ClanInfoGoal(this)); addGoal(new ClanInfoGoal(this));
addGoal(new MountCannonGoal(this)); addGoal(new MountCannonGoal(this, clansManager));
addGoal(new LoadCannonGoal(this)); addGoal(new LoadCannonGoal(this));
addGoal(new BlowUpWallGoal(this)); addGoal(new BlowUpWallGoal(this));
addGoal(new StealEnemyPotatoesGoal(this)); addGoal(new StealEnemyPotatoesGoal(this));

View File

@ -102,16 +102,16 @@ public class BlowUpWallGoal extends ObjectiveGoal<AttackEnemyObjective>
} }
}); });
event.setCancelled(true);
finish(shooter); finish(shooter);
} }
else else
{ {
UtilPlayer.message(shooter, F.main("Clans", "You missed! Try to hit the enemy's front wall, that should make a nice big hole!")); UtilPlayer.message(shooter, F.main("Clans", "You missed! Try to hit the enemy's front wall, that should make a nice big hole!"));
UtilInv.give(shooter, Material.TNT); UtilInv.give(shooter, Material.TNT);
}
event.setCancelled(true); event.setCancelled(true);
} }
}
@Override @Override
protected void customFinish(Player player) protected void customFinish(Player player)

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.SiegeManager; import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent; import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
import mineplex.game.clans.clans.siege.weapon.Cannon; import mineplex.game.clans.clans.siege.weapon.Cannon;
@ -21,7 +22,9 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjecti
public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective> public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
{ {
public MountCannonGoal(AttackEnemyObjective objective) private ClansManager _clansManager;
public MountCannonGoal(AttackEnemyObjective objective, ClansManager clansManager)
{ {
super( super(
objective, objective,
@ -31,12 +34,14 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
+ "TNT Cannons are the best way to do destroy enemy bases!", + "TNT Cannons are the best way to do destroy enemy bases!",
DyeColor.BLACK DyeColor.BLACK
); );
_clansManager = clansManager;
} }
@Override @Override
protected void customStart(Player player) protected void customStart(Player player)
{ {
getObjective().getCannons().put(player.getName(), SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false)); getObjective().getCannons().put(player.getName(), _clansManager.getSiegeManager().spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45); getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45);
getObjective().getCannons().get(player.getName()).setInvincible(true); getObjective().getCannons().get(player.getName()).setInvincible(true);

View File

@ -106,7 +106,11 @@ public class Hub extends JavaPlugin implements IRelation
//Other Modules //Other Modules
PacketHandler packetHandler = new PacketHandler(this); PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager);
incognito.setPreferencesManager(preferenceManager);
preferenceManager.GiveItem = true; preferenceManager.GiveItem = true;
Creature creature = new Creature(this); Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature); NpcManager npcManager = new NpcManager(this, creature);
@ -140,11 +144,10 @@ public class Hub extends JavaPlugin implements IRelation
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);
IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler);
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager);
Chat chat = new Chat(this, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
new MemoryFix(this); new MemoryFix(this);
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
new CustomTagFix(this, packetHandler); new CustomTagFix(this, packetHandler);

View File

@ -9,8 +9,6 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Random; import java.util.Random;
import mineplex.core.reward.RewardManager;
import mineplex.core.valentines.ValentinesGiftManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -74,8 +72,8 @@ import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.events.IncognitoHidePlayerEvent;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.message.PrivateMessageEvent; import mineplex.core.message.PrivateMessageEvent;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
@ -97,12 +95,14 @@ import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish; import mineplex.core.punish.Punish;
import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager; import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.core.treasure.TreasureManager; import mineplex.core.treasure.TreasureManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.valentines.ValentinesGiftManager;
import mineplex.hub.commands.DisguiseCommand; import mineplex.hub.commands.DisguiseCommand;
import mineplex.hub.commands.ForcefieldRadius; import mineplex.hub.commands.ForcefieldRadius;
import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.GadgetToggle;
@ -575,6 +575,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
} }
} }
@EventHandler
public void Incog(IncognitoHidePlayerEvent event)
{
if (!_clientManager.hasRank(event.getPlayer(), Rank.ADMIN))
{
event.setCancelled(true);
}
}
@EventHandler @EventHandler
public void PlayerChat(AsyncPlayerChatEvent event) public void PlayerChat(AsyncPlayerChatEvent event)
{ {

View File

@ -272,9 +272,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "the games you want, when you want.", C.Reset + "the games you want, when you want.",
}).setHideInfo(true).build(), new SelectPLAYERButton(this)); }).setHideInfo(true).build(), new SelectPLAYERButton(this));
addButton(40, new ItemBuilder(Material.IRON_DOOR).setTitle(C.cYellowB + "Mineplex Clans " + C.cGray + "Champions Teams").addLore(new String[] addButton(40, new ItemBuilder(Material.IRON_DOOR).setTitle(C.cYellowB + "Mineplex Clans " + C.cGray + "Factions PvP").addLore(new String[]
{ {
(_extraValue ? C.cAquaB : C.cWhiteB) + "ALPHA RELEASE", (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA RELEASE",
C.Reset + "", C.Reset + "",
C.Reset + "Equip custom skills and builds", C.Reset + "Equip custom skills and builds",
C.Reset + "and join your clan to destroy", C.Reset + "and join your clan to destroy",

View File

@ -58,6 +58,11 @@ public class Recall extends Skill
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.getOpenInventory() != null)
{
return;
}
int level = getLevel(player); int level = getLevel(player);
if (level == 0) if (level == 0)
return; return;

View File

@ -24,6 +24,7 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -56,6 +57,11 @@ public class SmokeBomb extends Skill
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.getOpenInventory() != null)
{
return;
}
int level = getLevel(player); int level = getLevel(player);
if (level == 0) return; if (level == 0) return;
@ -141,6 +147,18 @@ public class SmokeBomb extends Skill
Factory.Condition().EndCondition(event.getPlayer(), null, GetName()); Factory.Condition().EndCondition(event.getPlayer(), null, GetName());
} }
@EventHandler
public void closeInv(InventoryCloseEvent event)
{
if (getLevel(event.getPlayer()) == 0)
{
return;
}
event.getPlayer().getInventory().addItem(event.getPlayer().getItemOnCursor());
event.getPlayer().setItemOnCursor(null);
}
@EventHandler @EventHandler
public void Smoke(UpdateEvent event) public void Smoke(UpdateEvent event)
{ {

View File

@ -70,6 +70,7 @@ public class BlockToss extends SkillCharge implements IThrown
Material.STONE_BUTTON, Material.STONE_BUTTON,
Material.WOOD_BUTTON, Material.WOOD_BUTTON,
Material.LEVER, Material.LEVER,
Material.BARRIER,
}; };
public BlockToss(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) public BlockToss(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels)

View File

@ -5,8 +5,8 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blockrestore.BlockRestoreMap; import mineplex.core.blockrestore.BlockRestoreMap;
@ -25,7 +26,7 @@ import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
@ -65,6 +66,14 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
private boolean _isArcade; private boolean _isArcade;
private double _difficulty = 1; private double _difficulty = 1;
private double _minX;
private double _minY;
private double _minZ;
private double _maxX;
private double _maxY;
private double _maxZ;
public WorldEvent(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation) public WorldEvent(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation)
{ {
this(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, name, cornerLocation, null); this(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, name, cornerLocation, null);
@ -328,7 +337,6 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
{ {
onComplete.run(); onComplete.run();
} }
} }
}); });
@ -407,4 +415,50 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
} }
} }
public boolean isInBounds(Location location)
{
if (_minX == 0)
{
// Calculate bounds
Set<Block> blocks = _blocks.getChangedBlocks();
for (Block block : blocks)
{
if (_minX > block.getX())
{
_minX = block.getX();
}
if (_minY > block.getY())
{
_minY = block.getY();
}
if (_minZ > block.getZ())
{
_minZ = block.getZ();
}
if (_maxX < block.getX())
{
_maxX = block.getX();
}
if (_maxY < block.getY())
{
_maxY = block.getY();
}
if (_maxZ < block.getZ())
{
_maxZ = block.getZ();
}
}
_maxY++;
}
return UtilAlg.inBoundingBox(location, new Vector(_minX, _minY, _minZ), new Vector(_maxX, _maxY, _maxZ));
}
} }

View File

@ -379,7 +379,7 @@ public class ConditionEffect implements Listener
Manager.getDamagerManager().NewDamageEvent(ent, condition.GetSource(), null, Manager.getDamagerManager().NewDamageEvent(ent, condition.GetSource(), null,
DamageCause.CUSTOM, 0.1, false, true, false, DamageCause.CUSTOM, 0.1, false, true, false,
condition.GetSource().getName(), "Poison"); condition.GetSource() != null ? condition.GetSource().getName() : "The Mighty Defek7", "Poison");
} }
} }

View File

@ -2,6 +2,12 @@ package mineplex.staffServer;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.plugin.java.JavaPlugin;
import com.mojang.authlib.GameProfile;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.AntiHack;
@ -9,6 +15,7 @@ import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter; import mineplex.core.command.CommandCenter;
import mineplex.core.creature.Creature; import mineplex.core.creature.Creature;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.memory.MemoryFix; import mineplex.core.memory.MemoryFix;
import mineplex.core.monitor.LagMeter; import mineplex.core.monitor.LagMeter;
@ -26,12 +33,6 @@ import mineplex.staffServer.customerSupport.CustomerSupport;
import mineplex.staffServer.salespackage.SalesPackageManager; import mineplex.staffServer.salespackage.SalesPackageManager;
import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.plugin.java.JavaPlugin;
import com.mojang.authlib.GameProfile;
public class StaffServer extends JavaPlugin public class StaffServer extends JavaPlugin
{ {
private String WEB_CONFIG = "webServer"; private String WEB_CONFIG = "webServer";
@ -56,11 +57,11 @@ public class StaffServer extends JavaPlugin
Punish punish = new Punish(this, webServerAddress, clientManager); Punish punish = new Punish(this, webServerAddress, clientManager);
new NpcManager(this, new Creature(this)); new NpcManager(this, new Creature(this));
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager); PreferencesManager preferenceManager = new PreferencesManager(this, null, clientManager, donationManager);
preferenceManager.GiveItem = false; preferenceManager.GiveItem = false;
Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName()); Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName());
new Chat(this, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager), serverStatusManager.getCurrentServerName()); new Chat(this, null, clientManager, preferenceManager, new AchievementManager(new StatsManager(this, clientManager), clientManager, donationManager), serverStatusManager.getCurrentServerName());
new MemoryFix(this); new MemoryFix(this);
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);

View File

@ -109,7 +109,12 @@ public class Arcade extends JavaPlugin
_serverConfiguration = new ServerConfiguration(this, _clientManager); _serverConfiguration = new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); PacketHandler packetHandler = new PacketHandler(this);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
incognito.setPreferencesManager(preferenceManager);
Creature creature = new Creature(this); Creature creature = new Creature(this);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
@ -117,7 +122,6 @@ public class Arcade extends JavaPlugin
Teleport teleport = new Teleport(this, _clientManager); Teleport teleport = new Teleport(this, _clientManager);
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler); DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
@ -128,14 +132,12 @@ public class Arcade extends JavaPlugin
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false); AntiHack.Instance.setKick(false);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
StatsManager statsManager = new StatsManager(this, _clientManager); StatsManager statsManager = new StatsManager(this, _clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager);
FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal); FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal);
Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
BlockRestore blockRestore = new BlockRestore(this); BlockRestore blockRestore = new BlockRestore(this);
@ -157,7 +159,7 @@ public class Arcade extends JavaPlugin
//Arcade Manager //Arcade Manager
PollManager pollManager = new PollManager(this, _clientManager, _donationManager); PollManager pollManager = new PollManager(this, _clientManager, _donationManager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish); _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish);
new MemoryFix(this); new MemoryFix(this);
new CustomTagFix(this, packetHandler); new CustomTagFix(this, packetHandler);

View File

@ -192,6 +192,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private CustomDataManager _customDataManager; private CustomDataManager _customDataManager;
private Punish _punishmentManager; private Punish _punishmentManager;
private IncognitoManager _incognitoManager;
private TaskManager _taskManager; private TaskManager _taskManager;
private PacketHandler _packetHandler; private PacketHandler _packetHandler;
@ -212,7 +214,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig,
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, StatsManager statsManager, IncognitoManager incognitoManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat,
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager,
NpcManager npcManager, CustomDataManager customDataManager, Punish punish) NpcManager npcManager, CustomDataManager customDataManager, Punish punish)
@ -224,6 +226,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Modules // Modules
_blockRestore = new BlockRestore(plugin); _blockRestore = new BlockRestore(plugin);
_incognitoManager = incognitoManager;
_blood = blood; _blood = blood;
_preferencesManager = preferences; _preferencesManager = preferences;
@ -616,7 +620,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
if (event.getNewState() && _game != null && _game.IsPlaying(event.getPlayer()) && _game.IsLive()) if (event.getNewState() && _game != null && _game.IsPlaying(event.getPlayer()) && _game.IsLive())
{ {
UtilPlayer.message(event.getPlayer(), F.main("Incognito", "You may not go incognito whilst in a game.")); addSpectator(event.getPlayer(), true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -624,10 +628,25 @@ public class ArcadeManager extends MiniPlugin implements IRelation
if (event.getNewState()) if (event.getNewState())
{ {
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
if (_game == null || _game.GetState() != GameState.Live)
{
_specList.add(event.getPlayer());
}
} }
else else
{ {
UtilServer.broadcast(F.sys("Join", event.getPlayer().getName())); UtilServer.broadcast(F.sys("Join", event.getPlayer().getName()));
if (_game != null && isSpectator(event.getPlayer()))
{
if (_game.GetState() != GameState.Live)
{
_specList.remove(event.getPlayer());
}
event.show(false);
}
} }
} }
@ -695,7 +714,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
String name = event.getPlayer().getName(); String name = event.getPlayer().getName();
if (IncognitoManager.Instance.Get(event.getPlayer()).Status) if (_incognitoManager.Get(event.getPlayer()).Status)
{ {
event.setJoinMessage(null); event.setJoinMessage(null);
return; return;
@ -714,7 +733,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@EventHandler @EventHandler
public void MessageQuit(PlayerQuitEvent event) public void MessageQuit(PlayerQuitEvent event)
{ {
if (IncognitoManager.Instance.Get(event.getPlayer()).Status) if (_incognitoManager.Get(event.getPlayer()).Status)
{ {
event.setQuitMessage(null); event.setQuitMessage(null);
return; return;
@ -1123,7 +1142,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
public boolean IsObserver(Player player) public boolean IsObserver(Player player)
{ {
if (IncognitoManager.Instance.Get(player).Status) if (_incognitoManager.Get(player).Status)
{ {
_specList.add(player); _specList.add(player);
} }