Create a clans-only hub

This commit is contained in:
AlexTheCoder 2016-07-25 10:55:18 -04:00
parent 9fab8366b7
commit 275ab52f79
18 changed files with 2242 additions and 0 deletions

View File

@ -0,0 +1,3 @@
name: ClansHub
main: mineplex.clanshub.ClansHub
version: 0.1

View File

@ -0,0 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-plugin</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../plugin.xml</relativePath>
</parent>
<name>ClansHub</name>
<artifactId>mineplex-clanshub</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-game-clans-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-minecraft-game-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,164 @@
package mineplex.clanshub;
import mineplex.core.CustomTagFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.aprilfools.AprilFoolsManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.creature.Creature;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.friend.FriendManager;
import mineplex.core.give.Give;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.memory.MemoryFix;
import mineplex.core.message.MessageManager;
import mineplex.core.monitor.LagMeter;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.party.PartyManager;
import mineplex.core.pet.PetManager;
import mineplex.core.poll.PollManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.profileCache.ProfileCacheManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
import mineplex.core.recharge.Recharge;
import mineplex.core.resourcepack.ResourcePackManager;
import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.velocity.VelocityFix;
import mineplex.core.visibility.VisibilityManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class ClansHub extends JavaPlugin
{
private String WEB_CONFIG = "webServer";
@Override
public void onEnable()
{
Bukkit.setSpawnRadius(0);
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
String webServerAddress = getConfig().getString(WEB_CONFIG);
//Logger.initialize(this);
//Velocity Fix
new VelocityFix(this);
//Static Modules
new ProfileCacheManager(this);
CommandCenter.Initialize(this);
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress);
CommandCenter.Instance.setClientManager(clientManager);
// new ProfileCacheManager(this);
ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this);
VisibilityManager.Initialize(this); Give.Initialize(this);
Punish punish = new Punish(this, webServerAddress, clientManager);
BlockRestore blockRestore = new BlockRestore(this);
DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress);
ServerConfiguration serverConfiguration = new ServerConfiguration(this, clientManager);
//Other Modules
PacketHandler packetHandler = new PacketHandler(this);
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager, donationManager);
incognito.setPreferencesManager(preferenceManager);
preferenceManager.GiveItem = true;
Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature);
InventoryManager inventoryManager = new InventoryManager(this, clientManager);
PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress);
PollManager pollManager = new PollManager(this, clientManager, donationManager);
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
new TitanGiveawayManager(this, clientManager, serverStatusManager);
Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName());
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal);
FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal);
StatsManager statsManager = new StatsManager(this, clientManager);
EloManager eloManager = new EloManager(this, clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager, incognito, eloManager);
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
CustomDataManager customDataManager = new CustomDataManager(this, clientManager);
ConditionManager condition = new ConditionManager(this);
BoosterManager boosterManager = new BoosterManager(this, "", clientManager, donationManager, inventoryManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, condition, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager);
HologramManager hologramManager = new HologramManager(this, packetHandler);
ClansTransferManager serverManager = new ClansTransferManager(this, clientManager, donationManager, partyManager, portal, hubManager);
Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
new MemoryFix(this);
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
new CustomTagFix(this, packetHandler);
new PacketsInteractionFix(this, packetHandler);
new ResourcePackManager(this, portal);
new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, hubManager.getBonusManager().getRewardManager());
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
CombatManager combatManager = new CombatManager(this);
ProjectileManager throwManager = new ProjectileManager(this);
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, condition);
Teleport teleport = new Teleport(this, clientManager);
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
}
@Override
public void onDisable()
{
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
}
}

View File

@ -0,0 +1,144 @@
package mineplex.clanshub;
import java.util.Collection;
import java.util.Comparator;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class ClansServerPage extends ShopPageBase<ClansTransferManager, ClansServerShop>
{
public ClansServerPage(ClansTransferManager plugin, ClansServerShop shop, CoreClientManager clientManager,
DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Clans", player, 54);
buildPage();
}
@Override
protected void buildPage()
{
if (!getPlugin().Get(_player).getClanName().isEmpty())
{
buildClanPage(getPlugin().Get(_player));
}
else
{
buildNoClanPage();
}
}
private void buildClanPage(SimpleClanToken clan)
{
if (getClientManager().hasRank(_player, Rank.HELPER))
{
buildStaffJoinServers(clan);
}
else
{
buildJoinHomeServer(clan);
}
}
private void buildNoClanPage()
{
Collection<ServerInfo> servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator<ServerInfo>()
{
@Override
public int compare(ServerInfo o1, ServerInfo o2)
{
return o1.Name.compareTo(o2.Name);
}
});
int currentSlot = 9;
for (ServerInfo server : servers)
{
buildJoinServer(currentSlot, server);
currentSlot++;
}
}
private void buildJoinHomeServer(SimpleClanToken clan)
{
ServerInfo serverInfo = getServerInfo(clan.getHomeServer());
boolean serverOnline = (serverInfo != null);
String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline";
String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!";
String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer();
String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus;
String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "" );
String change = C.cRed + "Note: " + C.cWhite + "You must leave your Clan to ";
String change2 = C.cWhite + "play on a different Clans Server!";
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " ", change, change2, " "}, 0, true, true);
addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer())));
}
private void buildJoinServer(int slot, ServerInfo server)
{
String title = C.cGreen + C.Bold + "Join Clans Server!";
String desc1 = C.cYellow + "Server Name " + C.cWhite + server.Name;
String desc2 = C.cYellow + "Players " + C.cWhite + server.CurrentPlayers + "/" + server.MaxPlayers;
String desc3 = C.cRed + "Note: " + C.cWhite + "Creating or Joining a clan on this";
String desc4 = C.cWhite + "server will set your Home Server!";
ShopItem shopItem = new ShopItem(Material.GOLD_BLOCK, title, new String[] {" ", desc1, desc2, " ", desc3, desc4}, 0, true, true);
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), server));
}
private void buildStaffJoinServers(SimpleClanToken clan)
{
ServerInfo serverInfo = getServerInfo(clan.getHomeServer());
boolean serverOnline = (serverInfo != null);
String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline";
String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!";
String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer();
String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus;
String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "" );
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " "}, 0, true, true);
addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer())));
Collection<ServerInfo> servers = UtilAlg.sortSet(getPlugin().getServers(), new Comparator<ServerInfo>()
{
@Override
public int compare(ServerInfo o1, ServerInfo o2)
{
return o1.Name.compareTo(o2.Name);
}
});
int currentSlot = 27;
for (ServerInfo server : servers)
{
if (server.Name.equalsIgnoreCase(clan.getHomeServer()))
{
continue;
}
buildJoinServer(currentSlot, server);
currentSlot++;
}
}
private ServerInfo getServerInfo(String serverName)
{
return getPlugin().getServer(serverName);
}
public void update()
{
getButtonMap().clear();
buildPage();
}
}

