Merge remote-tracking branch 'origin/master'

This commit is contained in:
Shaun Bennett 2014-11-17 18:19:06 -06:00
commit e99a3f6544
29 changed files with 2607 additions and 547 deletions

View File

@ -10,7 +10,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import me.chiss.Core.Clans.ClansClan;
import me.chiss.Core.Clans.ClanInfo;
import me.chiss.Core.Clans.ClansUtility.ClanRelation;
import me.chiss.Core.ClientData.ClientGame;
import me.chiss.Core.Module.AModule;
@ -263,7 +263,7 @@ public class PointManager extends AModule implements IScheduleListener
double petLevel = 0;
double clanAge = 0;
ClansClan clan = Clans().CUtil().getClanByPlayer(cur);
ClanInfo clan = Clans().CUtil().getClanByPlayer(cur);
if (clan != null) clanAge = (System.currentTimeMillis() - clan.GetDateCreated()) / 86400000d;
if (clanAge > 7)
clanAge = 7;
@ -341,7 +341,7 @@ public class PointManager extends AModule implements IScheduleListener
double petLevel = 0;
double clanAge = 0;
ClansClan clan = Clans().CUtil().getClanByPlayer(cur);
ClanInfo clan = Clans().CUtil().getClanByPlayer(cur);
if (clan != null) clanAge = (System.currentTimeMillis() - clan.GetDateCreated()) / 86400000d;
if (clanAge > 7)
clanAge = 7;

View File

@ -89,7 +89,7 @@ public abstract class MiniPlugin implements Listener
CommandCenter.Instance.RemoveCommand(command);
}
protected void log(String message)
public void log(String message)
{
System.out.println(F.main(_moduleName, message));
}

View File

@ -401,6 +401,12 @@ public class CoreClientManager extends MiniPlugin
}, playerName);
}
// DONT USE THIS IN PRODUCTION...its for enjin listener -someone you despise but definitely not me (defek7)
public UUID loadUUIDFromDB(String name)
{
return _repository.getClientUUID(name);
}
@EventHandler
public void cleanGlitchedClients(UpdateEvent event)
{

View File

@ -1,9 +1,13 @@
package mineplex.core.account.repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin;
@ -14,6 +18,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.DatabaseRunnable;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnBoolean;
import mineplex.core.database.column.ColumnTimestamp;
import mineplex.core.database.column.ColumnVarChar;
@ -30,6 +35,8 @@ public class AccountRepository extends RepositoryBase
private static String UPDATE_ACCOUNT_RANK_DONOR_PERM = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=true WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_NULL_RANK = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=?, rankExpire=? WHERE uuid = ? AND rank IS NULL;";
private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ?;";
private String _webAddress;
public AccountRepository(JavaPlugin plugin, String webAddress)
@ -68,6 +75,28 @@ public class AccountRepository extends RepositoryBase
return new JsonWebCall(_webAddress + "PlayerAccount/GetAccountByUUID").ExecuteReturnStream(uuid.toString());
}
public UUID getClientUUID(String name)
{
final List<UUID> uuids = new ArrayList<UUID>();
executeQuery(SELECT_ACCOUNT_UUID_BY_NAME, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
uuids.add(UUID.fromString(resultSet.getString(1)));
}
}
}, new ColumnVarChar("name", 100, name));
if (uuids.size() > 1)
return null;
else
return uuids.size() == 1 ? uuids.get(0) : null;
}
public void saveRank(final Callback<Rank> callback, final String name, final Rank rank, final boolean perm)
{
final RankUpdateToken token = new RankUpdateToken();
@ -77,7 +106,7 @@ public class AccountRepository extends RepositoryBase
final Callback<Rank> extraCallback = new Callback<Rank>()
{
public void run(Rank response)
public void run(final Rank response)
{
if (rank == Rank.ULTRA || rank == Rank.HERO)
{
@ -94,7 +123,14 @@ public class AccountRepository extends RepositoryBase
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
}
callback.run(response);
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
{
@Override
public void run()
{
callback.run(response);
}
});
}
};

View File

@ -1,6 +1,7 @@
package mineplex.core.disguise.disguises;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
public class DisguiseWither extends DisguiseMonster
{

View File

@ -2,6 +2,7 @@ package mineplex.core.donation.repository;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback;
@ -45,12 +46,19 @@ public class DonationRepository extends RepositoryBase
final Callback<TransactionResponse> extraCallback = new Callback<TransactionResponse>()
{
public void run(TransactionResponse response)
public void run(final TransactionResponse response)
{
if (response == TransactionResponse.Success)
executeUpdate(UPDATE_ACCOUNT_GEMS, new ColumnInt("gems", cost), new ColumnVarChar("uuid", 100, uuid));
callback.run(response);
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
{
@Override
public void run()
{
callback.run(response);
}
});
}
};
@ -74,7 +82,7 @@ public class DonationRepository extends RepositoryBase
final Callback<TransactionResponse> extraCallback = new Callback<TransactionResponse>()
{
public void run(TransactionResponse response)
public void run(final TransactionResponse response)
{
if (response == TransactionResponse.Success)
{
@ -90,7 +98,14 @@ public class DonationRepository extends RepositoryBase
}
}
callback.run(response);
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
{
@Override
public void run()
{
callback.run(response);
}
});
}
};
@ -112,7 +127,7 @@ public class DonationRepository extends RepositoryBase
final Callback<Boolean> extraCallback = new Callback<Boolean>()
{
public void run(Boolean response)
public void run(final Boolean response)
{
if (response)
{
@ -120,7 +135,14 @@ public class DonationRepository extends RepositoryBase
executeUpdate(INSERT_GEM_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Given by " + giver), new ColumnInt("gems", greenGems));
}
callback.run(response);
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
{
@Override
public void run()
{
callback.run(response);
}
});
}
};
@ -142,7 +164,7 @@ public class DonationRepository extends RepositoryBase
final Callback<Boolean> extraCallback = new Callback<Boolean>()
{
public void run(Boolean response)
public void run(final Boolean response)
{
if (response)
{
@ -150,7 +172,14 @@ public class DonationRepository extends RepositoryBase
executeUpdate(INSERT_COIN_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins));
}
callback.run(response);
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
{
@Override
public void run()
{
callback.run(response);
}
});
}
};

View File

@ -112,12 +112,12 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphBlock(this));
addGadget(new MorphEnderman(this));
addGadget(new MorphBat(this));
addGadget(new MorphNotch(this));
//addGadget(new MorphNotch(this));
addGadget(new MorphPumpkinKing(this));
addGadget(new MorphPig(this));
addGadget(new MorphCreeper(this));
addGadget(new MorphBlaze(this));
addGadget(new MorphGeno(this));
//addGadget(new MorphGeno(this));
// Particles
addGadget(new ParticleFoot(this));

