lots of work on outposts,

fixed gold dupe glitch,
fixed clans ban gui title being "Customize New Gear".
This commit is contained in:
NewGarbo 2016-01-02 14:02:50 +00:00
parent aa50c4762f
commit b47665e115
35 changed files with 1347 additions and 140 deletions

View File

@ -39,7 +39,7 @@ public class PlayerCache
catch (Exception exception)
{
System.out.println("Error adding player info in PlayerCache : " + exception.getMessage());
exception.printStackTrace();
// exception.printStackTrace();
}
}

View File

@ -2,6 +2,8 @@ package mineplex.core.common.util;
import mineplex.core.common.Rank;
import java.util.LinkedList;
import org.bukkit.ChatColor;
public class F
@ -198,5 +200,4 @@ public class F
return out;
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.common.util;
import java.util.List;
public class LoopIterator<T>
{
private List<T> _list;
private int _pointer;
public LoopIterator(List<T> list)
{
_list = list;
}
public T next()
{
if (_list.isEmpty())
{
return null;
}
if (++_pointer == _list.size())
{
_pointer = 0;
}
return _list.get(_pointer);
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.common.util;
public class NonFinalInteger
{
private int _value;
public NonFinalInteger()
{
this(0);
}
public NonFinalInteger(int value)
{
_value = value;
}
public NonFinalInteger add(int value)
{
_value += value;
return this;
}
public NonFinalInteger subtract(int value)
{
_value -= value;
return this;
}
public int get()
{
return _value;
}
}

View File

@ -0,0 +1,45 @@
package mineplex.core.common.util;
public class RGBData
{
private double _red;
private double _green;
private double _blue;
public RGBData(double red, double green, double blue)
{
_red = UtilMath.clamp(red, 0, 1);
_green = UtilMath.clamp(green, 0, 1);
_blue = UtilMath.clamp(blue, 0, 1);
}
public int getFullRed()
{
return (int) (_red * 255);
}
public int getFullGreen()
{
return (int) (_green * 255);
}
public int getFullBlue()
{
return (int) (_blue * 255);
}
public double getRed()
{
return _red;
}
public double getGreen()
{
return _green;
}
public double getBlue()
{
return _blue;
}
}

View File

@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class UtilAlg
{
@ -510,4 +510,9 @@ public class UtilAlg
Math.toRadians(UtilAlg.GetYaw(vector)),
0);
}
public static AxisAlignedBB toBoundingBox(Location a, Location b)
{
return new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ());
}
}

View File

@ -7,6 +7,7 @@ import org.bukkit.ChatColor;
*/
public class UtilColor
{
public static final RGBData RgbRed = hexToRgb(0xee0100);
public static byte chatColorToClayData(ChatColor chatColor)
{
@ -66,4 +67,24 @@ public class UtilColor
return 0;
}
}
public static RGBData hexToRgb(int hex)
{
String hexStr = hexPad(Integer.toHexString(hex));
int red = Integer.parseInt(hexStr.substring(0, 2), 16);
int green = Integer.parseInt(hexStr.substring(2, 4), 16);
int blue = Integer.parseInt(hexStr.substring(4, 6), 16);
return new RGBData(((double) red) / 255.d, ((double) green) / 255.d, ((double) blue) / 255.d);
}
public static String hexPad(String hex)
{
if (hex.length() == 6)
{
return hex;
}
return UtilText.repeat("0", 6 - hex.length()) + hex;
}
}

View File

@ -116,4 +116,15 @@ public class UtilMath
{
return num < min ? min : (num > max ? max : num);
}
public static double random(double min, double max)
{
min = Math.abs(min);
int rand = -random.nextInt((int)(min * 100));
rand += random.nextInt((int)(max * 100));
return ((double) rand) / 100.d;
}
}

View File

@ -285,6 +285,76 @@ public class CoreClientManager extends MiniPlugin
});
}
public void loadClientByNameSync(final String playerName, final Runnable runnable)
{
try
{
ClientToken token = null;
Gson gson = new Gson();
// Fails if not in DB and if duplicate.
UUID uuid = loadUUIDFromDB(playerName);
if (uuid == null)
{
try
{
uuid = UUIDFetcher.getUUIDOf(playerName);
}
catch (Exception exception)
{
System.out.println("Error fetching uuid from mojang : " + exception.getMessage());
}
}
String response = "";
if (uuid == null)
{
response = _repository.getClientByName(playerName);
}
else
{
response = _repository.getClientByUUID(uuid);
}
token = gson.fromJson(response, ClientToken.class);
CoreClient client = Add(playerName);
client.SetRank(Rank.valueOf(token.Rank), false);
client.setAccountId(_repository.login(_loginProcessors, _querylessLoginProcessors, uuid.toString(), client.GetPlayerName()));
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
if (client.getAccountId() > 0)
{
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
if (playerInfo != null)
{
playerInfo.setAccountId(client.getAccountId());
PlayerCache.getInstance().addPlayer(playerInfo);
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
{
public void run()
{
if (runnable != null)
runnable.run();
}
});
}
}
public boolean LoadClient(final CoreClient client, final UUID uuid, String ipAddress)
{
TimingManager.start(client.GetPlayerName() + " LoadClient Total.");

View File

@ -352,7 +352,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
if (donor != null)
{
donor.addGold(amount);
donor.setGold(amount);
}
}
}
@ -445,7 +445,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
@Override
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
Get(playerName).addGold(_repository.retrieveDonorInfo(resultSet).getGold());
Get(playerName).setGold(_repository.retrieveDonorInfo(resultSet).getGold());
}
@Override