View File

@ -0,0 +1,40 @@
package mineplex.clanshub;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.donation.DonationManager;
import mineplex.core.party.Party;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class ClansServerShop extends ShopBase<ClansTransferManager>
{
public ClansServerShop(ClansTransferManager plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Clans");
}
@Override
protected ShopPageBase<ClansTransferManager, ? extends ShopBase<ClansTransferManager>> buildPagesFor(Player player)
{
return new ClansServerPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
}
@Override
protected boolean canOpenShop(Player player)
{
Party party = getPlugin().getPartyManager().getParty(player);
if (party != null)
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
player.sendMessage(F.main("Party", "You cannot join Clans while in a party."));
return false;
}
return true;
}
}

View File

@ -0,0 +1,259 @@
package mineplex.clanshub;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.npc.event.NpcDamageByEntityEvent;
import mineplex.core.npc.event.NpcInteractEntityEvent;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.portal.Portal;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.servers.ServerManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityPortalEnterEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
public class ClansTransferManager extends MiniDbClientPlugin<SimpleClanToken>
{
private static final long SERVER_RELOAD_INTERVAL = 5000;
private PartyManager _party;
private Portal _portal;
private HubManager _hub;
private Region _region;
private final HashMap<MinecraftServer, ServerInfo> _servers = new HashMap<MinecraftServer, ServerInfo>();
private boolean _loading = false;
private long _lastLoaded;
private ClansServerShop _serverShop;
public ClansTransferManager(JavaPlugin plugin, CoreClientManager client, DonationManager donation, PartyManager party, Portal portal, HubManager hub)
{
super("Server Transfer", plugin, client);
_party = party;
_portal = portal;
_hub = hub;
_region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
_serverShop = new ClansServerShop(this, client, donation);
}
public PartyManager getPartyManager()
{
return _party;
}
public List<ServerInfo> getServers()
{
List<ServerInfo> servers = Lists.newArrayList();
servers.addAll(_servers.values());
return servers;
}
public ServerInfo getServer(String name)
{
for (ServerInfo server : _servers.values())
{
if (server.Name.equalsIgnoreCase(name))
{
return server;
}
}
return null;
}
public void reload()
{
_servers.clear();
for (MinecraftServer server : ServerManager.getServerRepository(_region).getServerStatusesByPrefix("Clans-"))
{
ServerInfo info = new ServerInfo();
info.Name = server.getName();
info.CurrentPlayers = server.getPlayerCount();
info.MaxPlayers = server.getMaxPlayerCount();
_servers.put(server, info);
}
}
public void selectServer(Player player, ServerInfo serverInfo)
{
Party party = _party.getParty(player);
if (party != null)
{
if(!party.getOwner().equalsIgnoreCase(player.getName()))
{
Lang.NOT_OWNER_SERVER.send(player);
return;
}
_party.getJoinManager().requestServerJoin(serverInfo.Name, party);
return;
}
player.leaveVehicle();
player.eject();
_portal.sendPlayerToServer(player, serverInfo.Name);
}
@EventHandler
public void reloadServers(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || _loading || !UtilTime.elapsed(_lastLoaded, SERVER_RELOAD_INTERVAL))
{
return;
}
_loading = true;
final Runnable after = new Runnable()
{
public void run()
{
_lastLoaded = System.currentTimeMillis();
_loading = false;
}
};
runAsync(() ->
{
reload();
runSync(after);
});
}
@SuppressWarnings("rawtypes")
@EventHandler
public void refreshPages(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (ShopPageBase page : _serverShop.getPageMap().values())
{
if (page instanceof ClansServerPage)
{
((ClansServerPage)page).update();
}
}
}
@EventHandler
public void onEnterPortal(EntityPortalEnterEvent event)
{
if (!(event.getEntity() instanceof Player))
{
UtilAction.velocity(event.getEntity(), UtilAlg.getTrajectory(event.getEntity().getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true);
return;
}
Player player = (Player) event.getEntity();
if (!_hub.CanPortal(player))
{
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hub.GetSpawn()), 1, true, 0.5, 0, 1.0, true);
return;
}
if (!Recharge.Instance.use(player, "Transfer Portal", 5000, false, false))
{
return;
}
if (Get(player) == null || Get(player).getHomeServer() == null || Get(player).getHomeServer().isEmpty())
{
player.teleport(_hub.GetSpawn());
runSyncLater(() ->
{
_serverShop.attemptShopOpen(player);
}, 20L);
return;
}
if (getServer(Get(player).getHomeServer()) != null)
{
UtilPlayer.message(player, F.main(getName(), "You are being transferred to your Clan's home server!"));
selectServer(player, getServer(Get(player).getHomeServer()));
}
else
{
UtilPlayer.message(player, F.main(getName(), "Your Clan's home server is not online!"));
}
}
@EventHandler
public void onUseNPC(NpcInteractEntityEvent event)
{
if (event.getNpc().getName().contains("Clans"))
{
_serverShop.attemptShopOpen(event.getPlayer());
}
if (event.getNpc().getName().contains("Return"))
{
_portal.sendToHub(event.getPlayer(), "Returning to Mineplex!");
}
}
@EventHandler
public void onUseNPC(NpcDamageByEntityEvent event)
{
if (!(event.getDamager() instanceof Player))
{
return;
}
Player player = (Player) event.getDamager();
if (event.getNpc().getName().contains("Clans") && Recharge.Instance.use(player, "Go to Clans", 1000, false, false))
{
_serverShop.attemptShopOpen(player);
}
if (event.getNpc().getName().contains("Return") && Recharge.Instance.use(player, "Return to Mineplex", 1000, false, false))
{
_portal.sendToHub(player, "Returning to Mineplex!");
}
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = " + accountId + ";";
}
@Override
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
SimpleClanToken clanToken = new SimpleClanToken();
while (resultSet.next())
{
String clanName = resultSet.getString(1);
String clanRole = resultSet.getString(2);
String homeServer = resultSet.getString(3);
int clanId = resultSet.getInt(4);
clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId);
}
Set(playerName, clanToken);
}
@Override
protected SimpleClanToken addPlayer(String player)
{
return new SimpleClanToken();
}
}