View File

@ -1,26 +1,30 @@
package mineplex.enjinTranslator;
import java.text.SimpleDateFormat;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.punish.Category;
import mineplex.core.punish.Punish;
import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -32,6 +36,10 @@ public class Enjin extends MiniPlugin implements CommandExecutor
private TempRepository _repository;
private NautHashMap<String, Entry<UUID, Long>> _cachedUUIDs = new NautHashMap<String, Entry<UUID, Long>>();
private List<QueuedCommand> _commandQueue = new ArrayList<QueuedCommand>();
private static Object _commandLock = new Object();
public long _lastPoll = System.currentTimeMillis() - 120000;
private SimpleDateFormat _dateFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
@ -50,111 +58,213 @@ public class Enjin extends MiniPlugin implements CommandExecutor
plugin.getCommand("pull").setExecutor(this);
}
@EventHandler
public void expireCachedUUIDs(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_01)
return;
for (Iterator<Entry<String, Entry<UUID, Long>>> iterator = _cachedUUIDs.entrySet().iterator(); iterator.hasNext();)
{
Entry<String, Entry<UUID, Long>> entry = iterator.next();
if (System.currentTimeMillis() > entry.getValue().getValue())
iterator.remove();
}
}
@EventHandler
public void processCommandQueue(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_01 || _commandQueue.size() == 0)
return;
List<QueuedCommand> commandCopyQueue = new ArrayList<QueuedCommand>();
synchronized (_commandLock)
{
for (QueuedCommand command : _commandQueue)
commandCopyQueue.add(command);
_commandQueue.clear();
}
System.out.println("=====] Processing queued commands [=====");
for (QueuedCommand command : commandCopyQueue)
{
try
{
onCommand(command.Sender, command.Command, command.Label, command.Args);
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
System.out.println("========================================");
}
@EventHandler
public void pollLastPurchases(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_01)
return;
//@SuppressWarnings("serial")
//List<EnjinPurchase> purchases = new JsonWebCall("http://www.mineplex.com/api/m-shopping-purchases/m/14702725").Execute(new TypeToken<List<EnjinPurchase>>(){}.getType(), null);
//_lastPoll = System.currentTimeMillis();
/*
@SuppressWarnings("serial")
List<EnjinPurchase> purchases = new JsonWebCall("http://www.mineplex.com/api/m-shopping-purchases/m/14702725").Execute(new TypeToken<List<EnjinPurchase>>(){}.getType(), null);
_lastPoll = System.currentTimeMillis();
int i = 0;
for (EnjinPurchase purchase : purchases)
{
if (i > 10)
break;
purchase.logInfoToConsole();
i++;
}
*/
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args)
{
if (sender instanceof Player)
((Player)sender).kickPlayer("Like bananas? I don't. Here take these and go have fun.");
if (label.equalsIgnoreCase("enjin_mineplex"))
synchronized (_commandLock)
{
if (args.length == 3 && args[0].equalsIgnoreCase("gem"))
{
String name = args[1];
int amount = Integer.parseInt(args[2]);
_donationManager.RewardGems(null, "purchase", name, UUIDFetcher.getUUIDOf(name), amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " gems.");
}
else if (args.length == 3 && args[0].equalsIgnoreCase("coin"))
{
String name = args[1];
int amount = Integer.parseInt(args[2]);
_donationManager.RewardCoins(null, "purchase", name, UUIDFetcher.getUUIDOf(name), amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " coins.");
}
else if (args.length == 3 && args[0].equalsIgnoreCase("booster"))
{
String name = args[1];
int amount = Integer.parseInt(args[2]);
_donationManager.PurchaseUnknownSalesPackage(null, name, UUIDFetcher.getUUIDOf(name), "Gem Booster " + amount, false, 0, false);
_repository.addGemBooster(name, amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Gem Boosters" + ".");
}
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))
try
{
final String name = args[1];
final String rank = args[2];
final boolean perm = Boolean.parseBoolean(args[3]);
_clientManager.loadClientByName(name, new Runnable()
if (sender instanceof Player)
((Player)sender).kickPlayer("Like bananas? I don't. Here take these and go have fun.");
if (label.equalsIgnoreCase("enjin_mineplex"))
{
public void run()
final String name = args[1];
UUID playerUUID = null;
if (_cachedUUIDs.containsKey(name))
playerUUID = _cachedUUIDs.get(name).getKey();
else
{
if (_clientManager.Get(name).GetRank() == Rank.ALL || _clientManager.Get(name).GetRank() == Rank.ULTRA || _clientManager.Get(name).GetRank() == Rank.HERO)
{
_clientManager.SaveRank(name, mineplex.core.common.Rank.valueOf(rank), perm);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month."));
}
else
{
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank + " " + (perm ? "permanently." : "for 1 month."));
}
// Fails if not in DB and if duplicate.
playerUUID = _clientManager.loadUUIDFromDB(name);
if (playerUUID == null)
playerUUID = UUIDFetcher.getUUIDOf(name);
}
_cachedUUIDs.put(name, new AbstractMap.SimpleEntry<UUID, Long>(playerUUID, System.currentTimeMillis() + 240000));
if (args.length == 3 && args[0].equalsIgnoreCase("gem"))
{
final int amount = Integer.parseInt(args[2]);
_donationManager.RewardGems(new Callback<Boolean>()
{
public void run (Boolean response)
{
if (response)
{
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " gems.");
}
else
{
_commandQueue.add(new QueuedCommand(sender, command, label, args));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " gems. Queuing for run later.");
}
}
}, "purchase", name, playerUUID, amount);
}
else if (args.length == 3 && args[0].equalsIgnoreCase("coin"))
{
final int amount = Integer.parseInt(args[2]);
_donationManager.RewardCoins(new Callback<Boolean>()
{
public void run (Boolean response)
{
if (response)
{
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " coins.");
}
else
{
_commandQueue.add(new QueuedCommand(sender, command, label, args));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " coins. Queuing for run later.");
}
}
}, "purchase", name, playerUUID, amount);
}
else if (args.length == 3 && args[0].equalsIgnoreCase("booster"))
{
int amount = Integer.parseInt(args[2]);
_donationManager.PurchaseUnknownSalesPackage(null, name, playerUUID, "Gem Booster " + amount, false, 0, false);
_repository.addGemBooster(name, amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Gem Boosters" + ".");
}
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))
{
final String rank = args[2];
final boolean perm = Boolean.parseBoolean(args[3]);
_clientManager.loadClientByName(name, new Runnable()
{
public void run()
{
if (_clientManager.Get(name).GetRank() == Rank.ALL || _clientManager.Get(name).GetRank() == Rank.ULTRA || _clientManager.Get(name).GetRank() == Rank.HERO)
{
_clientManager.SaveRank(name, mineplex.core.common.Rank.valueOf(rank), perm);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + rank + " " + (perm ? "permanently." : "for 1 month."));
}
else
{
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " DENIED INFERIOR " + rank + " " + (perm ? "permanently." : "for 1 month."));
}
}
});
}
else if (args.length >= 3 && args[0].equalsIgnoreCase("purchase"))
{
String packageName = args[2];
for (int i = 3; i < args.length; i++)
{
packageName += " " + args[i];
}
_donationManager.PurchaseUnknownSalesPackage(null, name, playerUUID, packageName, false, 0, false);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + packageName + ".");
}
else if (args.length >= 3 && args[0].equalsIgnoreCase("unban"))
{
String reason = args[2];
for (int i = 3; i < args.length; i++)
{
reason += " " + args[i];
}
_punish.RemoveBan(name, reason);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " unbanned for " + reason);
}
else if (args.length >= 3 && args[0].equalsIgnoreCase("ban"))
{
String reason = args[2];
for (int i = 3; i < args.length; i++)
{
reason += " " + args[i];
}
_punish.AddPunishment(name, Category.Other, reason, null, 3, true, -1);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " banned for " + reason);
}
});
}
else if (args.length >= 3 && args[0].equalsIgnoreCase("purchase"))
{
String name = args[1];
String packageName = args[2];
for (int i = 3; i < args.length; i++)
{
packageName += " " + args[i];
}
_donationManager.PurchaseUnknownSalesPackage(null, name, UUIDFetcher.getUUIDOf(name), packageName, false, 0, false);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + packageName + ".");
}
else if (args.length >= 3 && args[0].equalsIgnoreCase("unban"))
catch (Exception exception)
{
String name = args[1];
String reason = args[2];
for (int i = 3; i < args.length; i++)
{
reason += " " + args[i];
}
_punish.RemoveBan(name, reason);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " unbanned for " + reason);
}
else if (args.length >= 3 && args[0].equalsIgnoreCase("ban"))
{
String name = args[1];
String reason = args[2];
for (int i = 3; i < args.length; i++)
{
reason += " " + args[i];
}
_punish.AddPunishment(name, Category.Other, reason, null, 3, true, -1);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " banned for " + reason);
exception.printStackTrace();
}
}

