Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

Conflicts:
	Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java
This commit is contained in:
Chiss 2015-02-05 11:37:35 +11:00
commit dbd6f449eb
32 changed files with 721 additions and 72 deletions

View File

@ -11,6 +11,7 @@
<orderEntry type="library" name="commons-codec" level="project" />
<orderEntry type="library" name="commons-io" level="project" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="httpcore" level="project" />
<orderEntry type="library" name="httpclient" level="project" />
</component>
</module>
</module>

View File

@ -3,7 +3,7 @@ package mineplex.bungee.playerTracker;
import java.io.File;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
@ -26,7 +26,7 @@ public class PlayerTracker implements Listener
}
@EventHandler
public void playerConnect(final ServerSwitchEvent event)
public void playerConnect(final ServerConnectedEvent event)
{
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
{

View File

@ -25,6 +25,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.friend.command.AddFriend;
import mineplex.core.friend.command.DeleteFriend;
import mineplex.core.friend.command.FriendsDisplay;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendRepository;
import mineplex.core.friend.data.FriendStatus;
@ -49,7 +50,12 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
_repository = new FriendRepository(plugin);
_portal = portal;
}
public PreferencesManager getPreferenceManager()
{
return _preferenceManager;
}
public Portal getPortal()
{
return _portal;
@ -60,6 +66,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
{
addCommand(new AddFriend(this));
addCommand(new DeleteFriend(this));
addCommand(new FriendsDisplay(this));
}
@Override
@ -107,8 +114,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
{
if (caller.getName().equalsIgnoreCase(name))
{
caller.sendMessage(F.main(getName(), ChatColor.GRAY
+ "You cannot add yourself as a friend"));
caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend"));
return;
}
@ -243,7 +249,6 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
});
}
@Deprecated
public void showFriends(Player caller)
{
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
@ -369,7 +374,15 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
caller.sendMessage(" ");
}
caller.sendMessage(C.cAqua + C.Strike + "=====================================================");
ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================");
message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay");
message.hover("show_text", C.cAqua + "Toggle friends to display in a inventory");
message.add(C.cAqua + C.Strike + "======================");
message.sendToPlayer(caller);
}
@Override

View File

@ -20,7 +20,14 @@ public class AddFriend extends CommandBase<FriendManager>
{
if (args == null)
{
new FriendsGUI(Plugin, caller);
if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI)
{
new FriendsGUI(Plugin, caller);
}
else
{
Plugin.showFriends(caller);
}
}
else
{

View File

@ -0,0 +1,39 @@
package mineplex.core.friend.command;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.friend.FriendManager;
import mineplex.core.friend.ui.FriendsGUI;
import mineplex.core.preferences.UserPreferences;
public class FriendsDisplay extends CommandBase<FriendManager>
{
public FriendsDisplay(FriendManager plugin)
{
super(plugin, Rank.ALL, "friendsdisplay");
}
@Override
public void Execute(Player caller, final String[] args)
{
UserPreferences preferences = Plugin.getPreferenceManager().Get(caller);
preferences.friendDisplayInventoryUI = !preferences.friendDisplayInventoryUI;
Plugin.getPreferenceManager().savePreferences(caller);
caller.playSound(caller.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
if (preferences.friendDisplayInventoryUI)
{
new FriendsGUI(Plugin, caller);
}
else
{
Plugin.showFriends(caller);
}
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.friend.ui;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import org.bukkit.Material;
@ -13,7 +14,10 @@ public enum FriendPage
DELETE_FRIENDS(new ItemBuilder(Material.TNT).setTitle("Delete Friends").build(), "Delete Friends"),
SEND_REQUEST(new ItemBuilder(Material.BOOK_AND_QUILL).setTitle("Send Friend Request").build(), "Send Friend Request");
SEND_REQUEST(new ItemBuilder(Material.BOOK_AND_QUILL).setTitle("Send Friend Request").build(), "Send Friend Request"),
TOGGLE_DISPLAY(new ItemBuilder(Material.SIGN).setTitle(C.cGray + "Toggle friends to display in chat").build(),
"Toggle Display");
private ItemStack _icon;
private String _name;

View File

@ -320,7 +320,7 @@ public class FriendsGUI implements Listener
_page = 0;
_buttonMap.clear();
ArrayList<Integer> itemSlots = new ItemLayout("XOXOXOXOX").getItemSlots();
ArrayList<Integer> itemSlots = new ItemLayout("OXOXOXOXO").getItemSlots();
for (int i = 0; i < FriendPage.values().length; i++)
{
@ -370,6 +370,14 @@ public class FriendsGUI implements Listener
return;
}
else if (_currentPage == FriendPage.TOGGLE_DISPLAY)
{
_player.closeInventory();
CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(_player, "/friendsdisplay"));
return;
}
if (_previousPage != _currentPage)
{

View File

@ -80,19 +80,21 @@ public abstract class ItemGadget extends Gadget
}
@EventHandler
public void orderThatChest(final PlayerDropItemEvent event)
public void orderThatChest(PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == GetDisplayMaterial())
if (IsActive(event.getPlayer()) && event.getItemDrop().getItemStack().getType() == GetDisplayMaterial())
{
final Player player = event.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
if (player.isOnline())
{
event.getPlayer().getInventory().remove(GetDisplayMaterial());
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName())));
UtilInv.Update(event.getPlayer());
player.getInventory().remove(GetDisplayMaterial());
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())));
UtilInv.Update(player);
}
}
});