View File

@ -0,0 +1,96 @@
package mineplex.clanshub;
import java.util.HashMap;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
public class ForcefieldManager extends MiniPlugin
{
public HubManager Manager;
private HashMap<Player, Integer> _radius = new HashMap<Player, Integer>();
public ForcefieldManager(HubManager manager)
{
super("Forcefield", manager.getPlugin());
Manager = manager;
}
@EventHandler
public void ForcefieldUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (Player player : UtilServer.getPlayers())
{
if (Manager.getPreferences().Get(player).HubForcefield && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL))
{
for (Player other : UtilServer.getPlayers())
{
if (player.equals(other))
continue;
int range = 5;
if (_radius.containsKey(player))
range = _radius.get(player);
if (UtilMath.offset(other, player) > range)
continue;
if (Manager.GetClients().Get(other).GetRank().has(Rank.JNR_DEV))
continue;
if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false))
{
Entity bottom = other;
while (bottom.getVehicle() != null)
bottom = bottom.getVehicle();
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(player, bottom), 1.6, true, 0.8, 0, 10, true);
other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
}
}
}
}
}
public void ForcefieldRadius(Player caller, String[] args)
{
try
{
int range = Integer.parseInt(args[0]);
_radius.put(caller, range);
UtilPlayer.message(caller, F.main(getName(), "Radius set to " + F.elem(range + "") + "."));
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main(getName(), "Invalid Input. Correct input is " + F.elem("/radius #") + "."));
}
}
@EventHandler
public void ForcefieldReset(PlayerQuitEvent event)
{
_radius.remove(event.getPlayer());
}
}

View File