View File

@ -0,0 +1,23 @@
package mineplex.enjinTranslator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class EnjinItem
{
public String item_name;
public double item_price;
public int item_id;
public Map<String, String> variables = new HashMap<String, String>();
public void logInfoToConsole()
{
System.out.println("item_id : " + item_id + ", item_name : " + item_name + ", item_price : " + item_price);
for (Entry<String, String> variable : variables.entrySet())
{
System.out.println("key : " + variable.getKey() + ", value : " + variable.getValue());
}
}
}

View File

@ -0,0 +1,27 @@
package mineplex.enjinTranslator;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class EnjinPurchase
{
private static SimpleDateFormat _dateFormat = new SimpleDateFormat();
public EnjinUser user;
public long purchase_date;
public String currency;
public String character;
public List<EnjinItem> items;
public void logInfoToConsole()
{
user.logInfoToConsole();
System.out.println(" MC Character : " + character + ", purchase_date : " + _dateFormat.format(new Date(purchase_date)) + ", currency : " + currency);
for (EnjinItem item : items)
{
item.logInfoToConsole();
}
}
}

View File

@ -0,0 +1,12 @@
package mineplex.enjinTranslator;
public class EnjinUser
{
public int user_id;
public String username;
public void logInfoToConsole()
{
System.out.println("user_id : " + user_id + ", username : " + username);
}
}

View File

@ -0,0 +1,20 @@
package mineplex.enjinTranslator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
public class QueuedCommand
{
public CommandSender Sender;
public Command Command;
public String Label;
public String[] Args;
public QueuedCommand(CommandSender sender, Command command, String label, String[] args)
{
Sender = sender;
Command = command;
Label = label;
Args = args;
}
}

View File