View File

@ -130,6 +130,6 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
@Override
public String getQuery(String uuid, String name)
{
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
}
}

View File

@ -15,7 +15,7 @@ public class PreferencesRepository extends RepositoryBase
{
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ? WHERE uuid=?;";
public PreferencesRepository(JavaPlugin plugin, String connectionString)
{
@ -53,8 +53,9 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setString(12, entry.getKey());
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setString(13, entry.getKey());
preparedStatement.addBatch();
}
@ -79,7 +80,8 @@ public class PreferencesRepository extends RepositoryBase
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setString(12, entry.getKey());
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setString(13, entry.getKey());
preparedStatement.execute();
}
@ -123,6 +125,7 @@ public class PreferencesRepository extends RepositoryBase
preferences.ShowMacReports = resultSet.getBoolean(9);
preferences.IgnoreVelocity = resultSet.getBoolean(10);
preferences.PendingFriendRequests = resultSet.getBoolean(11);
preferences.friendDisplayInventoryUI = resultSet.getBoolean(12);
}
return preferences;

View File

@ -14,4 +14,5 @@ public class UserPreferences
public boolean ShowMacReports = false;
public boolean IgnoreVelocity = false;
public boolean PendingFriendRequests = true;
public boolean friendDisplayInventoryUI = true;
}

View File

@ -11,6 +11,7 @@
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="craftbukkit" level="project" />
</component>
</module>

View File

@ -1,8 +1,6 @@
package mineplex.game.clans.clans;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
@ -71,13 +69,12 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
_shop.attemptShopOpen(player);
}
// TODO DEBUG
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/energyshop"))
{
openShop(event.getPlayer());
}
}
// @EventHandler
// public void command(PlayerCommandPreprocessEvent event)
// {
// if (event.getMessage().startsWith("/energyshop"))
// {
// openShop(event.getPlayer());
// }
// }
}

View File