@ -0,0 +1,912 @@
package mineplex.clanshub;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.clanshub.commands.ForcefieldRadius;
import mineplex.clanshub.commands.GadgetToggle;
import mineplex.clanshub.commands.GameModeCommand;
import mineplex.clanshub.profile.gui.GUIProfile;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.benefit.BenefitManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.botspam.BotSpamManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.PlayerDisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.donation.DonationManager;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.morph.MorphWither;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.incognito.events.IncognitoHidePlayerEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.message.PrivateMessageEvent;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.types.MountDragon;
import mineplex.core.notifier.NotificationManager;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.pet.PetManager;
import mineplex.core.playerCount.PlayerCountManager;
import mineplex.core.poll.PollManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.valentines.ValentinesGiftManager;
import mineplex.core.youtube.YoutubeManager;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.ConditionManager;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.HoverEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
public class HubManager extends MiniPlugin
{
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;
private ConditionManager _conditionManager;
private DonationManager _donationManager;
private DisguiseManager _disguiseManager;
private PartyManager _partyManager;
private ForcefieldManager _forcefieldManager;
private PollManager _pollManager;
private Portal _portal;
private StatsManager _statsManager;
private GadgetManager _gadgetManager;
private MountManager _mountManager;
private HubVisibilityManager _visibilityManager;
private PreferencesManager _preferences;
private InventoryManager _inventoryManager;
private AchievementManager _achievementManager;
private TreasureManager _treasureManager;
private PetManager _petManager;
private PacketHandler _packetHandler;
private PlayerCountManager _playerCountManager;
private CustomDataManager _customDataManager;
private Punish _punishManager;
private IncognitoManager _incognito;
private BonusManager _bonusManager;
private Location _spawn;
private int _scoreboardTick = 0;
private HashMap<Player, Scoreboard> _scoreboards = new HashMap<Player, Scoreboard>();
private String _serverName = "";
private int _lastPlayerCount = 0;
private boolean _shuttingDown;
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, IncognitoManager incognito, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, CustomDataManager customDataManager, BoosterManager boosterManager)
{
super("Hub Manager", plugin);
_incognito = incognito;
_blockRestore = blockRestore;
_clientManager = clientManager;
_conditionManager = conditionManager;
_donationManager = donationManager;
_disguiseManager = disguiseManager;
_pollManager = pollManager;
_portal = portal;
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 179, 0.5);
((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0;
new WorldManager(this);
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
_inventoryManager = inventoryManager;
new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager, packetHandler, hologramManager);
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, boosterManager);
World world = _spawn.getWorld();
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());
_treasureManager.disable();
{
Block chestBlock = world.getBlockAt(-1, 178, -9);
Block chestLoc1 = world.getBlockAt(-4, 178, -8);
Block chestLoc2 = world.getBlockAt(-4, 178, -10);
Block chestLoc3 = world.getBlockAt(-2, 178, -12);
Block chestLoc4 = world.getBlockAt(0, 178, -12);
Block chestLoc5 = world.getBlockAt(2, 178, -10);
Block chestLoc6 = world.getBlockAt(2, 178, -8);
Block chestLoc7 = world.getBlockAt(0, 178, -6);
Block chestLoc8 = world.getBlockAt(-2, 178, -6);
TreasureLocation loc = new TreasureLocation(_treasureManager, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, _spawn, hologramManager, _gadgetManager, serverStatusManager);
_treasureManager.addTreasureLocation(loc);
}
{
Block chestBlock = world.getBlockAt(-1, 178, 9);
Block chestLoc1 = world.getBlockAt(-4, 178, 10);
Block chestLoc2 = world.getBlockAt(-4, 178, 8);
Block chestLoc3 = world.getBlockAt(-2, 178, 6);
Block chestLoc4 = world.getBlockAt(0, 178, 6);
Block chestLoc5 = world.getBlockAt(2, 178, 8);
Block chestLoc6 = world.getBlockAt(2, 178, 10);
Block chestLoc7 = world.getBlockAt(0, 178, 12);
Block chestLoc8 = world.getBlockAt(-2, 178, 12);
TreasureLocation loc = new TreasureLocation(_treasureManager, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, _spawn, hologramManager, _gadgetManager, serverStatusManager);
_treasureManager.addTreasureLocation(loc);
}
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager);
_petManager = petManager;
_partyManager = partyManager;
_preferences = preferences;
_visibilityManager = new HubVisibilityManager(this);
_forcefieldManager = new ForcefieldManager(this);
addCommand(new ForcefieldRadius(_forcefieldManager));
_statsManager = statsManager;
_achievementManager = achievementManager;
_achievementManager.setGiveInterfaceItem(true);
_packetHandler = packetHandler;
new NotificationManager(getPlugin(), clientManager, _preferences);
new BotSpamManager(plugin, clientManager, punish);
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
new PlayerDisguiseManager(plugin, _clientManager);
new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager);
_playerCountManager = new PlayerCountManager(plugin);
_customDataManager = new CustomDataManager(plugin, clientManager);
_punishManager = punish;
_serverName = getPlugin().getConfig().getString("serverstatus.name");
_serverName = _serverName.substring(0, Math.min(16, _serverName.length()));
}
@Override
public void addCommands()
{
addCommand(new GadgetToggle(this));
addCommand(new GameModeCommand(this));
}
@EventHandler(priority = EventPriority.HIGHEST)
public void reflectMotd(ServerListPingEvent event)
{
if (_shuttingDown)
{
event.setMotd("Restarting soon");
}
}
public boolean BumpDisabled(Entity ent)
{
if (ent == null)
return false;
if (ent instanceof Player)
{
return !_preferences.Get((Player)ent).HubGames;
}
return true;
}
@EventHandler
public void redirectStopCommand(PlayerCommandPreprocessEvent event)
{
if (event.getPlayer().isOp() && event.getMessage().equalsIgnoreCase("/stop"))
{
_shuttingDown = true;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
{
public void run()
{
_portal.sendAllPlayers("Lobby");
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
{
public void run()
{
Bukkit.shutdown();
}
}, 40L);
}
}, 60L);
event.setCancelled(true);
}
}
@EventHandler
public void preventEggSpawn(ItemSpawnEvent event)
{
if (event.getEntity() instanceof Egg)
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOW)
public void login(final PlayerLoginEvent event)
{
CoreClient client = _clientManager.Get(event.getPlayer().getName());
// Reserved Slot Check
if (Bukkit.getOnlinePlayers().size() - Bukkit.getServer().getMaxPlayers() >= 20)
{
if (!client.GetRank().has(Rank.ULTRA))
{
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
_portal.sendPlayerToServer(event.getPlayer(), "Lobby");
}
});
event.allow();
}
}
else
event.allow();
}
@EventHandler(priority = EventPriority.LOW)
public void handleOP(PlayerJoinEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.ADMIN))
event.getPlayer().setOp(true);
else
event.getPlayer().setOp(false);
}
@EventHandler
public void PlayerRespawn(PlayerRespawnEvent event)
{
event.setRespawnLocation(GetSpawn());
}
@EventHandler(priority = EventPriority.LOW)
public void PlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
//Public Message
event.setJoinMessage(null);
//Teleport
player.teleport(GetSpawn());
//Survival
player.setGameMode(GameMode.SURVIVAL);
//Clear Inv
UtilInv.Clear(player);
//Health
player.setHealth(20);
//Scoreboard
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
player.setScoreboard(board);
_scoreboards.put(player, board);
//Objective
Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
for (Rank rank : Rank.values())
{
if (rank != Rank.ALL)
board.registerNewTeam(rank.Name).setPrefix(rank.getTag(true, true) + ChatColor.RESET + " ");
else
board.registerNewTeam(rank.Name).setPrefix("");
}
for (Player otherPlayer : Bukkit.getOnlinePlayers())
{
if (_clientManager.Get(otherPlayer) == null)
continue;
String rankName = _clientManager.Get(player).GetRank().Name;
String otherRankName = _clientManager.Get(otherPlayer).GetRank().Name;
//Add Other to Self
board.getTeam(otherRankName).addPlayer(otherPlayer);
//Add Self to Other
otherPlayer.getScoreboard().getTeam(rankName).addPlayer(player);
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
event.setQuitMessage(null);
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
event.getPlayer().setOp(false);
for (Player player : UtilServer.getPlayers())
player.getScoreboard().resetScores(event.getPlayer().getName());
_scoreboards.remove(event.getPlayer());
_portalTime.remove(event.getPlayer().getName());
}
@EventHandler
public void playerPrivateMessage(PrivateMessageEvent event)
{
//Dont Let PM Near Spawn!
if (UtilMath.offset2d(GetSpawn(), event.getSender().getLocation()) == 0 && !_clientManager.Get(event.getSender()).GetRank().has(Rank.HELPER))
{
UtilPlayer.message(event.getSender(), F.main("Chat", "You must leave spawn before you can Private Message!"));
event.setCancelled(true);
}
}
@EventHandler
public void Incog(IncognitoHidePlayerEvent event)
{
if (!_clientManager.hasRank(event.getPlayer(), Rank.CMOD))
{
event.setCancelled(true);
}
}
@EventHandler
public void PlayerChat(AsyncPlayerChatEvent event)
{
if (event.isCancelled())
return;
//Dont Let Chat Near Spawn!
if (UtilMath.offset2d(GetSpawn(), event.getPlayer().getLocation()) == 0 && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
{
UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!"));
event.setCancelled(true);
return;
}
Player player = event.getPlayer();
String playerName = player.getName();
Rank rank = GetClients().Get(player).GetRank();
if (GetClients().Get(player).isDisguised())
rank = GetClients().Get(player).getDisguisedRank();
//Level Prefix
String levelStr = _achievementManager.getMineplexLevel(player, rank);
//Rank Prefix
String rankStr = "";
if (rank != Rank.ALL)
rankStr = rank.getTag(true, true) + " ";
//Party Chat
if (event.getMessage().charAt(0) == '#')
{
Party party = _partyManager.getParty(player);
if (party != null)
{
event.getRecipients().clear();
event.setMessage(event.getMessage().substring(1, event.getMessage().length()));
event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + playerName + " " + C.cPurple + "%2$s");
for (String name : party.getMembers())
{
Player other = UtilPlayer.searchExact(name);
if (other != null)
event.getRecipients().add(other);
}
}
else
{
UtilPlayer.message(player, F.main("Party", "You are not in a Party."));
event.setCancelled(true);
}
return;
}
else
{
TextComponent rankComponent = new TextComponent(rankStr);
TextComponent playerNameText = new TextComponent(ChatColor.YELLOW + playerName);
TextComponent component = new TextComponent();
rankComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder(rank.getColor() + rank.getTag(true, true) + ChatColor.WHITE + "\n" + rank.getDescription()).create()));
component.setText(levelStr);
component.addExtra(rankComponent);
component.addExtra(playerNameText);
component.addExtra(" " + ChatColor.WHITE + event.getMessage());
for (Player other : UtilServer.getPlayers())
{
if (!event.isCancelled())
other.spigot().sendMessage(component);
}
event.setCancelled(true);
}
}
@EventHandler
public void Damage(EntityDamageEvent event)
{
if (event.getCause() == DamageCause.VOID)
{
if (event.getEntity() instanceof Player)
{
event.getEntity().eject();
event.getEntity().leaveVehicle();
event.getEntity().teleport(GetSpawn());
}
else
{
event.getEntity().remove();
}
}
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void handleDeath(PlayerDeathEvent event)
{
event.setKeepInventory(true);
event.getDrops().clear();
event.getEntity().setHealth(20);
event.getEntity().teleport(GetSpawn());
}
@EventHandler
public void combatDeath(CombatDeathEvent event)
{
event.SetBroadcastType(DeathMessageType.None);
}
@EventHandler
public void FoodHealthUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
player.setFoodLevel(20);
player.setExhaustion(0f);
player.setSaturation(3f);
}
}
@EventHandler
public void InventoryCancel(InventoryClickEvent event)
{
if (event.getWhoClicked() instanceof Player && ((Player)event.getWhoClicked()).getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
@EventHandler
public void UpdateScoreboard(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
_scoreboardTick = (_scoreboardTick + 1)%3;
if (_scoreboardTick != 0)
return;
int playerCount = _playerCountManager.getPlayerCount();
for (Player player : UtilServer.getPlayers())
{
//Return to Main Scoreboard
if (!player.getScoreboard().equals(_scoreboards.get(player)))
player.setScoreboard(_scoreboards.get(player));
//Objective
Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
//Title
obj.setDisplayName(C.cRed + C.Bold + C.Line + "Mineplex Clans");
int line = 15;
//Space
obj.getScore(" ").setScore(line--);
//Server
obj.getScore(C.cAqua + C.Bold + "Server").setScore(line--);
obj.getScore(_serverName).setScore(line--);
//Space
obj.getScore(" ").setScore(line--);
//Players
obj.getScore(C.cYellow + C.Bold + "Players").setScore(line--);
player.getScoreboard().resetScores(_lastPlayerCount + "");
obj.getScore(playerCount + "").setScore(line--);
//Space
obj.getScore(" ").setScore(line--);
//Display Rank
obj.getScore(C.cGold + C.Bold + "Rank").setScore(line--);
//Remove Old
player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(false).Name);
player.getScoreboard().resetScores(_clientManager.Get(player).GetLastRank(true).Name);
player.getScoreboard().resetScores("No Rank");
//Add New
if (GetClients().Get(player).GetRank() != Rank.ALL)
obj.getScore(GetClients().Get(player).GetRank().Name).setScore(line--);
else
obj.getScore("No Rank").setScore(line--);
//Space
obj.getScore(" ").setScore(line--);
//Website
obj.getScore(C.cRed + C.Bold + "Website").setScore(line--);
obj.getScore("www.mineplex.com").setScore(line--);
}
_lastPlayerCount = playerCount;
Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).GetRank() == Rank.ALL).forEach(player ->
{
UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player);
});
}
public BlockRestore GetBlockRestore()
{
return _blockRestore;
}
public CoreClientManager GetClients()
{
return _clientManager;
}
public ConditionManager GetCondition()
{
return _conditionManager;
}
public DonationManager GetDonation()
{
return _donationManager;
}
public DisguiseManager GetDisguise()
{
return _disguiseManager;
}
public GadgetManager GetGadget()
{
return _gadgetManager;
}
public TreasureManager GetTreasure()
{
return _treasureManager;
}
public MountManager GetMount()
{
return _mountManager;
}
public PreferencesManager getPreferences()
{
return _preferences;
}
public Location GetSpawn()
{
return _spawn.clone();
}
public PetManager getPetManager()
{
return _petManager;
}
public BonusManager getBonusManager()
{
return _bonusManager;
}
public StatsManager GetStats()
{
return _statsManager;
}
public HubVisibilityManager GetVisibility()
{
return _visibilityManager;
}
public CustomDataManager getCustomDataManager()
{
return _customDataManager;
}
public Punish getPunishments()
{
return _punishManager;
}
public IncognitoManager getIncognitoManager()
{
return _incognito;
}
@EventHandler(priority = EventPriority.MONITOR)
public void gadgetCollide(GadgetCollideEntityEvent event)
{
if (!event.isCancelled())
{
SetPortalDelay(event.getOther());
}
}
public void SetPortalDelay(Entity ent)
{
if (ent instanceof Player)
{
_portalTime.put(((Player)ent).getName(), System.currentTimeMillis());
}
}
public boolean CanPortal(Player player)
{
//Riding
if (player.getVehicle() != null || player.getPassenger() != null)
return false;
//Portal Delay
if (!_portalTime.containsKey(player.getName()))
return true;
return UtilTime.elapsed(_portalTime.get(player.getName()), 5000);
}
@EventHandler
public void ignoreVelocity(PlayerVelocityEvent event)
{
if (_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH) && _preferences.Get(event.getPlayer()).IgnoreVelocity)
{
event.setCancelled(true);
}
}
public void ToggleGadget(Player caller)
{
toggleGadget();
}
public void toggleGadget()
{
GetGadget().toggleGadgetEnabled();
for (Player player : UtilServer.getPlayers())
player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
}
public void addGameMode(Player caller, Player target)
{
if (!_creativeAdmin.containsKey(caller.getName()))
_creativeAdmin.put(caller.getName(), new ArrayList<String>());
if (target.getGameMode() == GameMode.CREATIVE)
{
_creativeAdmin.get(caller.getName()).add(target.getName());
}
else
{
_creativeAdmin.get(caller.getName()).remove(target.getName());
}
}
@EventHandler
public void clearEntityTargets(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Entity entity : Bukkit.getWorlds().get(0).getEntities())
{
if (entity instanceof EntityInsentient)
{
EntityInsentient entityMonster = (EntityInsentient)entity;
if (entityMonster.getGoalTarget() != null && entityMonster.getGoalTarget() instanceof EntityPlayer)
{
if (((EntityPlayer)entityMonster.getGoalTarget()).playerConnection.isDisconnected())
entityMonster.setGoalTarget(null, TargetReason.FORGOT_TARGET, false);
}
}
}
}
@EventHandler
public void clearGameMode(PlayerQuitEvent event)
{
ArrayList<String> creative = _creativeAdmin.remove(event.getPlayer().getName());
if (creative == null)
return;
for (String name : creative)
{
Player player = UtilPlayer.searchExact(name);
if (player == null)
continue;
player.setGameMode(GameMode.SURVIVAL);
UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false)));
}
}
public PacketHandler getPacketHandler()
{
return _packetHandler;
}
@EventHandler
public void openProfile(PlayerInteractEvent event)
{
if(event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM)
return;
new GUIProfile(getPlugin(), event.getPlayer(), _preferences, _achievementManager).openInventory();;
}
@EventHandler
public void trackPortalDelayPlayers(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Iterator<String> playerNameIterator = _portalTime.keySet().iterator(); playerNameIterator.hasNext();)
{
String playerName = playerNameIterator.next();
if (UtilTime.elapsed(_portalTime.get(playerName), 5000))
{
playerNameIterator.remove();
}
}
}
@EventHandler
public void showHeader(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
{
return;
}
String text = C.cRed + "Welcome to Mineplex Clans";
UtilTextTop.display(text, UtilServer.getPlayers());
//Fix Entity Names
for (Creature pet : _petManager.getPets())
{
DisguiseBase disguise = _disguiseManager.getDisguise(pet);
if (disguise instanceof DisguiseWither)
{
((DisguiseWither) disguise).setName(text);
disguise.resendMetadata();
}
}
for (Mount mount : _mountManager.getMounts())
{
if (mount instanceof MountDragon)
{
((MountDragon)mount).SetName(text);
}
}
for (Gadget gadget : _gadgetManager.getGadgets(GadgetType.MORPH))
{
if (gadget instanceof MorphWither)
{
((MorphWither)gadget).setWitherData(text, 100);
}
}
}
}

