Merge branch 'clans/beta' of https://github.com/Mineplex-LLC/Minecraft-PC into clans/beta
This commit is contained in:
commit
7de23216f6
@ -0,0 +1,8 @@
|
|||||||
|
package mineplex.core.common;
|
||||||
|
|
||||||
|
public enum MinecraftVersion
|
||||||
|
{
|
||||||
|
ALL,
|
||||||
|
Version1_9,
|
||||||
|
Version1_8
|
||||||
|
}
|
@ -27,6 +27,7 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.util.BlockIterator;
|
import org.bukkit.util.BlockIterator;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.common.MinecraftVersion;
|
||||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||||
import net.minecraft.server.v1_8_R3.Packet;
|
import net.minecraft.server.v1_8_R3.Packet;
|
||||||
import net.minecraft.server.v1_8_R3.PlayerConnection;
|
import net.minecraft.server.v1_8_R3.PlayerConnection;
|
||||||
@ -814,4 +815,12 @@ public class UtilPlayer
|
|||||||
{
|
{
|
||||||
((CraftPlayer) player).getHandle().setWingsDeployAt(distance);
|
((CraftPlayer) player).getHandle().setWingsDeployAt(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MinecraftVersion getVersion(Player player)
|
||||||
|
{
|
||||||
|
if (is1_9(player))
|
||||||
|
return MinecraftVersion.Version1_9;
|
||||||
|
|
||||||
|
return MinecraftVersion.Version1_8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,19 +10,16 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
import mineplex.core.command.ICommand;
|
import mineplex.core.command.ICommand;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.thread.ThreadPool;
|
||||||
|
|
||||||
public abstract class MiniPlugin implements Listener
|
public abstract class MiniPlugin implements Listener
|
||||||
{
|
{
|
||||||
private static final ExecutorService threadPool = Executors.newCachedThreadPool(
|
|
||||||
new ThreadFactoryBuilder().setNameFormat("MiniPlugin Async %1$d").build());
|
|
||||||
|
|
||||||
protected String _moduleName = "Default";
|
protected String _moduleName = "Default";
|
||||||
protected JavaPlugin _plugin;
|
protected JavaPlugin _plugin;
|
||||||
protected NautHashMap<String, ICommand> _commands;
|
protected NautHashMap<String, ICommand> _commands;
|
||||||
@ -118,7 +115,7 @@ public abstract class MiniPlugin implements Listener
|
|||||||
public void runAsync(Runnable runnable)
|
public void runAsync(Runnable runnable)
|
||||||
{
|
{
|
||||||
// Instead of using
|
// Instead of using
|
||||||
threadPool.execute(runnable);
|
ThreadPool.ASYNC.execute(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runAsync(Runnable runnable, long time)
|
public void runAsync(Runnable runnable, long time)
|
||||||
|
@ -60,17 +60,11 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name)
|
public int login(final List<ILoginProcessor> loginProcessors, final UUID uuid, final String name)
|
||||||
{
|
{
|
||||||
// First we try to grab the account id from cache - this saves an extra trip to database
|
// First we try to grab the account id from cache - this saves an extra trip to database
|
||||||
int accountId = -1;
|
int accountId = PlayerCache.getInstance().getAccountId(uuid);
|
||||||
|
|
||||||
try (Connection connection = getConnection(); Statement statement = connection.createStatement())
|
try (Connection connection = getConnection(); Statement statement = connection.createStatement())
|
||||||
{
|
{
|
||||||
int cachedId = PlayerCache.getInstance().getAccountId(uuid);
|
if (accountId <= 0)
|
||||||
if (cachedId > 0)
|
|
||||||
{
|
|
||||||
accountId = cachedId;
|
|
||||||
System.out.println("Loaded Account ID From Cache [" + name + " - " + accountId + "]");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Player was not found in cache, we need to grab the account id from database
|
// Player was not found in cache, we need to grab the account id from database
|
||||||
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;");
|
statement.execute("SELECT id FROM accounts WHERE accounts.uuid = '" + uuid + "' LIMIT 1;");
|
||||||
@ -100,6 +94,10 @@ public class AccountRepository extends MinecraftRepository
|
|||||||
accountId = tempList.get(0);
|
accountId = tempList.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println(name + " Loaded Account ID From Cache [" + name + " - " + accountId + "]");
|
||||||
|
}
|
||||||
|
|
||||||
final int finalId = accountId;
|
final int finalId = accountId;
|
||||||
final String uuidString = uuid.toString();
|
final String uuidString = uuid.toString();
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package mineplex.core.incognito;
|
package mineplex.core.incognito;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -10,6 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -23,7 +27,7 @@ import mineplex.core.packethandler.PacketHandler;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
public class IncognitoManager extends MiniClientPlugin<IncognitoClient>
|
public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
|
||||||
{
|
{
|
||||||
private CoreClientManager _clientManager;
|
private CoreClientManager _clientManager;
|
||||||
private IncognitoRepository _repository;
|
private IncognitoRepository _repository;
|
||||||
@ -32,9 +36,9 @@ public class IncognitoManager extends MiniClientPlugin<IncognitoClient>
|
|||||||
|
|
||||||
public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler)
|
public IncognitoManager(JavaPlugin plugin, CoreClientManager clientManager, PacketHandler packetHandler)
|
||||||
{
|
{
|
||||||
super("Incognito", plugin);
|
super("Incognito", plugin, clientManager);
|
||||||
|
|
||||||
_repository = new IncognitoRepository(this, clientManager);
|
_repository = new IncognitoRepository(this);
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
@ -66,7 +70,7 @@ public class IncognitoManager extends MiniClientPlugin<IncognitoClient>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runAsync(() -> _repository.SetStatus(_clientManager.getAccountId(caller), enabled));
|
runAsync(() -> _repository.setStatus(_clientManager.getAccountId(caller), enabled));
|
||||||
|
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
@ -76,8 +80,10 @@ public class IncognitoManager extends MiniClientPlugin<IncognitoClient>
|
|||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.FAST)
|
if (event.getType() != UpdateType.FAST)
|
||||||
{
|
{
|
||||||
UtilServer.getPlayersCollection().forEach(player -> {
|
UtilServer.getPlayersCollection().forEach(player ->
|
||||||
UtilServer.getPlayersCollection().forEach(other -> {
|
{
|
||||||
|
UtilServer.getPlayersCollection().forEach(other ->
|
||||||
|
{
|
||||||
if (Get(other).Status && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
|
if (Get(other).Status && !_clientManager.hasRank(player, _clientManager.Get(other).GetRank()))
|
||||||
player.hidePlayer(other);
|
player.hidePlayer(other);
|
||||||
|
|
||||||
@ -91,14 +97,6 @@ public class IncognitoManager extends MiniClientPlugin<IncognitoClient>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void ClientLoad(AsyncPlayerPreLoginEvent event)
|
|
||||||
{
|
|
||||||
_clientManager.getRepository().getAccountId(event.getUniqueId(), accountId -> {
|
|
||||||
Get(event.getName()).Status = _repository.GetStatus(accountId.intValue());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void Join(PlayerJoinEvent event)
|
public void Join(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
@ -155,4 +153,19 @@ public class IncognitoManager extends MiniClientPlugin<IncognitoClient>
|
|||||||
{
|
{
|
||||||
return _repository;
|
return _repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(int accountId, String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT * FROM incognitoStaff WHERE accountId = " + accountId + ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
Get(playerName).Status = resultSet.getInt("status") == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,5 @@
|
|||||||
package mineplex.core.incognito.repository;
|
package mineplex.core.incognito.repository;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.common.util.EnclosedObject;
|
|
||||||
import mineplex.core.common.util.UUIDFetcher;
|
|
||||||
import mineplex.core.database.MinecraftRepository;
|
import mineplex.core.database.MinecraftRepository;
|
||||||
import mineplex.core.incognito.IncognitoManager;
|
import mineplex.core.incognito.IncognitoManager;
|
||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
@ -11,57 +8,18 @@ import mineplex.serverdata.database.column.ColumnInt;
|
|||||||
public class IncognitoRepository extends MinecraftRepository
|
public class IncognitoRepository extends MinecraftRepository
|
||||||
{
|
{
|
||||||
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS incognitoStaff (accountId INT NOT NULL, status TINYINT(1) DEFAULT '0', PRIMARY KEY (accountId));";
|
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS incognitoStaff (accountId INT NOT NULL, status TINYINT(1) DEFAULT '0', PRIMARY KEY (accountId));";
|
||||||
private static final String GET_STATUS = "SELECT * FROM incognitoStaff WHERE accountId = ?;";
|
|
||||||
private static final String INSERT_STATUS = "INSERT INTO incognitoStaff (accountId, status) VALUES (?, ?);";
|
private static final String INSERT_STATUS = "INSERT INTO incognitoStaff (accountId, status) VALUES (?, ?);";
|
||||||
private static final String UPDATE_STATUS = "UPDATE incognitoStaff SET status=? WHERE accountId=?;";
|
private static final String UPDATE_STATUS = "UPDATE incognitoStaff SET status=? WHERE accountId=?;";
|
||||||
|
|
||||||
private IncognitoManager _incognitoManager;
|
public IncognitoRepository(IncognitoManager incognitoManager)
|
||||||
|
|
||||||
private CoreClientManager _clientManager;
|
|
||||||
|
|
||||||
public IncognitoRepository(IncognitoManager incognitoManager, CoreClientManager clientManager)
|
|
||||||
{
|
{
|
||||||
super(incognitoManager.getPlugin(), DBPool.getAccount());
|
super(incognitoManager.getPlugin(), DBPool.getAccount());
|
||||||
|
|
||||||
_clientManager = clientManager;
|
|
||||||
|
|
||||||
_incognitoManager = incognitoManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStatus(int accountId, boolean status)
|
public void setStatus(int accountId, boolean status)
|
||||||
{
|
{
|
||||||
// Prevent duplicate entries for individuals
|
if (executeUpdate(UPDATE_STATUS, new ColumnInt("accountId", accountId)) <= 0)
|
||||||
executeQuery(GET_STATUS, result -> {
|
executeInsert(INSERT_STATUS, null, new ColumnInt("accountId", accountId), new ColumnInt("status", status ? 1 : 0));
|
||||||
if (result.next())
|
|
||||||
executeUpdate(UPDATE_STATUS, new ColumnInt("status", status ? 1 : 0), new ColumnInt("accountId", accountId));
|
|
||||||
else
|
|
||||||
executeUpdate(INSERT_STATUS, new ColumnInt("accountId", accountId), new ColumnInt("status", status ? 1 : 0));
|
|
||||||
}, new ColumnInt("accountId", accountId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean GetStatus(int accountId)
|
|
||||||
{
|
|
||||||
EnclosedObject<Boolean> status = new EnclosedObject<>();
|
|
||||||
|
|
||||||
executeQuery(GET_STATUS, result -> {
|
|
||||||
if (result.next())
|
|
||||||
status.Set(result.getInt("status") == 1 ? Boolean.TRUE : Boolean.FALSE);
|
|
||||||
else
|
|
||||||
status.Set(Boolean.FALSE);
|
|
||||||
}, new ColumnInt("accountId", accountId));
|
|
||||||
|
|
||||||
return status.Get().booleanValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean GetStatus(String name)
|
|
||||||
{
|
|
||||||
EnclosedObject<Integer> accountId = new EnclosedObject<>();
|
|
||||||
|
|
||||||
_clientManager.getRepository().getAccountId(UUIDFetcher.getUUIDOf(name), id ->
|
|
||||||
accountId.Set(id)
|
|
||||||
);
|
|
||||||
|
|
||||||
return GetStatus(accountId.Get().intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initialize()
|
protected void initialize()
|
||||||
@ -72,5 +30,4 @@ public class IncognitoRepository extends MinecraftRepository
|
|||||||
protected void update()
|
protected void update()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -553,11 +553,14 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
// TODO Newgarbo wrote this stuff inefficiently and for sake of time and thousands of players i'm going to just comment this out
|
||||||
|
/*
|
||||||
if (IncognitoManager.Instance.getRepository().GetStatus(playerTarget))
|
if (IncognitoManager.Instance.getRepository().GetStatus(playerTarget))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "]."));
|
UtilPlayer.message(sender, F.main("Online Player Search", F.elem("0") + " matches for [" + F.elem(target) + "]."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
runSync(new Runnable()
|
runSync(new Runnable()
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.common.MinecraftVersion;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
import mineplex.core.common.jsonchat.ClickEvent;
|
import mineplex.core.common.jsonchat.ClickEvent;
|
||||||
import mineplex.core.common.jsonchat.JsonMessage;
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -31,8 +33,7 @@ import mineplex.serverdata.commands.ServerCommandManager;
|
|||||||
|
|
||||||
public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
||||||
{
|
{
|
||||||
private String _resourcePackUrl;
|
private Pair<MinecraftVersion, String>[] _resourcePackUrls;
|
||||||
private String _resourcePackUrl19; // Resource pack for 1.9 clients
|
|
||||||
private boolean _resourcePackRequired;
|
private boolean _resourcePackRequired;
|
||||||
private NautHashMap<String, Boolean> _resourcePackUsers = new NautHashMap<String, Boolean>();
|
private NautHashMap<String, Boolean> _resourcePackUsers = new NautHashMap<String, Boolean>();
|
||||||
private NautHashMap<String, Long> _resourcePackNoResponse = new NautHashMap<String, Long>();
|
private NautHashMap<String, Long> _resourcePackNoResponse = new NautHashMap<String, Long>();
|
||||||
@ -47,12 +48,33 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
|||||||
ServerCommandManager.getInstance().registerCommandType("RedisUnloadResPack", RedisUnloadResPack.class, this);
|
ServerCommandManager.getInstance().registerCommandType("RedisUnloadResPack", RedisUnloadResPack.class, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPlayerPack(Player player)
|
||||||
|
{
|
||||||
|
MinecraftVersion version = UtilPlayer.getVersion(player);
|
||||||
|
|
||||||
|
if (_resourcePackUrls == null || _resourcePackUrls.length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Pair<MinecraftVersion, String> entry : _resourcePackUrls)
|
||||||
|
{
|
||||||
|
if (entry.getLeft() == version || entry.getLeft() == MinecraftVersion.ALL)
|
||||||
|
{
|
||||||
|
player.setResourcePack(entry.getRight());
|
||||||
|
player.sendMessage("A: " + entry.getRight());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setResourcePack(_resourcePackUrls[0].getRight());
|
||||||
|
player.sendMessage("B: " + _resourcePackUrls[0].getRight());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void ResourcePackJoin(PlayerJoinEvent event)
|
public void ResourcePackJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (_resourcePackUrl == null)
|
if (_resourcePackUrls == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,9 +86,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
|||||||
|
|
||||||
_resourcePackUsers.put(player.getName(), false);
|
_resourcePackUsers.put(player.getName(), false);
|
||||||
|
|
||||||
String url = getUrl(player);
|
setPlayerPack(player);
|
||||||
System.out.println("Set resource pack for player: " + player + " to " + url);
|
|
||||||
player.setResourcePack(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -93,14 +113,15 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
|||||||
|
|
||||||
// Send it again, enforce it!
|
// Send it again, enforce it!
|
||||||
_resourcePackNoResponse.put(player.getName(), System.currentTimeMillis());
|
_resourcePackNoResponse.put(player.getName(), System.currentTimeMillis());
|
||||||
player.setResourcePack(getUrl(player));
|
|
||||||
|
setPlayerPack(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onResourcePackStatus(PlayerResourcePackStatusEvent event)
|
public void onResourcePackStatus(PlayerResourcePackStatusEvent event)
|
||||||
{
|
{
|
||||||
if (_resourcePackUrl == null)
|
if (_resourcePackUrls == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +130,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
|||||||
|
|
||||||
if (_resourcePackRequired)
|
if (_resourcePackRequired)
|
||||||
{
|
{
|
||||||
if (event.getStatus() == Status.ACCEPTED || event.getStatus() == Status.SUCCESSFULLY_LOADED)
|
if (event.getStatus() == Status.ACCEPTED)
|
||||||
{
|
{
|
||||||
_resourcePackNoResponse.remove(player.getName());
|
_resourcePackNoResponse.remove(player.getName());
|
||||||
}
|
}
|
||||||
@ -180,25 +201,19 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
|||||||
returnHubNoResPack(player);
|
returnHubNoResPack(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResourcePack(String resourcePack, boolean forceResourcePack)
|
public void setResourcePack(Pair<MinecraftVersion, String>[] resourcePack, boolean forceResourcePack)
|
||||||
{
|
{
|
||||||
setResourcePack(resourcePack, resourcePack, forceResourcePack);
|
if (Objects.equal(resourcePack, _resourcePackUrls) && forceResourcePack == _resourcePackRequired)
|
||||||
}
|
|
||||||
|
|
||||||
public void setResourcePack(String resourcePack, String resourcePack19, boolean forceResourcePack)
|
|
||||||
{
|
|
||||||
if (Objects.equal(resourcePack, _resourcePackUrl) && forceResourcePack == _resourcePackRequired)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_resourcePackNoResponse.clear();
|
_resourcePackNoResponse.clear();
|
||||||
_resourcePackUsers.clear();
|
_resourcePackUsers.clear();
|
||||||
_resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack;
|
_resourcePackUrls = resourcePack == null || (resourcePack.length == 0) ? null : resourcePack;
|
||||||
_resourcePackUrl19 = resourcePack19;
|
|
||||||
_resourcePackRequired = forceResourcePack;
|
_resourcePackRequired = forceResourcePack;
|
||||||
|
|
||||||
if (_resourcePackUrl == null || _resourcePackUrl.isEmpty())
|
if (_resourcePackUrls == null || _resourcePackUrls.length == 0)
|
||||||
{
|
{
|
||||||
_resourcePackRequired = false;
|
_resourcePackRequired = false;
|
||||||
|
|
||||||
@ -217,7 +232,8 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
_resourcePackUsers.put(player.getName(), false);
|
_resourcePackUsers.put(player.getName(), false);
|
||||||
player.setResourcePack(getUrl(player));
|
|
||||||
|
setPlayerPack(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,9 +261,4 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUrl(Player player)
|
|
||||||
{
|
|
||||||
return UtilPlayer.is1_9(player) ? _resourcePackUrl19 : _resourcePackUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
129
Plugins/Mineplex.Core/src/mineplex/core/slack/SlackAPI.java
Normal file
129
Plugins/Mineplex.Core/src/mineplex/core/slack/SlackAPI.java
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package mineplex.core.slack;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import mineplex.core.thread.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An API for sending and handling Slack messages.
|
||||||
|
*/
|
||||||
|
public class SlackAPI
|
||||||
|
{
|
||||||
|
// Default emoji.
|
||||||
|
public static final String DEFAULT_ICON = ":mineplex:";
|
||||||
|
|
||||||
|
// Singular instance.
|
||||||
|
private static SlackAPI _instance;
|
||||||
|
|
||||||
|
// Don't allow instantiation elsewhere.
|
||||||
|
private SlackAPI() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a message asynchronously to a Slack channel.
|
||||||
|
*
|
||||||
|
* @param team The team which contains the target channel.
|
||||||
|
* @param channel The target channel for the message.
|
||||||
|
* @param message The message to be displayed.
|
||||||
|
* @param customTitle Whether or not to use a custom title for the message.
|
||||||
|
* If <code>false</code> the default team title is used.
|
||||||
|
*/
|
||||||
|
public void sendMessage(SlackTeam team, String channel, SlackMessage message, boolean customTitle)
|
||||||
|
{
|
||||||
|
ThreadPool.ASYNC.execute(() ->
|
||||||
|
{
|
||||||
|
// Set message title.
|
||||||
|
if (!customTitle)
|
||||||
|
{
|
||||||
|
message.setUsername(team.getTitle());
|
||||||
|
message.setIcon(DEFAULT_ICON);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set message channel.
|
||||||
|
JsonObject msg = message.toJson();
|
||||||
|
msg.addProperty("channel", channel);
|
||||||
|
|
||||||
|
// Run the call.
|
||||||
|
runWebCall(team, msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a web call to a specified Slack incoming-hook.
|
||||||
|
*
|
||||||
|
* @param team The team to run the call on.
|
||||||
|
* @param call The call to be run.
|
||||||
|
*/
|
||||||
|
private String runWebCall(SlackTeam team, JsonObject call)
|
||||||
|
{
|
||||||
|
HttpURLConnection connection = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create connection.
|
||||||
|
URL url = new URL(team.getURL());
|
||||||
|
connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setConnectTimeout(5000);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
|
||||||
|
// Setup payload.
|
||||||
|
String payload = "payload=" + URLEncoder.encode(call.toString(), "UTF-8");
|
||||||
|
|
||||||
|
// Send request.
|
||||||
|
DataOutputStream dos = new DataOutputStream(connection.getOutputStream());
|
||||||
|
dos.writeBytes(payload);
|
||||||
|
dos.flush();
|
||||||
|
dos.close();
|
||||||
|
|
||||||
|
// Receive response.
|
||||||
|
InputStream is = connection.getInputStream();
|
||||||
|
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
|
||||||
|
String line;
|
||||||
|
String response = "";
|
||||||
|
while ((line = rd.readLine()) != null)
|
||||||
|
{
|
||||||
|
response += line + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
rd.close();
|
||||||
|
return response.toString();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (connection != null)
|
||||||
|
{
|
||||||
|
// Terminate connection.
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "500 Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the singular instance of the Slack API.
|
||||||
|
*
|
||||||
|
* @return The {@link SlackAPI} instance.
|
||||||
|
*/
|
||||||
|
public static SlackAPI getInstance()
|
||||||
|
{
|
||||||
|
if (_instance == null)
|
||||||
|
{
|
||||||
|
_instance = new SlackAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
139
Plugins/Mineplex.Core/src/mineplex/core/slack/SlackMessage.java
Normal file
139
Plugins/Mineplex.Core/src/mineplex/core/slack/SlackMessage.java
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
package mineplex.core.slack;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A message to be sent through the {@link SlackAPI}.
|
||||||
|
*/
|
||||||
|
public class SlackMessage
|
||||||
|
{
|
||||||
|
private String _username;
|
||||||
|
private String _icon;
|
||||||
|
|
||||||
|
private String _content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param content The content of the message.
|
||||||
|
*/
|
||||||
|
public SlackMessage(String content)
|
||||||
|
{
|
||||||
|
_icon = SlackAPI.DEFAULT_ICON;
|
||||||
|
_content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param username The username of the message.
|
||||||
|
* @param content The content of the message.
|
||||||
|
*/
|
||||||
|
public SlackMessage(String username, String content)
|
||||||
|
{
|
||||||
|
_username = username;
|
||||||
|
_icon = SlackAPI.DEFAULT_ICON;
|
||||||
|
_content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param username The username of the message.
|
||||||
|
* @param icon The icon/emoji of the message.
|
||||||
|
* @param content The content of the message.
|
||||||
|
*/
|
||||||
|
public SlackMessage(String username, String icon, String content)
|
||||||
|
{
|
||||||
|
_username = username;
|
||||||
|
_icon = ":" + icon + ":";
|
||||||
|
_content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the message to JSON format.
|
||||||
|
*
|
||||||
|
* @return The {@link SlackMessage} in the form of a {@link JsonObject}.
|
||||||
|
*/
|
||||||
|
public JsonObject toJson()
|
||||||
|
{
|
||||||
|
JsonObject msg = new JsonObject();
|
||||||
|
|
||||||
|
if (_username != null)
|
||||||
|
{
|
||||||
|
msg.addProperty("username", _username);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_icon != null)
|
||||||
|
{
|
||||||
|
msg.addProperty("icon_emoji", _icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_content != null)
|
||||||
|
{
|
||||||
|
msg.addProperty("text", _content);
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the username that displays as a title.
|
||||||
|
*
|
||||||
|
* @return The username in use.
|
||||||
|
*/
|
||||||
|
public String getUsername()
|
||||||
|
{
|
||||||
|
return _username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the username that displays as a title.
|
||||||
|
*
|
||||||
|
* @param username The username to use.
|
||||||
|
*/
|
||||||
|
public void setUsername(String username)
|
||||||
|
{
|
||||||
|
_username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the icon that displays with the title.
|
||||||
|
*
|
||||||
|
* @return The icon in use.
|
||||||
|
*/
|
||||||
|
public String getIcon()
|
||||||
|
{
|
||||||
|
return _icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the icon that displays with the title.
|
||||||
|
*
|
||||||
|
* @param icon The icon to use.
|
||||||
|
*/
|
||||||
|
public void setIcon(String icon)
|
||||||
|
{
|
||||||
|
_icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the content of the message.
|
||||||
|
*
|
||||||
|
* @return The content of the message.
|
||||||
|
*/
|
||||||
|
public String getContent()
|
||||||
|
{
|
||||||
|
return _content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the content of the message.
|
||||||
|
*
|
||||||
|
* @param content The content of the message.
|
||||||
|
*/
|
||||||
|
public void setContent(String content)
|
||||||
|
{
|
||||||
|
_content = content;
|
||||||
|
}
|
||||||
|
}
|
79
Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java
Normal file
79
Plugins/Mineplex.Core/src/mineplex/core/slack/SlackTeam.java
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
package mineplex.core.slack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enumeration of Mineplex Slack teams.
|
||||||
|
*/
|
||||||
|
public enum SlackTeam
|
||||||
|
{
|
||||||
|
// Dev team - mineplex.slack.com
|
||||||
|
DEVELOPER("Mineplex Dev", "T045RUM7F", "B0VK6GFKN", "6GxwJsDfEpbVnQl8pYuEyq5T"),
|
||||||
|
|
||||||
|
// QA team - mineplexqa.slack.com
|
||||||
|
QA("Mineplex QA", "todo", "todo", "todo"), // TODO: new details
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private String _title;
|
||||||
|
private String _id1;
|
||||||
|
private String _id2;
|
||||||
|
private String _token;
|
||||||
|
|
||||||
|
SlackTeam(String title, String id1, String id2, String token)
|
||||||
|
{
|
||||||
|
_title = title;
|
||||||
|
_id1 = id1;
|
||||||
|
_id2 = id2;
|
||||||
|
_token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the title that will be displayed that the top of each
|
||||||
|
* {@link SlackMessage}.
|
||||||
|
*
|
||||||
|
* @return The title of this team.
|
||||||
|
*/
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return _title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the first ID of this Slack team.
|
||||||
|
*
|
||||||
|
* @return The individual first ID.
|
||||||
|
*/
|
||||||
|
public String getId1()
|
||||||
|
{
|
||||||
|
return _id1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the second ID of this Slack team.
|
||||||
|
*
|
||||||
|
* @return The individual second ID.
|
||||||
|
*/
|
||||||
|
public String getId2()
|
||||||
|
{
|
||||||
|
return _id2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the token key of this Slack team.
|
||||||
|
*
|
||||||
|
* @return The individual and <b>secret</b> token.
|
||||||
|
*/
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return _token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the web hook in the form of a URL.
|
||||||
|
*
|
||||||
|
* @return The URL as a string.
|
||||||
|
*/
|
||||||
|
public String getURL()
|
||||||
|
{
|
||||||
|
return "https://hooks.slack.com/services/" + getId1() + "/" + getId2() + "/" + getToken();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package mineplex.core.thread;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of threads for different uses.
|
||||||
|
*/
|
||||||
|
public class ThreadPool
|
||||||
|
{
|
||||||
|
|
||||||
|
// Async Thread
|
||||||
|
public static ExecutorService ASYNC = Executors.newCachedThreadPool(
|
||||||
|
new ThreadFactoryBuilder().setNameFormat("MiniPlugin Async %1$d").build()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@ package mineplex.game.clans.core.repository.tokens;
|
|||||||
public class SimpleClanToken
|
public class SimpleClanToken
|
||||||
{
|
{
|
||||||
|
|
||||||
private String _clanName;
|
private String _clanName = "";
|
||||||
public String getClanName() { return _clanName; }
|
public String getClanName() { return _clanName; }
|
||||||
|
|
||||||
private String _clanRole;
|
private String _clanRole;
|
||||||
@ -22,4 +22,6 @@ public class SimpleClanToken
|
|||||||
_homeServer = homeServer;
|
_homeServer = homeServer;
|
||||||
_clanId = clanId;
|
_clanId = clanId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleClanToken() { }
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ import mineplex.core.antihack.AntiHack;
|
|||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.chat.Chat;
|
import mineplex.core.chat.Chat;
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
|
import mineplex.core.common.MinecraftVersion;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
import mineplex.core.common.events.ServerShutdownEvent;
|
import mineplex.core.common.events.ServerShutdownEvent;
|
||||||
import mineplex.core.delayedtask.DelayedTask;
|
import mineplex.core.delayedtask.DelayedTask;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
@ -130,7 +132,11 @@ public class Clans extends JavaPlugin
|
|||||||
new Explosion(this, blockRestore);
|
new Explosion(this, blockRestore);
|
||||||
new InventoryManager(this, _clientManager);
|
new InventoryManager(this, _clientManager);
|
||||||
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
|
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
|
||||||
resourcePackManager.setResourcePack("http://phinary.ca/ResClans.zip", "http://phinary.ca/ResClans19.zip", true);
|
resourcePackManager.setResourcePack(new Pair[]
|
||||||
|
{
|
||||||
|
Pair.create(MinecraftVersion.Version1_8, "http://phinary.ca/ResClans.zip"),
|
||||||
|
Pair.create(MinecraftVersion.Version1_9, "http://phinary.ca/ResClans19.zip")
|
||||||
|
}, true);
|
||||||
|
|
||||||
// Enable custom-gear related managers
|
// Enable custom-gear related managers
|
||||||
new CustomTagFix(this, packetHandler);
|
new CustomTagFix(this, packetHandler);
|
||||||
|
@ -361,27 +361,27 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
|
|
||||||
List<Location> jumpOffHolograms = Arrays.asList(
|
List<Location> jumpOffHolograms = Arrays.asList(
|
||||||
// West Spawn
|
// West Spawn
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 204, 359),
|
new Location(Spawn.getSpawnWorld(), 8, 200, 359),
|
||||||
new Location(Spawn.getSpawnWorld(), 34, 204, 390),
|
new Location(Spawn.getSpawnWorld(), 34, 200, 390),
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 204, 418),
|
new Location(Spawn.getSpawnWorld(), 8, 200, 418),
|
||||||
new Location(Spawn.getSpawnWorld(), -25, 204, 390),
|
new Location(Spawn.getSpawnWorld(), -25, 200, 390),
|
||||||
|
|
||||||
// East Spawn
|
// East Spawn
|
||||||
new Location(Spawn.getSpawnWorld(), 34, 207, -393),
|
new Location(Spawn.getSpawnWorld(), 34, 200, -393),
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 207, -365),
|
new Location(Spawn.getSpawnWorld(), 8, 200, -365),
|
||||||
new Location(Spawn.getSpawnWorld(), -25, 207, -393),
|
new Location(Spawn.getSpawnWorld(), -25, 200, -393),
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 207, -424)
|
new Location(Spawn.getSpawnWorld(), 8, 200, -424)
|
||||||
);
|
);
|
||||||
|
|
||||||
List<Location> welcomeHolograms = Arrays.asList(
|
List<Location> welcomeHolograms = Arrays.asList(
|
||||||
new Location(Spawn.getSpawnWorld(), 17, 204, 390),
|
new Location(Spawn.getSpawnWorld(), 17, 200, 390),
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 204, 399),
|
new Location(Spawn.getSpawnWorld(), 8, 200, 399),
|
||||||
new Location(Spawn.getSpawnWorld(), 0, 204, 390),
|
new Location(Spawn.getSpawnWorld(), 0, 200, 390),
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 204, 381),
|
new Location(Spawn.getSpawnWorld(), 8, 200, 381),
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 207, -384),
|
new Location(Spawn.getSpawnWorld(), 8, 200, -384),
|
||||||
new Location(Spawn.getSpawnWorld(), 0, 207, -393),
|
new Location(Spawn.getSpawnWorld(), 0, 200, -393),
|
||||||
new Location(Spawn.getSpawnWorld(), 8, 207, -402),
|
new Location(Spawn.getSpawnWorld(), 8, 200, -402),
|
||||||
new Location(Spawn.getSpawnWorld(), 17, 207, -393)
|
new Location(Spawn.getSpawnWorld(), 17, 200, -393)
|
||||||
);
|
);
|
||||||
|
|
||||||
for (Location location : jumpOffHolograms)
|
for (Location location : jumpOffHolograms)
|
||||||
@ -854,8 +854,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
|
|
||||||
List<Player> recipients = new ArrayList<>();
|
List<Player> recipients = new ArrayList<>();
|
||||||
|
|
||||||
|
String message = event.getMessage();//_chat.getFilteredMessage(event.getPlayer(), event.getMessage());
|
||||||
|
|
||||||
for (Player other : event.getRecipients())
|
for (Player other : event.getRecipients())
|
||||||
{
|
{
|
||||||
|
if (_tutorial.inTutorial(other))
|
||||||
|
continue;
|
||||||
|
|
||||||
ClanInfo otherClan = _clanUtility.getClanByPlayer(other);
|
ClanInfo otherClan = _clanUtility.getClanByPlayer(other);
|
||||||
|
|
||||||
if (otherClan == null)
|
if (otherClan == null)
|
||||||
@ -864,14 +869,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage());
|
|
||||||
ClanRelation rel = _clanUtility.rel(clan, otherClan);
|
ClanRelation rel = _clanUtility.rel(clan, otherClan);
|
||||||
|
|
||||||
other.sendMessage(rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message);
|
other.sendMessage(rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recipients.forEach(p -> p.sendMessage(String.format(rank + C.cGold + clan.getName() + " " + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage())));
|
recipients.forEach(p -> p.sendMessage(String.format(rank + C.cGold + clan.getName() + " " + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), message)));
|
||||||
|
|
||||||
recipients.clear();
|
recipients.clear();
|
||||||
}
|
}
|
||||||
@ -1197,12 +1200,14 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onJoin(PlayerLoginEvent event)
|
public void onJoin(PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
if (true)
|
Rank rank = _clientManager.Get(event.getPlayer()).GetRank();
|
||||||
|
|
||||||
|
if (rank.has(Rank.MODERATOR))
|
||||||
{
|
{
|
||||||
return;
|
event.allow();
|
||||||
|
event.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rank rank = _clientManager.Get(event.getPlayer()).GetRank();
|
|
||||||
if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
|
if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon");
|
||||||
|
@ -42,7 +42,7 @@ public class ClansRegions extends MiniPlugin
|
|||||||
public final static int SPAWN_RADIUS = 3; // Radius of spawn claim area (measured in chunks)
|
public final static int SPAWN_RADIUS = 3; // Radius of spawn claim area (measured in chunks)
|
||||||
public final static int SHOP_RADIUS = 5; // Radius of shop claim area (measured in chunks)
|
public final static int SHOP_RADIUS = 5; // Radius of shop claim area (measured in chunks)
|
||||||
public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks)
|
public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks)
|
||||||
public final static int BORDERLANDS_RADIUS = 50; // Radius of borderlands claim area (measured in chunks)
|
public final static int BORDERLANDS_RADIUS = 85; // Radius of borderlands claim area (measured in chunks)
|
||||||
public static final int BORDER_RADIUS = 1319;
|
public static final int BORDER_RADIUS = 1319;
|
||||||
|
|
||||||
private ClansManager _manager;
|
private ClansManager _manager;
|
||||||
|
@ -221,13 +221,14 @@ public class Cannon extends SiegeWeapon
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getClick() == ClickType.SHIFT_RIGHT)
|
if (event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.SHIFT_RIGHT)
|
||||||
{
|
{
|
||||||
if(_inventory.getViewers().contains(event.getWhoClicked()))
|
if(_inventory.getViewers().contains(event.getWhoClicked()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true); //block shift right clicking tnt into this inventory
|
event.setCancelled(true); //block shift right clicking tnt into this inventory
|
||||||
getClans().runSyncLater(() -> ((Player) event.getWhoClicked()).updateInventory(), 1L);
|
getClans().runSyncLater(() -> ((Player) event.getWhoClicked()).updateInventory(), 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ package mineplex.game.clans.clans.warpoints;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.common.util.F;
|
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.UtilTime;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -12,75 +10,102 @@ import mineplex.game.clans.clans.ClansManager;
|
|||||||
import mineplex.game.clans.clans.event.*;
|
import mineplex.game.clans.clans.event.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WarPointEvasion extends MiniPlugin{
|
public class WarPointEvasion extends MiniPlugin
|
||||||
|
{
|
||||||
private HashMap<Chunk, Long> _chunkCooldown;
|
private HashMap<Chunk, Long> _chunkCooldown;
|
||||||
private HashMap<UUID, Long> _playerCooldown;
|
private HashMap<UUID, Long> _playerCooldown;
|
||||||
|
|
||||||
private final long COOLDOWN_TIME = 1000 * 60 * 10;
|
private final long COOLDOWN_TIME = 1000 * 60 * 10;
|
||||||
|
|
||||||
public WarPointEvasion(JavaPlugin plugin) {
|
public WarPointEvasion(JavaPlugin plugin)
|
||||||
|
{
|
||||||
super("WP Evasion", plugin);
|
super("WP Evasion", plugin);
|
||||||
|
|
||||||
_chunkCooldown = Maps.newHashMap();
|
_chunkCooldown = Maps.newHashMap();
|
||||||
_playerCooldown = Maps.newHashMap();
|
_playerCooldown = Maps.newHashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void updateCooldown(UpdateEvent event) {
|
public void updateCooldown(UpdateEvent event)
|
||||||
|
{
|
||||||
if(!event.getType().equals(UpdateType.SEC)) return;
|
if(!event.getType().equals(UpdateType.SEC)) return;
|
||||||
|
|
||||||
_chunkCooldown.keySet().stream().filter(chunk -> UtilTime.elapsed(_chunkCooldown.get(chunk), COOLDOWN_TIME)).forEach(chunk -> _chunkCooldown.remove(chunk));
|
for (Iterator<Chunk> chunkIterator = _chunkCooldown.keySet().iterator(); chunkIterator.hasNext();)
|
||||||
|
{
|
||||||
|
Chunk chunk = chunkIterator.next();
|
||||||
|
|
||||||
_playerCooldown.keySet().stream().filter(player -> UtilTime.elapsed(_playerCooldown.get(player), COOLDOWN_TIME)).forEach(player -> {
|
if (UtilTime.elapsed(_chunkCooldown.get(chunk), COOLDOWN_TIME))
|
||||||
_playerCooldown.remove(player);
|
chunkIterator.remove();
|
||||||
if(Bukkit.getOfflinePlayer(player).isOnline()) {
|
}
|
||||||
if(ClansManager.getInstance().getClan(Bukkit.getPlayer(player)) == null) {
|
|
||||||
Bukkit.getPlayer(player).sendMessage(F.main("Clans", "You can now create a clan."));
|
|
||||||
|
for (Iterator<UUID> uuidIterator = _playerCooldown.keySet().iterator(); uuidIterator.hasNext();)
|
||||||
|
{
|
||||||
|
UUID uuid = uuidIterator.next();
|
||||||
|
|
||||||
|
if (UtilTime.elapsed(_playerCooldown.get(uuid), COOLDOWN_TIME))
|
||||||
|
{
|
||||||
|
uuidIterator.remove();
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
if (player.isOnline())
|
||||||
|
{
|
||||||
|
if(ClansManager.getInstance().getClan(player) == null)
|
||||||
|
{
|
||||||
|
player.sendMessage(F.main("Clans", "You can now create a clan."));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClaim(PlayerPreClaimTerritoryEvent event) {
|
public void onClaim(PlayerPreClaimTerritoryEvent event)
|
||||||
|
{
|
||||||
Chunk chunk = event.getClaimedChunk();
|
Chunk chunk = event.getClaimedChunk();
|
||||||
if(_chunkCooldown.containsKey(chunk)) {
|
|
||||||
|
if(_chunkCooldown.containsKey(chunk))
|
||||||
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _chunkCooldown.get(chunk)), 1, UtilTime.TimeUnit.MINUTES)));
|
event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _chunkCooldown.get(chunk)), 1, UtilTime.TimeUnit.MINUTES)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onunClaim(PlayerUnClaimTerritoryEvent event) {
|
public void onunClaim(PlayerUnClaimTerritoryEvent event)
|
||||||
Chunk chunk = event.getUnClaimedChunk();
|
{
|
||||||
_chunkCooldown.put(chunk, System.currentTimeMillis());
|
_chunkCooldown.put(event.getUnClaimedChunk(), System.currentTimeMillis());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClanDisband(ClanDisbandedEvent event) {
|
public void onClanDisband(ClanDisbandedEvent event)
|
||||||
|
{
|
||||||
_playerCooldown.put(event.getDisbander().getUniqueId(), System.currentTimeMillis());
|
_playerCooldown.put(event.getDisbander().getUniqueId(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClanLeave(ClanLeaveEvent event) {
|
public void onClanLeave(ClanLeaveEvent event)
|
||||||
|
{
|
||||||
_playerCooldown.put(event.getPlayer().getUuid(), System.currentTimeMillis());
|
_playerCooldown.put(event.getPlayer().getUuid(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClanCreate(ClanCreatedEvent event) {
|
public void onClanCreate(ClanCreatedEvent event)
|
||||||
|
{
|
||||||
if (event.getFounder() == null)
|
if (event.getFounder() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_playerCooldown.containsKey(event.getFounder().getUniqueId())) {
|
if (_playerCooldown.containsKey(event.getFounder().getUniqueId()))
|
||||||
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getFounder().sendMessage(F.main("Clans", "You cannot create a clan for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _playerCooldown.get(event.getFounder().getUniqueId())), 1, UtilTime.TimeUnit.MINUTES)));
|
event.getFounder().sendMessage(F.main("Clans", "You cannot create a clan for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _playerCooldown.get(event.getFounder().getUniqueId())), 1, UtilTime.TimeUnit.MINUTES)));
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ import mineplex.core.common.util.UtilEvent;
|
|||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
import mineplex.core.common.util.UtilGear;
|
import mineplex.core.common.util.UtilGear;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
@ -582,46 +583,50 @@ public class Gameplay extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
// public void replantTree(BlockBreakEvent event)
|
public void replantTree(BlockBreakEvent event)
|
||||||
// {
|
{
|
||||||
// final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
//
|
|
||||||
// if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null)
|
if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null)
|
||||||
// {
|
{
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (!UtilItem.isLog(block.getType()))
|
if (!UtilItem.isLog(block.getType()))
|
||||||
// {
|
{
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType()))
|
if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType()))
|
||||||
// {
|
{
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType()))
|
if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType()))
|
||||||
// {
|
{
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS)
|
if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS)
|
||||||
// {
|
{
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// final byte data = block.getData();
|
final byte data = block.getData();
|
||||||
//
|
|
||||||
// UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
||||||
// public void run()
|
public void run()
|
||||||
// {
|
{
|
||||||
// block.setType(Material.SAPLING);
|
Material mat = block.getRelative(BlockFace.DOWN).getType();
|
||||||
// block.setData(data);
|
if (mat == Material.DIRT || mat == Material.GRASS)
|
||||||
// }
|
{
|
||||||
// }, 20 * 5);
|
block.setType(Material.SAPLING);
|
||||||
// }
|
block.setData(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 20 * 10);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void killRain(WeatherChangeEvent event)
|
public void killRain(WeatherChangeEvent event)
|
||||||
|
@ -38,7 +38,7 @@ public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
|
|||||||
@Override
|
@Override
|
||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
addTravelLocation(Spawn.getNorthSpawn(), getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "East Spawn", new String[] {
|
addTravelLocation(Spawn.getNorthSpawn(), getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "North Spawn", new String[] {
|
||||||
C.cWhite + "Spawns are locations where",
|
C.cWhite + "Spawns are locations where",
|
||||||
C.cWhite + "you respawn after dying.",
|
C.cWhite + "you respawn after dying.",
|
||||||
" ",
|
" ",
|
||||||
@ -46,9 +46,9 @@ public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
|
|||||||
C.cWhite + "as they are Safe Zones.",
|
C.cWhite + "as they are Safe Zones.",
|
||||||
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? " " : "",
|
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? " " : "",
|
||||||
getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? C.cRed + "You are already here." : "",
|
getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? C.cRed + "You are already here." : "",
|
||||||
}, 14 + 10, getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? (byte) 3 : (byte) 0);
|
}, 4, getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? (byte) 3 : (byte) 0);
|
||||||
|
|
||||||
addTravelLocation(Spawn.getSouthSpawn(), getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "West Spawn", new String[] {
|
addTravelLocation(Spawn.getSouthSpawn(), getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "South Spawn", new String[] {
|
||||||
C.cWhite + "Spawns are locations where",
|
C.cWhite + "Spawns are locations where",
|
||||||
C.cWhite + "you respawn after dying.",
|
C.cWhite + "you respawn after dying.",
|
||||||
" ",
|
" ",
|
||||||
@ -56,23 +56,23 @@ public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
|
|||||||
C.cWhite + "as they are Safe Zones.",
|
C.cWhite + "as they are Safe Zones.",
|
||||||
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? " " : "",
|
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? " " : "",
|
||||||
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? C.cRed + "You are already here." : "",
|
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? C.cRed + "You are already here." : "",
|
||||||
}, 12 + 8, getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? (byte) 3 : (byte) 0);
|
}, 22 + 9 + 9, getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? (byte) 3 : (byte) 0);
|
||||||
|
|
||||||
addTravelLocation(Spawn.getWestTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "North Shop", new String[] {
|
addTravelLocation(Spawn.getWestTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "West Shop", new String[] {
|
||||||
C.cWhite + "Shops are locations where you",
|
C.cWhite + "Shops are locations where you",
|
||||||
C.cWhite + "can buy and sell all sorts of goods.",
|
C.cWhite + "can buy and sell all sorts of goods.",
|
||||||
" ",
|
" ",
|
||||||
C.cWhite + "You cannot be attacked here,",
|
C.cWhite + "You cannot be attacked here,",
|
||||||
C.cWhite + "as they are Safe Zones.",
|
C.cWhite + "as they are Safe Zones.",
|
||||||
}, 4, ClanIcon.CASTLE.getData());
|
}, 12 + 8, ClanIcon.CASTLE.getData());
|
||||||
|
|
||||||
addTravelLocation(Spawn.getEastTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "South Shop", new String[] {
|
addTravelLocation(Spawn.getEastTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "East Shop", new String[] {
|
||||||
C.cWhite + "Shops are locations where you",
|
C.cWhite + "Shops are locations where you",
|
||||||
C.cWhite + "can buy and sell all sorts of goods.",
|
C.cWhite + "can buy and sell all sorts of goods.",
|
||||||
" ",
|
" ",
|
||||||
C.cWhite + "You cannot be attacked here,",
|
C.cWhite + "You cannot be attacked here,",
|
||||||
C.cWhite + "as they are Safe Zones.",
|
C.cWhite + "as they are Safe Zones.",
|
||||||
}, 22 + 9 + 9, ClanIcon.CASTLE.getData());
|
}, 14 + 10, ClanIcon.CASTLE.getData());
|
||||||
|
|
||||||
final ClanInfo clan = _plugin.getClan(getPlayer());
|
final ClanInfo clan = _plugin.getClan(getPlayer());
|
||||||
Outpost outpost = _plugin.getSiegeManager().getOutpostManager().Get(clan);
|
Outpost outpost = _plugin.getSiegeManager().getOutpostManager().Get(clan);
|
||||||
|
@ -65,8 +65,10 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
|
|||||||
Player recipient = recipients.next();
|
Player recipient = recipients.next();
|
||||||
|
|
||||||
if (inTutorial(recipient))
|
if (inTutorial(recipient))
|
||||||
|
{
|
||||||
recipients.remove();
|
recipients.remove();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}, FilterPriority.HIGH);
|
}, FilterPriority.HIGH);
|
||||||
|
@ -10,7 +10,7 @@ public class FinishCommand extends CommandBase<TutorialManager>
|
|||||||
{
|
{
|
||||||
public FinishCommand(TutorialManager plugin)
|
public FinishCommand(TutorialManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.MODERATOR, "finish", "end");
|
super(plugin, Rank.DEVELOPER, "finish", "end");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@ public class StartCommand extends CommandBase<TutorialManager>
|
|||||||
{
|
{
|
||||||
public StartCommand(TutorialManager plugin)
|
public StartCommand(TutorialManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.MODERATOR, "start");
|
super(plugin, Rank.DEVELOPER, "start");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@ public class TutorialCommand extends MultiCommandBase<TutorialManager>
|
|||||||
{
|
{
|
||||||
public TutorialCommand(TutorialManager plugin)
|
public TutorialCommand(TutorialManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.MODERATOR, "tutorial", "tut");
|
super(plugin, Rank.DEVELOPER, "tutorial", "tut");
|
||||||
|
|
||||||
AddCommand(new StartCommand(plugin));
|
AddCommand(new StartCommand(plugin));
|
||||||
AddCommand(new FinishCommand(plugin));
|
AddCommand(new FinishCommand(plugin));
|
||||||
|
@ -129,6 +129,8 @@ public class ClansMainTutorial extends Tutorial
|
|||||||
|
|
||||||
//ClansManager.getInstance().getPvpTimer().unpause(player);
|
//ClansManager.getInstance().getPvpTimer().unpause(player);
|
||||||
|
|
||||||
|
if (!_taskManager.hasCompletedTask(player, getTaskIdentifier()))
|
||||||
|
{
|
||||||
_taskManager.completedTask(new Callback<Boolean>()
|
_taskManager.completedTask(new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -139,6 +141,7 @@ public class ClansMainTutorial extends Tutorial
|
|||||||
UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
|
UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
|
||||||
}
|
}
|
||||||
}, player, getTaskIdentifier());
|
}, player, getTaskIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ClansManager.getInstance().runAsync(() -> {
|
ClansManager.getInstance().runAsync(() -> {
|
||||||
@ -217,6 +220,9 @@ public class ClansMainTutorial extends Tutorial
|
|||||||
|
|
||||||
public boolean isIn(Location location, TutorialRegion region, Bounds bounds)
|
public boolean isIn(Location location, TutorialRegion region, Bounds bounds)
|
||||||
{
|
{
|
||||||
|
if (region.getOrigin().getWorld() != location.getWorld())
|
||||||
|
return false;
|
||||||
|
|
||||||
List<Location> locs = region.getLocationMap().getGoldLocations(bounds.getDataLocColor());
|
List<Location> locs = region.getLocationMap().getGoldLocations(bounds.getDataLocColor());
|
||||||
return UtilAlg.inBoundingBox(location, locs.get(0), locs.get(1));
|
return UtilAlg.inBoundingBox(location, locs.get(0), locs.get(1));
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,10 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -20,9 +15,7 @@ import com.google.common.collect.Lists;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
|
||||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
|
||||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
||||||
|
|
||||||
public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
|
public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
|
||||||
@ -98,6 +91,4 @@ public class BuildHouseGoal extends ObjectiveGoal<ClanObjective>
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1091,13 +1091,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
if (UtilTime.elapsed(_portalTime.get(playerName), 5000))
|
if (UtilTime.elapsed(_portalTime.get(playerName), 5000))
|
||||||
{
|
{
|
||||||
playerNameIterator.remove();
|
playerNameIterator.remove();
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = Bukkit.getPlayerExact(playerName);
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
System.out.println(playerName + "'s location: " + player.getLocation().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,8 +278,6 @@ public class StackerManager extends MiniPlugin implements IThrown
|
|||||||
UtilPlayer.message(thrower, F.main("Stacker", "You threw " + F.name(UtilEnt.getName(throwee)) + "."));
|
UtilPlayer.message(thrower, F.main("Stacker", "You threw " + F.name(UtilEnt.getName(throwee)) + "."));
|
||||||
UtilPlayer.message(throwee, F.main("Stacker", "You were thrown by " + F.name(thrower.getName()) + "."));
|
UtilPlayer.message(throwee, F.main("Stacker", "You were thrown by " + F.name(thrower.getName()) + "."));
|
||||||
|
|
||||||
System.out.println("Stacker throw (" + thrower.getName() + ") -> (" + UtilEnt.getName(throwee) + ")");
|
|
||||||
|
|
||||||
UtilAction.velocity(throwee, thrower.getLocation().getDirection(), 1.8, false, 0, 0.3, 2, false);
|
UtilAction.velocity(throwee, thrower.getLocation().getDirection(), 1.8, false, 0, 0.3, 2, false);
|
||||||
|
|
||||||
_projectileManager.AddThrow(throwee, thrower, this, 4000, true, false, true, false, 0.5f);
|
_projectileManager.AddThrow(throwee, thrower, this, 4000, true, false, true, false, 0.5f);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.hub.server;
|
package mineplex.hub.server;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -26,7 +28,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
@ -48,10 +50,10 @@ import mineplex.core.shop.ShopBase;
|
|||||||
import mineplex.core.status.ServerStatusManager;
|
import mineplex.core.status.ServerStatusManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
|
||||||
import mineplex.hub.HubManager;
|
import mineplex.hub.HubManager;
|
||||||
import mineplex.hub.modules.StackerManager;
|
import mineplex.hub.modules.StackerManager;
|
||||||
import mineplex.hub.queue.QueueManager;
|
import mineplex.hub.queue.QueueManager;
|
||||||
import mineplex.hub.queue.ui.QueueShop;
|
|
||||||
import mineplex.hub.server.ui.LobbyShop;
|
import mineplex.hub.server.ui.LobbyShop;
|
||||||
import mineplex.hub.server.ui.QuickShop;
|
import mineplex.hub.server.ui.QuickShop;
|
||||||
import mineplex.hub.server.ui.ServerCountSorter;
|
import mineplex.hub.server.ui.ServerCountSorter;
|
||||||
@ -61,7 +63,7 @@ import mineplex.serverdata.Region;
|
|||||||
import mineplex.serverdata.data.MinecraftServer;
|
import mineplex.serverdata.data.MinecraftServer;
|
||||||
import mineplex.serverdata.data.ServerGroup;
|
import mineplex.serverdata.data.ServerGroup;
|
||||||
|
|
||||||
public class ServerManager extends MiniPlugin
|
public class ServerManager extends MiniDbClientPlugin<SimpleClanToken>
|
||||||
{
|
{
|
||||||
private static final Long FREE_PORTAL_TIMER = 20000L;
|
private static final Long FREE_PORTAL_TIMER = 20000L;
|
||||||
private static final Long BETA_PORTAL_TIMER = 120000L;
|
private static final Long BETA_PORTAL_TIMER = 120000L;
|
||||||
@ -77,8 +79,6 @@ public class ServerManager extends MiniPlugin
|
|||||||
private PartyManager _partyManager;
|
private PartyManager _partyManager;
|
||||||
private ServerStatusManager _statusManager;
|
private ServerStatusManager _statusManager;
|
||||||
private HubManager _hubManager;
|
private HubManager _hubManager;
|
||||||
private StackerManager _stackerManager;
|
|
||||||
private QueueManager _queueManager;
|
|
||||||
|
|
||||||
private NautHashMap<String, Long> _queueCooldowns = new NautHashMap<String, Long>();
|
private NautHashMap<String, Long> _queueCooldowns = new NautHashMap<String, Long>();
|
||||||
private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
||||||
@ -93,7 +93,6 @@ public class ServerManager extends MiniPlugin
|
|||||||
// Join Time for Free Players Timer
|
// Join Time for Free Players Timer
|
||||||
private NautHashMap<String, Long> _joinTime = new NautHashMap<String, Long>();
|
private NautHashMap<String, Long> _joinTime = new NautHashMap<String, Long>();
|
||||||
|
|
||||||
private QueueShop _domShop;
|
|
||||||
private QuickShop _quickShop;
|
private QuickShop _quickShop;
|
||||||
private LobbyShop _lobbyShop;
|
private LobbyShop _lobbyShop;
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ public class ServerManager extends MiniPlugin
|
|||||||
|
|
||||||
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager, QueueManager queueManager)
|
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager, QueueManager queueManager)
|
||||||
{
|
{
|
||||||
super("Server Manager", plugin);
|
super("Server Manager", plugin, clientManager);
|
||||||
|
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
@ -111,8 +110,6 @@ public class ServerManager extends MiniPlugin
|
|||||||
_partyManager = partyManager;
|
_partyManager = partyManager;
|
||||||
_statusManager = statusManager;
|
_statusManager = statusManager;
|
||||||
_hubManager = hubManager;
|
_hubManager = hubManager;
|
||||||
_stackerManager = stackerManager;
|
|
||||||
_queueManager = queueManager;
|
|
||||||
|
|
||||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||||
|
|
||||||
@ -120,7 +117,6 @@ public class ServerManager extends MiniPlugin
|
|||||||
|
|
||||||
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
|
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
|
||||||
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
|
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
|
||||||
//_domShop = new new QueueShop(_queueManager, clientManager, donationManager, "Dominate");
|
|
||||||
|
|
||||||
// TODO: Find more appropriate place to initialize Clans server shop?
|
// TODO: Find more appropriate place to initialize Clans server shop?
|
||||||
_clansShop = new ClansServerShop(this, _clientManager, _donationManager);
|
_clansShop = new ClansServerShop(this, _clientManager, _donationManager);
|
||||||
@ -918,4 +914,33 @@ public class ServerManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return _serverNpcShopMap.get("Valentines Vendetta");
|
return _serverNpcShopMap.get("Valentines Vendetta");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(int accountId, String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = " + accountId + "?;";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
SimpleClanToken clanToken = new SimpleClanToken();
|
||||||
|
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
String clanName = resultSet.getString(1);
|
||||||
|
String clanRole = resultSet.getString(2);
|
||||||
|
String homeServer = resultSet.getString(3);
|
||||||
|
int clanId = resultSet.getInt(4);
|
||||||
|
clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Set(playerName, clanToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SimpleClanToken AddPlayer(String player)
|
||||||
|
{
|
||||||
|
return new SimpleClanToken();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.party.Party;
|
import mineplex.core.party.Party;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package mineplex.hub.server.ui.clans;
|
package mineplex.hub.server.ui.clans;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -10,6 +12,7 @@ import org.bukkit.event.inventory.ClickType;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.item.DisplayButton;
|
import mineplex.core.shop.item.DisplayButton;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
@ -24,18 +27,10 @@ import mineplex.serverdata.data.DataRepository;
|
|||||||
|
|
||||||
public class ClansServerPage extends ShopPageBase<ServerManager, ClansServerShop>
|
public class ClansServerPage extends ShopPageBase<ServerManager, ClansServerShop>
|
||||||
{
|
{
|
||||||
|
|
||||||
//private DataRepository<PlayerServerInfo> _repository; // Stores the name of the last Clans server a player was on
|
|
||||||
private ClanRepository _repository;
|
|
||||||
private int _accountId;
|
|
||||||
|
|
||||||
public ClansServerPage(ServerManager plugin, ClansServerShop shop, CoreClientManager clientManager,
|
public ClansServerPage(ServerManager plugin, ClansServerShop shop, CoreClientManager clientManager,
|
||||||
DonationManager donationManager, Player player, ClanRepository repository)
|
DonationManager donationManager, Player player)
|
||||||
{
|
{
|
||||||
super(plugin, shop, clientManager, donationManager, "Clans Alpha", player, 27);
|
super(plugin, shop, clientManager, donationManager, "Clans Beta", player, 54);
|
||||||
|
|
||||||
_repository = repository;
|
|
||||||
_accountId = clientManager.getAccountId(player);
|
|
||||||
|
|
||||||
buildPage();
|
buildPage();
|
||||||
}
|
}
|
||||||
@ -43,22 +38,15 @@ public class ClansServerPage extends ShopPageBase<ServerManager, ClansServerShop
|
|||||||
@Override
|
@Override
|
||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
_repository.retrievePlayersClan(_accountId, new Callback<SimpleClanToken>()
|
if (!getPlugin().Get(_player).getClanName().isEmpty())
|
||||||
{
|
{
|
||||||
@Override
|
buildClanPage(getPlugin().Get(_player));
|
||||||
public void run(SimpleClanToken data)
|
|
||||||
{
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
buildClanPage(data);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buildNoClanPage();
|
buildNoClanPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildClanPage(SimpleClanToken clan)
|
private void buildClanPage(SimpleClanToken clan)
|
||||||
{
|
{
|
||||||
@ -72,7 +60,14 @@ public class ClansServerPage extends ShopPageBase<ServerManager, ClansServerShop
|
|||||||
|
|
||||||
private void buildNoClanPage()
|
private void buildNoClanPage()
|
||||||
{
|
{
|
||||||
Collection<ServerInfo> servers = getPlugin().getServerList("Clans");
|
Collection<ServerInfo> servers = UtilAlg.sortSet(getPlugin().getServerList("Clans"), new Comparator<ServerInfo>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public int compare(ServerInfo o1, ServerInfo o2)
|
||||||
|
{
|
||||||
|
return o1.Name.compareTo(o2.Name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
int currentSlot = 9;
|
int currentSlot = 9;
|
||||||
for (ServerInfo server : servers)
|
for (ServerInfo server : servers)
|
||||||
|
@ -2,29 +2,23 @@ package mineplex.hub.server.ui.clans;
|
|||||||
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.block.Action;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.party.Party;
|
import mineplex.core.party.Party;
|
||||||
import mineplex.core.shop.ShopBase;
|
import mineplex.core.shop.ShopBase;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.game.clans.core.repository.ClanRepository;
|
import mineplex.game.clans.core.repository.ClanRepository;
|
||||||
import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
|
|
||||||
import mineplex.hub.server.ServerManager;
|
import mineplex.hub.server.ServerManager;
|
||||||
|
|
||||||
public class ClansServerShop extends ShopBase<ServerManager>
|
public class ClansServerShop extends ShopBase<ServerManager>
|
||||||
{
|
{
|
||||||
|
|
||||||
private ClanRepository _repository;
|
private ClanRepository _repository;
|
||||||
|
|
||||||
public ClansServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
public ClansServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||||
{
|
{
|
||||||
super(plugin, clientManager, donationManager, "Clans Alpha");
|
super(plugin, clientManager, donationManager, "Clans Beta");
|
||||||
|
|
||||||
_repository = new ClanRepository(plugin.getPlugin(), plugin.getStatusManager().getCurrentServerName());
|
_repository = new ClanRepository(plugin.getPlugin(), plugin.getStatusManager().getCurrentServerName());
|
||||||
}
|
}
|
||||||
@ -32,7 +26,7 @@ public class ClansServerShop extends ShopBase<ServerManager>
|
|||||||
@Override
|
@Override
|
||||||
protected ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> buildPagesFor(Player player)
|
protected ShopPageBase<ServerManager, ? extends ShopBase<ServerManager>> buildPagesFor(Player player)
|
||||||
{
|
{
|
||||||
return new ClansServerPage(getPlugin(), this, getClientManager(), getDonationManager(), player, _repository);
|
return new ClansServerPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,8 +29,8 @@ public final class DBPool
|
|||||||
source.setUrl(url);
|
source.setUrl(url);
|
||||||
source.setUsername(username);
|
source.setUsername(username);
|
||||||
source.setPassword(password);
|
source.setPassword(password);
|
||||||
source.setMaxTotal(3);
|
source.setMaxTotal(4);
|
||||||
source.setMaxIdle(3);
|
source.setMaxIdle(4);
|
||||||
source.setTimeBetweenEvictionRunsMillis(180 * 1000);
|
source.setTimeBetweenEvictionRunsMillis(180 * 1000);
|
||||||
source.setSoftMinEvictableIdleTimeMillis(180 * 1000);
|
source.setSoftMinEvictableIdleTimeMillis(180 * 1000);
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package nautilus.game.arcade;
|
package nautilus.game.arcade;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import mineplex.core.common.MinecraftVersion;
|
||||||
|
import mineplex.core.common.Pair;
|
||||||
import mineplex.core.game.GameCategory;
|
import mineplex.core.game.GameCategory;
|
||||||
import mineplex.core.game.GameDisplay;
|
import mineplex.core.game.GameDisplay;
|
||||||
import nautilus.game.arcade.game.Game;
|
import nautilus.game.arcade.game.Game;
|
||||||
@ -82,25 +87,38 @@ public enum GameType
|
|||||||
ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF),
|
ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF),
|
||||||
ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate),
|
ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate),
|
||||||
ChampionsTDM(ChampionsTDM.class, GameDisplay.ChampionsTDM),
|
ChampionsTDM(ChampionsTDM.class, GameDisplay.ChampionsTDM),
|
||||||
Christmas(Christmas.class, GameDisplay.Christmas, "http://file.mineplex.com/ResChristmas.zip", true),
|
Christmas(Christmas.class, GameDisplay.Christmas, new Pair[]
|
||||||
|
{
|
||||||
|
Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResChristmas.zip")
|
||||||
|
}, true),
|
||||||
DeathTag(DeathTag.class, GameDisplay.DeathTag),
|
DeathTag(DeathTag.class, GameDisplay.DeathTag),
|
||||||
DragonEscape(DragonEscape.class, GameDisplay.DragonEscape),
|
DragonEscape(DragonEscape.class, GameDisplay.DragonEscape),
|
||||||
DragonEscapeTeams(DragonEscapeTeams.class, GameDisplay.DragonEscapeTeams),
|
DragonEscapeTeams(DragonEscapeTeams.class, GameDisplay.DragonEscapeTeams),
|
||||||
DragonRiders(DragonRiders.class, GameDisplay.DragonRiders),
|
DragonRiders(DragonRiders.class, GameDisplay.DragonRiders),
|
||||||
Dragons(Dragons.class, GameDisplay.Dragons),
|
Dragons(Dragons.class, GameDisplay.Dragons),
|
||||||
DragonsTeams(DragonsTeams.class, GameDisplay.DragonsTeams),
|
DragonsTeams(DragonsTeams.class, GameDisplay.DragonsTeams),
|
||||||
Draw(Draw.class, GameDisplay.Draw, "http://chivebox.com/mineplex/ResDrawMyThing.zip", true),
|
Draw(Draw.class, GameDisplay.Draw, new Pair[]
|
||||||
|
{
|
||||||
|
Pair.create(MinecraftVersion.ALL, "http://chivebox.com/mineplex/ResDrawMyThing.zip")
|
||||||
|
}, true),
|
||||||
ElytraRings(ElytraRings.class, GameDisplay.ElytraRings),
|
ElytraRings(ElytraRings.class, GameDisplay.ElytraRings),
|
||||||
Evolution(Evolution.class, GameDisplay.Evolution),
|
Evolution(Evolution.class, GameDisplay.Evolution),
|
||||||
Gravity(Gravity.class, GameDisplay.Gravity),
|
Gravity(Gravity.class, GameDisplay.Gravity),
|
||||||
Halloween(Halloween.class, GameDisplay.Halloween, "http://file.mineplex.com/ResHalloween.zip", true),
|
Halloween(Halloween.class, GameDisplay.Halloween, new Pair[]
|
||||||
|
{
|
||||||
|
Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResHalloween.zip")
|
||||||
|
}, true),
|
||||||
HideSeek(HideSeek.class, GameDisplay.HideSeek),
|
HideSeek(HideSeek.class, GameDisplay.HideSeek),
|
||||||
HoleInTheWall(HoleInTheWall.class, GameDisplay.HoleInTheWall),
|
HoleInTheWall(HoleInTheWall.class, GameDisplay.HoleInTheWall),
|
||||||
Horse(Horse.class, GameDisplay.Horse),
|
Horse(Horse.class, GameDisplay.Horse),
|
||||||
Lobbers(BombLobbers.class, GameDisplay.Lobbers),
|
Lobbers(BombLobbers.class, GameDisplay.Lobbers),
|
||||||
Micro(Micro.class, GameDisplay.Micro),
|
Micro(Micro.class, GameDisplay.Micro),
|
||||||
MilkCow(MilkCow.class, GameDisplay.MilkCow),
|
MilkCow(MilkCow.class, GameDisplay.MilkCow),
|
||||||
MineStrike(MineStrike.class, GameDisplay.MineStrike, "http://chivebox.com/mineplex/ResMinestrike.zip", true),
|
MineStrike(MineStrike.class, GameDisplay.MineStrike, new Pair[]
|
||||||
|
{
|
||||||
|
Pair.create(MinecraftVersion.Version1_8, "http://chivebox.com/mineplex/ResMinestrike.zip"),
|
||||||
|
Pair.create(MinecraftVersion.Version1_9, "http://chivebox.com/mineplex/ResMinestrike19.zip")
|
||||||
|
}, true),
|
||||||
MineWare(MineWare.class, GameDisplay.MineWare),
|
MineWare(MineWare.class, GameDisplay.MineWare),
|
||||||
OldMineWare(OldMineWare.class, GameDisplay.OldMineWare),
|
OldMineWare(OldMineWare.class, GameDisplay.OldMineWare),
|
||||||
Paintball(Paintball.class, GameDisplay.Paintball),
|
Paintball(Paintball.class, GameDisplay.Paintball),
|
||||||
@ -128,7 +146,10 @@ public enum GameType
|
|||||||
TurfWars(TurfForts.class, GameDisplay.TurfWars),
|
TurfWars(TurfForts.class, GameDisplay.TurfWars),
|
||||||
UHC(UHC.class, GameDisplay.UHC),
|
UHC(UHC.class, GameDisplay.UHC),
|
||||||
WitherAssault(WitherGame.class, GameDisplay.WitherAssault),
|
WitherAssault(WitherGame.class, GameDisplay.WitherAssault),
|
||||||
Wizards(Wizards.class, GameDisplay.Wizards, "http://file.mineplex.com/ResWizards.zip", true),
|
Wizards(Wizards.class, GameDisplay.Wizards, new Pair[]
|
||||||
|
{
|
||||||
|
Pair.create(MinecraftVersion.ALL, "http://file.mineplex.com/ResWizards.zip")
|
||||||
|
}, true),
|
||||||
ZombieSurvival(ZombieSurvival.class, GameDisplay.ZombieSurvival),
|
ZombieSurvival(ZombieSurvival.class, GameDisplay.ZombieSurvival),
|
||||||
Build(Build.class, GameDisplay.Build),
|
Build(Build.class, GameDisplay.Build),
|
||||||
Cards(Cards.class, GameDisplay.Cards),
|
Cards(Cards.class, GameDisplay.Cards),
|
||||||
@ -158,7 +179,7 @@ public enum GameType
|
|||||||
boolean _enforceResourcePack;
|
boolean _enforceResourcePack;
|
||||||
GameType[] _mapSource;
|
GameType[] _mapSource;
|
||||||
boolean _ownMaps;
|
boolean _ownMaps;
|
||||||
String _resourcePack;
|
Pair<MinecraftVersion, String>[] _resourcePacks;
|
||||||
Class<? extends Game> _gameClass;
|
Class<? extends Game> _gameClass;
|
||||||
|
|
||||||
private int _gameId; // Unique identifying id for this gamemode (used for statistics)
|
private int _gameId; // Unique identifying id for this gamemode (used for statistics)
|
||||||
@ -169,7 +190,7 @@ public enum GameType
|
|||||||
this(gameClass, display, null, false, null, true);
|
this(gameClass, display, null, false, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType(Class<? extends Game> gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack)
|
GameType(Class<? extends Game> gameClass, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrl, boolean enforceResourcePack)
|
||||||
{
|
{
|
||||||
this(gameClass, display, resourcePackUrl, enforceResourcePack, null, true);
|
this(gameClass, display, resourcePackUrl, enforceResourcePack, null, true);
|
||||||
}
|
}
|
||||||
@ -179,11 +200,11 @@ public enum GameType
|
|||||||
this(gameClass, display, null, false, mapSource, ownMap);
|
this(gameClass, display, null, false, mapSource, ownMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType(Class<? extends Game> gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps)
|
GameType(Class<? extends Game> gameClass, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrls, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps)
|
||||||
{
|
{
|
||||||
_display = display;
|
_display = display;
|
||||||
_gameClass = gameClass;
|
_gameClass = gameClass;
|
||||||
_resourcePack = resourcePackUrl;
|
_resourcePacks = resourcePackUrls;
|
||||||
_enforceResourcePack = enforceResourcePack;
|
_enforceResourcePack = enforceResourcePack;
|
||||||
_mapSource = mapSource;
|
_mapSource = mapSource;
|
||||||
_ownMaps = ownMaps;
|
_ownMaps = ownMaps;
|
||||||
@ -199,9 +220,9 @@ public enum GameType
|
|||||||
return _enforceResourcePack;
|
return _enforceResourcePack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResourcePackUrl()
|
public Pair<MinecraftVersion, String>[] getResourcePackUrls()
|
||||||
{
|
{
|
||||||
return _resourcePack;
|
return _resourcePacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameType[] getMapSource()
|
public GameType[] getMapSource()
|
||||||
@ -243,5 +264,4 @@ public enum GameType
|
|||||||
{
|
{
|
||||||
return _display.getKitGameName();
|
return _display.getKitGameName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -401,7 +401,7 @@ public abstract class Game implements Listener
|
|||||||
new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
|
new ExperienceStatTracker(this), new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(
|
||||||
this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
|
this), new DamageTakenStatTracker(this), new GamesPlayedStatTracker(this));
|
||||||
|
|
||||||
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack());
|
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(), gameType.isEnforceResourcePack());
|
||||||
|
|
||||||
_useEntityPacketHandler = new IPacketHandler()
|
_useEntityPacketHandler = new IPacketHandler()
|
||||||
{
|
{
|
||||||
|
@ -3124,7 +3124,7 @@ public class MineStrike extends TeamGame
|
|||||||
}
|
}
|
||||||
else if (event.getMessage().equalsIgnoreCase("/rpon"))
|
else if (event.getMessage().equalsIgnoreCase("/rpon"))
|
||||||
{
|
{
|
||||||
event.getPlayer().setResourcePack(GetType().getResourcePackUrl());
|
Manager.getResourcePackManager().setPlayerPack(event.getPlayer());
|
||||||
|
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Resource Pack", "Resource Pack: " + C.cGreen + "Enabled"));
|
UtilPlayer.message(event.getPlayer(), F.main("Resource Pack", "Resource Pack: " + C.cGreen + "Enabled"));
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Resource Pack", "Type " + F.elem("/rpoff") + " to disable."));
|
UtilPlayer.message(event.getPlayer(), F.main("Resource Pack", "Type " + F.elem("/rpoff") + " to disable."));
|
||||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.managers;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import mineplex.core.antihack.AntiHack;
|
import mineplex.core.antihack.AntiHack;
|
||||||
|
import mineplex.core.common.MinecraftVersion;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -1204,7 +1205,7 @@ public class GameFlagManager implements Listener
|
|||||||
if (Manager.GetGame() == null)
|
if (Manager.GetGame() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Manager.GetGame().GetType().getResourcePackUrl() == null)
|
if (Manager.GetGame().GetType().getResourcePackUrls() == null || Manager.GetGame().GetType().getResourcePackUrls().length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer());
|
UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer());
|
||||||
|
Loading…
Reference in New Issue
Block a user