@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
@ -54,11 +55,11 @@ public class ClanInfo
private long _dateCreated = 0;
private long _lastOnline = 0;
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
// Loaded from Client
private NautHashMap<String, Role> _memberMap = new NautHashMap<String, Role>();
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
private HashSet<String> _claimSet = new HashSet<String>();
private EnemyData _enemyData;
// Temporary
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
@ -106,6 +107,16 @@ public class ClanInfo
{
_allyMap.put(allianceToken.ClanName, allianceToken.Trusted);
}
updateEnemy(token.EnemyToken);
}
public void updateEnemy(ClanEnemyToken enemyToken)
{
if (enemyToken != null)
{
_enemyData = new EnemyData(enemyToken.EnemyName, enemyToken.Initiator, enemyToken.Score, enemyToken.Kills, enemyToken.TimeFormed);
}
}
public int getClaims()
@ -215,7 +226,8 @@ public class ClanInfo
stringList.add(F.value("Clan Energy", "" + energy));
// stringList.add(F.value("Max Energy", "" + getEnergyMax()));
stringList.add(F.value("Energy Drain/Hour", "" + costPerHour));
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
if (costPerHour > 0)
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
stringList.add(" ");
// Ally String
@ -259,6 +271,27 @@ public class ClanInfo
return stringList;
}
public LinkedList<String> mEnemy()
{
LinkedList<String> stringList = new LinkedList<String>();
if (_enemyData == null)
{
stringList.add(F.main("Clans", "You do not have an enemy!"));
}
else
{
stringList.add(F.main("Clans", "Enemy Details"));
String enemyName = _enemyData.getEnemyName();
EnemyData otherEnemyData = Clans.getClanUtility().getClanByClanName(enemyName).getEnemyData();
stringList.add(F.value("Enemy", _enemyData.getEnemyName()));
stringList.add(F.value("Formed", _enemyData.getRelativeTimeFormed()));
stringList.add(F.value("War Score", _enemyData.getScore() + " : " + otherEnemyData.getScore()));
}
return stringList;
}
public LinkedList<String> mTerritory()
{
LinkedList<String> stringList = new LinkedList<String>();
@ -422,6 +455,16 @@ public class ClanInfo
{
return _energy;
}
public EnemyData getEnemyData()
{
return _enemyData;
}
public boolean hasEnemy()
{
return _enemyData != null;
}
public void adjustEnergy(int energy)
{
@ -440,7 +483,6 @@ public class ClanInfo
public int getEnergyMax()
{
// TODO
// 10080 = 7 days of minutes
return 1440 + (getEnergyCostPerMinute() * 10080);
}

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.clans;
import java.util.Date;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -10,6 +12,7 @@ import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClanInfo.Role;
import mineplex.game.clans.clans.repository.ClanRepository;
import mineplex.game.clans.clans.repository.ClanTerritory;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
public class ClansDataAccessLayer
@ -152,6 +155,26 @@ public class ClansDataAccessLayer
_manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "].");
}
public void enemy(ClanInfo clan, ClanInfo otherClan, String player)
{
_repository.addEnemy(clan.getId(), otherClan.getId());
Date currDate = new Date();
ClanEnemyToken clanEnemyToken = new ClanEnemyToken();
clanEnemyToken.Initiator = true;
clanEnemyToken.TimeFormed = currDate;
clanEnemyToken.EnemyName = otherClan.getName();
clan.updateEnemy(clanEnemyToken);
ClanEnemyToken otherClanEnemyToken = new ClanEnemyToken();
otherClanEnemyToken.Initiator = false;
otherClanEnemyToken.TimeFormed = currDate;
otherClanEnemyToken.EnemyName = clan.getName();
otherClan.updateEnemy(otherClanEnemyToken);
_manager.log("Added Enemy for [" + clan.getName() + "] and [" + otherClan.getName() + "] by [" + player + "].");
}
public boolean trust(ClanInfo ownerClan, ClanInfo otherClan, String player)
{
if (!ownerClan.getAllyMap().containsKey(otherClan.getName()))
@ -277,6 +300,21 @@ public class ClansDataAccessLayer
//Log
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
}
public void updateEnemy(ClanInfo clan, ClanInfo otherClan)
{
assert clan.getEnemyData() != null && otherClan.getEnemyData() != null;
assert clan.getEnemyData().getEnemyName() == otherClan.getName() && otherClan.getEnemyData().getEnemyName() == clan.getName();
ClanInfo initiator = clan.getEnemyData().isInitiator() ? clan : otherClan;
EnemyData iData = initiator.getEnemyData();
ClanInfo other = clan == initiator ? otherClan : clan;
EnemyData oData = other.getEnemyData();
_repository.updateEnemy(initiator.getId(), other.getId(), iData.getScore(), oData.getScore(), iData.getKills(), oData.getKills());
//Log
_manager.log("Updated Enemy Data for [" + clan.getName() + ", " + otherClan.getName() + "]");
}
public void updateEnergy(ClanInfo clan)
{

View File

@ -23,9 +23,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.blockrestore.BlockRestoreData;
import mineplex.core.common.util.C;
@ -38,12 +35,14 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo.Role;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class ClansGame extends MiniPlugin
{
@ -172,7 +171,7 @@ public class ClansGame extends MiniPlugin
@EventHandler(priority = EventPriority.LOW)
public void BlockBreak(BlockBreakEvent event)
{
if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL)
if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE)
return;
String mimic = Clans.Get(event.getPlayer()).getMimic();

View File

@ -34,10 +34,12 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand;
import mineplex.game.clans.clans.commands.ClansCommand;
import mineplex.game.clans.clans.commands.ServerTimeCommand;
import mineplex.game.clans.clans.repository.ClanTerritory;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.fields.Field;
import mineplex.game.clans.gameplay.Gameplay;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
@ -71,6 +73,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
private ConditionManager _condition;
private ClassCombatShop _classShop;
private ClassManager _classManager;
private WarManager _warManager;
private int _inviteExpire = 2;
private int _nameMin = 3;
@ -135,6 +138,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
_warManager = new WarManager(plugin, this);
ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager);
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
@ -156,6 +161,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
addCommand(new ClansCommand(this));
addCommand(new ClansChatCommand(this));
addCommand(new ClansAllyChatCommand(this));
addCommand(new ServerTimeCommand(this));
}
public int getInviteExpire()
@ -484,6 +490,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
return _classShop;
}
public WarManager getWarManager()
{
return _warManager;
}
public int convertGoldToEnergy(int gold)
{
return gold * 4;

View File

@ -0,0 +1,76 @@
package mineplex.game.clans.clans;
import java.util.Date;
import mineplex.core.common.util.UtilTime;
public class EnemyData
{
private String _enemy;
private boolean _initiator;
private int _score;
private int _kills;
private Date _timeFormed;
public EnemyData(String enemy, boolean initiator, int score, int kills, Date timeFormed)
{
_enemy = enemy;
_initiator = initiator;
_score = score;
_kills = kills;
_timeFormed = timeFormed;
}
public String getEnemyName()
{
return _enemy;
}
public int getScore()
{
return _score;
}
public int getKills()
{
return _kills;
}
public void addDeath()
{
addScore(-1);
}
public void addKill()
{
addScore(1);
addKills(1);
}
private void addScore(int add)
{
_score = Math.max(0, Math.min(_score + 1, 40));
}
private void addKills(int add)
{
_kills++;
}
public boolean isInitiator()
{
return _initiator;
}
public Date getTimeFormed()
{
return _timeFormed;
}
public String getRelativeTimeFormed()
{
long timeFormed = _timeFormed.getTime();
long currentTime = System.currentTimeMillis();
return UtilTime.convertString(System.currentTimeMillis() - timeFormed, 1, UtilTime.TimeUnit.FIT);
}
}

View File

@ -14,8 +14,8 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanInfo.Role;
@ -97,6 +97,9 @@ public class ClansCommand extends CommandBase<ClansManager>
else if (args[0].equalsIgnoreCase("sethome"))
homeSet(caller);
else if (args[0].equalsIgnoreCase("enemy") || args[0].equals("e"))
enemy(caller, args);
else if (args[0].equalsIgnoreCase("territory") || args[0].equalsIgnoreCase("t"))
infoTerritory(caller, args);
@ -110,6 +113,43 @@ public class ClansCommand extends CommandBase<ClansManager>
infoClan(caller, args[0]);
}
public void enemy(Player caller, String[] args)
{
if (args.length == 2)
{
ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller);
ClanInfo otherClan = Plugin.getClanUtility().searchClan(caller, args[1], true);
if (playerClan == null)
{
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
else if (otherClan == null)
{
return;
}
attemptEnemy(caller, playerClan, otherClan);
}
else
{
infoEnemy(caller);
}
}
private void attemptEnemy(Player caller, ClanInfo initiatorClan, ClanInfo otherClan)
{
Plugin.getWarManager().attemptEnemy(caller, initiatorClan, otherClan);
}
private void infoEnemy(Player caller)
{
ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller);
UtilPlayer.message(caller, playerClan.mEnemy());
}
public void commandChat(Player caller, String[] args)
{
if (args.length == 0)

View File

@ -0,0 +1,22 @@
package mineplex.game.clans.clans.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ClansManager;
public class ServerTimeCommand extends CommandBase<ClansManager>
{
public ServerTimeCommand(ClansManager plugin)
{
super(plugin, Rank.ALL, "servertime", "t");
}
@Override
public void Execute(Player caller, String[] args)
{
UtilPlayer.message(caller, Plugin.getWarManager().mServerTime());
}
}

View File

@ -3,6 +3,7 @@ package mineplex.game.clans.clans.repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin;
@ -16,6 +17,7 @@ import mineplex.core.database.column.ColumnLong;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
@ -30,6 +32,7 @@ public class ClanRepository extends RepositoryBase
private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverName = ?;";
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, a.uuid, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverName = ?;";
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverName = ?;";
private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills, timeFormed FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverName = ?;";
private static String DELETE_CLAN_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? AND accounts.name = ?;";
private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;";
@ -37,16 +40,19 @@ public class ClanRepository extends RepositoryBase
private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;";
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;";
private static String DELETE_CLAN_ENEMY = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;";
private static String DELETE_CLAN = "DELETE FROM clans WHERE id = ?;";
private static String ADD_CLAN = "INSERT INTO clans (serverName, name, description, home, admin, dateCreated, energy, lastOnline) VALUES (?, ?, ?, ?, ?, now(), ?, now());";
private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;";
private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);";
private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, timeFormed) VALUES (?, ?, now());";
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, serverName, chunk, safe) VALUES (?, ?, ?, ?);";
private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, lastOnline = ? WHERE id = ?;";
private static String UPDATE_CLAN_MEMBER = "UPDATE accountClan AS AC INNER JOIN accounts ON accounts.id = AC.accountId SET AC.clanRole = ? WHERE AC.clanId = ? AND accounts.name = ?;";
private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;";
private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverName = ? AND chunk = ?;";
private String _serverName;
@ -149,6 +155,44 @@ public class ClanRepository extends RepositoryBase
}
}, new ColumnVarChar("serverName", 100, _serverName));
executeQuery(RETRIEVE_CLAN_ENEMY_INFO, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
ClanEnemyToken clanToken = new ClanEnemyToken();
ClanEnemyToken otherClanToken = new ClanEnemyToken();
//c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills
String clanName = resultSet.getString(1);
String otherClanName = resultSet.getString(2);
int clanScore = resultSet.getInt(3);
int otherClanScore = resultSet.getInt(4);
int clanKills = resultSet.getInt(5);
int otherClanKills = resultSet.getInt(6);
Date timeFormed = resultSet.getTimestamp(7);
clanToken.EnemyName = otherClanName;
clanToken.Score = clanScore;
clanToken.Kills = clanKills;
clanToken.Initiator = true;
clanToken.TimeFormed = timeFormed;
otherClanToken.EnemyName = clanName;
otherClanToken.Score = otherClanScore;
otherClanToken.Kills = otherClanKills;
otherClanToken.Initiator = false;
otherClanToken.TimeFormed = timeFormed;
clans.get(clanName).EnemyToken = clanToken;
clans.get(otherClanName).EnemyToken = otherClanToken;
}
}
}, new ColumnVarChar("serverName", 100, _serverName));
return clans.values();
}
@ -163,6 +207,7 @@ public class ClanRepository extends RepositoryBase
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN_TERRITORIES, new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN_ALLIANCES, new ColumnInt("clanid", clanId), new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN_ENEMY, new ColumnInt("clanid", clanId));
executeUpdate(DELETE_CLAN, new ColumnInt("clanid", clanId));
}
@ -218,6 +263,11 @@ public class ClanRepository extends RepositoryBase
executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe));
}
public void addEnemy(int clanId, int otherClanId)
{
executeUpdate(ADD_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId));
}
public void removeTerritoryClaim(int clanId, String chunk)
{
executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));
@ -228,6 +278,13 @@ public class ClanRepository extends RepositoryBase
executeUpdate(UPDATE_CLAN, new ColumnVarChar("name", 100, name), new ColumnVarChar("desc", 100, desc), new ColumnVarChar("home", 100, home), new ColumnBoolean("admin", admin), new ColumnInt("energy", energy), new ColumnLong("lastOnline", lastOnline), new ColumnInt("clanId", clanId));
}
public void updateEnemy(int clanId, int otherClanId, int clanScore, int otherClanScore, int clanKills, int otherClanKills)
{
executeUpdate(UPDATE_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId),
new ColumnInt("clanScore", clanScore), new ColumnInt("otherClanScore", otherClanScore), new ColumnInt("clanKills", clanKills),
new ColumnInt("otherClanKills", otherClanKills), new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId));
}
public void updateTerritoryClaim(String chunk, boolean safe)
{
executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));