@ -1,25 +1,20 @@
package mineplex.game.clans.clans;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import mineplex.core.account.CoreClient;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -172,7 +167,7 @@ public class ClanInfo
{
LinkedList<String> stringList = new LinkedList<String>();
stringList.add(F.main("Clans", C.mRel(C.relPC(caller, this), getName() + " Information;", true)));
stringList.add(F.main("Clans", Clans.getClanUtility().mRel(Clans.getClanUtility().relPC(caller, this), getName() + " Information;", true)));
// stringList.add(F.value("Desc", _desc));
// Age
@ -180,7 +175,7 @@ public class ClanInfo
UtilTime.convertString(System.currentTimeMillis() - _dateCreated, 1, TimeUnit.FIT)));
// Home
if (C.relPC(caller, this) == ClanRelation.SELF)
if (Clans.getClanUtility().relPC(caller, this) == ClanRelation.SELF)
stringList.add(F.value("Home", UtilWorld.locToStrClean(getHome())));
// Land
@ -194,7 +189,7 @@ public class ClanInfo
allyUnsorted.add(allyName);
for (String cur : UtilAlg.sortKey(allyUnsorted))
allySorted += C.mRel(C.relPC(caller, Clans.getClanMap().get(cur)), cur, false)
allySorted += Clans.getClanUtility().mRel(Clans.getClanUtility().relPC(caller, Clans.getClanMap().get(cur)), cur, false)
+ ", ";
stringList.add(F.value("Allies", allySorted));
@ -224,12 +219,6 @@ public class ClanInfo
// Protected
stringList.add(F.value("TNT Protection", getProtected()));
// Dominance
ClanInfo callerClan = Clans.CUtil().getClanByPlayer(caller);
if (callerClan != null)
if (this.isEnemy(callerClan.getName()))
stringList.add(F.value("Dominance", callerClan.getDominanceString(this)));
return stringList;
}
@ -264,44 +253,6 @@ public class ClanInfo
}
}
public void chat(Player sender, String message, String filteredMessage)
{
for (String cur : getMembers().keySet())
{
Player player = UtilPlayer.searchOnline(null, cur, false);
if (player == null)
continue;
CoreClient client = Clans.Clients().Get(player);
if (client.Game().GetFilterChat())
UtilPlayer.message(player, C.cAqua + sender.getName() + C.cDAqua + " " + filteredMessage);
else
UtilPlayer.message(player, C.cAqua + sender.getName() + C.cDAqua + " " + message);
}
}
public void allyChat(ClanInfo senderClan, Player sender, String message, String filteredMessage)
{
for (String cur : getMembers().keySet())
{
Player player = UtilPlayer.searchOnline(null, cur, false);
if (player == null)
continue;
CoreClient client = Clans.Clients().Get(player);
// C.cDGreen + senderClan.GetName() + " " +
if (client.Game().GetFilterChat())
UtilPlayer.message(player, C.cDGreen + sender.getName() + C.cGreen + " " + filteredMessage);
else
UtilPlayer.message(player, C.cDGreen + sender.getName() + C.cGreen + " " + message);
}
}
public String getName()
{
return _name;
@ -382,73 +333,6 @@ public class ClanInfo
_lastOnline = lastOnline;
}
public void saveAlliances()
{
}
public void saveMembers()
{
}
public void saveTerritories()
{
}
public void saveBasicInfo()
{
}
public ClanToken GetToken()
{
// Update Members
_token.Members = new ArrayList<ClanMemberToken>();
for (String name : getMembers().keySet())
{
ClanMemberToken token = new ClanMemberToken();
token.Name = name;
token.ClanRole = getMembers().get(name).toString();
_token.Members.add(token);
}
// Update Territory
_token.Territories = new ArrayList<ClanTerritoryToken>();
for (String chunk : getClaimSet())
{
ClanTerritoryToken token = new ClanTerritoryToken();
token.ClanName = _token.Name;
token.ClanId = _token.ClanId;
token.ServerName = Clans.GetServerName();
token.Chunk = chunk;
if (Clans.GetClaimMap().get(chunk) != null)
token.Safe = Clans.GetClaimMap().get(chunk).safe;
_token.Territories.add(token);
}
// Update Relations
_token.Alliances = new ArrayList<AllianceToken>();
for (String clanName : getAllyMap().keySet())
{
ClanInfo clan = Clans.getClan(clanName);
ClanAllianceToken token = new ClanAllianceToken();
token.ClanId = clan.GetTokenUnupdated().ClanId;
token.ClanName = clan.GetTokenUnupdated().Name;
if (getAllyMap().get(clanName))
token.Trusted = true;
_token.Alliances.add(token);
}
return _token;
}
public boolean isOnlineNow()
{
for (String cur : getMembers().keySet())
@ -464,7 +348,7 @@ public class ClanInfo
if (UtilPlayer.isOnline(cur))
return true;
return System.currentTimeMillis() - _lastOnline < Clans.GetOnlineTime();
return System.currentTimeMillis() - _lastOnline < Clans.getOnlineTime();
}
public String getProtected()
@ -473,12 +357,12 @@ public class ClanInfo
if (UtilPlayer.isOnline(cur))
return C.cRed + "No - Clan Members are Online";
if (System.currentTimeMillis() - _lastOnline > Clans.GetOnlineTime())
if (System.currentTimeMillis() - _lastOnline > Clans.getOnlineTime())
return C.cGreen + "Yes - Clan Members are Offline";
return C.cGold
+ "No, "
+ UtilTime.convertString(Clans.GetOnlineTime() - (System.currentTimeMillis() - _lastOnline), 1,
+ UtilTime.convertString(Clans.getOnlineTime() - (System.currentTimeMillis() - _lastOnline), 1,
TimeUnit.FIT) + " to Protection";
}

View File