View File

@ -246,7 +246,7 @@ public class DonationRepository extends RepositoryBase
while (resultSet.next())
{
donor.addGold(resultSet.getInt(1));
donor.setGold(resultSet.getInt(1));
}
return donor;

View File

@ -173,6 +173,7 @@ public class ItemBuilder
{
for (String lore : lores)
{
if (lore == null) continue;
_lore.add(C.cGray + lore);
}

View File

@ -100,7 +100,7 @@ public class Clans extends JavaPlugin
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
// new ClansBanManager(this, webServerAddress, _clientManager, _donationManager);
new ClansBanManager(this, _clientManager, _donationManager);
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);

View File

@ -38,8 +38,4 @@ public class ClansBlacklist
return true;
}
public static void addBlacklist(String blacklist) {
BLACKLISTED_NAMES.add(blacklist);
}
}

View File

@ -31,6 +31,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -72,6 +75,7 @@ import mineplex.game.clans.clans.commands.ClansCommand;
import mineplex.game.clans.clans.commands.ClansLoginManager;
import mineplex.game.clans.clans.commands.KillCommand;
import mineplex.game.clans.clans.commands.MapCommand;
import mineplex.game.clans.clans.commands.Meow;
import mineplex.game.clans.clans.commands.RegionsCommand;
import mineplex.game.clans.clans.data.PlayerClan;
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
@ -79,6 +83,7 @@ import mineplex.game.clans.clans.gui.ClanShop;
import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager;
import mineplex.game.clans.clans.observer.ObserverManager;
import mineplex.game.clans.clans.outpost.OutpostManager;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.clans.potato.PotatoManager;
import mineplex.game.clans.clans.pvptimer.PvpTimer;
@ -203,6 +208,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
super("Clans Manager", plugin);
addCommand(new Meow(new OutpostManager(this)));
_instance = this;
_serverName = serverName;
@ -584,6 +591,27 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
}
@EventHandler
public void disallowReplayMod(PlayerJoinEvent event)
{
// happens 20 ticks later because player channels don't
// seem to work immediately after joining.
runSyncLater(() -> {
ByteArrayDataOutput bado = ByteStreams.newDataOutput();
bado.writeUTF("no_xray");
bado.writeBoolean(true);
bado.writeUTF("no_noclip");
bado.writeBoolean(true);
bado.writeUTF("only_recording_player");
bado.writeBoolean(true);
event.getPlayer().sendPluginMessage(_plugin, "Replay|Restrict", bado.toByteArray());
}, 20L);
}
@EventHandler
public void denyBow(EntityShootBowEvent event)
{
@ -710,15 +738,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
@EventHandler
public void command(PlayerCommandPreprocessEvent event){
if (event.getMessage().startsWith("/blacklist ")){
String blacklist = event.getMessage().split(" ")[1];
ClansBlacklist.addBlacklist(blacklist);
}
}
public void messageClan(ClanInfo clan, String message)
{
for (Player player : clan.getOnlinePlayers())

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.clans.ban;
import java.sql.Timestamp;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime;
@ -8,11 +10,12 @@ public class ClansBan
private int _id;
private int _accountId;
private String _reason;
private long _banTime;
private long _unbanTime;
private Timestamp _banTime;
private Timestamp _unbanTime;
private boolean _permanent;
private boolean _removed;
public ClansBan(int id, int accountId, String reason, long banTime, long unbanTime, boolean permanent)
public ClansBan(int id, int accountId, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed)
{
_id = id;
_accountId = accountId;
@ -20,6 +23,7 @@ public class ClansBan
_banTime = banTime;
_unbanTime = unbanTime;
_permanent = permanent;
_removed = removed;
}
public int getId()
@ -37,22 +41,22 @@ public class ClansBan
return _reason;
}
public long getBanTime()
public Timestamp getBanTime()
{
return _banTime;
}
public long getLength()
{
return _unbanTime - _banTime;
return _unbanTime.getTime() - _banTime.getTime();
}
public long getTimeLeft()
{
return Math.max(0, _unbanTime - System.currentTimeMillis());
return Math.max(0, _unbanTime.getTime() - System.currentTimeMillis());
}
public long getUnbanTime()
public Timestamp getUnbanTime()
{
return _unbanTime;
}
@ -71,7 +75,7 @@ public class ClansBan
public boolean isRemoved()
{
return _unbanTime == -1;
return _removed;
}
public boolean isActive()

View File

@ -35,6 +35,11 @@ public class ClansBanClient
for (ClansBan ban : Bans)
{
if (!ban.isActive())
{
continue;
}
if (ban.isPermanent())
{
return -1;
@ -52,20 +57,30 @@ public class ClansBanClient
return time == -1 ? F.time("permanently") : "for " + F.time(UtilTime.MakeStr(time));
}
public String toString()
public ClansBan getLongestBan()
{
StringBuilder str = new StringBuilder();
str.append("{ClansBanClient:" + AccountId + "} [\n");
ClansBan longest = null;
for (ClansBan ban : Bans)
{
str.append("(\nid: " + ban.getId() + ",\nbanTime: " + ban.getBanTime() + ",\nunbanTime: " + ban.getUnbanTime() + ",\nbanTimeLeft:" + ban.getTimeLeft() + ",\nReason:\"" + ban.getReason() + "\"\n)");
if (!ban.isActive())
{
continue;
}
if (longest == null)
{
longest = ban;
continue;
}
if (ban.getTimeLeft() > longest.getTimeLeft())
{
longest = ban;
}
}
str.append("]");
return str.toString();
return longest;
}
}

View File

@ -1,20 +1,32 @@
package mineplex.game.clans.clans.ban;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager;
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
import mineplex.game.clans.clans.ban.commands.ClansBanListCommand;
import mineplex.game.clans.clans.ban.ui.ClansBanListShop;
import mineplex.game.clans.clans.ban.ui.ClansBanShop;
public class ClansBanManager extends MiniPlugin
@ -24,32 +36,35 @@ public class ClansBanManager extends MiniPlugin
private Map<String, ClansBanClient> _clients;
private Map<String, String> _cache;
private ClansBanShop _shop;
private ClansBanListShop _shop2;
public ClansBanManager(JavaPlugin plugin, String webServerAddress, CoreClientManager clientManager, DonationManager donationManager)
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("Blacklist", plugin);
_clientManager = clientManager;
_repository = new ClansBanRepository(plugin, this, webServerAddress);
_repository = new ClansBanRepository(plugin, this);
_clients = new HashMap<>();
_cache = new HashMap<>();
_shop = new ClansBanShop(this, clientManager, donationManager);
_shop2 = new ClansBanListShop(this, clientManager, donationManager);
}
@Override
public void addCommands()
{
addCommand(new ClansBanCommand(this));
addCommand(new ClansBanListCommand(this));
}
public void ban(ClansBanClient client, String name, long time, String reason)
public void ban(ClansBanClient client, String name, long time, String reason, Callback<ClansBanClient> callback)
{
_repository.ban(client.AccountId, time, reason, time == -1);
LoadClient(name, null);
LoadClient(name, callback);
}
public CoreClientManager getClientManager()
@ -65,36 +80,85 @@ public class ClansBanManager extends MiniPlugin
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
LoadClient(event.getPlayer().getName(), null);
ClansBanClient client = _clients.get(event.getPlayer().getName());
if (client.isBanned())
{
event.setJoinMessage(null);
event.getPlayer().kickPlayer(C.cRed + "You have been banned from Clans " + client.getBanTimeFormatted() + ".");
}
LoadClient(event.getPlayer().getName(), client -> {
if (client.isBanned())
{
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
if (client.getLongestBan().isPermanent())
time = "Permanent";
String reason = C.cRedB + "You are banned from Clans for " + time +
"\n" + C.cWhite + client.getLongestBan().getReason()
;
event.getPlayer().kickPlayer(reason);
}
else
{
UtilServer.broadcast(F.sys("Join", event.getPlayer().getName()));
}
});
}
@EventHandler
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerQuitEvent event)
{
if (Get(event.getPlayer().getName()) == null)
{
return;
}
if (Get(event.getPlayer().getName()).isBanned())
{
event.setQuitMessage(null);
}
UnloadClient(Get(event.getPlayer().getName()));
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerKicked(PlayerKickEvent event)
{
ClansBanClient client = _clients.get(event.getPlayer().getName());
if (Get(event.getPlayer().getName()) == null)
{
return;
}
if (client.isBanned())
if (Get(event.getPlayer().getName()).isBanned())
{
event.setLeaveMessage(null);
}
UnloadClient(Get(event.getPlayer().getName()));
}
public void UnloadClient(ClansBanClient client)
{
String name = "";
for (Entry<String, ClansBanClient> entry : _clients.entrySet())
{
if (entry.getValue().equals(client))
{
name = entry.getKey();
break;
}
}
_clients.remove(name);
}
public void LoadClient(final String name, Callback<ClansBanClient> callback)
{
GetRepository().loadBans(name, client -> {
_clients.put(name, client);
System.out.println("> CLIENTS: " + _clients);
if (callback != null) callback.run(client);
});
}
public ClansBanClient GetClient(String name)
public ClansBanClient Get(String name)
{
synchronized (this)
{
@ -107,6 +171,11 @@ public class ClansBanManager extends MiniPlugin
return _shop;
}
public ClansBanListShop getShop2()
{
return _shop2;
}
public void cache(Player player, String playerName)
{
_cache.put(player.getName(), playerName);
@ -122,7 +191,7 @@ public class ClansBanManager extends MiniPlugin
_cache.remove(name);
}
public void unban(ClansBanClient target, ClansBan ban, String name)
public void unban(ClansBanClient target, ClansBan ban, String name, Callback<ClansBanClient> callback)
{
if (target.AccountId != ban.getAccountId())
{
@ -131,6 +200,11 @@ public class ClansBanManager extends MiniPlugin
_repository.removeBan(ban);
LoadClient(name, null);
LoadClient(name, callback);
}
public void listRecordedNames(Callback<List<ClansBanClient>> callback)
{
GetRepository().loadAll(callback);
}
}

View File

@ -8,9 +8,8 @@ import java.util.List;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.gson.reflect.TypeToken;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NonFinalInteger;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
@ -18,20 +17,18 @@ import mineplex.core.database.column.ColumnBoolean;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnTimestamp;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.core.server.remotecall.JsonWebCall;
public class ClansBanRepository extends RepositoryBase
{
private ClansBanManager _manager;
private static final String GET_LONGEST_BAN = "SELECT * FROM clanBans WHERE (NOW() < unbanTime OR permanent=1) AND accountId = ? ORDER BY permanent DESC, unbanTime DESC LIMIT 1;";
private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, reason, banTime, unbanTime, permanent) VALUES (?, ?, ?, ?, ?);";
private static final String REMOVE_BAN = "UPDATE clanBans SET unbanTime = -1 WHERE id = ?;";
private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?);";
private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;";
private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE accountId = ?;";
private static final String GET_ALL_ACCOUNTS = "SELECT DISTINCT accountId FROM clanBans;";
private String _webAddress;
public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager, String webServerAddress)
public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager)
{
super(plugin, DBPool.getAccount());
@ -45,20 +42,26 @@ public class ClansBanRepository extends RepositoryBase
new ColumnVarChar("reason", 128, reason),
new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())),
new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)),
new ColumnBoolean("permanent", permanent)
new ColumnBoolean("permanent", permanent),
new ColumnBoolean("removed", false)
);
}
public void loadBans(final String name, final Callback<ClansBanClient> callback)
{
System.out.println(">> Attempting to load Clans Bans for \"" + name + "\"");
_manager.getClientManager().loadClientByName(name, new Runnable() {
public void run()
{
System.out.println("> Successfully loaded CoreClient");
executeQuery(GET_ALL_BANS, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
System.out.println("> Successfully executed query, result set object: " + resultSet);
final List<ClansBan> list = new ArrayList<ClansBan>();
while (resultSet.next())
@ -66,14 +69,58 @@ public class ClansBanRepository extends RepositoryBase
int id = resultSet.getInt(1);
int accountId = resultSet.getInt(2);
String reason = resultSet.getString(3);
long banTime = resultSet.getLong(4);
long unbanTime = resultSet.getLong(5);
Timestamp banTime = resultSet.getTimestamp(4);
Timestamp unbanTime = resultSet.getTimestamp(5);
boolean permanent = resultSet.getBoolean(6);
boolean removed = resultSet.getBoolean(7);
list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent));
list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
}
callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list));
System.out.println("> Successfully handled result");
System.out.println(">> FINISH");
}
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
}
});
}
public void loadBansSync(final String name, final Callback<ClansBanClient> callback)
{
System.out.println(">> Attempting to load Clans Bans for \"" + name + "\"");
_manager.getClientManager().loadClientByNameSync(name, new Runnable() {
public void run()
{
System.out.println("> Successfully loaded CoreClient");
executeQuery(GET_ALL_BANS, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
System.out.println("> Successfully executed query, result set object: " + resultSet);
final List<ClansBan> list = new ArrayList<ClansBan>();
while (resultSet.next())
{
int id = resultSet.getInt(1);
int accountId = resultSet.getInt(2);
String reason = resultSet.getString(3);
Timestamp banTime = resultSet.getTimestamp(4);
Timestamp unbanTime = resultSet.getTimestamp(5);
boolean permanent = resultSet.getBoolean(6);
boolean removed = resultSet.getBoolean(7);
list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
}
callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list));
System.out.println("> Successfully handled result");
System.out.println(">> FINISH");
}
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
}
@ -103,8 +150,9 @@ public class ClansBanRepository extends RepositoryBase
Timestamp banTime = resultSet.getTimestamp(4);
Timestamp unbanTime = resultSet.getTimestamp(5);
boolean permanent = resultSet.getBoolean(6);
callback.run(new ClansBan(id, accountId, reason, banTime.getTime(), unbanTime.getTime(), permanent));
boolean removed = resultSet.getBoolean(7);
callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
}
}
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
@ -112,20 +160,33 @@ public class ClansBanRepository extends RepositoryBase
});
}
public void matchPlayerName(final Callback<List<String>> callback, final String userName)
public void loadAll(Callback<List<ClansBanClient>> callback)
{
Thread asyncThread = new Thread(new Runnable()
{
public void run()
_manager.runAsync(() -> {
executeQuery(GET_ALL_ACCOUNTS, new ResultSetCallable()
{
List<String> tokenList = new JsonWebCall(_webAddress + "PlayerAccount/GetMatches").Execute(new TypeToken<List<String>>(){}.getType(), userName);
callback.run(tokenList);
}
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
final List<ClansBanClient> clients = new ArrayList<>();
final NonFinalInteger resultsProcessed = new NonFinalInteger();
int resultsFound = 0;
while (resultSet.next())
{
resultsFound++;
int accountId = resultSet.getInt(0);
// loadBans(_manager.getClientManager().)
}
System.out.println("Found: " + resultsFound + ", Processed: " + resultsProcessed);
}
});
});
asyncThread.start();
}
@Override
protected void initialize()

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.clans.ban.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -28,10 +29,8 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
{
final String playerName = args[0];
Plugin.LoadClient(playerName, client -> {
Plugin.cache(caller, playerName);
Plugin.getShop().attemptShopOpen(caller);
});
Plugin.cache(caller, playerName);
Plugin.getShop().attemptShopOpen(caller);
}
else if (args.length > 2)
{
@ -71,18 +70,21 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
if (target != null)
{
Plugin.LoadClient(playerName, client -> {
Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason);
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(client.getBanTimeFormatted()) + "."));
Plugin.runSync(() -> target.kickPlayer(C.cRed + "You have been banned from Clans " + client.getBanTimeFormatted() + "."));
Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + "."));
Bukkit.broadcastMessage(F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + "."));
Plugin.runSync(() -> target.kickPlayer(C.cRedB + "You have been banned from Clans " + c.getBanTimeFormatted() + "."));
});
});
return;
}
Plugin.LoadClient(playerName, client -> {
Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason);
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + client.getBanTimeFormatted() + "."));
Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + c.getBanTimeFormatted() + "."));
Bukkit.broadcastMessage(F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + "."));
});
});
}
else