View File

@ -0,0 +1,12 @@
package mineplex.game.clans.clans.repository.tokens;
import java.util.Date;
public class ClanEnemyToken
{
public boolean Initiator;
public String EnemyName;
public int Score;
public int Kills;
public Date TimeFormed;
}

View File

@ -13,6 +13,8 @@ public class ClanToken
public int Energy;
public long DateCreated;
public long LastOnline;
public ClanEnemyToken EnemyToken;
public List<ClanMemberToken> Members = new ArrayList<ClanMemberToken>();
public List<ClanTerritoryToken> Territories = new ArrayList<ClanTerritoryToken>();

View File

@ -0,0 +1,197 @@
package mineplex.game.clans.clans.war;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
public class WarManager extends MiniPlugin
{
private static final int INVADE_ENEMY_DATE = Calendar.SATURDAY;
private static final int CREATE_ENEMY_DATE = Calendar.SUNDAY;
private final ClansManager _clansManager;
public WarManager(JavaPlugin plugin, ClansManager clansManager)
{
super("War Manager", plugin);
_clansManager = clansManager;
}
public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan)
{
attemptEnemy(player, initiatingClan, otherClan, true);
}
public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan, boolean notify)
{
String notifyMessage = null;
if (!isEnemyTime())
{
notifyMessage = "Enemies cannot be formed at this time. Please see mineplex.com/clans for info";
}
else if (initiatingClan.getEnemyData() != null)
{
notifyMessage = "Your clan already has an enemy.";
}
else if (otherClan.getEnemyData() != null)
{
notifyMessage = "The clan " + F.elem(otherClan.getName()) + " already has an enemy.";
}
else
{
_clansManager.getClanDataAccess().enemy(initiatingClan, otherClan, player.getName());
_clansManager.messageClan(initiatingClan, F.main("Clans", "Your clan is now enemies with " + F.elem(otherClan.getName())));
_clansManager.messageClan(otherClan, F.main("Clans", "Your clan is now enemies with " + F.elem(initiatingClan.getName())));
}
if (notify && notifyMessage != null)
UtilPlayer.message(player, F.main("Clans", notifyMessage));
}
@EventHandler
public void handleDeath(PlayerDeathEvent event)
{
Player player = event.getEntity();
Player killer = player.getKiller();
ClanInfo playerClan = _clansManager.getClan(player);
ClanInfo killerClan = _clansManager.getClan(killer);
if (playerClan != null && killerClan != null)
{
if (playerClan.getEnemyData() != null && playerClan.getEnemyData().getEnemyName().equalsIgnoreCase(killerClan.getName()))
{
if (isWarInProgress())
{
playerClan.getEnemyData().addDeath();
killerClan.getEnemyData().addKill();
}
}
}
}
/**
* Can enemies be formed at the current time
*
* Enemy forming will happen once a week during a set period
*/
private boolean isEnemyTime()
{
Calendar c = Calendar.getInstance();
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == CREATE_ENEMY_DATE)
{
return true;
}
return false;
}
private boolean isInvadeTime()
{
Calendar c = Calendar.getInstance();
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == INVADE_ENEMY_DATE)
{
return true;
}
return false;
}
private boolean isWarInProgress()
{
return !isInvadeTime();
}
/**
* Get the starting time of when enemies can be formed next
* @return The enemy start time in the form of {@link java.util.Date}
*/
private Date getNextEnemyTime()
{
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_WEEK, CREATE_ENEMY_DATE);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.add(Calendar.DATE, 7);
return c.getTime();
}
/**
* Get the starting time of the next enemy invasion
* @return The invasion start time in the form of {@link java.util.Date}
*/
private Date getNextInvadeTime()
{
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_WEEK, INVADE_ENEMY_DATE);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.add(Calendar.DATE, 7);
return c.getTime();
}
/**
* Send the current server time information to the player
*/
public LinkedList<String> mServerTime()
{
LinkedList<String> messageList = new LinkedList<String>();
messageList.add(F.main("Clans", "Server Time;"));
Date currDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
messageList.add(F.value("Server Time", dateFormat.format(currDate)));
if (isInvadeTime())
{
messageList.add(F.elem("Winning clans can invade enemies right now"));
}
else
{
long next = getNextInvadeTime().getTime();
long currTime = System.currentTimeMillis();
messageList.add(F.value("Enemy Invasion", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT)));
}
if (isEnemyTime())
{
messageList.add(F.elem("Enemies can be formed at this time"));
}
else
{
long next = getNextEnemyTime().getTime();
long currTime = System.currentTimeMillis();
messageList.add(F.value("Can Form Enemies In", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT)));
}
return messageList;
}
}