View File

@ -0,0 +1,80 @@
package mineplex.clanshub;
import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.visibility.VisibilityManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
public class HubVisibilityManager extends MiniPlugin
{
public HubManager Manager;
private HashSet<Player> _hiddenPlayers = new HashSet<Player>();
public HubVisibilityManager(HubManager manager)
{
super("Visibility Manager", manager.getPlugin());
Manager = manager;
}
public void addHiddenPlayer(Player player)
{
_hiddenPlayers.add(player);
}
public void removeHiddenPlayer(Player player)
{
_hiddenPlayers.remove(player);
}
@EventHandler
public void removeHiddenPlayerOnQuit(PlayerQuitEvent event)
{
_hiddenPlayers.remove(event.getPlayer());
}
@EventHandler
public void updateVisibility(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
Rank rank = Manager.GetClients().Get(player).GetRank();
boolean hideMe = UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 ||
(Manager.getPreferences().Get(player).Invisibility && (rank.has(Rank.MODERATOR) || rank == Rank.YOUTUBE || rank == Rank.TWITCH)) ||
_hiddenPlayers.contains(player);
for (Player other : UtilServer.getPlayers())
{
boolean localHideMe = hideMe;
if (player.equals(other))
continue;
if (Manager.GetClients().Get(other).GetRank().has(Rank.MODERATOR))
localHideMe = false;
if (localHideMe || !Manager.getPreferences().Get(other).ShowPlayers)
{
VisibilityManager.Instance.setVisibility(player, false, other);
}
else
{
VisibilityManager.Instance.setVisibility(player, true, other);
}
}
}
}
}