@ -0,0 +1,309 @@
package mineplex.game.clans.clans;
import java.util.ArrayList;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import mineplex.core.account.CoreClient;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClanInfo.Role;
import mineplex.game.clans.clans.repository.ClanRepository;
import mineplex.game.clans.clans.repository.ClanTerritory;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
public class ClansDataAccessLayer
{
private ClansManager _manager;
private ClanRepository _repository;
public ClansDataAccessLayer(ClansManager clans)
{
_manager = clans;
_repository = new ClanRepository(clans.GetPlugin(), clans.GetServerName());
}
public void delete(ClanInfo clan)
{
//Territory Unclaim
for (String cur : clan.getClaimSet())
_manager.getClaimMap().remove(cur);
_manager.getClanMap().remove(clan.getName());
for (String cur : clan.getMembers().keySet())
{
_manager.getClanMemberMap().remove(cur);
}
//Clean from Others
for (ClanInfo cur : _manager.getClanMap().values())
{
cur.getAllyMap().remove(clan.getName());
cur.getRequestMap().remove(clan.getName());
}
//Save
_repository.deleteClan(clan.getName());
//Log
_manager.log("Deleted [" + clan.getName() + "].");
}
public ClanInfo create(String creator, String name, boolean admin)
{
ClanToken token = new ClanToken();
token.Name = name;
token.Description = "No Description";
token.Home = "";
token.Admin = admin;
token.Members = new ArrayList<ClanMemberToken>();
ClanMemberToken memberToken = new ClanMemberToken();
memberToken.ClanRole = Role.ADMIN.toString();
memberToken.Name = creator;
//Create Clan
ClanInfo clan = new ClanInfo(_manager, token);
_manager.getClanMap().put(name, clan);
//Save
_repository.addClan(token);
//Log
_manager.log("[" + clan.getName() + "] with Admin [" + admin + "] created by [" + creator + "].");
return clan;
}
public void join(ClanInfo clan, String player, Role role)
{
if (_manager.getClanMemberMap().containsKey(player))
leave(_manager.getClanUtility().getClanByPlayer(player), player);
//Update Clan
clan.getMembers().put(player, role);
_manager.getClanMemberMap().put(player, clan);
clan.getInviteeMap().remove(player);
clan.getInviterMap().remove(player);
//Save
_repository.addMember(clan.getName(), player);
//Log
_manager.log("Added [" + player + "] to [" + clan.getName() + "].");
}
public void leave(ClanInfo clan, String player)
{
if (clan == null)
return;
//Update Clan
clan.getMembers().remove(player);
_manager.getClanMemberMap().remove(player);
//Save
_repository.removeMember(clan.getName(), player);
//Log
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
}
public void role(ClanInfo clan, String player, Role role)
{
//Update Clan
clan.getMembers().put(player, role);
//Save
_repository.updateMember(clan.getName(), player, role);
//Log
_manager.log("Removed [" + player + "] from [" + clan.getName() + "].");
}
public void invite(ClanInfo clan, String player, String inviter)
{
clan.getInviteeMap().put(player, System.currentTimeMillis());
clan.getInviterMap().put(player, inviter);
//Log
_manager.log("Invited [" + player + "] to [" + clan.getName() + "] by [" + inviter + "].");
}
public void requestAlly(ClanInfo clan, ClanInfo target, String player)
{
clan.getRequestMap().put(target.getName(), System.currentTimeMillis());
//Log
_manager.log("Alliance Request to [" + target.getName() + "] from [" + clan.getName() + "] by [" + player + "].");
}
public void ally(ClanInfo cA, ClanInfo cB, String player)
{
//Remove Requests
cA.getRequestMap().remove(cB.getName());
cB.getRequestMap().remove(cA.getName());
//Update ClansManager
cA.getAllyMap().put(cB.getName(), false);
cB.getAllyMap().put(cA.getName(), false);
//Save
_manager.CRepo().EditClan(cA.GetToken());
_manager.CRepo().EditClan(cB.GetToken());
//Log
_manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "].");
}
public boolean trust(ClanInfo cA, ClanInfo cB, String player)
{
if (!cA.getAllyMap().containsKey(cB.getName()))
return false;
boolean trust = !cA.getAllyMap().get(cB.getName());
//Memory
cA.getAllyMap().put(cB.getName(), trust);
//Save
_manager.CRepo().EditClan(cA.GetToken());
_manager.CRepo().EditClan(cB.GetToken());
//Update Relations
for (String cur : cA.getMembers().keySet())
_manager.getClanUtility().updateRelations(cur);
//Update Relations
for (String cur : cB.getMembers().keySet())
_manager.getClanUtility().updateRelations(cur);
//Log
_manager.log("Gave Trust [" + trust + "] to [" + cB.getName() + "] for [" + cA.getName() + "] by [" + player + "].");
return trust;
}
public void neutral(ClanInfo cA, ClanInfo cB, String player, boolean bothClansManager)
{
//Update ClansManager
cA.getAllyMap().remove(cB.getName());
cB.getAllyMap().remove(cA.getName());
//Save
_manager.CRepo().EditClan(cA.GetToken());
_manager.CRepo().EditClan(cB.GetToken());
//Update Relations
for (String cur : cA.getMembers().keySet())
_manager.getClanUtility().updateRelations(cur);
//Update Relations
for (String cur : cB.getMembers().keySet())
_manager.getClanUtility().updateRelations(cur);
//Log
_manager.log("Added Neutral between [" + cA.getName() + "] and [" + cB.getName() + "] by [" + player + "].");
}
public boolean claim(String name, String chunk, String player, boolean safe)
{
if (!_manager.getClanMap().containsKey(name))
return false;
ClanInfo clan = _manager.getClanMap().get(name);
//Unclaim
if (_manager.getClaimMap().containsKey(chunk))
unclaim(chunk, player, false);
//Memory
ClanTerritory claim = new ClanTerritory(_manager, name, chunk, safe);
clan.getClaimSet().add(chunk);
_manager.getClaimMap().put(chunk, claim);
//Save
_manager.CRepo().EditClan(clan.GetToken());
//Visual
Chunk c = UtilWorld.strToChunk(chunk);
if (!clan.IsAdmin())
for (int i = 0 ; i < 3 ; i++)
for (int x=0 ; x < 16 ; x++)
for (int z=0 ; z < 16 ; z++)
if (z == 0 || z == 15 || x == 0 || x == 15)
{
Block down = UtilBlock.getHighest(c.getWorld(), c.getBlock(x, 0, z).getX(), c.getBlock(x, 0, z).getZ()).getRelative(BlockFace.DOWN);
if (down.getTypeId() == 1 || down.getTypeId() == 2 || down.getTypeId() == 3 || down.getTypeId() == 12 || down.getTypeId() == 8)
_manager.BlockRestore().Add(down, 89, (byte)0, 180000);
}
//Log
_manager.log("Added Claim for [" + name + "] at [" + chunk + "] by [" + player + "].");
return true;
}
public boolean unclaim(String chunk, String player, boolean sql)
{
ClanTerritory claim = _manager.getClaimMap().remove(chunk);
if (claim == null)
{
_manager.log("Unclaiming NULL Chunk Failed.");
return false;
}
ClanInfo clan = _manager.getClanMap().get(claim.Owner);
if (clan == null)
{
_manager.log("Unclaiming from NULL Clan Failed.");
return false;
}
//Memory
clan.getClaimSet().remove(chunk);
//Save
_manager.CRepo().EditClan(clan.GetToken());
//Register
_manager.getUnclaimMap().put(chunk, System.currentTimeMillis());
//Log
_manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [" + player + "].");
return true;
}
public void home(ClanInfo clan, Location loc, String player)
{
//Memory
clan.SetHome(loc);
//Save
_manager.CRepo().EditClan(clan.GetToken());
//Log
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
}
public void safe(ClanTerritory claim, String player)
{
//Memory
claim.Safe = !claim.Safe;
//Save
_manager.CRepo().EditClan(_manager.getClan(claim.Owner).GetToken());
//Log
_manager.log("Safe Zone at [" + claim.chunk + "] set to [" + claim.Safe + "] by [" + player + "].");
}
}

View File