View File

@ -12,6 +12,7 @@
<orderEntry type="module" module-name="Mineplex.Core" />
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
<orderEntry type="library" name="gson" level="project" />
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
<orderEntry type="library" name="craftbukkit" level="project" />
<orderEntry type="module" module-name="Mineplex.ServerData" />
@ -19,5 +20,6 @@
<orderEntry type="library" name="commons-pool2" level="project" />
<orderEntry type="module" module-name="Mineplex.Database" />
<orderEntry type="library" name="jooq" level="project" />
<orderEntry type="library" name="jedis" level="project" />
</component>
</module>

View File

@ -123,14 +123,22 @@ public class BlockToss extends SkillCharge implements IThrown
return;
}
//TrapDoor
if ( grab.getRelative(BlockFace.NORTH).getType() == Material.TRAP_DOOR ||
grab.getRelative(BlockFace.SOUTH).getType() == Material.TRAP_DOOR ||
grab.getRelative(BlockFace.EAST).getType() == Material.TRAP_DOOR ||
grab.getRelative(BlockFace.WEST).getType() == Material.TRAP_DOOR)
//TrapDoor or ladder
for (int x = -1; x <= 1; x++)
{
UtilPlayer.message(player, F.main(GetName(), "You cannot grab this block."));
return;
for (int z = -1; z <= 1; z++)
{
if (x != z && (z == 0 || x == 0))
{
Block block = grab.getRelative(x, 0, z);
if (block.getType() == Material.TRAP_DOOR || block.getType() == Material.LADDER)
{
UtilPlayer.message(player, F.main(GetName(), "You cannot grab this block."));
return;
}
}
}
}
//Block to Item