View File

@ -0,0 +1,50 @@
package mineplex.clanshub;
import mineplex.core.common.Rank;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class JoinServerButton implements IButton
{
private ShopPageBase<?, ?> _page;
private ClansTransferManager _transferManager;
private ServerInfo _serverInfo;
public JoinServerButton(ShopPageBase<?, ?> page, ClansTransferManager transferManager, ServerInfo serverInfo)
{
_page = page;
_transferManager = transferManager;
_serverInfo = serverInfo;
}
@Override
public void onClick(Player player, ClickType clickType)
{
selectServer(player, _serverInfo);
}
public void selectServer(Player player, ServerInfo serverInfo)
{
if (serverInfo != null)
{
System.out.println("Selecting server :" + serverInfo.Name);
int slots = 1;
if (serverInfo.getAvailableSlots() < slots && !_page.getClient().GetRank().has(Rank.ULTRA))
{
_page.playDenySound(player);
}
else
{
_transferManager.selectServer(player, serverInfo);
}
}
else
{
_page.playDenySound(player);
}
}
}

View File

@ -0,0 +1,13 @@
package mineplex.clanshub;
public class ServerInfo
{
public String Name;
public int CurrentPlayers = 0;
public int MaxPlayers = 0;
public int getAvailableSlots()
{
return MaxPlayers - CurrentPlayers;
}
}