@ -1,13 +1,49 @@
package mineplex.game.clans.clans;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.repository.ClanTerritory;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class ClansManager extends MiniPlugin
public class ClansManager extends MiniClientPlugin<ClientClan>
{
private CombatManager _combatManager;
private ClansUtility _clanUtility;
private int _dominanceLimit = 16;
private int _inviteExpire = 2;
private int _nameMin = 3;
@ -21,9 +57,12 @@ public class ClansManager extends MiniPlugin
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
public ClansManager(String moduleName, JavaPlugin plugin)
public ClansManager(JavaPlugin plugin, CombatManager combatManager)
{
super(moduleName, plugin);
super("Clans Manager", plugin);
_combatManager = combatManager;
_clanUtility = new ClansUtility(this);
}
public int getInviteExpire()
@ -50,4 +89,317 @@ public class ClansManager extends MiniPlugin
{
return _claimMap;
}
@Override
public void commands()
{
AddCommand("cc");
AddCommand("fc");
AddCommand("ac");
}
@Override
public void command(Player caller, String cmd, String[] args)
{
if (cmd.equals("cc") || cmd.equals("fc"))
CCommand().commandChat(caller, args);
else if (cmd.equals("ac"))
CCommand().commandAllyChat(caller, args);
else
CCommand().command(caller, args);
}
public ClansClan getClan(String name)
{
return GetClanMap().get(name);
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.SEC)
Power();
if (event.getType() == UpdateType.FAST)
CGame().UpdateSafe();
if (event.getType() == UpdateType.FASTER)
CGame().UpdateDisplay();
if (event.getType() == UpdateType.SEC)
{
for (ClansClan clan : _clanMap.values())
{
if (clan.GeneratorUpdate())
_genUpdateList.add(clan);
clan.OutpostUpdate();
}
if (_genUpdateList.size() > 0)
{
CRepo().Repository.UpdateClanTNTGenerators(_genUpdateList);
_genUpdateList.clear();
}
}
if (event.getType() == UpdateType.FAST)
for (ClansClan clan : _clanMap.values())
if (clan.GetOutpost() != null)
clan.GetOutpost().BuildUpdate();
}
public long lastPower = System.currentTimeMillis();
@EventHandler(priority = EventPriority.LOW)
public void BlockBurn(BlockBurnEvent event)
{
CGame().BlockBurn(event);
}
@EventHandler(priority = EventPriority.LOW)
public void BlockIgnite(BlockIgniteEvent event)
{
CGame().BlockSpread(event);
}
@EventHandler(priority = EventPriority.LOW)
public void BlockPlace(BlockPlaceEvent event)
{
if (event.isCancelled())
return;
CGame().BlockPlace(event);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void BlockCreatureSpawn(CreatureSpawnCustomEvent event)
{
ClansClan clan = Clans().CUtil().getOwner(event.GetLocation());
if (clan != null)
if (!clan.IsAdmin() && !clan.GetName().equals("Spawn"))
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void Damage(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
CGame().Damage(event);
}
@EventHandler(priority = EventPriority.LOWEST)
public void Interact(PlayerInteractEvent event)
{
CGame().Interact(event);
CDisplay().handleInteract(event);
if (Util().Event().isAction(event, ActionType.R_BLOCK))
if (event.getClickedBlock().getType() == Material.BREWING_STAND && !event.isCancelled())
{
for (ClansClan clan : _clanMap.values())
clan.GeneratorUse(event.getPlayer(), event.getClickedBlock().getLocation());
event.setCancelled(true);
}
else if (event.getClickedBlock().getType() == Material.BEACON)
{
for (ClansClan clan : _clanMap.values())
clan.OutpostUse(event.getPlayer(), event.getClickedBlock().getLocation());
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void Piston(BlockPistonExtendEvent event)
{
CGame().Piston(event);
}
@EventHandler(priority = EventPriority.LOW)
public void SkillTrigger(SkillTriggerEvent event)
{
CGame().SafeSkill(event);
}
@EventHandler(priority = EventPriority.MONITOR)
public void Death(CombatDeathEvent event)
{
CGame().DeathDominance(event);
CGame().DeathColor(event);
}
@EventHandler
public void Join(PlayerJoinEvent event)
{
CGame().Join(event);
}
@EventHandler
public void Quit(PlayerQuitEvent event)
{
CGame().Quit(event);
}
@EventHandler(priority = EventPriority.LOWEST)
public void Explosion(EntityExplodeEvent event)
{
CGame().Explode(event);
}
public boolean HandleClanChat(AsyncPlayerChatEvent event, String filteredMessage)
{
CoreClient client = Clients().Get(event.getPlayer());
if (client == null)
return false;
if (!client.Clan().IsClanChat())
return false;
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
if (clan == null)
{
Clients().Get(event.getPlayer()).Clan().SetClanChat(false);
return false;
}
ChatClan(clan, event.getPlayer(), event.getMessage(), filteredMessage);
return true;
}
public boolean HandleAllyChat(AsyncPlayerChatEvent event, String filteredMessage)
{
if (!Get(event.getPlayer()).isAllyChat())
return false;
ClansClan clan = CUtil().getClanByPlayer(event.getPlayer());
if (clan == null)
{
Clients().Get(event.getPlayer()).Clan().SetAllyChat(false);
return false;
}
ChatAlly(clan, event.getPlayer(), event.getMessage(), filteredMessage);
return true;
}
public void ChatClan(ClanInfo clan, Player sender, String message, String filteredMessage)
{
clan.chat(sender, message, filteredMessage);
}
public void ChatAlly(ClanInfo clan, Player sender, String message, String filteredMessage)
{
for (String cur : clan.getAllyMap().keySet())
{
ClanInfo ally = _clanUtility.getClanByClanName(cur);
if (ally == null) continue;
ally.allyChat(clan, sender, message, filteredMessage);
}
clan.allyChat(clan, sender, message, filteredMessage);
}
public int getNameMin()
{
return _nameMin;
}
public int getNameMax()
{
return _nameMax;
}
public long getReclaimTime()
{
return _reclaimTime;
}
@Override
public boolean CanHurt(Player a, Player b)
{
if (a.equals(b))
return false;
return CUtil().canHurt(a, b);
}
@Override
public boolean CanHurt(String a, String b)
{
if (a.equals(b))
return false;
return CUtil().canHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b));
}
@Override
public boolean IsSafe(Player a)
{
return CUtil().isSafe(a);
}
public IRepository GetRepository() {
return _repository;
}
public void SetRepository(IRepository _repository) {
this._repository = _repository;
}
public HashMap<String, ClansClan> GetClanMemberMap()
{
return _clanMemberMap;
}
public ClanRelation GetRelation(String playerA, String playerB)
{
return Clients().Get(playerA).Clan().GetRelation(playerB);
}
@Override
public ChatColor GetColorOfFor(String other, Player player)
{
return CUtil().relChatColor(Clients().Get(player).Clan().GetRelation(other), false);
}
public String GetServerName()
{
return _serverName;
}
public long getOnlineTime()
{
return _onlineTime;
}
public CombatManager getCombatManager()
{
return _combatManager;
}
public ClansUtility getClanUtility()
{
return _clanUtility;
}
@Override
protected ClientClan AddPlayer(String player)
{
return new ClientClan();
}
@Override
protected void loadClientInformation(RetrieveClientInformationEvent event)
{
}
}

View File

@ -8,15 +8,13 @@ import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClient;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClanInfo.Role;
import mineplex.game.clans.clans.repository.ClanTerritory;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
public class ClansUtility
{
@ -33,8 +31,6 @@ public class ClansUtility
ALLY,
ALLY_TRUST,
NEUTRAL,
ENEMY,
PILLAGE,
ADMIN,
SAFE
}
@ -178,9 +174,7 @@ public class ClansUtility
public boolean isSafe(Player player)
{
ClanInfo clan = getClanByPlayer(player);
if (!UtilTime.elapsed(Clans.Clients().Get(player).Player().GetLastDamager(), 15000))
if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), 15000))
return false;
return isSafe(player.getLocation());
@ -307,24 +301,12 @@ public class ClansUtility
public ClanRelation getAccess(Player player, Location loc)
{
//Observer Override
if (Clans.Observer().isObserver(player, false))
{
if (Clans.Observer().isObserver(player, true))
return ClanRelation.SELF;
else
return ClanRelation.NEUTRAL;
}
ClanInfo owner = this.getOwner(loc);
ClanInfo clan = getClanByPlayer(player);
if (owner == null)
return ClanRelation.SELF;
if (owner.equals(Clans.CAdmin().getMimic(player, false)))
return ClanRelation.SELF;
if (owner.equals(clan))
return ClanRelation.SELF;
@ -336,10 +318,6 @@ public class ClansUtility
if (owner.isAlly(clan.getName()))
return ClanRelation.ALLY;
if (clan != null)
if (owner.isEnemy(clan.getName()))
return ClanRelation.ENEMY;
return ClanRelation.NEUTRAL;
}
@ -428,16 +406,12 @@ public class ClansUtility
if (relation == ClanRelation.SELF) return C.xSelf;
if (relation == ClanRelation.ALLY_TRUST) return C.xdAlly;
if (relation == ClanRelation.ALLY) return C.xAlly;
if (relation == ClanRelation.ENEMY) return C.xWar;
if (relation == ClanRelation.PILLAGE) return C.xPillage;
return C.xEnemy;
}
if (relation == ClanRelation.SELF) return C.xdSelf;
if (relation == ClanRelation.ALLY_TRUST) return C.xAlly;
if (relation == ClanRelation.ALLY) return C.xdAlly;
if (relation == ClanRelation.ENEMY) return C.xdWar;
if (relation == ClanRelation.PILLAGE) return C.xdPillage;
return C.xdEnemy;
}
@ -500,49 +474,13 @@ public class ClansUtility
if (isSafe(damager))
return false;
ClanRelation rel = Clans.CUtil().relPP(damagee.getName(), damager.getName());
ClanRelation rel = relPP(damagee.getName(), damager.getName());
if (rel == ClanRelation.ALLY || rel == ClanRelation.ALLY_TRUST || rel == ClanRelation.SELF)
return false;
return true;
}
public void updateRelations(String name)
{
updateRelations(UtilPlayer.searchExact(name));
}
public void updateRelations(Player player)
{
if (player == null)
return;
CoreClient client = Clans.Clients().Get(player);
for (Player cur : UtilServer.getPlayers())
{
//For Player
client.Clan().SetRelationship(
cur.getName(), relPP(cur.getName(), player.getName()));
//For Other
Clans.Clients().Get(cur.getName()).Clan().SetRelationship(
player.getName(), relPP(player.getName(), cur.getName()));
if (player.canSee(cur))
{
player.hidePlayer(cur);
player.showPlayer(cur);
}
if (cur.canSee(player))
{
cur.hidePlayer(player);
cur.showPlayer(player);
}
}
}
public boolean isBorderlands(Location loc)
{

View File

@ -0,0 +1,51 @@
package mineplex.game.clans.clans;
public class ClientClan
{
private boolean _clanChat;
private boolean _allyChat;
private boolean _mapOn;
private boolean _canJoin;
private long _joinDelay;
public boolean isAllyChat()
{
return _allyChat;
}
public void setAllyChat(boolean allyChat)
{
_allyChat = allyChat;
}
public boolean isClanChat()
{
return _clanChat;
}
public void setClanChat(boolean clanChat)
{
_clanChat = clanChat;
}
public boolean isMapOn()
{
return _mapOn;
}
public void setMapOn(boolean mapOn)
{
_mapOn = mapOn;
}
public boolean canJoin()
{
return _canJoin;
}
public long getDelay()
{
return _joinDelay;
}
}

View File

@ -2,13 +2,17 @@ package mineplex.game.clans.clans.repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Collection;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
import mineplex.game.clans.clans.repository.tokens.ClanToken;
public class ClanRepository extends RepositoryBase
@ -18,9 +22,9 @@ public class ClanRepository extends RepositoryBase
private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverName VARCHAR(100), chunk VARCHAR(100), safe BOOL, PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverName));";
private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BOOL, PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
private static String RETRIEVE_START_CLAN_INFO = "SELECT id, name, description, home, admin, dateCreated, lastOnline FROM clans AS c INNER JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE serverName = ?;";
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT a.name, role FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId WHERE ac.clanId = ?;";
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT cOther.id, cOther.name 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 ac.clanId = ?;";
private static String RETRIEVE_START_CLAN_INFO = "SELECT id, name, description, home, admin, dateCreated, lastOnline, ct.chunk, ct.safe FROM clans AS c INNER JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE serverName = ?;";
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, role FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId;";
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;";
private String _serverName;
@ -40,16 +44,86 @@ public class ClanRepository extends RepositoryBase
executeUpdate(CREATE_CLAN_ALLIANCE_TABLE);
}
public List<ClanToken> retrieveStartupClanInformation()
public Collection<ClanToken> retrieveClans()
{
final NautHashMap<String, ClanToken> clans = new NautHashMap<String, ClanToken>();
executeQuery(RETRIEVE_START_CLAN_INFO, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
ClanToken token = new ClanToken();
token.Id = resultSet.getInt(1);
token.Name = resultSet.getString(2);
token.Description = resultSet.getString(3);
token.Home = resultSet.getString(4);
token.Admin = resultSet.getBoolean(5);
token.DateCreated = resultSet.getLong(6);
token.LastOnline = resultSet.getLong(7);
ClanTerritoryToken territoryToken = new ClanTerritoryToken();
territoryToken.Chunk = resultSet.getString(8);
territoryToken.Safe = resultSet.getBoolean(9);
if (!clans.containsKey(token.Name))
{
clans.put(token.Name, token);
}
clans.get(token.Name).Territories.add(territoryToken);
}
}
}, new ColumnVarChar("serverName", 100, _serverName));
executeQuery(RETRIEVE_CLAN_MEMBER_INFO, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
String clanName = resultSet.getString(1);
if (clans.containsKey(clanName))
{
ClanMemberToken memberToken = new ClanMemberToken();
memberToken.Name = resultSet.getString(2);
memberToken.ClanRole = resultSet.getString(3);
clans.get(clanName).Members.add(memberToken);
}
}
}
});
executeQuery(RETRIEVE_CLAN_ALLIANCE_INFO, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
String clanName = resultSet.getString(1);
if (clans.containsKey(clanName))
{
ClanAllianceToken allianceToken = new ClanAllianceToken();
allianceToken.ClanName = resultSet.getString(2);
allianceToken.Trusted = resultSet.getBoolean(3);
clans.get(clanName).Alliances.add(allianceToken);
}
}
}
}, new ColumnVarChar("serverName", 100, _serverName));
return clans.values();
}
@Override