View File

@ -0,0 +1,21 @@
package mineplex.game.clans.clans.ban.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.game.clans.clans.ban.ClansBanManager;
public class ClansBanListCommand extends CommandBase<ClansBanManager>
{
public ClansBanListCommand(ClansBanManager plugin)
{
super(plugin, Rank.ADMIN, "listbans");
}
@Override
public void Execute(final Player caller, String[] args)
{
Plugin.getShop2().attemptShopOpen(caller);
}
}

View File

@ -0,0 +1,32 @@
package mineplex.game.clans.clans.ban.ui;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ban.ClansBanClient;
import mineplex.game.clans.clans.ban.ClansBanManager;
public class ClansBanListPage extends ShopPageBase<ClansBanManager, ClansBanListShop>
{
public ClansBanListPage(final ClansBanManager banManager, final ClansBanListShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player)
{
super(banManager, shop, clientManager, donationManager, name, player);
buildPage();
}
protected void buildPage()
{
getPlugin().listRecordedNames(clients -> {
for (ClansBanClient client : clients)
{
}
});
}
}

View File

@ -0,0 +1,24 @@
package mineplex.game.clans.clans.ban.ui;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ban.ClansBanManager;
public class ClansBanListShop extends ShopBase<ClansBanManager>
{
public ClansBanListShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Clans Punish");
}
@Override
protected ShopPageBase<ClansBanManager, ? extends ShopBase<ClansBanManager>> buildPagesFor(final Player player)
{
return new ClansBanListPage(getPlugin(), this, getClientManager(), getDonationManager(), "Clans Punish", player);
}
}

