Artix QOL/Fixes Round 4 (#589)
This commit is contained in:
parent
34428f7b5f
commit
888861c4e5
@ -117,6 +117,11 @@ public class UtilColor
|
||||
}
|
||||
}
|
||||
|
||||
public static String chatColorToJsonColor(ChatColor chatColor)
|
||||
{
|
||||
return chatColor.name().toLowerCase();
|
||||
}
|
||||
|
||||
public static Vector colorToVector(Color color)
|
||||
{
|
||||
return new Vector(Math.max(color.getRed()/255.0, 0.00001f), color.getGreen()/255.0, color.getBlue()/255.0);
|
||||
|
@ -15,6 +15,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -70,6 +71,9 @@ public class UtilPlayer
|
||||
// The amount of time (in milliseconds) after changin hotbars that you can block
|
||||
public static final long BLOCKING_HOTBAR_DELAY = 100;
|
||||
|
||||
// Regex used to match player names
|
||||
private static final Pattern USERNMAME_PATTERN = Pattern.compile("^([A-Za-z0-9_]{1,16}|\\$)$");
|
||||
|
||||
private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max)
|
||||
{
|
||||
final double epsilon = 0.0001f;
|
||||
@ -1215,4 +1219,14 @@ public class UtilPlayer
|
||||
{
|
||||
return ((CraftPlayer) player).getHandle().getProtocol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a given string is valid as a player's username.
|
||||
* @param playerName - The name of the player
|
||||
* @return Whether this name is synatactically valid. If this returns true it does not necessarily mean they exist.
|
||||
*/
|
||||
public static boolean isValidName(String playerName)
|
||||
{
|
||||
return USERNMAME_PATTERN.matcher(playerName).matches();
|
||||
}
|
||||
}
|
||||
|
@ -885,4 +885,9 @@ public class CoreClientManager extends MiniPlugin
|
||||
{
|
||||
_loginProcessors.add(processor);
|
||||
}
|
||||
|
||||
public void loadLastLogin(int accountId, Consumer<Long> lastLogin)
|
||||
{
|
||||
_repository.loadLastLogin(accountId, lastLogin);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package mineplex.core.account.repository;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
@ -17,6 +18,7 @@ import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@ -51,6 +53,8 @@ public class AccountRepository extends MinecraftRepository
|
||||
private static String SELECT_ACCOUNT_UUID_BY_ID = "SELECT uuid FROM accounts WHERE id=?;";
|
||||
private static String SELECT_ACCOUNT_ID_BY_UUID = "SELECT id FROM accounts WHERE accounts.uuid = ? LIMIT 1";
|
||||
|
||||
private static final String SELECT_LAST_LOGIN_BY_ID = "SELECT lastLogin FROM accounts WHERE id = ?";
|
||||
|
||||
public AccountRepository()
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
@ -456,4 +460,32 @@ public class AccountRepository extends MinecraftRepository
|
||||
{
|
||||
return handleSyncMSSQLCallStream("PlayerAccount/GetAccount", playerName);
|
||||
}
|
||||
|
||||
public void loadLastLogin(int accountId, Consumer<Long> lastLogin)
|
||||
{
|
||||
UtilServer.runAsync(() ->
|
||||
{
|
||||
try (Connection connection = DBPool.getAccount().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(SELECT_LAST_LOGIN_BY_ID))
|
||||
{
|
||||
statement.setInt(1, accountId);
|
||||
|
||||
try (ResultSet resultSet = statement.executeQuery())
|
||||
{
|
||||
if (resultSet.next())
|
||||
{
|
||||
lastLogin.accept(resultSet.getTimestamp("lastLogin").getTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
lastLogin.accept(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
lastLogin.accept(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package mineplex.core.admin.command;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
|
||||
public class AdminCommands extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _coreClientManager;
|
||||
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
SEEN_COMMAND
|
||||
}
|
||||
|
||||
public AdminCommands()
|
||||
{
|
||||
super("Staff");
|
||||
|
||||
_coreClientManager = require(CoreClientManager.class);
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
public CoreClientManager getCoreClientManager()
|
||||
{
|
||||
return _coreClientManager;
|
||||
}
|
||||
|
||||
public void generatePermissions()
|
||||
{
|
||||
PermissionGroup.TRAINEE.setPermission(Perm.SEEN_COMMAND, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new SeenCommand(this));
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package mineplex.core.admin.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
public class SeenCommand extends CommandBase<AdminCommands>
|
||||
{
|
||||
public SeenCommand(AdminCommands plugin)
|
||||
{
|
||||
super(plugin, AdminCommands.Perm.SEEN_COMMAND, "seen", "lastlogin");
|
||||
}
|
||||
|
||||
private void help(Player caller)
|
||||
{
|
||||
reply(caller, "Usage: " + F.elem("/seen <player>"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
help(caller);
|
||||
return;
|
||||
}
|
||||
|
||||
String target = args[0];
|
||||
|
||||
if (!UtilPlayer.isValidName(target))
|
||||
{
|
||||
reply(caller, "That name isn't valid! Try again?");
|
||||
}
|
||||
|
||||
if (target.equalsIgnoreCase(caller.getName()))
|
||||
{
|
||||
reply(caller, "I see you right now! Is this a trick?");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Bukkit.getPlayerExact(target) != null)
|
||||
{
|
||||
reply(caller, "They're on this server, right now! Have you no eyes?");
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getCoreClientManager().getOrLoadClient(target, (client) ->
|
||||
{
|
||||
if (client == null)
|
||||
{
|
||||
reply(caller, "The player " + F.name(target) + " was not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getCoreClientManager().loadLastLogin(client.getAccountId(), (lastLogin) ->
|
||||
{
|
||||
if (lastLogin == null)
|
||||
{
|
||||
reply(caller, "Unable to load that player's last login. Try again later?");
|
||||
return;
|
||||
}
|
||||
|
||||
reply(caller, "The player " + F.name(target) + " last logged in at " + F.elem(UtilTime.when(lastLogin)));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -30,13 +31,17 @@ import mineplex.core.antihack.logging.builtin.PlayerInfoMetadata;
|
||||
import mineplex.core.antihack.logging.builtin.ServerInfoMetadata;
|
||||
import mineplex.core.antihack.logging.builtin.ViolationInfoMetadata;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class AntihackLogger extends MiniPlugin
|
||||
{
|
||||
public static final Gson GSON = new Gson();
|
||||
private final static String READABLE_NAME = "GWEN";
|
||||
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
@ -76,8 +81,12 @@ public class AntihackLogger extends MiniPlugin
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
if (args.length != 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(READABLE_NAME, "Usage: " + F.elem("/smeta <player>")));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (player != null)
|
||||
{
|
||||
@ -86,13 +95,23 @@ public class AntihackLogger extends MiniPlugin
|
||||
String id = AntiHack.generateId();
|
||||
saveMetadata(player, id, () ->
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "Saved metadata for " + player.getName() + " with id " + id));
|
||||
new JsonMessage(READABLE_NAME + "> ")
|
||||
.color(UtilColor.chatColorToJsonColor(ChatColor.BLUE))
|
||||
.extra("Saved metadata for ")
|
||||
.color(UtilColor.chatColorToJsonColor(ChatColor.GRAY))
|
||||
.extra(player.getName())
|
||||
.color(UtilColor.chatColorToJsonColor(ChatColor.YELLOW))
|
||||
.extra(" with id ")
|
||||
.color(UtilColor.chatColorToJsonColor(ChatColor.GRAY))
|
||||
.extra(id)
|
||||
.color(UtilColor.chatColorToJsonColor(ChatColor.GREEN))
|
||||
.click(ClickEvent.OPEN_URL, String.format("https://frozor.io/gwen/meta/%s", id))
|
||||
.sendToPlayer(caller);
|
||||
}, custom);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "That player doesn't exist!"));
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(READABLE_NAME, "That player doesn't exist!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -690,18 +690,30 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
BonusClientData client = Get(player);
|
||||
int streak = client.getDailyStreak();
|
||||
|
||||
// Increase the multiplier by 5 for each day
|
||||
// in the player's streak, until they reach
|
||||
// 200 (aka 40 days)
|
||||
int multiplier = Math.min(200, 5 * streak);
|
||||
if (streak >= 40) multiplier += (1 * (streak - 40));
|
||||
|
||||
// Once they reach 40 days (the 200 cap from
|
||||
// above), begin adding 1 per day instead of 5.
|
||||
if (streak >= 40)
|
||||
{
|
||||
multiplier += (1 * (streak - 40));
|
||||
}
|
||||
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
public int getVoteMultiplier(int streak)
|
||||
{
|
||||
int multiplier = Math.min(100, 5 * streak);
|
||||
|
||||
if (streak >= 20)
|
||||
{
|
||||
multiplier += (1 * (streak - 40));
|
||||
}
|
||||
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
@ -710,9 +722,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
double mult = getDailyMultiplier(player) / 100.0;
|
||||
|
||||
BonusAmount amount = new BonusAmount();
|
||||
int shards = 100;
|
||||
int gems = 100;
|
||||
int experience = 250;
|
||||
int shards = 200;
|
||||
int gems = 200;
|
||||
int experience = 350;
|
||||
|
||||
amount.setShards(shards);
|
||||
amount.setGems(gems);
|
||||
|
@ -3,20 +3,27 @@ package mineplex.core.boosters.command;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import static mineplex.core.Managers.require;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
*/
|
||||
public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
||||
{
|
||||
CoreClientManager _coreClientManager;
|
||||
|
||||
public BoosterCommand(BoosterManager plugin)
|
||||
{
|
||||
super(plugin, BoosterManager.Perm.BOOSTER_COMMAND, "amplifier");
|
||||
|
||||
_coreClientManager = require(CoreClientManager.class);
|
||||
|
||||
AddCommand(new AddCommand(plugin));
|
||||
AddCommand(new GuiCommand(plugin));
|
||||
AddCommand(new ReloadCommand(plugin));
|
||||
@ -25,9 +32,20 @@ public class BoosterCommand extends MultiCommandBase<BoosterManager>
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
if (_coreClientManager.Get(caller).hasPermission(BoosterManager.Perm.ADD_BOOSTER_COMMAND))
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("amplifier add <group>", "Add an amplifier to that group", ChatColor.DARK_RED));
|
||||
}
|
||||
|
||||
if (_coreClientManager.Get(caller).hasPermission(BoosterManager.Perm.BOOSTER_GUI_COMMAND))
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("amplifier gui", "Open Amplifier GUI", ChatColor.DARK_RED));
|
||||
}
|
||||
|
||||
if (_coreClientManager.Get(caller).hasPermission(BoosterManager.Perm.THANK_COMMAND))
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("amplifier thank <group>", "Thank an Amplifier for a specific Booster Group", ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@ import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.chat.command.BroadcastCommand;
|
||||
import mineplex.core.chat.command.ChatSlowCommand;
|
||||
import mineplex.core.chat.command.HelpCommand;
|
||||
import mineplex.core.chat.command.SilenceCommand;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -49,6 +50,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.preferences.Preference;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
@ -70,6 +72,7 @@ public class Chat extends MiniPlugin
|
||||
SILENCE_COMMAND,
|
||||
SLOW_CHAT_COMMAND,
|
||||
BROADCAST_COMMAND,
|
||||
HELP_COMMAND
|
||||
}
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
@ -127,6 +130,7 @@ public class Chat extends MiniPlugin
|
||||
PermissionGroup.ADMIN.setPermission(Perm.SILENCE_COMMAND, true, true);
|
||||
PermissionGroup.SRMOD.setPermission(Perm.SLOW_CHAT_COMMAND, true, true);
|
||||
PermissionGroup.MOD.setPermission(Perm.BROADCAST_COMMAND, true, true);
|
||||
PermissionGroup.PLAYER.setPermission(Perm.HELP_COMMAND, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,6 +139,7 @@ public class Chat extends MiniPlugin
|
||||
addCommand(new SilenceCommand(this));
|
||||
addCommand(new BroadcastCommand(this));
|
||||
addCommand(new ChatSlowCommand(this));
|
||||
addCommand(new HelpCommand(this));
|
||||
}
|
||||
|
||||
public void setChatSlow(int seconds, boolean inform)
|
||||
@ -359,7 +364,9 @@ public class Chat extends MiniPlugin
|
||||
|
||||
Player sender = event.getPlayer();
|
||||
|
||||
if (_incognitoManager != null && _incognitoManager.Get(sender).Status && !UtilServer.isTestServer())
|
||||
if (_incognitoManager != null && _incognitoManager.Get(sender).Status
|
||||
&& !event.getMessage().startsWith(CommunityManager.CHAT_PREFIX)
|
||||
&& !UtilServer.isTestServer())
|
||||
{
|
||||
UtilPlayer.message(sender, C.cYellow + "You can not chat while incognito.");
|
||||
event.setCancelled(true);
|
||||
|
@ -0,0 +1,108 @@
|
||||
package mineplex.core.chat.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.HoverEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
|
||||
public class HelpCommand extends CommandBase<Chat>
|
||||
{
|
||||
|
||||
public HelpCommand(Chat plugin)
|
||||
{
|
||||
super(plugin, Chat.Perm.HELP_COMMAND, "help", "?", "pleasehelpmeiamgoingtoexplode");
|
||||
}
|
||||
|
||||
private void sendMain(Player caller, String message)
|
||||
{
|
||||
caller.sendMessage(F.main("Help", message));
|
||||
}
|
||||
|
||||
private void sendSingle(Player caller, String message)
|
||||
{
|
||||
caller.sendMessage(F.main("", message));
|
||||
}
|
||||
|
||||
private JsonMessage getSingleStart(String before)
|
||||
{
|
||||
return new JsonMessage(C.cBlue + "> ")
|
||||
.extra(before)
|
||||
.color(C.cGray);
|
||||
}
|
||||
|
||||
private void sendUrl(Player caller, String before, String clickText, ChatColor clickTextColor, String url, String hoverText)
|
||||
{
|
||||
getSingleStart(before)
|
||||
.color(UtilColor.chatColorToJsonColor(ChatColor.GRAY))
|
||||
.extra(clickText)
|
||||
.color(UtilColor.chatColorToJsonColor(clickTextColor))
|
||||
.click(ClickEvent.OPEN_URL, url)
|
||||
.hover(HoverEvent.SHOW_TEXT, hoverText)
|
||||
.sendToPlayer(caller);
|
||||
}
|
||||
|
||||
private void sendFaq(Player caller)
|
||||
{
|
||||
sendUrl(caller,
|
||||
"Check out ",
|
||||
"our FAQ for commonly asked questions", ChatColor.YELLOW,
|
||||
"http://www.mineplex.com/faq",
|
||||
C.cYellow + "Click to visit our FAQ page!");
|
||||
}
|
||||
|
||||
private void sendRules(Player caller)
|
||||
{
|
||||
sendUrl(caller,
|
||||
"Read ",
|
||||
"our rules to avoid being punished!", ChatColor.YELLOW,
|
||||
"http://www.mineplex.com/rules",
|
||||
C.cYellow + "Click to visit our rules page!");
|
||||
}
|
||||
|
||||
private void sendTrainee(Player caller)
|
||||
{
|
||||
sendUrl(caller,
|
||||
"Want to apply for Trainee? Visit ",
|
||||
"apply.mineplex.com" + C.cGray + "!", ChatColor.YELLOW,
|
||||
"http://apply.mineplex.com",
|
||||
C.cDAqua + "Click to visit our forums to learn about Trainee!");
|
||||
}
|
||||
|
||||
private void sendSupport(Player caller)
|
||||
{
|
||||
sendUrl(caller,
|
||||
"Question about a purchase? Contact support at ",
|
||||
"mineplex.com/support" + C.cGray + "!", ChatColor.YELLOW,
|
||||
"http://www.mineplex.com/support",
|
||||
C.cYellow + "Click to visit our support page!");
|
||||
}
|
||||
|
||||
private void sendTwitter(Player caller)
|
||||
{
|
||||
sendUrl(caller,
|
||||
"Find us on twitter at ",
|
||||
"@Mineplex", ChatColor.AQUA,
|
||||
"https://twitter.com/Mineplex",
|
||||
C.cAqua + "Click to visit our twitter!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
sendMain(caller, "Hi there! Need some help?");
|
||||
sendFaq(caller);
|
||||
sendRules(caller);
|
||||
sendTrainee(caller);
|
||||
sendSupport(caller);
|
||||
sendTwitter(caller);
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.PlayerSelector;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilLambda;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
@ -60,6 +61,11 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
|
||||
Recharge.Instance.recharge(caller, "Command");
|
||||
}
|
||||
|
||||
protected void reply(Player caller, String message)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, String commandLabel, String[] args)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ public class CommandCenter implements Listener, IPacketHandler
|
||||
protected JavaPlugin Plugin;
|
||||
protected CoreClientManager ClientManager;
|
||||
protected static NautHashMap<String, ICommand> Commands;
|
||||
private final List<String> BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit", "about", "?", "help");
|
||||
private final List<String> BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit", "about");
|
||||
private final String MESSAGE = C.cRed + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.";
|
||||
|
||||
private final PacketHandler _packetHandler = Managers.require(PacketHandler.class);
|
||||
|
@ -3,21 +3,20 @@ package mineplex.core.communities;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -33,6 +32,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -66,6 +66,7 @@ import mineplex.core.communities.redis.CommunityUpdateNameHandler;
|
||||
import mineplex.core.communities.redis.CommunityUpdateSetting;
|
||||
import mineplex.core.communities.redis.CommunityUpdateSettingHandler;
|
||||
import mineplex.core.communities.storage.CommunityRepository;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.preferences.Preference;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
@ -102,10 +103,15 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
COMMUNITY_UNINVITE_STAFF_COMMAND,
|
||||
}
|
||||
|
||||
public final static String CHAT_PREFIX = "!";
|
||||
public final static String COMMUNITY_CHAT_KEY = "core.communities.chat.selected";
|
||||
public final static int MAX_NAME_LENGTH = 15;
|
||||
|
||||
private final int UPDATE_CYCLE_SECONDS = 10; // The number of seconds between dirty communities refreshes
|
||||
private final int CACHE_INVALIDATION_SECONDS = 300; // The number of seconds between full communities refreshes
|
||||
public final Pattern ALPHA_NUMERIC_PATTERN = Pattern.compile("[^A-Za-z0-9]");
|
||||
public final String[] BLOCKED_NAMES = new String[] {"help", "chat", "create", "description", "disband", "invite", "join", "mcs", "rename", "uninvite", "trainee", "mod", "moderator", "srmod", "seniormod", "seniormoderator", "builder", "maplead", "twitch", "youtube", "support", "admin", "administrator", "leader", "dev", "developer", "owner", "party", "mineplex", "mineplexOfficial", "staff", "mineplexstaff", "qualityassurance", "traineemanagement", "modcoordination", "forumninja", "communitymanagement", "event", "socialmedia"};
|
||||
public final Pattern VALID_NAME_PATTERN = Pattern.compile("^[A-Za-z0-9]{1," + MAX_NAME_LENGTH + "}$");
|
||||
public final Pattern NON_ALPHANUMERIC_PATTERN = Pattern.compile("[^A-Za-z0-9]");
|
||||
public final List<String> BLOCKED_NAMES = Arrays.asList("help", "chat", "create", "description", "disband", "invite", "join", "mcs", "rename", "uninvite", "trainee", "mod", "moderator", "srmod", "seniormod", "seniormoderator", "builder", "maplead", "twitch", "youtube", "support", "admin", "administrator", "leader", "dev", "developer", "owner", "party", "mineplex", "mineplexofficial", "staff", "mineplexstaff", "qualityassurance", "traineemanagement", "modcoordination", "forumninja", "communitymanagement", "event", "socialmedia");
|
||||
|
||||
private final CommunityRepository _repo;
|
||||
private final Map<Integer, Community> _loadedCommunities;
|
||||
@ -123,6 +129,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
private volatile boolean _cycling = false;
|
||||
|
||||
private final CoreClientManager _clientManager;
|
||||
private final CustomDataManager _customDataManager;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private CommunityManager()
|
||||
@ -145,6 +152,10 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
});
|
||||
|
||||
_clientManager = require(CoreClientManager.class);
|
||||
_customDataManager = require(CustomDataManager.class);
|
||||
|
||||
_customDataManager.getRepository().registerKey(COMMUNITY_CHAT_KEY);
|
||||
|
||||
_clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor()
|
||||
{
|
||||
@Override
|
||||
@ -261,9 +272,24 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_UNINVITE_STAFF_COMMAND, true, true);
|
||||
}
|
||||
|
||||
public void communityExists(String name, Runnable onTrue, Runnable onFalse)
|
||||
public CustomDataManager getCustomDataManager()
|
||||
{
|
||||
_repo.communityExists(name, onTrue, onFalse);
|
||||
return _customDataManager;
|
||||
}
|
||||
|
||||
public boolean isNameValid(String communityName)
|
||||
{
|
||||
return VALID_NAME_PATTERN.matcher(communityName).find();
|
||||
}
|
||||
|
||||
public boolean isNameAllowed(Player caller, String communityName)
|
||||
{
|
||||
return !Managers.get(Chat.class).getFilteredMessage(caller, communityName).contains("*");
|
||||
}
|
||||
|
||||
public void communityExists(String name, Consumer<Boolean> result)
|
||||
{
|
||||
_repo.communityExists(name, result);
|
||||
}
|
||||
|
||||
public boolean ownsCommunity(UUID uuid)
|
||||
@ -466,7 +492,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
Get(Bukkit.getPlayer(targetUUID)).Invites.add(community.getId());
|
||||
if (Managers.get(PreferencesManager.class).get(Bukkit.getPlayer(targetUUID)).isActive(Preference.COMMUNITY_INVITES))
|
||||
{
|
||||
new JsonMessage(F.main(getName(), "You have been invited to join " + F.elem(community.getName()) + " by " + F.name(sender) + "! Click to join!")).click(ClickEvent.RUN_COMMAND, "/community join " + community.getName()).sendToPlayer(Bukkit.getPlayer(targetUUID));
|
||||
new JsonMessage(F.main(getName(), "You have been invited to join " + F.elem(community.getName()) + " by " + F.name(sender) + "! " + C.cGreen + "Click this message to join!")).click(ClickEvent.RUN_COMMAND, "/community join " + community.getName()).sendToPlayer(Bukkit.getPlayer(targetUUID));
|
||||
}
|
||||
|
||||
UtilServer.CallEvent(new CommunityMemberDataUpdateEvent(Bukkit.getPlayer(targetUUID)));
|
||||
@ -871,15 +897,52 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (!event.getMessage().startsWith("!"))
|
||||
if (!event.getMessage().startsWith(CHAT_PREFIX))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Player sender = event.getPlayer();
|
||||
if (Get(sender).getCommunityChattingTo() != -1)
|
||||
|
||||
CommunityMemberData memberData = Get(sender);
|
||||
|
||||
// If the player does not have a specified community to chat to...
|
||||
if (memberData.getCommunityChattingTo() == -1)
|
||||
{
|
||||
Community target = _loadedCommunities.get(Get(sender).getCommunityChattingTo());
|
||||
// And they are only in a single community...
|
||||
if (memberData.getTotalCommunities() == 1)
|
||||
{
|
||||
// Set that as the one they are chatting to.
|
||||
memberData.setCommunityChattingTo(memberData.getCommunities().get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
int savedChattingTo = _customDataManager.getData(sender, COMMUNITY_CHAT_KEY);
|
||||
|
||||
if (savedChattingTo != -1)
|
||||
{
|
||||
memberData.setCommunityChattingTo(savedChattingTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(sender, F.main(getName(), "You are not chatting to a specific community! Use " + F.elem("/com chat <community>") + " to select a community to chat to."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String newMessage = event.getMessage().substring(1).trim();
|
||||
|
||||
if (newMessage.length() == 0)
|
||||
{
|
||||
UtilPlayer.message(sender, F.main(getName(), "You can't send an empty message."));
|
||||
return;
|
||||
}
|
||||
|
||||
Community target = _loadedCommunities.get(memberData.getCommunityChattingTo());
|
||||
|
||||
if (target == null || !target.getMembers().containsKey(event.getPlayer().getUniqueId()))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main(getName(), "You are not in that community! Use " + F.elem("/com chat <community>") + " to select a new community to chat to!"));
|
||||
@ -888,7 +951,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
{
|
||||
if (Recharge.Instance.use(sender, "Community Chat to " + target.getId(), target.getChatDelay(), false, false))
|
||||
{
|
||||
new CommunityChat(sender.getName(), target.getId(), event.getMessage().substring(1)).publish();
|
||||
new CommunityChat(sender.getName(), target.getId(), newMessage).publish();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -896,11 +959,6 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(sender, F.main(getName(), "You are not chatting to a specific community! Use " + F.elem("/com chat <community>") + " to select a community to chat to."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
|
@ -21,7 +21,6 @@ public class CommunityMemberData
|
||||
|
||||
public CommunityMemberData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int getTotalCommunities()
|
||||
@ -39,9 +38,14 @@ public class CommunityMemberData
|
||||
return _chattingTo;
|
||||
}
|
||||
|
||||
public void setCommunityChattingTo(int id)
|
||||
{
|
||||
_chattingTo = id;
|
||||
}
|
||||
|
||||
public void setCommunityChattingTo(Community community)
|
||||
{
|
||||
_chattingTo = community.getId();
|
||||
setCommunityChattingTo(community.getId());
|
||||
}
|
||||
|
||||
Set<Integer> getCommunityIds()
|
||||
|
@ -11,6 +11,7 @@ import mineplex.core.communities.CommunityManager;
|
||||
|
||||
public class CommunityChatCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
|
||||
public CommunityChatCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, CommunityManager.Perm.COMMUNITY_CHAT_COMMAND, "chat");
|
||||
@ -36,6 +37,10 @@ public class CommunityChatCommand extends CommandBase<CommunityManager>
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are now chatting to " + F.name(c.getName()) + "! Use " + F.elem("!") + " before your message to use community chat!"));
|
||||
|
||||
Plugin.getCustomDataManager().Get(caller).put(CommunityManager.COMMUNITY_CHAT_KEY, c.getId());
|
||||
Plugin.getCustomDataManager().saveData(caller);
|
||||
|
||||
Plugin.Get(caller).setCommunityChattingTo(c);
|
||||
}
|
||||
}
|
@ -29,37 +29,47 @@ public class CommunityCreateCommand extends CommandBase<CommunityManager>
|
||||
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Plugin.Get(caller).ownsCommunity())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You already own a community!"));
|
||||
return;
|
||||
}
|
||||
if (args[0].length() > 15 || Plugin.ALPHA_NUMERIC_PATTERN.matcher(args[0]).find())
|
||||
|
||||
String communityName = args[0];
|
||||
|
||||
if (!Plugin.isNameValid(communityName))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community name cannot be longer than 15 characters and must be alphanumeric!"));
|
||||
return;
|
||||
}
|
||||
if (Arrays.asList(Plugin.BLOCKED_NAMES).contains(args[0].toLowerCase()))
|
||||
|
||||
if (Plugin.BLOCKED_NAMES.contains(communityName.toLowerCase()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not allowed!"));
|
||||
return;
|
||||
}
|
||||
|
||||
final int accountId = Managers.get(CoreClientManager.class).getAccountId(caller);
|
||||
final String senderName = Managers.get(CoreClientManager.class).Get(caller).getName();
|
||||
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
Plugin.communityExists(args[0], () -> // onTrue
|
||||
Plugin.communityExists(communityName, (exists) ->
|
||||
{
|
||||
if (exists)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community with that name already exists!"));
|
||||
}, () -> // onFalse
|
||||
{
|
||||
if (Managers.get(Chat.class).getFilteredMessage(caller, args[0]).contains("*"))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Plugin.isNameAllowed(caller, communityName))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not allowed!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.runSync(() -> Plugin.handleCreate(caller, senderName, accountId, args[0]));
|
||||
Plugin.runSync(() -> Plugin.handleCreate(caller, senderName, accountId, communityName));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community description cannot be longer than 30 characters!"));
|
||||
return;
|
||||
}
|
||||
if (Plugin.ALPHA_NUMERIC_PATTERN.matcher(desc.replace(" ", "").replace("!", "").replace("?", "").replace(".", "").replace("'", "").replace("\"", "")).find())
|
||||
if (Plugin.NON_ALPHANUMERIC_PATTERN.matcher(desc.replace(" ", "").replace("!", "").replace("?", "").replace(".", "").replace("'", "").replace("\"", "")).find())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community description must be alphanumeric!"));
|
||||
return;
|
||||
|
@ -31,13 +31,16 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
||||
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", ChatColor.DARK_AQUA));
|
||||
return;
|
||||
}
|
||||
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
String newName = args[1];
|
||||
|
||||
if (c == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).hasPermission(CommunityManager.Perm.COMMUNITY_RENAME_STAFF_COMMAND))
|
||||
@ -46,24 +49,30 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (newName.length() > 15 || Plugin.ALPHA_NUMERIC_PATTERN.matcher(newName).find())
|
||||
|
||||
if (!Plugin.isNameValid(newName))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community name cannot be longer than 15 characters and must be alphanumeric!"));
|
||||
return;
|
||||
}
|
||||
if (Arrays.asList(Plugin.BLOCKED_NAMES).contains(newName.toLowerCase()))
|
||||
|
||||
if (Plugin.BLOCKED_NAMES.contains(newName.toLowerCase()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not allowed!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
Plugin.communityExists(newName, () -> // onTrue - community already exists
|
||||
Plugin.communityExists(newName, (exists) ->
|
||||
{
|
||||
if (exists)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community with that name already exists!"));
|
||||
}, () -> // onFalse - we're good
|
||||
{
|
||||
if (Managers.get(Chat.class).getFilteredMessage(caller, newName).contains("*"))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Plugin.isNameAllowed(caller, newName))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not allowed!"));
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -65,20 +66,14 @@ public class CommunityRepository extends RepositoryBase
|
||||
_us = us;
|
||||
}
|
||||
|
||||
public void communityExists(String name, Runnable onTrue, Runnable onFalse)
|
||||
public void communityExists(String name, Consumer<Boolean> result)
|
||||
{
|
||||
try (Connection connection = getConnection())
|
||||
{
|
||||
executeQuery(connection, "SELECT name FROM communities WHERE name=?", resultSet ->
|
||||
{
|
||||
if (resultSet.next())
|
||||
{
|
||||
onTrue.run();
|
||||
} else
|
||||
{
|
||||
onFalse.run();
|
||||
}
|
||||
}, new ColumnVarChar("name", 15, name));
|
||||
executeQuery(connection,
|
||||
"SELECT name FROM communities WHERE name=?",
|
||||
resultSet -> result.accept(resultSet.next()),
|
||||
new ColumnVarChar("name", 15, name));
|
||||
} catch (Exception ex)
|
||||
{
|
||||
throw new RuntimeException("Failed to determine if community exists", ex);
|
||||
|
@ -1,18 +0,0 @@
|
||||
package mineplex.core.customdata;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CorePlayer extends MineplexPlayer
|
||||
{
|
||||
|
||||
CorePlayer(Player player, CustomDataManager customDataManager)
|
||||
{
|
||||
super(player, customDataManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyPrefix()
|
||||
{
|
||||
return "core.";
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package mineplex.core.customdata;
|
||||
|
||||
public class CustomData
|
||||
{
|
||||
|
||||
private final int _id;
|
||||
private final String _key;
|
||||
|
||||
public CustomData(int id, String key)
|
||||
{
|
||||
_id = id;
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
}
|
@ -2,20 +2,19 @@ package mineplex.core.customdata;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.customdata.repository.CustomDataRepository;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
public class CustomDataManager extends MiniDbClientPlugin<Map<String, Integer>>
|
||||
{
|
||||
|
||||
private final CustomDataRepository _repository;
|
||||
|
||||
private CustomDataManager()
|
||||
@ -25,14 +24,19 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
_repository = new CustomDataRepository(ClientManager, this);
|
||||
}
|
||||
|
||||
public CustomDataRepository getRepository()
|
||||
{
|
||||
return _repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
PlayerCustomData data = new PlayerCustomData(_repository);
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data"));
|
||||
data.put(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data"));
|
||||
}
|
||||
|
||||
Set(uuid, data);
|
||||
@ -44,13 +48,12 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
return "SELECT accountId, customDataId, data FROM accountCustomData INNER JOIN customData ON customData.id = accountCustomData.customDataId WHERE accountId = " + accountId + ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PlayerCustomData addPlayer(UUID uuid)
|
||||
protected Map<String, Integer> addPlayer(UUID uuid)
|
||||
{
|
||||
return new PlayerCustomData(_repository);
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
void saveAsync(Player player)
|
||||
public void saveData(Player player)
|
||||
{
|
||||
final int accountId = getClientManager().getAccountId(player);
|
||||
|
||||
@ -62,8 +65,8 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
runAsync(() -> _repository.saveData(player.getUniqueId(), accountId));
|
||||
}
|
||||
|
||||
public CorePlayer getCorePlayer(Player player)
|
||||
public int getData(Player player, String key)
|
||||
{
|
||||
return new CorePlayer(player, this);
|
||||
return Get(player).getOrDefault(key, -1);
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
package mineplex.core.customdata;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class MineplexPlayer
|
||||
{
|
||||
|
||||
private final Player _player;
|
||||
private final CustomDataManager _customDataManager;
|
||||
|
||||
public MineplexPlayer(Player player, CustomDataManager customDataManager)
|
||||
{
|
||||
_player = player;
|
||||
_customDataManager = customDataManager;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public String getKeyPrefix()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public void put(String key, int data, boolean save)
|
||||
{
|
||||
key = getKeyPrefix() + key;
|
||||
_customDataManager.Get(getPlayer()).setData(key, data);
|
||||
if (save)
|
||||
{
|
||||
_customDataManager.saveAsync(_player);
|
||||
}
|
||||
}
|
||||
|
||||
public int get(String key)
|
||||
{
|
||||
key = getKeyPrefix() + key;
|
||||
return _customDataManager.Get(getPlayer()).getData(key);
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package mineplex.core.customdata;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.customdata.repository.CustomDataRepository;
|
||||
|
||||
public class PlayerCustomData
|
||||
{
|
||||
|
||||
private final Map<CustomData, Integer> _data;
|
||||
private final CustomDataRepository _repository;
|
||||
|
||||
PlayerCustomData(CustomDataRepository repository)
|
||||
{
|
||||
_data = new HashMap<>();
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public Map<CustomData, Integer> getDataMap()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public void setData(CustomData cd, int amount)
|
||||
{
|
||||
_data.put(cd, amount);
|
||||
}
|
||||
|
||||
public void setData(String key, int amount)
|
||||
{
|
||||
if (_repository.doesKeyExist(key))
|
||||
{
|
||||
setData(_repository.getKey(key), amount);
|
||||
return;
|
||||
}
|
||||
|
||||
_repository.getCustomDataManager().runAsync(() ->
|
||||
{
|
||||
_repository.registerKey(key); // Make sure it's in the DB.
|
||||
|
||||
setData(_repository.getKey(key), amount); // Input
|
||||
});
|
||||
}
|
||||
|
||||
public int getData(String key)
|
||||
{
|
||||
if (_data.containsKey(_repository.getKey(key)))
|
||||
{
|
||||
return _data.get(_repository.getKey(key));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,11 @@
|
||||
package mineplex.core.customdata.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.customdata.CustomData;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.customdata.PlayerCustomData;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
@ -25,7 +22,7 @@ public class CustomDataRepository extends RepositoryBase
|
||||
private final CoreClientManager _clientManager;
|
||||
private final CustomDataManager _customDataManager;
|
||||
|
||||
private final List<CustomData> _dataKeys;
|
||||
private final Map<String, Integer> _dataKeys;
|
||||
|
||||
public CustomDataRepository(CoreClientManager clientManager, CustomDataManager customDataManager)
|
||||
{
|
||||
@ -34,7 +31,7 @@ public class CustomDataRepository extends RepositoryBase
|
||||
_clientManager = clientManager;
|
||||
_customDataManager = customDataManager;
|
||||
|
||||
_dataKeys = new ArrayList<>();
|
||||
_dataKeys = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,29 +48,32 @@ public class CustomDataRepository extends RepositoryBase
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
_dataKeys.add(new CustomData(resultSet.getInt("id"), resultSet.getString("name")));
|
||||
_dataKeys.put(resultSet.getString("name"), resultSet.getInt("id"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveData(UUID uuid, int accountId)
|
||||
{
|
||||
PlayerCustomData data = _customDataManager.Get(uuid);
|
||||
Map<String, Integer> data = _customDataManager.Get(uuid);
|
||||
|
||||
for (Map.Entry<CustomData, Integer> entry : data.getDataMap().entrySet())
|
||||
for (String dataKey : data.keySet())
|
||||
{
|
||||
int dataId = _dataKeys.get(dataKey);
|
||||
int dataVal = data.get(dataKey);
|
||||
|
||||
if (executeUpdate(
|
||||
UPDATE_DATA,
|
||||
new ColumnInt("data", entry.getValue()),
|
||||
new ColumnInt("data", dataVal),
|
||||
new ColumnInt("account", accountId),
|
||||
new ColumnInt("customData", entry.getKey().getId())) < 1)
|
||||
new ColumnInt("customData", dataId)) < 1)
|
||||
{
|
||||
// Not already in the DB
|
||||
executeUpdate(
|
||||
INSERT_DATA,
|
||||
new ColumnInt("account", accountId),
|
||||
new ColumnInt("customData", entry.getKey().getId()),
|
||||
new ColumnInt("data", entry.getValue())
|
||||
new ColumnInt("customData", dataId),
|
||||
new ColumnInt("data", dataVal)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class CustomDataRepository extends RepositoryBase
|
||||
|
||||
public void registerKey(String key)
|
||||
{
|
||||
if (doesKeyExist(key))
|
||||
if (_dataKeys.containsKey(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -90,39 +90,13 @@ public class CustomDataRepository extends RepositoryBase
|
||||
downloadDataKeys();
|
||||
}
|
||||
|
||||
public boolean doesKeyExist(String key)
|
||||
public String getKey(int id)
|
||||
{
|
||||
for (CustomData cur : _dataKeys)
|
||||
for (Map.Entry<String, Integer> cur : _dataKeys.entrySet())
|
||||
{
|
||||
if (cur.getKey().equals(key))
|
||||
if (cur.getValue() == id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public CustomData getKey(int id)
|
||||
{
|
||||
for (CustomData cur : _dataKeys)
|
||||
{
|
||||
if (cur.getId() == id)
|
||||
{
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CustomData getKey(String key)
|
||||
{
|
||||
for (CustomData cur : _dataKeys)
|
||||
{
|
||||
if (cur.getKey().equals(key))
|
||||
{
|
||||
return cur;
|
||||
return cur.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,9 +107,4 @@ public class CustomDataRepository extends RepositoryBase
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public CustomDataManager getCustomDataManager()
|
||||
{
|
||||
return _customDataManager;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class BalloonGadget extends Gadget
|
||||
if (active >= MAX_BALLOONS)
|
||||
{
|
||||
Manager.removeActive(player, this);
|
||||
player.sendMessage(F.main(Manager.getName(), "You already have the maximum about of balloons active!"));
|
||||
player.sendMessage(F.main(Manager.getName(), "You already have the maximum amount of balloons active!"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,4 +56,18 @@ public enum GadgetType
|
||||
{
|
||||
return _disableForGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of this category type, without the s at the end,
|
||||
* if it has an s at the end. e.g. "Hats" will return "Hat" instead.
|
||||
*/
|
||||
public String getSingularType()
|
||||
{
|
||||
if (!_name.toLowerCase().endsWith("s"))
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
return _name.substring(0, _name.length() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +189,8 @@ public enum GameDisplay
|
||||
return _lobbyName;
|
||||
}
|
||||
|
||||
public String getCustomDataKeyName() { return "arcade." + _name.toLowerCase().replaceAll(" ", ".") + "."; }
|
||||
|
||||
private static final Map<Integer, GameDisplay> BY_ID;
|
||||
|
||||
static
|
||||
|
@ -271,12 +271,19 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
// Inform
|
||||
UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message);
|
||||
|
||||
if (!_preferences.get(from).isActive(Preference.PRIVATE_MESSAGING))
|
||||
{
|
||||
UtilPlayer.message(from, C.cPurple + to.getName() + " won't be able to reply, because you have private messaging disabled.");
|
||||
UtilPlayer.message(from, C.cPurple + "You can re-enable it in your preferences.");
|
||||
}
|
||||
|
||||
// Save
|
||||
Get(from).LastTo = to.getName();
|
||||
Get(from).LastToTime = System.currentTimeMillis();
|
||||
|
||||
if (GetClientManager().Get(to).getRealOrDisguisedPrimaryGroup() == PermissionGroup.DEV)
|
||||
{
|
||||
UtilPlayer.message(from, "");
|
||||
UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development.");
|
||||
UtilPlayer.message(from, C.cPurple + "Please be patient if they do not reply instantly.");
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Coins!"));
|
||||
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Shards!"));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -25,8 +25,8 @@ public enum RewardType
|
||||
SPRING( 0, 6, 18, 0, 0),
|
||||
MOBA( 0, 5, 20, 30, 0),
|
||||
|
||||
SPINNER_FILLER( 0.1, 1, 4, 20, 30),
|
||||
SPINNER_REAL( 0.000001, 0.05, 0.4, 5, 20);
|
||||
SPINNER_FILLER( 0.1, 1, 5, 20, 28),
|
||||
SPINNER_REAL( 0.000005, 0.15, 1.2, 6, 18);
|
||||
|
||||
private final Rarity[] _rarities;
|
||||
|
||||
|
@ -33,6 +33,11 @@ public class GadgetReward extends Reward
|
||||
}
|
||||
}
|
||||
|
||||
public Gadget getGadget()
|
||||
{
|
||||
return _gadget;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
|
@ -39,6 +39,11 @@ public class TreasureShardReward extends Reward
|
||||
_shardsMax = max;
|
||||
}
|
||||
|
||||
public Reward getOtherReward()
|
||||
{
|
||||
return _otherReward;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
|
@ -130,10 +130,10 @@ public class TeamspeakManager extends MiniClientPlugin<TeamspeakClientInfo> impl
|
||||
private void generatePermissions()
|
||||
{
|
||||
|
||||
PermissionGroup.PLAYER.setPermission(Perm.LINK_COMMAND, true, true);
|
||||
PermissionGroup.PLAYER.setPermission(Perm.LIST_COMMAND, true, true);
|
||||
PermissionGroup.PLAYER.setPermission(Perm.TEAMSPEAK_COMMAND, true, true);
|
||||
PermissionGroup.PLAYER.setPermission(Perm.UNLINK_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.LINK_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.LIST_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.TEAMSPEAK_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.UNLINK_COMMAND, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -167,7 +167,7 @@ public class Teleport extends MiniPlugin
|
||||
PermissionGroup.ADMIN.setPermission(Perm.FIND_MOD_COMMAND, true, true);
|
||||
PermissionGroup.TM.setPermission(Perm.FIND_TRAINEE_COMMAND, false, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.FIND_TRAINEE_COMMAND, true, true);
|
||||
PermissionGroup.MOD.setPermission(Perm.TELEPORT_COMMAND, true, true);
|
||||
PermissionGroup.TRAINEE.setPermission(Perm.TELEPORT_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.TELEPORT_LOCATION_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.TELEPORT_OTHER_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.TELEPORT_ALL_COMMAND, true, true);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.core.treasure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -16,6 +17,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
@ -26,8 +28,12 @@ import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.rewards.GadgetReward;
|
||||
import mineplex.core.reward.rewards.TitleReward;
|
||||
import mineplex.core.reward.rewards.TreasureShardReward;
|
||||
import mineplex.core.treasure.animation.TreasureAnimation;
|
||||
import mineplex.core.treasure.animation.TreasureRewardAnimation;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
@ -109,6 +115,7 @@ public class TreasureSession implements Listener
|
||||
}
|
||||
|
||||
RewardData rewardData = _rewardData.get(_openedChests.size());
|
||||
Reward reward = _rewards.get(_openedChests.size());
|
||||
RewardRarity rarity = rewardData.getRarity();
|
||||
TreasureRewardAnimation rewardAnimation = TreasureRewardAnimation.getAnimationFor(_treasure, _treasureLocation, location.clone().add(0.5, 1, 0.5), rewardData);
|
||||
|
||||
@ -124,7 +131,47 @@ public class TreasureSession implements Listener
|
||||
if (rarity.ordinal() >= RewardRarity.RARE.ordinal())
|
||||
{
|
||||
boolean an = UtilText.startsWithVowel(rewardData.getFriendlyName());
|
||||
Bukkit.broadcastMessage(F.main(_treasureLocation.getManager().getName(), F.name(player.getName()) + " found " + (an ? "an" : "a") + " " + F.name(rarity.getColor() + rarity.getName()) + " " + F.name(rewardData.getFriendlyName()) + "."));
|
||||
|
||||
String message = F.name(player.getName()) + " found " + (an ? "an" : "a") + " " + F.name(rarity.getColor() + rarity.getName()) + " " + F.name(rewardData.getFriendlyName());
|
||||
|
||||
Reward actualReward = reward;
|
||||
String type = null;
|
||||
|
||||
if (reward instanceof TreasureShardReward)
|
||||
{
|
||||
actualReward = ((TreasureShardReward) reward).getOtherReward();
|
||||
}
|
||||
|
||||
// Add reward type to chat where possible
|
||||
if (actualReward instanceof GadgetReward)
|
||||
{
|
||||
GadgetType gadgetType = ((GadgetReward) actualReward).getGadget().getGadgetType();
|
||||
|
||||
// Don't set type if the reward contains the first word in the gadget's singular name.
|
||||
// This will catch "arrow" from "arrow trail", "death" from "death effect", etc.
|
||||
// It's possible this will have some false positives.
|
||||
if (rewardData.getFriendlyName().toLowerCase().contains(gadgetType.getSingularType().toLowerCase().split(" ")[0]))
|
||||
{
|
||||
type = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = gadgetType.getSingularType();
|
||||
}
|
||||
}
|
||||
else if (actualReward instanceof TitleReward)
|
||||
{
|
||||
type = "Title";
|
||||
}
|
||||
|
||||
if (type != null && !rewardData.getFriendlyName().toLowerCase().contains(type.toLowerCase()))
|
||||
{
|
||||
message += C.cGray + " (" + C.cAqua + type + C.cGray + ")";
|
||||
}
|
||||
|
||||
message += C.cGray + ".";
|
||||
|
||||
Bukkit.broadcastMessage(F.main(_treasureLocation.getManager().getName(), message));
|
||||
}
|
||||
|
||||
if (rewardAnimation != null)
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.treasure.reward;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
package mineplex.core.treasure.types;
|
||||
|
||||
import mineplex.core.gadget.gadgets.item.ItemCoinBomb;
|
||||
import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector;
|
||||
import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.treasure.animation.animations.MythicalChestAnimation;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
@ -20,6 +25,15 @@ public class MythicalTreasure extends NormalTreasure
|
||||
enabledByDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addRare(RewardRarity rarity)
|
||||
{
|
||||
super.addRare(rarity);
|
||||
|
||||
// Shard bomb
|
||||
addGadgetReward(getGadget(ItemCoinBomb.class), rarity, 25, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addMythical(RewardRarity rarity)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ import mineplex.core.PacketsInteractionFix;
|
||||
import mineplex.core.TwitchIntegrationFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.admin.command.AdminCommands;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
@ -204,6 +205,8 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
require(TeamspeakManager.class);
|
||||
new WebsiteLinkManager(this, clientManager);
|
||||
require(TwitchIntegrationFix.class);
|
||||
|
||||
new AdminCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,21 +0,0 @@
|
||||
package mineplex.hub.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.customdata.MineplexPlayer;
|
||||
|
||||
public class HubPlayer extends MineplexPlayer
|
||||
{
|
||||
|
||||
HubPlayer(Player player, CustomDataManager customDataManager)
|
||||
{
|
||||
super(player, customDataManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyPrefix()
|
||||
{
|
||||
return "hub.";
|
||||
}
|
||||
}
|
@ -43,8 +43,8 @@ public class CheckOwnsPackageCommand extends CommandBase<CustomerSupport>
|
||||
caller.sendMessage(F.main(Plugin.getName(),
|
||||
"Package "
|
||||
+ C.cYellow + salesPackage
|
||||
+ C.mBody + ": "
|
||||
+ (Plugin.getDonationManager().Get(client.getUniqueId()).ownsUnknownSalesPackage(salesPackage) ? C.cGreen + "Unlocked" : C.cRed + "Locked")
|
||||
+ C.mBody + " unlocked for " + F.name(playerName) + ": "
|
||||
+ (Plugin.getDonationManager().Get(client.getUniqueId()).ownsUnknownSalesPackage(salesPackage) ? C.cGreen + "YES" : C.cRed + "NO")
|
||||
));
|
||||
}
|
||||
else
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
@ -29,6 +30,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -44,6 +46,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.admin.command.AdminCommands;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.blood.Blood;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
@ -137,6 +140,7 @@ import nautilus.game.arcade.command.CancelNextGameCommand;
|
||||
import nautilus.game.arcade.command.GameCommand;
|
||||
import nautilus.game.arcade.command.GoToNextGameCommand;
|
||||
import nautilus.game.arcade.command.KitUnlockCommand;
|
||||
import nautilus.game.arcade.command.ReturnToHubCommand;
|
||||
import nautilus.game.arcade.command.TauntCommand;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
@ -159,14 +163,12 @@ import nautilus.game.arcade.managers.GameStatManager;
|
||||
import nautilus.game.arcade.managers.GameTournamentManager;
|
||||
import nautilus.game.arcade.managers.GameWorldManager;
|
||||
import nautilus.game.arcade.managers.IdleManager;
|
||||
import nautilus.game.arcade.managers.MiscManager;
|
||||
import nautilus.game.arcade.managers.NextBestGameManager;
|
||||
import nautilus.game.arcade.managers.ServerUptimeManager;
|
||||
import nautilus.game.arcade.managers.chat.GameChatManager;
|
||||
import nautilus.game.arcade.managers.lobby.LobbyManager;
|
||||
import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
|
||||
import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager;
|
||||
import nautilus.game.arcade.player.ArcadePlayer;
|
||||
|
||||
public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
@ -184,6 +186,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
JOIN_FULL_STAFF,
|
||||
BYPASS_WHITELIST,
|
||||
BYPASS_MPS_WHITELIST,
|
||||
RETURN_TO_HUB_COMMAND
|
||||
}
|
||||
|
||||
private static final List<String> TOURNAMENT_CONTROLLERS = Arrays.asList("Malfunction", "adeelzee", "gr8p", "HelloItsMeJack", "Aussi", "Jesusman3", "TyTy2017", "KingShook", "Sw1ck", "doodzee", "Chr1mz", "Giovanna", "xApolloJustice", "bawzee", "MessedUpLogic", "dehfi", "Geothermal", "captainfence", "Ecal", "Raydnn", "Otisdiver", "AussieFighter", "snevahmadaa", "eMoa", "Vilare", "xLouis", "PizzaMan319");
|
||||
@ -346,7 +349,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
new GameLootManager(this, petManager);
|
||||
_spectatorManager = new GameSpectatorManager(this);
|
||||
_gameWorldManager = new GameWorldManager(this);
|
||||
new MiscManager(this);
|
||||
_hologramManager = hologramManager;
|
||||
_idleManager = new IdleManager(this);
|
||||
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
||||
@ -398,6 +400,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
addCommand(new GoToNextGameCommand(this));
|
||||
addCommand(new CancelNextGameCommand(this));
|
||||
addCommand(new TauntCommand(this));
|
||||
addCommand(new ReturnToHubCommand(this));
|
||||
|
||||
require(PersonalServerManager.class);
|
||||
require(CommunityManager.class);
|
||||
@ -597,12 +600,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_winStreakManager = require(WinStreakManager.class);
|
||||
_mineplexGameManager = require(MineplexGameManager.class);
|
||||
|
||||
new AdminCommands();
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
|
||||
PermissionGroup.PLAYER.setPermission(Perm.RETURN_TO_HUB_COMMAND, true, true);
|
||||
PermissionGroup.CONTENT.setPermission(Perm.USE_MENU_DURING_GAME, true, true);
|
||||
PermissionGroup.BUILDER.setPermission(Perm.USE_MENU_DURING_GAME, true, true);
|
||||
PermissionGroup.PLAYER.setPermission(Perm.NEXT_BEST_GAME, true, true);
|
||||
@ -1910,11 +1915,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
}
|
||||
|
||||
public ArcadePlayer getArcadePlayer(Player player)
|
||||
{
|
||||
return new ArcadePlayer(player, getCustomDataManager(), this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void clearDisguises(GameStateChangeEvent event)
|
||||
{
|
||||
@ -2003,6 +2003,39 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void InteractActive(PlayerInteractEvent event)
|
||||
{
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void InteractClickCancel(PlayerInteractEvent event)
|
||||
{
|
||||
if (GetGame() == null)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
//BoneMeal
|
||||
if (!GetGame().WorldBoneMeal &&
|
||||
event.getAction() == Action.RIGHT_CLICK_BLOCK &&
|
||||
player.getItemInHand().getType() == Material.INK_SACK &&
|
||||
player.getItemInHand().getData().getData() == (byte)15)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
runSyncLater(player::updateInventory, 1L);
|
||||
}
|
||||
else if (GetGame().GetState() != GameState.Live)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
runSyncLater(player::updateInventory, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public KitProgressionManager getKitProgressionManager()
|
||||
{
|
||||
return _kitProgressionManager;
|
||||
|
@ -1,5 +1,8 @@
|
||||
package nautilus.game.arcade.booster;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.boosters.Booster;
|
||||
@ -30,6 +33,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
*/
|
||||
public class GameBoosterManager extends MiniPlugin
|
||||
{
|
||||
private static final List<String> TESTING_GROUPS = Collections.singletonList("testing");
|
||||
|
||||
private String _boosterGroup;
|
||||
|
||||
private BoosterManager _boosterManager;
|
||||
@ -86,16 +91,21 @@ public class GameBoosterManager extends MiniPlugin
|
||||
|
||||
boolean isTesting = UtilServer.isTestServer();
|
||||
|
||||
boolean canShowGroup = !isTesting && !TESTING_GROUPS.contains(event.getBoosterGroup().toLowerCase());
|
||||
|
||||
// If the booster is for the server the player is currently on
|
||||
if (event.getBoosterGroup().equals(_boosterGroup))
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier for " + booster.getMultiplier() + "x Shards!"));
|
||||
}
|
||||
else if (!isTesting)
|
||||
// If this is not currently a test server and the booster group is not blacklisted from
|
||||
// displaying on non-test servers
|
||||
else if (canShowGroup)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Amplifier", F.name(booster.getPlayerName()) + " has activated a Game Amplifier on " + F.elem(event.getBoosterGroup().replaceAll("_", " ")) + "!"));
|
||||
}
|
||||
|
||||
if (event.getBoosterGroup().equals(_boosterGroup) || !isTesting)
|
||||
if (event.getBoosterGroup().equals(_boosterGroup) || canShowGroup)
|
||||
{
|
||||
JsonMessage message = new JsonMessage(F.main("Amplifier", F.elem("Click here") + " to thank them and get " + F.currency(GlobalCurrency.TREASURE_SHARD, BoosterThankManager.TIP_FOR_TIPPER) + "!"));
|
||||
message.click(ClickEvent.RUN_COMMAND, "/amplifier thank " + event.getBoosterGroup());
|
||||
|
@ -12,7 +12,7 @@ public class GoToNextGameCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
public GoToNextGameCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, ArcadeManager.Perm.NEXT_BEST_GAME, "gotonextbestgame");
|
||||
super(plugin, ArcadeManager.Perm.NEXT_BEST_GAME, "gotonextbestgame", "nextgame", "nbg");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,24 @@
|
||||
package nautilus.game.arcade.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.portal.GenericServer;
|
||||
import mineplex.core.portal.Intent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
public class ReturnToHubCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
public ReturnToHubCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, ArcadeManager.Perm.RETURN_TO_HUB_COMMAND, "hub", "lobby", "leave", "takemebacktoparadisecity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.GetPortal().sendPlayerToGenericServer(caller, GenericServer.HUB, Intent.PLAYER_REQUEST);
|
||||
}
|
||||
}
|
@ -99,6 +99,7 @@ import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
|
||||
import nautilus.game.arcade.game.modules.HubClockModule;
|
||||
import nautilus.game.arcade.game.modules.Module;
|
||||
import nautilus.game.arcade.game.modules.gamesummary.GameSummaryModule;
|
||||
import nautilus.game.arcade.kit.ChampionsKit;
|
||||
@ -520,6 +521,12 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
new GameSummaryModule()
|
||||
.register(this);
|
||||
|
||||
if (getArcadeManager().IsHotbarHubClock())
|
||||
{
|
||||
new HubClockModule()
|
||||
.register(this);
|
||||
}
|
||||
|
||||
registerDebugCommand("kit", Perm.DEBUG_KIT_COMMAND, PermissionGroup.ADMIN, (caller, args) ->
|
||||
{
|
||||
String kit = Arrays.stream(args).collect(Collectors.joining(" "));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.game.games.baconbrawl;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
@ -58,6 +59,8 @@ public class BaconBrawl extends SoloGame
|
||||
.register(this);
|
||||
|
||||
StrictAntiHack = true;
|
||||
|
||||
PlayerGameMode = GameMode.ADVENTURE;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -28,6 +28,7 @@ import nautilus.game.arcade.stats.ComeAtMeBroStatTracker;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
@ -83,6 +84,8 @@ public class DeathTag extends SoloGame
|
||||
|
||||
this.PrepareFreeze = false;
|
||||
|
||||
this.PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
SplitKitXP = true;
|
||||
|
||||
registerStatTrackers(new ComeAtMeBroStatTracker(this));
|
||||
|
@ -30,6 +30,8 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -241,7 +243,7 @@ public class DragonEscape extends SoloGame
|
||||
@EventHandler
|
||||
public void Invisibility(PlayerKitGiveEvent event)
|
||||
{
|
||||
Manager.GetCondition().Factory().Invisible(GetName(), event.getPlayer(), event.getPlayer(), 40, 0, false, false, false);
|
||||
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -3,8 +3,10 @@ package nautilus.game.arcade.game.games.dragons;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
@ -72,6 +74,7 @@ public class Dragons extends SoloGame
|
||||
this.DamagePvP = false;
|
||||
this.HungerSet = 20;
|
||||
this.WorldWaterDamage = 4;
|
||||
this.PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
registerStatTrackers(
|
||||
new SparklezStatTracker(this)
|
||||
@ -139,17 +142,33 @@ public class Dragons extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Death(PlayerStateChangeEvent event)
|
||||
private void giveSurvivedGems(Player player)
|
||||
{
|
||||
if (event.GetState() != PlayerState.OUT)
|
||||
return;
|
||||
|
||||
long time = (System.currentTimeMillis() - GetStateTime());
|
||||
double gems = time/10000d;
|
||||
String reason = "Survived for " + UtilTime.MakeStr(time);
|
||||
|
||||
this.AddGems(event.GetPlayer(), gems, reason, false, false);
|
||||
this.AddGems(player, gems, reason, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AnnounceEnd(List<Player> places)
|
||||
{
|
||||
// Give the winner gems for surviving the latest
|
||||
giveSurvivedGems(places.get(0));
|
||||
|
||||
super.AnnounceEnd(places);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Death(PlayerStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != PlayerState.OUT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
giveSurvivedGems(event.GetPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.dragons;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
@ -120,17 +121,33 @@ public class DragonsTeams extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Death(PlayerStateChangeEvent event)
|
||||
private void giveSurvivedGems(Player player)
|
||||
{
|
||||
if (event.GetState() != PlayerState.OUT)
|
||||
return;
|
||||
|
||||
long time = (System.currentTimeMillis() - GetStateTime());
|
||||
double gems = time/10000d;
|
||||
String reason = "Survived for " + UtilTime.MakeStr(time);
|
||||
|
||||
this.AddGems(event.GetPlayer(), gems, reason, false, false);
|
||||
this.AddGems(player, gems, reason, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AnnounceEnd(List<Player> places)
|
||||
{
|
||||
// Give the winner gems for surviving the latest
|
||||
giveSurvivedGems(places.get(0));
|
||||
|
||||
super.AnnounceEnd(places);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Death(PlayerStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != PlayerState.OUT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
giveSurvivedGems(event.GetPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -143,7 +143,7 @@ public class Draw extends SoloGame
|
||||
"Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish",
|
||||
"Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl",
|
||||
"Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti",
|
||||
"Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel",
|
||||
"Couch", "Family", "Milk", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel",
|
||||
"Cheese", "Beans", "Water", "Chicken", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster",
|
||||
"Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone",
|
||||
"Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate",
|
||||
@ -244,7 +244,7 @@ public class Draw extends SoloGame
|
||||
"Goblin", "Potion", "Treat", "Trick"
|
||||
};
|
||||
|
||||
_tools = new HashSet<Tool>();
|
||||
_tools = new HashSet<>();
|
||||
_tools.add(new ToolLine(this));
|
||||
_tools.add(new ToolSquare(this));
|
||||
_tools.add(new ToolCircle(this));
|
||||
|
@ -12,6 +12,7 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -96,6 +97,8 @@ public class Gladiators extends SoloGame
|
||||
},
|
||||
GameType.Gladiators);
|
||||
|
||||
this.PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
registerStatTrackers(
|
||||
new BrawlerTracker(this),
|
||||
new UntouchableTracker(this),
|
||||
|
@ -27,6 +27,7 @@ import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -39,6 +40,7 @@ import nautilus.game.arcade.game.modules.Module;
|
||||
*/
|
||||
public class HotbarEditor extends Module
|
||||
{
|
||||
public static final String HOTBAR_DATA_KEY = GameDisplay.Gladiators.getCustomDataKeyName() + "hotbar";
|
||||
|
||||
private final ItemStack _item;
|
||||
private final Listener _pageListener;
|
||||
@ -103,6 +105,8 @@ public class HotbarEditor extends Module
|
||||
{
|
||||
if (event.GetState() == Game.GameState.Recruit)
|
||||
{
|
||||
getGame().getArcadeManager().getCustomDataManager().getRepository().registerKey(HOTBAR_DATA_KEY);
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
player.getInventory().setItem(0, _item);
|
||||
@ -139,7 +143,7 @@ public class HotbarEditor extends Module
|
||||
|
||||
public HotbarLayout getLayout(Player player)
|
||||
{
|
||||
int data = getGame().Manager.getArcadePlayer(player).get("hotbar");
|
||||
int data = getGame().Manager.getCustomDataManager().getData(player, HOTBAR_DATA_KEY);
|
||||
data = (data == -1 ? 1239 : data);
|
||||
|
||||
List<Integer> ints = new ArrayList<>();
|
||||
@ -193,7 +197,8 @@ public class HotbarEditor extends Module
|
||||
save.setRod(save.getEmpty());
|
||||
}
|
||||
|
||||
getGame().Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber(), true);
|
||||
getGame().Manager.getCustomDataManager().Get(player).put(HOTBAR_DATA_KEY, save.toDataSaveNumber());
|
||||
getGame().Manager.getCustomDataManager().saveData(player);
|
||||
player.sendMessage(F.main("Game", "Saved new hotbar layout!"));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
||||
@ -41,6 +42,7 @@ import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -89,8 +91,8 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
@ -373,11 +375,27 @@ public class HideSeek extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerPrepareTeleportEvent event)
|
||||
public void onceReady(GamePrepareCountdownCommence event)
|
||||
{
|
||||
if (_hiders.GetPlayers(false).contains(event.GetPlayer()))
|
||||
List<Player> hiders = _hiders.GetPlayers(false);
|
||||
|
||||
for (Player player : hiders)
|
||||
{
|
||||
event.GetPlayer().setGameMode(GameMode.ADVENTURE);
|
||||
// Apply Adventure Mode
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
|
||||
// Put initial forms in the map
|
||||
Kit kit = GetKit(player);
|
||||
if (!(kit instanceof KitHiderInfestor))
|
||||
{
|
||||
Form form = new BlockForm(this, player, _allowedBlocks.get(UtilMath.r(_allowedBlocks.size())));
|
||||
|
||||
_forms.put(player, form);
|
||||
|
||||
form.Apply();
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new PlayerChangeFormEvent(player, form));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,29 +552,14 @@ public class HideSeek extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InitialDisguise(PlayerPrepareTeleportEvent event)
|
||||
{
|
||||
if (_hiders.HasPlayer(event.GetPlayer().getName(), true))
|
||||
{
|
||||
GameTeam team = GetTeam(event.GetPlayer());
|
||||
Kit kit = GetKit(event.GetPlayer());
|
||||
if (team.GetColor() == ChatColor.AQUA && !(kit instanceof KitHiderInfestor))
|
||||
{
|
||||
Form form = new BlockForm(this, event.GetPlayer(), _allowedBlocks.get(UtilMath.r(_allowedBlocks.size())));
|
||||
|
||||
_forms.put(event.GetPlayer(), form);
|
||||
|
||||
form.Apply();
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new PlayerChangeFormEvent(event.GetPlayer(), form));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ChangeDisguise(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getAction() == Action.PHYSICAL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getClickedBlock() == null)
|
||||
return;
|
||||
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -203,6 +204,9 @@ public class ShopManager
|
||||
if (_disabled)
|
||||
return;
|
||||
|
||||
if (!(event.getClickedInventory() instanceof PlayerInventory))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Player player = UtilPlayer.searchExact(event.getWhoClicked().getName());
|
||||
@ -219,7 +223,7 @@ public class ShopManager
|
||||
if (!_shop.get(player).containsKey(event.getSlot()))
|
||||
return;
|
||||
|
||||
//Prevent accidently buying multi
|
||||
//Prevent accidentally buying multi
|
||||
if (!Recharge.Instance.use(player, "Shop Purchase", 120, false, false))
|
||||
return;
|
||||
|
||||
|
@ -64,6 +64,7 @@ import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTextTop;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
@ -1125,6 +1126,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
if (player.equals(other))
|
||||
continue;
|
||||
|
||||
// Allow staff members to go near players while vanished
|
||||
if (getArcadeManager().isVanished(player) && getArcadeManager().GetClients().Get(player).hasPermission(IncognitoManager.Perm.USE_INCOGNITO))
|
||||
continue;
|
||||
|
||||
if (UtilMath.offset(other, player) >= SPECTATOR_KNOCKBACK_RADIUS)
|
||||
continue;
|
||||
|
||||
|
@ -109,6 +109,8 @@ public class Paintball extends TeamGame
|
||||
|
||||
InventoryClick = false;
|
||||
|
||||
PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
registerStatTrackers(
|
||||
new KillingSpreeTracker(this),
|
||||
new WinWithoutLosingTeammateStatTracker(this, "FlawlessVictory"),
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Arrow;
|
||||
@ -47,7 +48,7 @@ import nautilus.game.arcade.stats.WinWithoutDyingStatTracker;
|
||||
public class Quiver extends SoloGame
|
||||
{
|
||||
private ArrayList<QuiverScore> _ranks = new ArrayList<QuiverScore>();
|
||||
private HashMap<Player, Integer> _combo = new HashMap<Player, Integer>();
|
||||
private HashMap<Player, Integer> _combo = new HashMap<>();
|
||||
private HashMap<Player, Integer> _bestCombo = new HashMap<Player, Integer>();
|
||||
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
|
||||
|
||||
@ -73,6 +74,8 @@ public class Quiver extends SoloGame
|
||||
// new KitNecromancer(manager),
|
||||
}, GameType.Quiver);
|
||||
|
||||
this.PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
registerStatTrackers(
|
||||
new WinWithoutDyingStatTracker(this, "Perfectionist"),
|
||||
new SharpShooterStatTracker(this),
|
||||
@ -205,6 +208,18 @@ public class Quiver extends SoloGame
|
||||
AddKill(player);
|
||||
}
|
||||
|
||||
private void updateBestCombo(Player player)
|
||||
{
|
||||
int combo = _combo.get(player);
|
||||
|
||||
int best = 0;
|
||||
if (_bestCombo.containsKey(player))
|
||||
best = _bestCombo.get(player);
|
||||
|
||||
if (combo > best)
|
||||
_bestCombo.put(player, combo);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ComboReset(CombatDeathEvent event)
|
||||
{
|
||||
@ -216,14 +231,8 @@ public class Quiver extends SoloGame
|
||||
if (!_combo.containsKey(player))
|
||||
return;
|
||||
|
||||
int combo = _combo.remove(player);
|
||||
|
||||
int best = 0;
|
||||
if (_bestCombo.containsKey(player))
|
||||
best = _bestCombo.get(player);
|
||||
|
||||
if (combo > best)
|
||||
_bestCombo.put(player, combo);
|
||||
updateBestCombo(player);
|
||||
_combo.remove(player);
|
||||
}
|
||||
|
||||
public void AddKill(Player player)
|
||||
@ -234,6 +243,7 @@ public class Quiver extends SoloGame
|
||||
combo += _combo.get(player);
|
||||
|
||||
_combo.put(player, combo);
|
||||
updateBestCombo(player);
|
||||
|
||||
AnnounceCombo(player, combo);
|
||||
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.Color;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -182,6 +183,8 @@ public class SheepGame extends TeamGame
|
||||
|
||||
this.WorldTimeSet = 2000;
|
||||
|
||||
this.PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
.setGiveCompassToSpecs(true)
|
||||
|
@ -24,6 +24,7 @@ import nautilus.game.arcade.stats.RevealStatTracker;
|
||||
import nautilus.game.arcade.stats.TheMastersMasterStatTracker;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
@ -83,6 +84,8 @@ public class SneakyAssassins extends SoloGame
|
||||
|
||||
this.AllowParticles = false;
|
||||
|
||||
this.PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompassToAlive(true)
|
||||
.setGiveCompass(false)
|
||||
|
@ -0,0 +1,104 @@
|
||||
package nautilus.game.arcade.game.modules;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.portal.GenericServer;
|
||||
import mineplex.core.portal.Intent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.managers.GameSpectatorManager;
|
||||
|
||||
public class HubClockModule extends Module
|
||||
{
|
||||
private static final int HUB_CLOCK_SLOT = 8;
|
||||
private static final ItemStack HUB_CLOCK_ITEM = ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte) 0, 1, (short) 0, C.cGreen
|
||||
+ "Return to Hub", new String[]{"", ChatColor.RESET + "Click while holding this",
|
||||
ChatColor.RESET + "to return to the Hub."});
|
||||
|
||||
public void giveClock(Player player)
|
||||
{
|
||||
if (!getGame().GiveClock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.getInventory().setItem(HUB_CLOCK_SLOT, HUB_CLOCK_ITEM);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveOnJoin(PlayerJoinEvent event)
|
||||
{
|
||||
giveClock(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveOnDeath(PlayerStateChangeEvent event)
|
||||
{
|
||||
// Only handle when the player is now out
|
||||
if (event.GetState() != GameTeam.PlayerState.OUT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getGame().getArcadeManager().runSyncLater(() -> giveClock(event.GetPlayer()), GameSpectatorManager.ITEM_GIVE_DELAY);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventDrop(PlayerDropItemEvent event)
|
||||
{
|
||||
if (event.getItemDrop().getItemStack().equals(HUB_CLOCK_ITEM))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(F.main("Game", "You can't drop the Hub Clock."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleClockInteract(PlayerInteractEvent event)
|
||||
{
|
||||
// Don't trigger the clock when players walk on pressure plates
|
||||
if (event.getAction() == Action.PHYSICAL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.getItemInHand() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only allow this exact clock to be used.
|
||||
if (!player.getItemInHand().equals(HUB_CLOCK_ITEM))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't allow spamming so we don't make too many send requests
|
||||
if (!Recharge.Instance.usable(event.getPlayer(), "Return to Hub"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Send to server
|
||||
getGame()
|
||||
.getArcadeManager()
|
||||
.GetPortal()
|
||||
.sendPlayerToGenericServer(event.getPlayer(), GenericServer.HUB, Intent.PLAYER_REQUEST);
|
||||
}
|
||||
}
|
@ -607,7 +607,7 @@ public class GameHostManager implements Listener
|
||||
if (_host == null)
|
||||
return;
|
||||
|
||||
if (!event.getMessage().toLowerCase().startsWith("/whitelist"))
|
||||
if (!event.getMessage().toLowerCase().startsWith("/whitelist") && !event.getMessage().toLowerCase().startsWith("/wl"))
|
||||
return;
|
||||
|
||||
if (!event.getPlayer().equals(_host))
|
||||
@ -643,12 +643,8 @@ public class GameHostManager implements Listener
|
||||
{
|
||||
return PermissionGroup.ETERNAL.hasPermission(permission);
|
||||
}
|
||||
if (_hostRank == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _hostRank.hasPermission(permission);
|
||||
return _hostRank != null && _hostRank.hasPermission(permission);
|
||||
}
|
||||
|
||||
public List<GameType> getGames()
|
||||
|
@ -46,6 +46,10 @@ import java.util.UUID;
|
||||
|
||||
public class GameSpectatorManager implements Listener, IPacketHandler
|
||||
{
|
||||
// Common delay for giving items when a spectator dies,
|
||||
// to prevent them from accidentally switching servers.
|
||||
public final static long ITEM_GIVE_DELAY = 3 * 20L;
|
||||
|
||||
// A map of a player UUID to the UUID of the entity they want to spectate
|
||||
private final Map<UUID, UUID> _pendingSpectate = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
|
@ -1,161 +0,0 @@
|
||||
package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.portal.GenericServer;
|
||||
import mineplex.core.portal.Intent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class MiscManager implements Listener
|
||||
{
|
||||
private List<String> _dontGiveClockList = new ArrayList<String>();
|
||||
private ArcadeManager Manager;
|
||||
|
||||
public MiscManager(ArcadeManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
|
||||
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void InteractActive(PlayerInteractEvent event)
|
||||
{
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void InteractClickCancel(PlayerInteractEvent event)
|
||||
{
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
//BoneMeal
|
||||
if (!Manager.GetGame().WorldBoneMeal &&
|
||||
event.getAction() == Action.RIGHT_CLICK_BLOCK &&
|
||||
event.getPlayer().getItemInHand().getType() == Material.INK_SACK &&
|
||||
event.getPlayer().getItemInHand().getData().getData() == (byte)15)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
Manager.runSyncLater(() ->
|
||||
{
|
||||
event.getPlayer().updateInventory();
|
||||
}, 1L);
|
||||
}
|
||||
else if (Manager.GetGame().GetState() != GameState.Live)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
Manager.runSyncLater(() ->
|
||||
{
|
||||
event.getPlayer().updateInventory();
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void addClockPrevent(InventoryOpenEvent event)
|
||||
{
|
||||
if (event.getPlayer() instanceof Player)
|
||||
{
|
||||
_dontGiveClockList.add(event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void removeClockPrevent(InventoryCloseEvent event)
|
||||
{
|
||||
if (event.getPlayer() instanceof Player)
|
||||
{
|
||||
_dontGiveClockList.remove(event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void HubClockUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!Manager.IsHotbarHubClock())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (Manager.GetGame().IsAlive(player))
|
||||
continue;
|
||||
|
||||
if (_dontGiveClockList.contains(player.getName()))
|
||||
continue;
|
||||
|
||||
Manager.HubClock(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void HubClockInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (!Manager.IsHotbarHubClock())
|
||||
return;
|
||||
|
||||
if (event.getAction() == Action.PHYSICAL)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.getItemInHand() == null)
|
||||
return;
|
||||
|
||||
if (player.getItemInHand().getType() != Material.WATCH)
|
||||
return;
|
||||
|
||||
// Prevent players from hub warping off clock in Master Builders
|
||||
if (!player.getItemInHand().hasItemMeta())
|
||||
return;
|
||||
if (!player.getItemInHand().getItemMeta().hasDisplayName())
|
||||
return;
|
||||
String displayName = player.getItemInHand().getItemMeta().getDisplayName();
|
||||
if (displayName == null || !displayName.contains("Hub"))
|
||||
return;
|
||||
|
||||
if (!Recharge.Instance.usable(event.getPlayer(), "Return to Hub"))
|
||||
return;
|
||||
|
||||
Manager.GetPortal().sendPlayerToGenericServer(event.getPlayer(), GenericServer.HUB, Intent.PLAYER_REQUEST);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void HubCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().toLowerCase().equals("/lobby") || event.getMessage().toLowerCase().equals("/hub") || event.getMessage().toLowerCase().equals("/leave"))
|
||||
{
|
||||
Manager.GetPortal().sendPlayerToGenericServer(event.getPlayer(), GenericServer.HUB, Intent.PLAYER_REQUEST);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -287,7 +287,7 @@ public class NextBestGameManager implements Listener
|
||||
|
||||
_tasks.put(player.getUniqueId(), new CountdownRunnable(player));
|
||||
|
||||
player.getInventory().setItem(INVENTORY_SLOT, CANCEL_ITEM);
|
||||
giveItem(player);
|
||||
|
||||
sendMessage(player, true);
|
||||
|
||||
@ -298,7 +298,7 @@ public class NextBestGameManager implements Listener
|
||||
{
|
||||
sendMessage(player, false);
|
||||
|
||||
player.getInventory().setItem(INVENTORY_SLOT, GO_TO_NEXT_ITEM);
|
||||
getGame().getArcadeManager().runSyncLater(() -> giveItem(player), GameSpectatorManager.ITEM_GIVE_DELAY);
|
||||
}
|
||||
|
||||
player.sendMessage(" ");
|
||||
@ -324,7 +324,7 @@ public class NextBestGameManager implements Listener
|
||||
|
||||
Player owner = Bukkit.getPlayer(party.getOwnerName());
|
||||
owner.sendMessage(F.main("Game", "All party members are dead!"));
|
||||
if (_partyManager.getPreferencesManager().get(player).isActive(Preference.AUTO_JOIN_NEXT_GAME))
|
||||
if (_partyManager.getPreferencesManager().get(owner).isActive(Preference.AUTO_JOIN_NEXT_GAME))
|
||||
{
|
||||
|
||||
owner.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
|
||||
@ -332,7 +332,7 @@ public class NextBestGameManager implements Listener
|
||||
owner.sendMessage(" ");
|
||||
owner.sendMessage(" ");
|
||||
|
||||
if (!_partyManager.getPreferencesManager().get(player).isActive(Preference.DISABLE_WARNING))
|
||||
if (!_partyManager.getPreferencesManager().get(owner).isActive(Preference.DISABLE_WARNING))
|
||||
{
|
||||
sendWarning(owner);
|
||||
owner.sendMessage(" ");
|
||||
@ -354,7 +354,7 @@ public class NextBestGameManager implements Listener
|
||||
owner.sendMessage(" ");
|
||||
owner.sendMessage(" ");
|
||||
|
||||
owner.getInventory().setItem(INVENTORY_SLOT, GO_TO_NEXT_ITEM);
|
||||
giveItem(owner);
|
||||
owner.updateInventory();
|
||||
}
|
||||
}
|
||||
@ -424,7 +424,7 @@ public class NextBestGameManager implements Listener
|
||||
if (_partyManager.getPreferencesManager().get(owner).isActive(Preference.COUNTDOWN_ON_CLICK))
|
||||
{
|
||||
_tasks.put(player.getUniqueId(), new CountdownRunnable(owner));
|
||||
player.getInventory().setItem(INVENTORY_SLOT, CANCEL_ITEM);
|
||||
giveItem(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -444,12 +444,11 @@ public class NextBestGameManager implements Listener
|
||||
if (_partyManager.getPreferencesManager().get(player).isActive(Preference.COUNTDOWN_ON_CLICK))
|
||||
{
|
||||
_tasks.put(player.getUniqueId(), new CountdownRunnable(player));
|
||||
player.getInventory().setItem(INVENTORY_SLOT, CANCEL_ITEM);
|
||||
giveItem(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
MinecraftServer server = findBestGame(_partyManager.getClientManager().Get(player.getUniqueId()).hasPermission(ArcadeManager.Perm.JOIN_FULL), null);
|
||||
player.getInventory().clear();
|
||||
sendToServer(player, server);
|
||||
}
|
||||
}
|
||||
@ -578,6 +577,16 @@ public class NextBestGameManager implements Listener
|
||||
_game = game;
|
||||
}
|
||||
|
||||
private void giveItem(Player player)
|
||||
{
|
||||
if (getGame().IsAlive(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.getInventory().setItem(INVENTORY_SLOT, GO_TO_NEXT_ITEM);
|
||||
}
|
||||
|
||||
private int getCountdown(String motd)
|
||||
{
|
||||
int countdown;
|
||||
@ -633,18 +642,20 @@ public class NextBestGameManager implements Listener
|
||||
|
||||
if (party != null)
|
||||
{
|
||||
party.getMembers().forEach(player1 ->
|
||||
party.getMembers().forEach(partyMember ->
|
||||
{
|
||||
player1.sendMessage(F.main("Game", "Cancelled sending your party to a new game!"));
|
||||
player1.playSound(player.getLocation(), Sound.ANVIL_BREAK, 1.0F, 1.0F);
|
||||
player1.getInventory().setItem(INVENTORY_SLOT, GO_TO_NEXT_ITEM);
|
||||
partyMember.sendMessage(F.main("Game", "Cancelled sending your party to a new game!"));
|
||||
partyMember.playSound(player.getLocation(), Sound.ANVIL_BREAK, 1.0F, 1.0F);
|
||||
|
||||
giveItem(partyMember);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_BREAK, 1.0F, 1.0F);
|
||||
player.getInventory().setItem(INVENTORY_SLOT, GO_TO_NEXT_ITEM);
|
||||
player.sendMessage(F.main("Game", "Cancelled sending you to a new game!"));
|
||||
|
||||
giveItem(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
package nautilus.game.arcade.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.customdata.MineplexPlayer;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public class ArcadePlayer extends MineplexPlayer
|
||||
{
|
||||
private ArcadeManager _arcadeManager;
|
||||
|
||||
public ArcadePlayer(Player player, CustomDataManager customDataManager, ArcadeManager arcadeManager)
|
||||
{
|
||||
super(player, customDataManager);
|
||||
|
||||
_arcadeManager = arcadeManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyPrefix()
|
||||
{
|
||||
return "arcade." + _arcadeManager.GetGame().GetName().toLowerCase().replaceAll(" ", ".") + ".";
|
||||
}
|
||||
}
|
@ -418,6 +418,16 @@
|
||||
return PunishmentResponse.PunishmentRemoved;
|
||||
}
|
||||
|
||||
public List<Punishment> GetAdminPunishments(String adminName)
|
||||
{
|
||||
String lowerName = adminName.ToLower();
|
||||
|
||||
using (var repository = _repositoryFactory.CreateRepository())
|
||||
{
|
||||
return repository.Where<Punishment>(p => p.Admin.ToLower() == lowerName).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public string PurchaseGameSalesPackage(PurchaseToken token)
|
||||
{
|
||||
try
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
PunishmentResponse Punish(PunishToken punish);
|
||||
PunishmentResponse RemovePunishment(RemovePunishmentToken ban);
|
||||
List<Punishment> GetAdminPunishments(String adminName);
|
||||
|
||||
string PurchaseGameSalesPackage(PurchaseToken token);
|
||||
bool AccountExists(string name);
|
||||
|
@ -192,5 +192,12 @@
|
||||
var json = JsonConvert.SerializeObject(new ClientToken(_accountAdministrator.GetAccountByName(name)));
|
||||
return Content(json, "application/json");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult GetAdminPunishments(string name)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(_accountAdministrator.GetAdminPunishments(name));
|
||||
return Content(json, "application/json");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@ -15,6 +16,12 @@
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>4.0</OldToolsVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -366,8 +373,13 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Forums\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
@ -1,6 +1,15 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2036
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2613EC6-7E43-4245-81FD-A6E9E190B481}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Local.testsettings = Local.testsettings
|
||||
LOCWebsite.vsmdi = LOCWebsite.vsmdi
|
||||
TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LOC.Core", "LOC.Core\LOC.Core.csproj", "{A994B28E-8AAA-4A53-BDFE-0E72F1B0F4AD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LOC.Website.Common", "LOC.Website.Common\LOC.Website.Common.csproj", "{B112BCCF-A0E9-497C-9821-FF408F1D0A76}"
|
||||
@ -12,17 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LOC.Website.Web", "LOC.Webs
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LOC.Website.Tests", "LOC.Website.Tests\LOC.Website.Tests.csproj", "{5A4544F8-662F-4D5B-B3CB-B9B3994A0C0D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2613EC6-7E43-4245-81FD-A6E9E190B481}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Local.testsettings = Local.testsettings
|
||||
LOCWebsite.vsmdi = LOCWebsite.vsmdi
|
||||
TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = LOCWebsite.vsmdi
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
@ -76,4 +75,10 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {063F27CF-4D1F-4218-BFDA-EC35028C7560}
|
||||
EndGlobalSection
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = LOCWebsite.vsmdi
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
Loading…
Reference in New Issue
Block a user