View File

@ -1,9 +1,11 @@
package mineplex.game.clans.clans.repository.tokens;
import java.util.ArrayList;
import java.util.List;
public class ClanToken
{
public int Id;
public String Name;
public String Description;
public String Home;
@ -11,7 +13,7 @@ public class ClanToken
public long DateCreated;
public long LastOnline;
List<ClanMemberToken> Members;
List<ClanTerritoryToken> Territories;
List<ClanAllianceToken> Alliances;
public List<ClanMemberToken> Members = new ArrayList<ClanMemberToken>();
public List<ClanTerritoryToken> Territories = new ArrayList<ClanTerritoryToken>();
public List<ClanAllianceToken> Alliances = new ArrayList<ClanAllianceToken>();
}

View File

@ -84,16 +84,17 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
byte data = (byte) (milliseconds - (seconds * 1000) > 500 ? 15 : 14);
ShopItem item = new ShopItem(Material.WOOL, data, ChatColor.RESET + C.Bold + (beta ? "Beta" : "Free") + " Server Timer", null, new String[] {
ChatColor.RESET + C.cGreen + timeLeft + " Remaining...",
ShopItem item = new ShopItem(Material.WOOL, data, C.cGreen + C.Bold + "Advertisement", null, new String[] {
ChatColor.RESET + timeLeft + " Remaining...",
ChatColor.RESET + "",
ChatColor.RESET + C.cYellow + "Free players must wait a " + (beta ? "long" : "short") + " time",
ChatColor.RESET + C.cYellow + "to help lighten the load on our" + (beta ? " Beta" : "") + " servers.",
ChatColor.RESET + C.cGreen + "Do you love playing on Mineplex?",
ChatColor.RESET + "If you do, please consider purchasing Ultra or Hero",
ChatColor.RESET + "from the store! Money goes towards running servers",
ChatColor.RESET + "and creating exciting new games for everyone!",
ChatColor.RESET + "",
ChatColor.RESET + C.cAqua + "Ultra and Hero players have",
ChatColor.RESET + C.cAqua + "instant access to our servers!",
ChatColor.RESET + C.cYellow + "Purchasing a Rank disables this advertisement.",
ChatColor.RESET + "",
ChatColor.RESET + "Visit " + C.cGreen + "www.mineplex.com/shop" + C.cWhite + "!"
ChatColor.RESET + C.cGreen + "www.mineplex.com/shop"
}, seconds, false, false);
AddItem(22, item);
@ -185,7 +186,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
int greenStartSlot = 18 + ((9 - serversToShow) / 2);
boolean showGreen = true;
boolean beta = serverList.size() > 0 && (serverList.get(0).Name.contains("BETA") || serverList.get(0).Name.contains("MS-"));
boolean beta = serverList.size() > 0 && serverList.get(0).Name.contains("BETA");
boolean tournament = serverList.size() > 0 && serverList.get(0).Name.contains("T_");
boolean ownsUltraPackage = Client.GetRank().Has(Rank.ULTRA) || (serverList.size() > 0 && DonationManager.Get(Player.getName()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA"));

View File

@ -1,6 +1,5 @@
package mineplex.minecraft.game.core.combat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

View File

@ -97,7 +97,7 @@ public class DrawRound
UtilPlayer.message(Drawer, C.cWhite + C.Bold + "You must draw: " + C.cGreen + C.Bold + Word);
Host.Manager.GetChat().Silence(-1, false);
Host.Manager.GetChat().Silence(0, false);
}
public boolean Guessed(Player player)

View File

@ -261,6 +261,8 @@ public class MineStrike extends TeamGame
this.InventoryClick = true;
this.JoinInProgress = true;
this.CompassSpectatorMenu = false;
_scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy");
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);

View File

@ -22,6 +22,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -1680,12 +1681,6 @@ public class SurvivalGames extends SoloGame
Scoreboard.Draw();
}
@Override
public boolean IsLive()
{
return super.IsLive() && !isDeathMatchAboutToStart();
}
public boolean isDeathMatchAboutToStart()
{
if (!_deathmatchLive)
@ -1696,4 +1691,11 @@ public class SurvivalGames extends SoloGame
return true;
}
@EventHandler
public void deathmatchBowShoot(EntityShootBowEvent event)
{
if (isDeathMatchAboutToStart())
event.getProjectile().remove();
}
}