View File

@ -1,10 +1,17 @@
package mineplex.game.clans.clans.ban.ui;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.ban.ClansBan;
import mineplex.game.clans.clans.ban.ClansBanManager;
public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
@ -18,6 +25,38 @@ public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
protected void buildPage()
{
String name = getPlugin().getCachedName(getPlayer());
getPlugin().LoadClient(name, client -> {
int slot = 0;
for (ClansBan ban : client.Bans)
{
ItemStack item =
new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
.setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive")
.addLore(" ")
.addLore("Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
.addLore("Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
.addLore("Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
.addLore("Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
.addLore(!ban.isActive() ? null : C.cDAqua + "Left-Click to disable ban")
.build();
if (ban.isActive())
{
UtilInv.addDullEnchantment(item);
}
addButton(slot++, item, (player, click) -> {
if (ban.isActive())
{
getPlugin().unban(client, ban, name, c -> refresh());
}
});
}
});
}
}

View File

@ -12,12 +12,13 @@ public class ClansBanShop extends ShopBase<ClansBanManager>
{
public ClansBanShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Customize New Gear");
super(plugin, clientManager, donationManager, "Clans Punish");
}
@Override
protected ShopPageBase<ClansBanManager, ? extends ShopBase<ClansBanManager>> buildPagesFor(final Player player)
{
return new ClansBanPage(getPlugin(), this, getClientManager(), getDonationManager(), "Customize New Gear", player);
return new ClansBanPage(getPlugin(), this, getClientManager(), getDonationManager(), "Clans Punish", player);
}
}

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.game.clans.clans.outpost.OutpostManager;
import mineplex.game.clans.clans.outpost.OutpostType;
public class Meow extends CommandBase<OutpostManager>
{
public Meow(OutpostManager plugin)
{
super(plugin, Rank.ALL, "meow");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.Spawn(caller, caller.getLocation().getBlock().getLocation(), OutpostType.ORIGINAL_CLANS);
}
}

View File

@ -0,0 +1,257 @@
package mineplex.game.clans.clans.outpost;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.FallingBlock;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LoopIterator;
import mineplex.core.common.util.NonFinalInteger;
import mineplex.core.common.util.RGBData;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.hologram.Hologram;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class Outpost
{
private final List<RGBData> _coreParticleColors = new ArrayList<RGBData>();
protected static final long MAX_LIFETIME = 60 * 1000; // 30 minutes
private OutpostManager _host;
private ClanInfo _clan;
private Location _startCorner;
private Location _middle;
private Location _endCorner;
private Location _core;
private LinkedHashMap<String, OutpostBlock> _blocks;
private LinkedHashMap<String, OutpostBlock> _buildQueue;
private OutpostType _type;
private OutpostState _state;
private LoopIterator<Vector> _circleStages;
private LoopIterator<Vector> _reverseCircleStages;
private long _spawnTime;
private long _lastConstructionSound;
public Outpost(OutpostManager host, ClanInfo clan, Location location, OutpostType type)
{
_host = host;
_clan = clan;
_startCorner = location.clone().subtract(type._size, 1, type._size);
_endCorner = location.clone().add(type._size, type._ySize - 1, type._size);
_middle = location.clone();
_type = type;
_spawnTime = System.currentTimeMillis();
_coreParticleColors.add(UtilColor.hexToRgb(0x00A296));
_coreParticleColors.add(UtilColor.hexToRgb(0x29E6B6));
_coreParticleColors.add(UtilColor.hexToRgb(0x29E67B));
beginConstruction();
}
private void cleanup()
{
_blocks = null;
_state = OutpostState.DEAD;
_host.queueForRemoval(_clan.getName());
}
protected void update()
{
if (_state == OutpostState.CONSTRUCTING)
{
if (_buildQueue.isEmpty())
{
_state = OutpostState.LIVE;
return;
}
else
{
Iterator<String> iterator = _buildQueue.keySet().iterator();
if (iterator.hasNext())
{
_buildQueue.remove(iterator.next()).set();
}
}
}
{
RGBData color = _state == OutpostState.LIVE ? UtilMath.randomElement(_coreParticleColors) : UtilColor.RgbRed;
Vector nextCircleStage = _circleStages.next();
double circleX = nextCircleStage.getX();
double circleZ = nextCircleStage.getZ();
UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.f, 0, ViewDist.NORMAL);
}
{
RGBData color = _state == OutpostState.LIVE ? UtilMath.randomElement(_coreParticleColors) : UtilColor.RgbRed;
Vector nextCircleStage = _reverseCircleStages.next();
double circleX = nextCircleStage.getX();
double circleZ = nextCircleStage.getZ();
UtilParticle.PlayParticleToAll(ParticleType.MOB_SPELL, _core.clone().add(circleX + .5, 1.1d, circleZ + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 5.f, 0, ViewDist.NORMAL);
}
}
public void beginConstruction()
{
_state = OutpostState.CONSTRUCTING;
_blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_middle, _clan.Clans));
_core = _type.getCoreLocation(_middle);
_circleStages = new LoopIterator<Vector>(circleAround(new Vector(0., 0., 0.), 40, .6d));
List<Vector> reverse = circleAround(new Vector(0., 0., 0.), 40, .6d);
Collections.reverse(reverse);
_reverseCircleStages = new LoopIterator<Vector>(reverse);
//Inform nearby Clans
for (int chunkX = -3; chunkX < 3; chunkX++)
{
for (int chunkZ = -3; chunkZ < 3; chunkZ++)
{
ClanTerritory territory = _clan.Clans.getClanUtility().getClaim(_middle.getWorld().getChunkAt(_middle.getChunk().getX() + chunkX, _middle.getChunk().getZ() + chunkZ));
if (territory != null && ClansBlacklist.isValidClanName(territory.Owner))
{
ClanInfo clan = _clan.Clans.getClanUtility().getClanByClanName(territory.Owner);
clan.inform("A siege has begun near your territory!", null);
}
}
}
}
private List<Vector> circleAround(Vector origin, int points, double radius)
{
List<Vector> list = new LinkedList<>();
double slice = 2 * Math.PI / points;
for (int point = 0; point < points; point++)
{
double angle = slice * point;
list.add(new Vector(origin.getX() + radius * Math.cos(angle), 0, origin.getZ() + radius * Math.sin(angle)));
}
return list;
}
public void kill()
{
_state = OutpostState.DESTRUCTING;
UtilServer.getPlayersCollection().stream().filter(p -> p.getLocation().distance(_middle) < 64).forEach(p -> {
NonFinalInteger wait = new NonFinalInteger(0);
_blocks.values().forEach(block -> {
if (UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean() || UtilMath.random.nextBoolean())
{
return;
}
_host.runSyncLater(() -> {
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, block._loc, new Vector(0,0,0), 0.1f, 3, ViewDist.LONG, p);
p.playSound(block._loc, Sound.EXPLODE, 1.0f, 1.0f);
}, wait.add(4 + UtilMath.random.nextInt(10)).get());
});
_host.runSyncLater(() -> {
_blocks.values().forEach(block -> {
Material mat = Material.getMaterial(block._id);
if (UtilItem.isTranslucent(mat))
{
block.restore();
return;
}
FallingBlock fall = block._loc.getWorld().spawnFallingBlock(block._loc, block._id, block._data);
Vector vec = UtilAlg.getTrajectory(fall.getLocation(), _middle);
UtilAction.velocity(fall, vec, 1, false, 0, 0.6, 10, false);
fall.setMetadata("ClansOutpost", new FixedMetadataValue(_clan.Clans.getPlugin(), _clan.getName()));
block.restore();
});
cleanup();
}, wait.get() + 5L);
});
_clan.inform("Your Clan's Outpost has been destroyed.", null);
}
public ClanInfo getClan()
{
return _clan;
}
public long getLifetime()
{
return System.currentTimeMillis() - _spawnTime;
}
public AxisAlignedBB getBounds()
{
return UtilAlg.toBoundingBox(_startCorner, _endCorner);
}
public Location getExactMiddle()
{
return UtilAlg.getMidpoint(_startCorner, _endCorner);
}
public OutpostState getState()
{
return _state;
}
}