View File

@ -0,0 +1,208 @@
package mineplex.clanshub;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
public class WorldManager extends MiniPlugin
{
public HubManager Manager;
public WorldManager(HubManager manager)
{
super("World Manager", manager.getPlugin());
Manager = manager;
World world = UtilWorld.getWorld("world");
world.setGameRuleValue("doDaylightCycle", "false");
world.setTime(6000);
world.setStorm(false);
world.setThundering(false);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event)
{
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
event.setCancelled(true);
}
@EventHandler
public void onBlockBurn(BlockBurnEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void onBlockIgnite(BlockIgniteEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent event)
{
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onExplosion(EntityExplodeEvent event)
{
event.blockList().clear();
}
@EventHandler
public void onVineGrow(BlockSpreadEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void onLeafDecay(LeavesDecayEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
event.setCancelled(true);
}
@EventHandler
public void onBorderUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
for (Player player : UtilServer.getPlayers())
{
if (UtilMath.offset(player.getLocation(), Manager.GetSpawn()) > 50)
{
player.eject();
player.leaveVehicle();
player.teleport(Manager.GetSpawn());
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void onItemPickup(PlayerPickupItemEvent event)
{
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOW)
public void onItemDrop(PlayerDropItemEvent event)
{
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOW)
public void onItemDespawn(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Entity ent : UtilWorld.getWorld("world").getEntities())
{
if (!(ent instanceof Item))
continue;
if (((Item)ent).getItemStack().getType() == Material.MONSTER_EGG)
continue;
if (UtilEnt.GetMetadata(ent, "UtilItemSpawning") != null)
continue;
if (ent.getTicksLived() > 1200)
ent.remove();
}
}
@EventHandler
public void onWeather(WeatherChangeEvent event)
{
if (!event.getWorld().getName().equals("world"))
return;
event.setCancelled(true);
}
@EventHandler
public void onBlockForm(BlockFormEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void onBoatBreak(CustomDamageEvent event)
{
if (event.GetDamageeEntity() instanceof Boat)
{
event.SetCancelled("Boat Cancel");
}
}
@EventHandler
public void prevenCombustiont(EntityCombustEvent event)
{
if (event.getEntity() instanceof Player)
{
event.setCancelled(true);
}
}
@EventHandler
public void preventMobs(CreatureSpawnEvent event)
{
if (event.getSpawnReason() == SpawnReason.NATURAL || event.getSpawnReason() == SpawnReason.NETHER_PORTAL)
{
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,21 @@
package mineplex.clanshub.commands;
import mineplex.clanshub.ForcefieldManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import org.bukkit.entity.Player;
public class ForcefieldRadius extends CommandBase<ForcefieldManager>
{
public ForcefieldRadius(ForcefieldManager plugin)
{
super(plugin, Rank.ADMIN, "radius", "forcefield");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.ForcefieldRadius(caller, args);
}
}

View File

@ -0,0 +1,21 @@
package mineplex.clanshub.commands;
import mineplex.clanshub.HubManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import org.bukkit.entity.Player;
public class GadgetToggle extends CommandBase<HubManager>
{
public GadgetToggle(HubManager plugin)
{
super(plugin, Rank.ADMIN, "gadget");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.ToggleGadget(caller);
}
}

View File

@ -0,0 +1,49 @@
package mineplex.clanshub.commands;
import mineplex.clanshub.HubManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
public class GameModeCommand extends CommandBase<HubManager>
{
public GameModeCommand(HubManager plugin)
{
super(plugin, Rank.ADMIN, "gamemode", "gm");
}
@Override
public void Execute(Player caller, String[] args)
{
Player target = caller;
if (args != null && args.length >= 1)
{
target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null)
return;
}
if (target.getGameMode() == GameMode.SURVIVAL)
{
target.setGameMode(GameMode.CREATIVE);
}
else
{
target.setGameMode(GameMode.SURVIVAL);
}
if (!target.equals(caller))
{
Plugin.addGameMode(caller, target);
UtilPlayer.message(target, F.main("Game Mode", caller.getName() + " toggled your Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
}
UtilPlayer.message(caller, F.main("Game Mode", target.getName() + " Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
}
}

View File

@ -0,0 +1,55 @@
package mineplex.clanshub.profile.buttons;
import mineplex.clanshub.profile.gui.GUIProfile;
import mineplex.core.common.util.C;
import mineplex.core.gui.GuiItem;
import mineplex.core.itemstack.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
public class ButtonPrefs implements GuiItem
{
private GUIProfile _profile;
private Player _player;
public ButtonPrefs(GUIProfile profile, Player player)
{
_profile = profile;
_player = player;
}
@Override
public void click(ClickType clickType)
{
_profile.getPrefManager().openShop(_player);
}
@Override
public ItemStack getObject()
{
return new ItemBuilder(Material.REDSTONE_COMPARATOR).setTitle(C.Reset + C.cYellow + "Preferences").addLore(new String[]
{
"",
C.cWhite + "Set your preferences to your liking",
C.cWhite + "so you can enjoy the game more!",
"",
C.cWhite + "Type " + C.cGreen + "/prefs" + C.cWhite + " to access this anywhere!"
}).build();
}
@Override
public void setup()
{
}
@Override
public void close()
{
}
}

View File

@ -0,0 +1,63 @@
package mineplex.clanshub.profile.buttons;
import mineplex.clanshub.profile.gui.GUIProfile;
import mineplex.core.common.util.C;
import mineplex.core.gui.GuiItem;
import mineplex.core.itemstack.ItemStackFactory;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
public class ButtonStats implements GuiItem
{
private GUIProfile _profile;
private Player _player;
public ButtonStats(GUIProfile profile, Player player)
{
_profile = profile;
_player = player;
}
@Override
public void click(ClickType clickType)
{
_profile.getAchievementManager().openShop(_player);
}
@Override
public ItemStack getObject()
{
ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1,
ChatColor.RESET + C.cYellow + "Stats and Achievements",
new String[]
{
"",
C.cWhite + "View your Statistics and Achievements",
C.cWhite + "for all of the games on Mineplex!",
"",
C.cWhite + "Type " + C.cGreen + "/stats" + C.cWhite + " to access this anywhere!"
});
SkullMeta meta = ((SkullMeta) item.getItemMeta());
meta.setOwner(_player.getName());
item.setItemMeta(meta);
return item;
}
@Override
public void setup()
{
}
@Override
public void close()
{
}
}

View File

@ -0,0 +1,36 @@
package mineplex.clanshub.profile.gui;
import mineplex.clanshub.profile.buttons.ButtonPrefs;
import mineplex.clanshub.profile.buttons.ButtonStats;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.gui.SimpleGui;
import mineplex.core.preferences.PreferencesManager;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class GUIProfile extends SimpleGui
{
private PreferencesManager _preferencesManager;
private AchievementManager _achievementManager;
public GUIProfile(Plugin plugin, Player player, PreferencesManager preferencesManager, AchievementManager achievementManager)
{
super(plugin, player, "My Profile", 9*3);
_preferencesManager = preferencesManager;
_achievementManager = achievementManager;
setItem(12, new ButtonStats(this, player));
setItem(14, new ButtonPrefs(this, player));
}
public PreferencesManager getPrefManager()
{
return _preferencesManager;
}
public AchievementManager getAchievementManager()
{
return _achievementManager;
}
}