View File

@ -146,9 +146,9 @@ public class ServerMonitor
}
for (Iterator<DedicatedServer> iterator = _dedicatedServers.iterator(); iterator.hasNext();)
{
{
DedicatedServer serverData = iterator.next();
if (_badServers.containsKey(serverData.getName()))
iterator.remove();
else
@ -176,17 +176,24 @@ public class ServerMonitor
for (Iterator<MinecraftServer> serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();)
{
MinecraftServer server = serverIterator.next();
int serverNum = Integer.parseInt(server.getName().split("-")[1]);
if (serverMap.containsKey(serverNum))
try
{
killServer(server.getName(), server.getPublicAddress(), server.getPlayerCount(), "[KILLED] [DUPLICATE] " + server.getName() + ":" + server.getPublicAddress(), true);
serverIterator.remove();
MinecraftServer server = serverIterator.next();
int serverNum = Integer.parseInt(server.getName().split("-")[1]);
if (serverMap.containsKey(serverNum))
{
killServer(server.getName(), server.getPublicAddress(), server.getPlayerCount(), "[KILLED] [DUPLICATE] " + server.getName() + ":" + server.getPublicAddress(), true);
serverIterator.remove();
}
else
{
serverMap.put(serverNum, server);
}
}
else
catch (Exception exception)
{
serverMap.put(serverNum, server);
exception.printStackTrace();
}
}

View File

@ -197,7 +197,7 @@ public class StatusHistoryRepository
try
{
if (_bungeeconnection == null || _bungeeconnection.isClosed())
_bungeeconnection = DriverManager.getConnection(_connectionString, _userName, _password);
_bungeeconnection = DriverManager.getConnection(_bungeeConnectionString, _userName, _password);
retrieveStatement = _bungeeconnection.prepareStatement(RETRIEVE_BUNGEE_STATUSES);
ResultSet resultSet = retrieveStatement.executeQuery();
@ -219,7 +219,8 @@ public class StatusHistoryRepository
if (bungeeData.Alive && bungeeData.US == (region == Region.US))
totalPlayers += bungeeData.Players;
bungeeStatuses.add(bungeeData);
if (bungeeData.US == (region == Region.US))
bungeeStatuses.add(bungeeData);
}
}
catch (Exception exception)

View File

@ -71,6 +71,9 @@ public abstract class TeamGame extends Game
if (player.isDead())
return;
if (player.getWorld() == UtilWorld.getWorld("world"))
return;
if (!QuitOut)
{

View File

@ -520,6 +520,9 @@ public class SuperSmash extends SoloGame
if (damager.equals(event.GetDamageeEntity()))
return;
if (!(event.GetDamageeEntity() instanceof Player))
return;
if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false))
return;