View File

@ -357,16 +357,16 @@ public class WitherGame extends TeamGame implements IBlockRestorer
ArrayList<Location> collisions = new ArrayList<Location>();
//Fly Speed
if (player.getLocation().getY() > _yLimit)
{
player.setFlySpeed(0.06f);
}
else
{
double speed = (_yLimit - player.getLocation().getY()) * 0.075;
player.setFlySpeed(Math.max(0.015f, 0.06f - (float)speed));
}
double speed = 0.06 - (_yLimit - player.getLocation().getY()) * 0.075;
if (speed > 0.16)
speed = 0.16;
if (speed < 0.015)
speed = 0.015;
player.setFlySpeed((float)speed);
//Bump
for (Block block : UtilBlock.getInRadius(player.getLocation().add(0, 0.5, 0), 1.5d).keySet())

View File

@ -223,6 +223,7 @@
if (account == null)
return false;
token.OriginalBalance = account.Gems;
account.Gems += token.Amount;
if (!token.Source.Contains("Earned") && !token.Source.Contains("Tutorial") && !token.Source.Contains("Parkour"))
@ -241,6 +242,17 @@
repository.Edit(account);
repository.CommitChanges();
}
using (var repository = _repositoryFactory.CreateRepository())
{
var account = repository.Where<Account>(x => x.Name == token.Name).FirstOrDefault();
if (account == null)
return false;
if (account.Gems != token.OriginalBalance + token.Amount)
return false;
}
}
return true;
@ -275,7 +287,17 @@
repository.Edit(account);
repository.CommitChanges();
}
using (var repository = _repositoryFactory.CreateRepository())
{
var account = repository.Where<Account>(x => x.Name == token.Name).FirstOrDefault();
if (account == null)
return false;
if (account.Coins != token.OriginalBalance + token.Amount)
return false;
}
}
@ -568,7 +590,7 @@
}
}
public void ApplyKits(String name)
public bool ApplyKits(String name)
{
using (var repository = _repositoryFactory.CreateRepository())
{
@ -642,6 +664,8 @@
repository.CommitChanges();
}
return true;
}
public string UpdateRank(RankUpdateToken token)
@ -681,7 +705,7 @@
if (token.Retries >= 3)
_logger.Log("ERROR", "Applying UpdateRank, retried 3 times and something didn't stick.");
else if (!account.Rank.Name.Equals(token.Rank) || account.RankPerm != token.Perm || account.RankExpire != expire)
else if (!account.Rank.Name.Equals(token.Rank) || account.RankPerm != token.Perm || account.RankExpire.Equals(expire))
{
token.Retries++;
UpdateRank(token);

View File

@ -21,7 +21,7 @@
void ApplySalesPackage(SalesPackage salesPackage, int accountId, decimal gross, decimal fee);
Account Login(LoginRequestToken loginToken);
void Logout(string name);
void ApplyKits(string name);
bool ApplyKits(string name);
PunishmentResponse Punish(PunishToken punish);
PunishmentResponse RemovePunishment(RemovePunishmentToken ban);

File diff suppressed because it is too large Load Diff