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:
commit
dbd6f449eb
@ -11,6 +11,7 @@
|
|||||||
<orderEntry type="library" name="commons-codec" level="project" />
|
<orderEntry type="library" name="commons-codec" level="project" />
|
||||||
<orderEntry type="library" name="commons-io" level="project" />
|
<orderEntry type="library" name="commons-io" level="project" />
|
||||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||||
|
<orderEntry type="library" name="httpcore" level="project" />
|
||||||
|
<orderEntry type="library" name="httpclient" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package mineplex.bungee.playerTracker;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
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.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
@ -26,7 +26,7 @@ public class PlayerTracker implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void playerConnect(final ServerSwitchEvent event)
|
public void playerConnect(final ServerConnectedEvent event)
|
||||||
{
|
{
|
||||||
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
|
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@ import mineplex.core.common.util.UtilServer;
|
|||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.friend.command.AddFriend;
|
import mineplex.core.friend.command.AddFriend;
|
||||||
import mineplex.core.friend.command.DeleteFriend;
|
import mineplex.core.friend.command.DeleteFriend;
|
||||||
|
import mineplex.core.friend.command.FriendsDisplay;
|
||||||
import mineplex.core.friend.data.FriendData;
|
import mineplex.core.friend.data.FriendData;
|
||||||
import mineplex.core.friend.data.FriendRepository;
|
import mineplex.core.friend.data.FriendRepository;
|
||||||
import mineplex.core.friend.data.FriendStatus;
|
import mineplex.core.friend.data.FriendStatus;
|
||||||
@ -50,6 +51,11 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
|||||||
_portal = portal;
|
_portal = portal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PreferencesManager getPreferenceManager()
|
||||||
|
{
|
||||||
|
return _preferenceManager;
|
||||||
|
}
|
||||||
|
|
||||||
public Portal getPortal()
|
public Portal getPortal()
|
||||||
{
|
{
|
||||||
return _portal;
|
return _portal;
|
||||||
@ -60,6 +66,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
|||||||
{
|
{
|
||||||
addCommand(new AddFriend(this));
|
addCommand(new AddFriend(this));
|
||||||
addCommand(new DeleteFriend(this));
|
addCommand(new DeleteFriend(this));
|
||||||
|
addCommand(new FriendsDisplay(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -107,8 +114,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
|||||||
{
|
{
|
||||||
if (caller.getName().equalsIgnoreCase(name))
|
if (caller.getName().equalsIgnoreCase(name))
|
||||||
{
|
{
|
||||||
caller.sendMessage(F.main(getName(), ChatColor.GRAY
|
caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend"));
|
||||||
+ "You cannot add yourself as a friend"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +249,6 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void showFriends(Player caller)
|
public void showFriends(Player caller)
|
||||||
{
|
{
|
||||||
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
||||||
@ -369,7 +374,15 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
|||||||
caller.sendMessage(" ");
|
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
|
@Override
|
||||||
|
@ -19,10 +19,17 @@ public class AddFriend extends CommandBase<FriendManager>
|
|||||||
public void Execute(final Player caller, final String[] args)
|
public void Execute(final Player caller, final String[] args)
|
||||||
{
|
{
|
||||||
if (args == null)
|
if (args == null)
|
||||||
|
{
|
||||||
|
if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI)
|
||||||
{
|
{
|
||||||
new FriendsGUI(Plugin, caller);
|
new FriendsGUI(Plugin, caller);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
Plugin.showFriends(caller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
|
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
|
||||||
{
|
{
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package mineplex.core.friend.ui;
|
package mineplex.core.friend.ui;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -13,7 +14,10 @@ public enum FriendPage
|
|||||||
|
|
||||||
DELETE_FRIENDS(new ItemBuilder(Material.TNT).setTitle("Delete Friends").build(), "Delete Friends"),
|
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 ItemStack _icon;
|
||||||
private String _name;
|
private String _name;
|
||||||
|
@ -320,7 +320,7 @@ public class FriendsGUI implements Listener
|
|||||||
_page = 0;
|
_page = 0;
|
||||||
_buttonMap.clear();
|
_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++)
|
for (int i = 0; i < FriendPage.values().length; i++)
|
||||||
{
|
{
|
||||||
@ -370,6 +370,14 @@ public class FriendsGUI implements Listener
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (_currentPage == FriendPage.TOGGLE_DISPLAY)
|
||||||
|
{
|
||||||
|
_player.closeInventory();
|
||||||
|
|
||||||
|
CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(_player, "/friendsdisplay"));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_previousPage != _currentPage)
|
if (_previousPage != _currentPage)
|
||||||
{
|
{
|
||||||
|
@ -80,19 +80,21 @@ public abstract class ItemGadget extends Gadget
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@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()
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (event.getPlayer().isOnline())
|
if (player.isOnline())
|
||||||
{
|
{
|
||||||
event.getPlayer().getInventory().remove(GetDisplayMaterial());
|
player.getInventory().remove(GetDisplayMaterial());
|
||||||
event.getPlayer().getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName())));
|
player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(GetName()) + " " + GetName())));
|
||||||
UtilInv.Update(event.getPlayer());
|
UtilInv.Update(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -130,6 +130,6 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
|||||||
@Override
|
@Override
|
||||||
public String getQuery(String uuid, String name)
|
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;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 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 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)
|
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||||
{
|
{
|
||||||
@ -54,7 +54,8 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
||||||
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
||||||
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
|
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
|
||||||
preparedStatement.setString(12, entry.getKey());
|
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
|
||||||
|
preparedStatement.setString(13, entry.getKey());
|
||||||
|
|
||||||
preparedStatement.addBatch();
|
preparedStatement.addBatch();
|
||||||
}
|
}
|
||||||
@ -79,7 +80,8 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
||||||
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
||||||
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
|
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
|
||||||
preparedStatement.setString(12, entry.getKey());
|
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
|
||||||
|
preparedStatement.setString(13, entry.getKey());
|
||||||
preparedStatement.execute();
|
preparedStatement.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +125,7 @@ public class PreferencesRepository extends RepositoryBase
|
|||||||
preferences.ShowMacReports = resultSet.getBoolean(9);
|
preferences.ShowMacReports = resultSet.getBoolean(9);
|
||||||
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
||||||
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
preferences.PendingFriendRequests = resultSet.getBoolean(11);
|
||||||
|
preferences.friendDisplayInventoryUI = resultSet.getBoolean(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
return preferences;
|
return preferences;
|
||||||
|
@ -14,4 +14,5 @@ public class UserPreferences
|
|||||||
public boolean ShowMacReports = false;
|
public boolean ShowMacReports = false;
|
||||||
public boolean IgnoreVelocity = false;
|
public boolean IgnoreVelocity = false;
|
||||||
public boolean PendingFriendRequests = true;
|
public boolean PendingFriendRequests = true;
|
||||||
|
public boolean friendDisplayInventoryUI = true;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<orderEntry type="module" module-name="Mineplex.Core.Common" />
|
<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.ClassCombat" />
|
||||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
|
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
|
||||||
|
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||||
<orderEntry type="library" name="craftbukkit" level="project" />
|
<orderEntry type="library" name="craftbukkit" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -1,8 +1,6 @@
|
|||||||
package mineplex.game.clans.clans;
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
@ -71,13 +69,12 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
|
|||||||
_shop.attemptShopOpen(player);
|
_shop.attemptShopOpen(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO DEBUG
|
// @EventHandler
|
||||||
@EventHandler
|
// public void command(PlayerCommandPreprocessEvent event)
|
||||||
public void command(PlayerCommandPreprocessEvent event)
|
// {
|
||||||
{
|
// if (event.getMessage().startsWith("/energyshop"))
|
||||||
if (event.getMessage().startsWith("/energyshop"))
|
// {
|
||||||
{
|
// openShop(event.getPlayer());
|
||||||
openShop(event.getPlayer());
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
|||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
|
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.ClanMemberToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||||
@ -54,11 +55,11 @@ public class ClanInfo
|
|||||||
private long _dateCreated = 0;
|
private long _dateCreated = 0;
|
||||||
private long _lastOnline = 0;
|
private long _lastOnline = 0;
|
||||||
|
|
||||||
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
|
|
||||||
|
|
||||||
// Loaded from Client
|
// Loaded from Client
|
||||||
private NautHashMap<String, Role> _memberMap = new NautHashMap<String, Role>();
|
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 HashSet<String> _claimSet = new HashSet<String>();
|
||||||
|
private EnemyData _enemyData;
|
||||||
|
|
||||||
// Temporary
|
// Temporary
|
||||||
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
|
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
|
||||||
@ -106,6 +107,16 @@ public class ClanInfo
|
|||||||
{
|
{
|
||||||
_allyMap.put(allianceToken.ClanName, allianceToken.Trusted);
|
_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()
|
public int getClaims()
|
||||||
@ -215,6 +226,7 @@ public class ClanInfo
|
|||||||
stringList.add(F.value("Clan Energy", "" + energy));
|
stringList.add(F.value("Clan Energy", "" + energy));
|
||||||
// stringList.add(F.value("Max Energy", "" + getEnergyMax()));
|
// stringList.add(F.value("Max Energy", "" + getEnergyMax()));
|
||||||
stringList.add(F.value("Energy Drain/Hour", "" + costPerHour));
|
stringList.add(F.value("Energy Drain/Hour", "" + costPerHour));
|
||||||
|
if (costPerHour > 0)
|
||||||
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
|
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
|
||||||
stringList.add(" ");
|
stringList.add(" ");
|
||||||
|
|
||||||
@ -259,6 +271,27 @@ public class ClanInfo
|
|||||||
return stringList;
|
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()
|
public LinkedList<String> mTerritory()
|
||||||
{
|
{
|
||||||
LinkedList<String> stringList = new LinkedList<String>();
|
LinkedList<String> stringList = new LinkedList<String>();
|
||||||
@ -423,6 +456,16 @@ public class ClanInfo
|
|||||||
return _energy;
|
return _energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnemyData getEnemyData()
|
||||||
|
{
|
||||||
|
return _enemyData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasEnemy()
|
||||||
|
{
|
||||||
|
return _enemyData != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void adjustEnergy(int energy)
|
public void adjustEnergy(int energy)
|
||||||
{
|
{
|
||||||
_energy += energy;
|
_energy += energy;
|
||||||
@ -440,7 +483,6 @@ public class ClanInfo
|
|||||||
|
|
||||||
public int getEnergyMax()
|
public int getEnergyMax()
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
// 10080 = 7 days of minutes
|
// 10080 = 7 days of minutes
|
||||||
return 1440 + (getEnergyCostPerMinute() * 10080);
|
return 1440 + (getEnergyCostPerMinute() * 10080);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.game.clans.clans;
|
package mineplex.game.clans.clans;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
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.ClanInfo.Role;
|
||||||
import mineplex.game.clans.clans.repository.ClanRepository;
|
import mineplex.game.clans.clans.repository.ClanRepository;
|
||||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||||
|
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||||
|
|
||||||
public class ClansDataAccessLayer
|
public class ClansDataAccessLayer
|
||||||
@ -152,6 +155,26 @@ public class ClansDataAccessLayer
|
|||||||
_manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "].");
|
_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)
|
public boolean trust(ClanInfo ownerClan, ClanInfo otherClan, String player)
|
||||||
{
|
{
|
||||||
if (!ownerClan.getAllyMap().containsKey(otherClan.getName()))
|
if (!ownerClan.getAllyMap().containsKey(otherClan.getName()))
|
||||||
@ -278,6 +301,21 @@ public class ClansDataAccessLayer
|
|||||||
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
|
_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)
|
public void updateEnergy(ClanInfo clan)
|
||||||
{
|
{
|
||||||
//Save
|
//Save
|
||||||
|
@ -23,9 +23,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.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.MiniPlugin;
|
||||||
import mineplex.core.blockrestore.BlockRestoreData;
|
import mineplex.core.blockrestore.BlockRestoreData;
|
||||||
import mineplex.core.common.util.C;
|
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.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
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
|
public class ClansGame extends MiniPlugin
|
||||||
{
|
{
|
||||||
@ -172,7 +171,7 @@ public class ClansGame extends MiniPlugin
|
|||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void BlockBreak(BlockBreakEvent event)
|
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;
|
return;
|
||||||
|
|
||||||
String mimic = Clans.Get(event.getPlayer()).getMimic();
|
String mimic = Clans.Get(event.getPlayer()).getMimic();
|
||||||
|
@ -34,10 +34,12 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
|||||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||||
import mineplex.game.clans.clans.commands.ClansCommand;
|
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.ClanTerritory;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
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.fields.Field;
|
||||||
import mineplex.game.clans.gameplay.Gameplay;
|
import mineplex.game.clans.gameplay.Gameplay;
|
||||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||||
@ -71,6 +73,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
private ConditionManager _condition;
|
private ConditionManager _condition;
|
||||||
private ClassCombatShop _classShop;
|
private ClassCombatShop _classShop;
|
||||||
private ClassManager _classManager;
|
private ClassManager _classManager;
|
||||||
|
private WarManager _warManager;
|
||||||
|
|
||||||
private int _inviteExpire = 2;
|
private int _inviteExpire = 2;
|
||||||
private int _nameMin = 3;
|
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);
|
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
|
||||||
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
|
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
|
||||||
|
|
||||||
|
_warManager = new WarManager(plugin, this);
|
||||||
|
|
||||||
ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager);
|
ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager);
|
||||||
|
|
||||||
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
||||||
@ -156,6 +161,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
addCommand(new ClansCommand(this));
|
addCommand(new ClansCommand(this));
|
||||||
addCommand(new ClansChatCommand(this));
|
addCommand(new ClansChatCommand(this));
|
||||||
addCommand(new ClansAllyChatCommand(this));
|
addCommand(new ClansAllyChatCommand(this));
|
||||||
|
addCommand(new ServerTimeCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInviteExpire()
|
public int getInviteExpire()
|
||||||
@ -484,6 +490,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
return _classShop;
|
return _classShop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WarManager getWarManager()
|
||||||
|
{
|
||||||
|
return _warManager;
|
||||||
|
}
|
||||||
|
|
||||||
public int convertGoldToEnergy(int gold)
|
public int convertGoldToEnergy(int gold)
|
||||||
{
|
{
|
||||||
return gold * 4;
|
return gold * 4;
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -14,8 +14,8 @@ import mineplex.core.common.util.UtilMath;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilWorld;
|
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.game.clans.clans.ClanInfo;
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||||
@ -97,6 +97,9 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
else if (args[0].equalsIgnoreCase("sethome"))
|
else if (args[0].equalsIgnoreCase("sethome"))
|
||||||
homeSet(caller);
|
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"))
|
else if (args[0].equalsIgnoreCase("territory") || args[0].equalsIgnoreCase("t"))
|
||||||
infoTerritory(caller, args);
|
infoTerritory(caller, args);
|
||||||
|
|
||||||
@ -110,6 +113,43 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
infoClan(caller, args[0]);
|
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)
|
public void commandChat(Player caller, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package mineplex.game.clans.clans.repository;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -16,6 +17,7 @@ import mineplex.core.database.column.ColumnLong;
|
|||||||
import mineplex.core.database.column.ColumnVarChar;
|
import mineplex.core.database.column.ColumnVarChar;
|
||||||
import mineplex.game.clans.clans.ClanInfo;
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
|
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.ClanMemberToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
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_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_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_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_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 = ?;";
|
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_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;";
|
||||||
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
|
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_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 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 = "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_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_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 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 = "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_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_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 static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverName = ? AND chunk = ?;";
|
||||||
|
|
||||||
private String _serverName;
|
private String _serverName;
|
||||||
@ -150,6 +156,44 @@ public class ClanRepository extends RepositoryBase
|
|||||||
|
|
||||||
}, new ColumnVarChar("serverName", 100, _serverName));
|
}, 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();
|
return clans.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +207,7 @@ public class ClanRepository extends RepositoryBase
|
|||||||
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnInt("clanid", clanId));
|
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnInt("clanid", clanId));
|
||||||
executeUpdate(DELETE_CLAN_TERRITORIES, 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_ALLIANCES, new ColumnInt("clanid", clanId), new ColumnInt("clanid", clanId));
|
||||||
|
executeUpdate(DELETE_CLAN_ENEMY, new ColumnInt("clanid", clanId));
|
||||||
executeUpdate(DELETE_CLAN, 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));
|
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)
|
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));
|
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));
|
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)
|
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));
|
executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -14,6 +14,8 @@ public class ClanToken
|
|||||||
public long DateCreated;
|
public long DateCreated;
|
||||||
public long LastOnline;
|
public long LastOnline;
|
||||||
|
|
||||||
|
public ClanEnemyToken EnemyToken;
|
||||||
|
|
||||||
public List<ClanMemberToken> Members = new ArrayList<ClanMemberToken>();
|
public List<ClanMemberToken> Members = new ArrayList<ClanMemberToken>();
|
||||||
public List<ClanTerritoryToken> Territories = new ArrayList<ClanTerritoryToken>();
|
public List<ClanTerritoryToken> Territories = new ArrayList<ClanTerritoryToken>();
|
||||||
public List<ClanAllianceToken> Alliances = new ArrayList<ClanAllianceToken>();
|
public List<ClanAllianceToken> Alliances = new ArrayList<ClanAllianceToken>();
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@
|
|||||||
<orderEntry type="module" module-name="Mineplex.Core" />
|
<orderEntry type="module" module-name="Mineplex.Core" />
|
||||||
<orderEntry type="module" module-name="Mineplex.Core.Common" />
|
<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.ClassCombat" />
|
||||||
|
<orderEntry type="library" name="gson" level="project" />
|
||||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
|
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
|
||||||
<orderEntry type="library" name="craftbukkit" level="project" />
|
<orderEntry type="library" name="craftbukkit" level="project" />
|
||||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||||
@ -19,5 +20,6 @@
|
|||||||
<orderEntry type="library" name="commons-pool2" level="project" />
|
<orderEntry type="library" name="commons-pool2" level="project" />
|
||||||
<orderEntry type="module" module-name="Mineplex.Database" />
|
<orderEntry type="module" module-name="Mineplex.Database" />
|
||||||
<orderEntry type="library" name="jooq" level="project" />
|
<orderEntry type="library" name="jooq" level="project" />
|
||||||
|
<orderEntry type="library" name="jedis" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -123,15 +123,23 @@ public class BlockToss extends SkillCharge implements IThrown
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TrapDoor
|
//TrapDoor or ladder
|
||||||
if ( grab.getRelative(BlockFace.NORTH).getType() == Material.TRAP_DOOR ||
|
for (int x = -1; x <= 1; x++)
|
||||||
grab.getRelative(BlockFace.SOUTH).getType() == Material.TRAP_DOOR ||
|
{
|
||||||
grab.getRelative(BlockFace.EAST).getType() == Material.TRAP_DOOR ||
|
for (int z = -1; z <= 1; z++)
|
||||||
grab.getRelative(BlockFace.WEST).getType() == Material.TRAP_DOOR)
|
{
|
||||||
|
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."));
|
UtilPlayer.message(player, F.main(GetName(), "You cannot grab this block."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Block to Item
|
//Block to Item
|
||||||
FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), event.getClickedBlock().getType(), (byte)0);
|
FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), event.getClickedBlock().getType(), (byte)0);
|
||||||
|
@ -175,6 +175,8 @@ public class ServerMonitor
|
|||||||
NautHashMap<Integer, MinecraftServer> serverMap = new NautHashMap<Integer, MinecraftServer>();
|
NautHashMap<Integer, MinecraftServer> serverMap = new NautHashMap<Integer, MinecraftServer>();
|
||||||
|
|
||||||
for (Iterator<MinecraftServer> serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();)
|
for (Iterator<MinecraftServer> serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
MinecraftServer server = serverIterator.next();
|
MinecraftServer server = serverIterator.next();
|
||||||
int serverNum = Integer.parseInt(server.getName().split("-")[1]);
|
int serverNum = Integer.parseInt(server.getName().split("-")[1]);
|
||||||
@ -189,6 +191,11 @@ public class ServerMonitor
|
|||||||
serverMap.put(serverNum, server);
|
serverMap.put(serverNum, server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (groupStatus.getHost() == null || groupStatus.getHost().isEmpty())
|
if (groupStatus.getHost() == null || groupStatus.getHost().isEmpty())
|
||||||
|
@ -197,7 +197,7 @@ public class StatusHistoryRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_bungeeconnection == null || _bungeeconnection.isClosed())
|
if (_bungeeconnection == null || _bungeeconnection.isClosed())
|
||||||
_bungeeconnection = DriverManager.getConnection(_connectionString, _userName, _password);
|
_bungeeconnection = DriverManager.getConnection(_bungeeConnectionString, _userName, _password);
|
||||||
|
|
||||||
retrieveStatement = _bungeeconnection.prepareStatement(RETRIEVE_BUNGEE_STATUSES);
|
retrieveStatement = _bungeeconnection.prepareStatement(RETRIEVE_BUNGEE_STATUSES);
|
||||||
ResultSet resultSet = retrieveStatement.executeQuery();
|
ResultSet resultSet = retrieveStatement.executeQuery();
|
||||||
@ -219,6 +219,7 @@ public class StatusHistoryRepository
|
|||||||
if (bungeeData.Alive && bungeeData.US == (region == Region.US))
|
if (bungeeData.Alive && bungeeData.US == (region == Region.US))
|
||||||
totalPlayers += bungeeData.Players;
|
totalPlayers += bungeeData.Players;
|
||||||
|
|
||||||
|
if (bungeeData.US == (region == Region.US))
|
||||||
bungeeStatuses.add(bungeeData);
|
bungeeStatuses.add(bungeeData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,9 @@ public abstract class TeamGame extends Game
|
|||||||
if (player.isDead())
|
if (player.isDead())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (player.getWorld() == UtilWorld.getWorld("world"))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!QuitOut)
|
if (!QuitOut)
|
||||||
{
|
{
|
||||||
//Store
|
//Store
|
||||||
|
@ -521,6 +521,9 @@ public class SuperSmash extends SoloGame
|
|||||||
if (damager.equals(event.GetDamageeEntity()))
|
if (damager.equals(event.GetDamageeEntity()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!(event.GetDamageeEntity() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false))
|
if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ package nautilus.game.arcade.gui.spectatorMenu.page;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -57,9 +59,22 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
|||||||
{
|
{
|
||||||
setItem(13, getTeamItem(team, 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;
|
int slot = 19;
|
||||||
|
|
||||||
for (Player other : team.GetPlayers(true))
|
for (Player other : players)
|
||||||
{
|
{
|
||||||
addPlayerItem(slot, team, other);
|
addPlayerItem(slot, team, other);
|
||||||
|
|
||||||
@ -79,6 +94,17 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
|
|||||||
ArrayList<Player> teamPlayers = team.GetPlayers(true);
|
ArrayList<Player> teamPlayers = team.GetPlayers(true);
|
||||||
int rowsNeeded = (teamPlayers.size() / 8) + 1;
|
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++)
|
for (int row = 0; row < rowsNeeded; row++)
|
||||||
{
|
{
|
||||||
int woolSlot = (row * 9) + (currentRow * 9);
|
int woolSlot = (row * 9) + (currentRow * 9);
|
||||||
|
@ -11,13 +11,14 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.FireworkEffect;
|
|
||||||
import org.bukkit.FireworkEffect.Type;
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
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.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
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.account.CoreClient;
|
||||||
import mineplex.core.common.Rank;
|
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.F;
|
||||||
import mineplex.core.common.util.MapUtil;
|
import mineplex.core.common.util.MapUtil;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
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.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilFirework;
|
import mineplex.core.common.util.UtilFirework;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilBlockText;
|
|
||||||
import mineplex.core.common.util.UtilBlockText.TextAlign;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
||||||
@ -57,8 +62,8 @@ import mineplex.core.donation.Donor;
|
|||||||
import mineplex.core.event.CustomTagEvent;
|
import mineplex.core.event.CustomTagEvent;
|
||||||
import mineplex.core.packethandler.IPacketHandler;
|
import mineplex.core.packethandler.IPacketHandler;
|
||||||
import mineplex.core.packethandler.PacketHandler;
|
import mineplex.core.packethandler.PacketHandler;
|
||||||
import mineplex.core.packethandler.PacketVerifier;
|
|
||||||
import mineplex.core.packethandler.PacketInfo;
|
import mineplex.core.packethandler.PacketInfo;
|
||||||
|
import mineplex.core.packethandler.PacketVerifier;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
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.Kit;
|
||||||
import nautilus.game.arcade.kit.KitAvailability;
|
import nautilus.game.arcade.kit.KitAvailability;
|
||||||
import nautilus.game.arcade.kit.KitSorter;
|
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
|
public class GameLobbyManager implements Listener, IPacketHandler
|
||||||
{
|
{
|
||||||
@ -1301,4 +1302,30 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
|||||||
|
|
||||||
event.setCancelled(true);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user