View File

@ -2,6 +2,8 @@ package nautilus.game.arcade.gui.spectatorMenu.page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.bukkit.ChatColor;
@ -56,10 +58,23 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
private void buildSingleTeam(GameTeam team, int playerCount)
{
setItem(13, getTeamItem(team, playerCount));
ArrayList<Player> players = team.GetPlayers(true);
Collections.sort(players, new Comparator<Player>()
{
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
int slot = 19;
for (Player other : team.GetPlayers(true))
for (Player other : players)
{
addPlayerItem(slot, team, other);
@ -78,6 +93,17 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
{
ArrayList<Player> teamPlayers = team.GetPlayers(true);
int rowsNeeded = (teamPlayers.size() / 8) + 1;
Collections.sort(teamPlayers, new Comparator<Player>()
{
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
for (int row = 0; row < rowsNeeded; row++)
{

View File

@ -11,13 +11,14 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -31,11 +32,15 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.WatchableObject;
import mineplex.core.account.CoreClient;
import mineplex.core.common.Rank;
@ -43,13 +48,13 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlockText;
import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilBlockText;
import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
@ -57,8 +62,8 @@ import mineplex.core.donation.Donor;
import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -71,10 +76,6 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.KitSorter;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.WatchableObject;
public class GameLobbyManager implements Listener, IPacketHandler
{
@ -1301,4 +1302,30 @@ public class GameLobbyManager implements Listener, IPacketHandler
event.setCancelled(true);
}
/**
* DEBUG
*/
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
Player player = event.getPlayer();
if (event.getMessage().startsWith("/enable"))
{
player.setGameMode(GameMode.CREATIVE);
player.setFlying(true);
player.setFlySpeed(0.1f);
((CraftPlayer) player).getHandle().spectating = true;
((CraftPlayer) player).getHandle().k = false;
}
else if (event.getMessage().startsWith("/disable"))
{
player.setGameMode(GameMode.SURVIVAL);
player.setFlying(false);
player.setFlySpeed(0.1f);
((CraftPlayer) player).getHandle().spectating = false;
((CraftPlayer) player).getHandle().k = true;
}
}
}