View File

@ -0,0 +1,59 @@
package mineplex.game.clans.clans.outpost;
import java.util.Map;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockState;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
public class OutpostBlock
{
protected Location _loc;
protected int _id;
protected byte _data;
protected int _originalId;
protected byte _originalData;
public OutpostBlock(Map<String, OutpostBlock> blocks, Location loc, int id, byte data)
{
_loc = loc;
_id = id;
_data = data;
String locStr = UtilWorld.locToStr(loc);
if (blocks.containsKey(locStr))
{
_originalId = blocks.get(locStr)._originalId;
_originalData = blocks.get(locStr)._originalData;
}
else
{
_originalId = _loc.getBlock().getTypeId();
_originalData = _loc.getBlock().getData();
}
}
public void set()
{
_loc.getBlock().setTypeIdAndData(_id, _data, false);
if (_id != 0)
{
_loc.getWorld().playEffect(_loc, Effect.STEP_SOUND, Material.getMaterial(_id), 10);
}
}
public void restore()
{
BlockState state = _loc.getBlock().getState();
state.setTypeId(_originalId);
state.setRawData(_originalData);
state.update(true, false);
}
}

View File

@ -0,0 +1,171 @@
package mineplex.game.clans.clans.outpost;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.metadata.FixedMetadataValue;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
public class OutpostManager extends MiniPlugin
{
private ClansManager _clansManager;
private Map<String, Outpost> _outposts = new HashMap<>();
private List<String> _removalQueue;
public OutpostManager(ClansManager clansManager)
{
super("Outpost Manager", clansManager.getPlugin());
_clansManager = clansManager;
_removalQueue = new ArrayList<>();
}
public void Spawn(Player player, Location location, OutpostType type)
{
if (!_clansManager.isInClan(player))
{
UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place an Outpost."));
return;
}
if (location.getBlockY() < 10)
{
UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost this deep."));
return;
}
ClanInfo clan = _clansManager.getClan(player);
if (UtilItem.isBoundless(location.clone().subtract(0, 1, 0).getBlock().getType()))
{
UtilPlayer.message(player, F.main("Clans", "An Outpost must not be placed floating."));
return;
}
if (Get(clan) != null)
{
UtilPlayer.message(player, F.main("Clans", "Your clan already has an outpost"));
return;
}
if (_clansManager.getClanUtility().getClaim(location) != null)
{
UtilPlayer.message(player, F.main("Clans", "An Outpost must be placed in the Wilderness."));
return;
}
for (Outpost outpost : _outposts.values())
{
if (UtilMath.offset(location, outpost.getExactMiddle()) < 10)
{
UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost near other Outposts."));
return;
}
}
for (int x = -type._size; x < type._size; x++)
{
for (int y = -1; y < type._ySize; y++)
{
for (int z = -type._size; z < type._size; z++)
{
Location loc = location.clone();
if (_clansManager.getClanUtility().isClaimed(loc))
{
UtilPlayer.message(player, F.main("Clans", "You cannot place an Outpost where it may intersect with claimed territory."));
return;
}
}
}
}
_outposts.put(clan.getName(), new Outpost(this, clan, location, type));
}
@EventHandler
public void onBlockFall(EntityChangeBlockEvent event)
{
if (event.getEntity().hasMetadata("ClansOutpost"))
{
event.setCancelled(true);
}
}
@EventHandler
public void onClaim(PlayerClaimTerritoryEvent event)
{
for (Outpost outpost : _outposts.values())
{
if (outpost.getBounds().b(UtilAlg.toBoundingBox(event.getClaimedChunk().getBlock(0, 0, 0).getLocation(), event.getClaimedChunk().getBlock(15, 254, 15).getLocation())))
{
event.setCancelled(true);
UtilPlayer.message(event.getClaimer(), F.main("Clans", "You cannot claim this territory as it overlaps with a " + F.elem(outpost.getClan().getName()) + "'s Outpost."));
break;
}
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
for (Outpost outpost : _outposts.values())
{
if (outpost.getState() != OutpostState.DEAD)
{
outpost.update();
}
}
if (!_removalQueue.isEmpty())
{
_outposts.remove(_removalQueue.remove(0));
}
}
if (event.getType() == UpdateType.TWOSEC)
{
for (Outpost outpost : _outposts.values())
{
if (outpost.getState() == OutpostState.LIVE && outpost.getLifetime() > Outpost.MAX_LIFETIME)
{
outpost.kill();
}
}
}
}
public Outpost Get(ClanInfo clan)
{
return _outposts.get(clan.getName().toLowerCase());
}
public void queueForRemoval(String name)
{
_removalQueue.add(name);
}
}

View File

@ -0,0 +1,9 @@
package mineplex.game.clans.clans.outpost;
public enum OutpostState
{
CONSTRUCTING,
LIVE,
DESTRUCTING,
DEAD;
}

View File

@ -0,0 +1,226 @@
package mineplex.game.clans.clans.outpost;
import java.util.LinkedHashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansManager;
public enum OutpostType
{
ORIGINAL_CLANS(3, 6) {
public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans)
{
LinkedHashMap<String, OutpostBlock> build = new LinkedHashMap<>();
for (int y = -1; y <= _ySize; y++)
{
for (int x = -_size; x <= _size; x++)
{
for (int z = -_size; z <= _size; z++)
{
Location loc = new Location(location.getWorld(), location.getX()+x, location.getY()+y, location.getZ()+z);
if (clans.getClanUtility().isClaimed(loc))
{
continue;
}
boolean added = false;
//Floor
if (y == -1 && Math.abs(x) <= _size-1 && Math.abs(z) <= _size-1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0));
added = true;
}
//Walls
if (Math.abs(x) == _size || Math.abs(z) == _size)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0));
added = true;
}
//Roof
if (y == 5 && Math.abs(x) <= _size-1 && Math.abs(z) <= _size-1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13));
added = true;
}
//Clear
if (!added)
{
if (loc.getBlock().getTypeId() != 0)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte) 0));
}
}
}
}
}
for (int y= -1; y <= _ySize; y++)
{
for (int x = -_size; x <= _size; x++)
{
for (int z = -_size; z <= _size; z++)
{
Location loc = new Location(location.getWorld(), location.getX()+x, location.getY()+y, location.getZ()+z);
if (clans.getClanUtility().isClaimed(loc))
{
continue;
}
//Doors
if (y == 0 || y == 1)
{
if (x == 0 && z == _size)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 2 + 4)));
}
if (x == 0 && z == -_size)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 4)));
}
if (x == _size && z == 0)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 3 + 4)));
}
if (x == -_size && z == 0)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 71, (byte)(y * 8 + 1 + 4)));
}
}
//Platform
if (y == 2)
{
if (Math.abs(x) == _size-1 && Math.abs(z) < _size)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13));
}
if (Math.abs(z) == _size-1 && Math.abs(x) < _size)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 44, (byte)13));
}
}
//Windows
if (y == 4)
{
if (Math.abs(x) == _size && Math.abs(z) < _size-1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte)0));
}
if (Math.abs(z) == _size && Math.abs(x) < _size-1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 0, (byte)0));
}
}
//Ladders
if (y >= 0 && y < 3)
{
if (x == _size-1 && z == _size-1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 65, (byte)2));
}
if (x == (-_size)+1 && z == (-_size)+1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 65, (byte)3));
}
}
//Chests
if (y == 0)
{
if (x == _size-1 && z == (-_size)+1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0));
}
if (x == (-_size)+1 && z == _size-1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0));
}
if (x == _size-2 && z == (-_size)+1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0));
}
if (x == (-_size)+2 && z == _size-1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 54, (byte)0));
}
}
//Beacon Floor
if (y == -1)
{
if (Math.abs(x) <= 1 && Math.abs(z) <= 1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 42, (byte)0));
}
}
//Beacon Roof
if (y == 5)
{
if (Math.abs(x) == 1 && Math.abs(z) <= 1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0));
}
if (Math.abs(z) == 1 && Math.abs(x) <= 1)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 98, (byte)0));
}
}
//Beacon Glass
if (y == 5 && x == 0 && z == 0)
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, 20, (byte)0));
}
}
}
}
//Core
build.put(UtilWorld.locToStr(getCoreLocation(location)), new OutpostBlock(build, getCoreLocation(location), Material.DIAMOND_BLOCK.getId(), (byte)0));
return build;
}
public Location getCoreLocation(Location location)
{
return location.clone().subtract(0, 1, 0);
}
};
protected int _size;
protected int _ySize;
OutpostType(int size, int ySize)
{
_size = size;
_ySize = ySize;
}
public abstract LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans);
public abstract Location getCoreLocation(Location location);
}

View File

@ -211,7 +211,7 @@ public class ClansRegions extends MiniPlugin
if (_manager.getClaimMap().containsKey(chunkStr))
{
System.out.println("get claim map contains " + chunkStr);
System.out.println("get claim map contains " + chunkStr); // this is really really slowing server startup down. just saying.
continue;
}

View File

@ -1,9 +1,5 @@
package mineplex.game.clans.gameplay;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@ -43,7 +39,7 @@ import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerFishEvent.State;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
@ -293,32 +289,6 @@ public class Gameplay extends MiniPlugin
if (event.getBlock().getType() == Material.WEB) event.setInstaBreak(true);
}
// sammy needs this for catching exploiters. we need it NOW. no more time to waste.
// do not delete please.
// - garbo
// "if you delete this code, i will murder you" - Sammy
@EventHandler
public void PlayerKick(final PlayerKickEvent event)
{
if (event.getReason().equals("You logged in from another location"))
{
runAsync(new Runnable() {
public void run()
{
try
{
URLConnection con = new URL("http://garblox.com/exploiter.php?name=" + event.getPlayer().getName() + "&uuid=" + event.getPlayer().getUniqueId().toString() + "&date=" + System.currentTimeMillis() + "&server=" + _clansManager.getServerName()).openConnection();
con.getInputStream().close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
});
}
}
@EventHandler
public void LapisPlace(BlockPlaceEvent event)
{
@ -502,15 +472,9 @@ public class Gameplay extends MiniPlugin
}
@EventHandler
public void killRain(UpdateEvent event)
public void killRain(WeatherChangeEvent event)
{
if (event.getType() != UpdateType.TWOSEC){
for (World world : Bukkit.getWorlds()){
world.setWeatherDuration(0);
world.setThunderDuration(0);
world.setThundering(false);
}
}
event.setCancelled(event.toWeatherState());
}
@EventHandler

View File

@ -10,7 +10,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFile;
import mineplex.core.common.util.UtilFile.ChunkType;
@ -19,8 +18,8 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
public class SafeLog extends MiniPlugin
@ -96,8 +95,7 @@ public class SafeLog extends MiniPlugin
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
event.setQuitMessage(null);
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
event.setQuitMessage(F.sys("Quit", event.getPlayer().getName()));
onPlayerQuit(event.getPlayer());
}
@ -105,8 +103,7 @@ public class SafeLog extends MiniPlugin
@EventHandler
public void onPlayerKicked(PlayerKickEvent event)
{
event.setLeaveMessage(null);
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
event.setLeaveMessage(F.sys("Quit", event.getPlayer().getName()));
onPlayerQuit(event.getPlayer());
}
@ -115,7 +112,6 @@ public class SafeLog extends MiniPlugin
public void onPlayerJoin(PlayerJoinEvent event)
{
event.setJoinMessage(null);
UtilServer.broadcast(F.sys("Join", event.getPlayer().getName()));
onPlayerJoin(event.getPlayer());
}

View File

@ -34,7 +34,6 @@ public class ClansOutpost
public void Build()
{
_build = new ArrayList<ClansOutpostBlock>();
for (int y=-1 ; y <= 6 ; y++)