Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b217edeadf | ||
|
|
aa4ad384c1 | ||
|
|
8021024b48 | ||
|
|
d3f246d048 | ||
|
|
9c2dfcab06 | ||
|
|
8b4224a034 | ||
|
|
61bf0007c1 | ||
|
|
151559c50e | ||
|
|
2dccf6e790 | ||
|
|
bc510b1ba0 | ||
|
|
0253d86b8d | ||
|
|
59cd31a6c8 | ||
|
|
068b24bd39 | ||
|
|
7f06797f5f | ||
|
|
3e2bdf4772 | ||
|
|
3b049299b1 | ||
|
|
05670bebeb | ||
|
|
81f73590a6 | ||
|
|
163e4cdadb | ||
|
|
512c02e501 | ||
|
|
25ef8ba315 | ||
|
|
8966feb35a | ||
|
|
0d29be48c7 | ||
|
|
bc2827659d | ||
|
|
0a72247a5d | ||
|
|
a102ec3566 | ||
|
|
f91b02d572 | ||
|
|
0f00741151 | ||
|
|
922302082f | ||
|
|
24e1fbb6e5 | ||
|
|
3026a2d48f | ||
|
|
58101bfea0 | ||
|
|
0a9e46ee85 | ||
|
|
fd67e45c58 | ||
|
|
b6af6de2df | ||
|
|
173051829e | ||
|
|
8a9ef4811f | ||
|
|
4fd6d580b1 | ||
|
|
415970101c | ||
|
|
668dcdd8b4 | ||
|
|
bf24533b54 | ||
|
|
b2daada576 | ||
|
|
9dd2c58134 | ||
|
|
7674c68bc7 | ||
|
|
0b3b0b29f5 | ||
|
|
60370a1a83 | ||
|
|
3bf273e854 | ||
|
|
a8e53c9b62 | ||
|
|
3015cd9604 | ||
|
|
839119e0a9 | ||
|
|
409a0665cc | ||
|
|
0549fe9c21 | ||
|
|
f047bb6176 | ||
|
|
ad04b7e966 | ||
|
|
2591cbf029 | ||
|
|
8213e07c74 | ||
|
|
972f9581e3 | ||
|
|
2e17b3defd | ||
|
|
76dbfb8fdf |
No files matched your search
@@ -11,7 +11,6 @@
|
||||
###########################################
|
||||
# Valid Options:
|
||||
# - SQLITE
|
||||
# - FLAT
|
||||
# - MYSQL
|
||||
DataStorage: SQLITE
|
||||
|
||||
@@ -297,6 +296,7 @@ Format:
|
||||
# Shop messages when using the /vote shop
|
||||
ShopPurchase: '&aYou bought the %Identifier% for %Points% Points!'
|
||||
ShopFailed: '&cYou do not have %Points% points to purchase this!'
|
||||
ShopNotPurchasable: '&cThis item is not buyable!'
|
||||
|
||||
# User not exist message, from commands such as /vote next (player)
|
||||
UserNotExist: '&cUser does not exist: %player%'
|
||||
@@ -433,6 +433,15 @@ CachedPlaceholders: []
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
|
||||
# Custom placeholder returns
|
||||
# For the example below use %votingplugin_custom_enoughpoints_5%
|
||||
# DO NOT USE ON MAIN THREAD IF POSSIBLE
|
||||
# Keep everything lowercase
|
||||
#CustomPlaceholderReturns:
|
||||
# 'enoughpoints_5':
|
||||
# 'true': 'User has enough points'
|
||||
# 'false': 'User does not have enough points'
|
||||
|
||||
###########################################
|
||||
# Login options
|
||||
###########################################
|
||||
@@ -637,11 +646,6 @@ DelayBetweenUpdates: 3
|
||||
# Recommend leaving this to false
|
||||
ExtraBackgroundUpdate: false
|
||||
|
||||
# Limit number of users to load in a second
|
||||
# Effects background tasks mainly
|
||||
# set to -1 to disable (default value)
|
||||
#PlayerDataLoadLimit: 500
|
||||
|
||||
##########################################
|
||||
# Inventory controls
|
||||
##########################################
|
||||
@@ -671,6 +675,10 @@ AlwaysCloseInventory: false
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# This will close GUI's if you shift click them rather than a regular
|
||||
# This can help prevent exploits
|
||||
CloseGUIOnShiftClick: false
|
||||
|
||||
###########################################
|
||||
# Purge settings
|
||||
###########################################
|
||||
|
||||
@@ -143,6 +143,10 @@ CHEST:
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
# Extra customization for displaying site names in GUI only
|
||||
#CustomSiteNamesDisplays:
|
||||
# Site1: site name display
|
||||
LoreLine: '%time%'
|
||||
VoteToday:
|
||||
Name: 'VoteToday'
|
||||
Line: '&6%VoteSite% : %Time%'
|
||||
@@ -162,11 +166,17 @@ CHEST:
|
||||
Lore: '&3&lVotes: &3%votes%'
|
||||
# Opens main GUI of the specific player that gets clicked
|
||||
OpenMainGUIOnClick: true
|
||||
# Close GUI when clicking on a player item
|
||||
CloseGUIOnClick: true
|
||||
SwitchItem:
|
||||
Name: '&3Switch TopVoter'
|
||||
Lore: '&bCurrently: %Top%'
|
||||
Material: 'OAK_SIGN'
|
||||
Amount: 1
|
||||
# Top voters for the switch item to use
|
||||
#TopVoters:
|
||||
#- ALLTIME
|
||||
#- MONTHLY
|
||||
# 8 Slots over from the bottom left
|
||||
# Bottom of GUI
|
||||
Slot: 7
|
||||
@@ -177,6 +187,15 @@ CHEST:
|
||||
# Item for player in GUI if use skull is false
|
||||
PlayerItem:
|
||||
Material: 'PAPER'
|
||||
Customization:
|
||||
Enabled: false
|
||||
# List of slots for top voter
|
||||
PlayerSlots: []
|
||||
# Add extra items
|
||||
ExtraItems: {}
|
||||
RemoveBottomBar: false
|
||||
# Set slot for backbutton
|
||||
BackButtonSlot: 0
|
||||
VoteTotal:
|
||||
Name: 'VoteTotal: %player%'
|
||||
BackButton: true
|
||||
@@ -279,6 +298,8 @@ CHEST:
|
||||
OpenVoteURL: false
|
||||
# If true, backbutton will be the last slot of the GUI
|
||||
EndOfGUI: false
|
||||
# If true, this item will become an exit button instead
|
||||
Exit: false
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
@@ -288,6 +309,10 @@ CHEST:
|
||||
VoteShopLimitReached: '&aYou reached your limit'
|
||||
VoteShopRequireConfirmation: false
|
||||
VoteShopDisabled: '&cVote shop disabled'
|
||||
# VoteShop extra items for display only
|
||||
#VoteShopExtraItems:
|
||||
#Item:
|
||||
#...
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.12</version>
|
||||
<version>6.13</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
|
||||
@@ -302,7 +302,7 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
@@ -385,7 +385,7 @@ public class BungeeHandler implements Listener {
|
||||
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
@@ -457,7 +457,7 @@ public class BungeeHandler implements Listener {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(player));
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
@@ -577,7 +577,7 @@ public class BungeeHandler implements Listener {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
@@ -610,7 +610,7 @@ public class BungeeHandler implements Listener {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
|
||||
import com.bencodez.advancedcore.api.skull.SkullHandler;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.logger.Logger;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
@@ -81,6 +82,7 @@ import com.bencodez.votingplugin.placeholders.MVdWPlaceholders;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceHolders;
|
||||
import com.bencodez.votingplugin.signs.Signs;
|
||||
import com.bencodez.votingplugin.specialrewards.SpecialRewards;
|
||||
import com.bencodez.votingplugin.test.VoteTester;
|
||||
import com.bencodez.votingplugin.timequeue.TimeQueueHandler;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterHandler;
|
||||
@@ -144,6 +146,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
@Getter
|
||||
private PlaceHolders placeholders;
|
||||
|
||||
@Getter
|
||||
private VoteTester voteTester;
|
||||
|
||||
@Getter
|
||||
private String profile = "";
|
||||
@@ -223,7 +228,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
public void basicBungeeUpdate() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
user.offVote();
|
||||
user.checkOfflineRewards();
|
||||
}
|
||||
@@ -1012,6 +1017,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
public void onPostLoad() {
|
||||
loadVersionFile();
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
|
||||
voteTester = new VoteTester(plugin);
|
||||
|
||||
loadVoteTimer();
|
||||
|
||||
@@ -1094,11 +1101,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
});
|
||||
getJavascriptEngine().put("VotingPluginHooks", VotingPluginHooks.getInstance());
|
||||
getJavascriptEngine().put("VotingPlugin", this);
|
||||
|
||||
loadTimer();
|
||||
|
||||
// placeholderapi loading
|
||||
placeholders = new PlaceHolders(this);
|
||||
getServerData().updatePlaceholders();
|
||||
placeholders.load();
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
|
||||
@@ -1385,11 +1394,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
placeholders.reload();
|
||||
}
|
||||
|
||||
voteReminding.loadRemindChecking();
|
||||
coolDownCheck.checkEnabled();
|
||||
placeholders.reload();
|
||||
|
||||
setUpdate(true);
|
||||
}
|
||||
|
||||
@@ -1416,6 +1426,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Loaded Files");
|
||||
}
|
||||
|
||||
@Getter
|
||||
private long lastBackgroundTaskTimeTaken = -1;
|
||||
|
||||
public void update() {
|
||||
if (update || configFile.isAlwaysUpdate()) {
|
||||
if (!updateStarted && plugin != null) {
|
||||
@@ -1430,7 +1443,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
|
||||
try {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
long startTime = System.currentTimeMillis();
|
||||
@@ -1452,17 +1464,23 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
.getTopVoterIgnorePermission();
|
||||
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
// ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
int currentDay = LocalDateTime.now().getDayOfMonth();
|
||||
int currentDataLoad = 0;
|
||||
for (String uuid : uuids) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished getting player data in " + time1 + " seconds, " + cols.size()
|
||||
+ " users, " + plugin.getStorageType().toString());
|
||||
time1 = System.currentTimeMillis();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
@@ -1504,24 +1522,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
if (dataLoadLimit > 0) {
|
||||
currentDataLoad++;
|
||||
if (currentDataLoad >= dataLoadLimit) {
|
||||
currentDataLoad -= dataLoadLimit;
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + uuids.size()
|
||||
+ " users, " + plugin.getStorageType().toString() + ", data load limit: "
|
||||
+ dataLoadLimit);
|
||||
time1 = System.currentTimeMillis();
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
topVoterHandler.updateTopVoters(tempTopVoter);
|
||||
placeholders.onUpdate();
|
||||
@@ -1529,17 +1536,22 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
serverData.updateValues();
|
||||
getSigns().updateSigns();
|
||||
|
||||
tempTopVoter = null;
|
||||
|
||||
checkFirstTimeLoaded();
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
plugin.getUserManager().getDataManager().clearNonNeededCachedUsers();
|
||||
plugin.extraDebug("Current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
update = false;
|
||||
|
||||
tempTopVoter = null;
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
lastBackgroundTaskTimeTaken = totalTime;
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (plugin != null) {
|
||||
plugin.getLogger().info("Looks like something went wrong");
|
||||
|
||||
@@ -351,6 +351,14 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("background_task_time_taken", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getLastBackgroundTaskTimeTaken();
|
||||
}
|
||||
}));
|
||||
|
||||
if (!plugin.getBuildNumber().equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("dev_build_number", new Callable<String>() {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class NonVotedPlayersCache {
|
||||
@@ -53,7 +54,8 @@ public class NonVotedPlayersCache {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File yamlFile = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
@@ -62,9 +64,24 @@ public class NonVotedPlayersCache {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -84,8 +101,8 @@ public class NonVotedPlayersCache {
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class VoteCache {
|
||||
@@ -114,7 +115,9 @@ public class VoteCache {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
File yamlFile = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
@@ -123,9 +126,23 @@ public class VoteCache {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -133,8 +150,8 @@ public class VoteCache {
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -572,7 +572,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
method = BungeeMethod.PLUGINMESSAGING;
|
||||
}
|
||||
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getData().getInt("TimeHourOffSet")) {
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getData().getString("TimeZone", ""),
|
||||
config.getData().getInt("TimeHourOffSet")) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
@@ -591,7 +592,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
try {
|
||||
lastOnline = Long.valueOf(lastOnlineStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastOnline < 1000
|
||||
@@ -889,7 +890,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.getServer().close();
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(getDescription().getVersion(),
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityJSONFile;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
public class NonVotedPlayersCache extends VelocityYMLFile {
|
||||
public class NonVotedPlayersCache extends VelocityJSONFile {
|
||||
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityJSONFile;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class VoteCache extends VelocityYMLFile {
|
||||
public class VoteCache extends VelocityJSONFile {
|
||||
|
||||
public VoteCache(File file) {
|
||||
super(file);
|
||||
|
||||
+32
-6
@@ -59,6 +59,7 @@ import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.advancedcore.bungeeapi.time.BungeeTimeChecker;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
@@ -611,7 +612,8 @@ public class VotingPluginVelocity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getNode("TimeHourOffSet").getInt()) {
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getNode("TimeZone").getString(""),
|
||||
config.getNode("TimeHourOffSet").getInt()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
@@ -632,7 +634,7 @@ public class VotingPluginVelocity {
|
||||
try {
|
||||
lastOnline = Long.valueOf(lastOnlineStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastOnline < 1000
|
||||
@@ -752,12 +754,36 @@ public class VotingPluginVelocity {
|
||||
if (mysqlLoaded) {
|
||||
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
|
||||
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.json"));
|
||||
|
||||
bungeeTimeChecker.loadTimer();
|
||||
// convert yml file if exists
|
||||
File yamlVoteCacheFile = new File(dataDirectory.toFile(), "votecache.yml");
|
||||
if (yamlVoteCacheFile.exists()) {
|
||||
VelocityYMLFile yamlVoteCache = new VelocityYMLFile(yamlVoteCacheFile);
|
||||
voteCacheFile.setConf(yamlVoteCache.getData());
|
||||
yamlVoteCacheFile.renameTo(new File(dataDirectory.toFile(), "oldvotecache.yml"));
|
||||
VelocityYMLFile oldYamlVoteCache = new VelocityYMLFile(
|
||||
new File(dataDirectory.toFile(), "oldvotecache.yml"));
|
||||
oldYamlVoteCache.setConf(yamlVoteCache.getData());
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(
|
||||
new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
|
||||
new File(dataDirectory.toFile(), "nonvotedplayerscache.json"), this);
|
||||
|
||||
// convert yml file if exists
|
||||
File yamlnonVotedPlayersCacheFile = new File(dataDirectory.toFile(), "nonvotedplayerscache.yml");
|
||||
if (yamlnonVotedPlayersCacheFile.exists()) {
|
||||
VelocityYMLFile yamlnonVotedPlayersCache = new VelocityYMLFile(yamlnonVotedPlayersCacheFile);
|
||||
voteCacheFile.setConf(yamlnonVotedPlayersCache.getData());
|
||||
yamlnonVotedPlayersCacheFile.renameTo(new File(dataDirectory.toFile(), "oldnonvotedplayerscache.yml"));
|
||||
VelocityYMLFile oldYamlnonVotedPlayersCache = new VelocityYMLFile(
|
||||
new File(dataDirectory.toFile(), "oldnonvotedplayerscache.yml"));
|
||||
oldYamlnonVotedPlayersCache.setConf(yamlnonVotedPlayersCache.getData());
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
bungeeTimeChecker.loadTimer();
|
||||
|
||||
try {
|
||||
for (String key : voteCacheFile.getTimedVoteCache()) {
|
||||
@@ -946,7 +972,7 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.getServer().close();
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.commands;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -30,7 +31,7 @@ import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
|
||||
@@ -65,7 +66,6 @@ import com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite;
|
||||
import com.bencodez.votingplugin.commands.tabcompleter.AliasesTabCompleter;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.test.VoteTester;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -93,6 +93,32 @@ public class CommandLoader {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void processSlotClick(Player player, VotingPluginUser user, String slot) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(slot, "url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the adminPerm
|
||||
*/
|
||||
@@ -103,25 +129,32 @@ public class CommandLoader {
|
||||
public BInventoryButton getBackButton(VotingPluginUser user) {
|
||||
ConfigurationSection sec = plugin.getGui().getCHESTBackButton();
|
||||
boolean a = false;
|
||||
boolean exit = false;
|
||||
|
||||
ItemBuilder item;
|
||||
if (sec != null) {
|
||||
item = new ItemBuilder(sec);
|
||||
a = sec.getBoolean("OpenVoteURL", false);
|
||||
exit = sec.getBoolean("Exit");
|
||||
} else {
|
||||
item = new ItemBuilder(Material.BARRIER, 1).setName("&8Back to VoteGUI");
|
||||
}
|
||||
|
||||
final boolean openVoteURL = a;
|
||||
final boolean exitGUI = exit;
|
||||
BInventoryButton b = new BInventoryButton(item) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (!openVoteURL) {
|
||||
new VoteGUI(plugin, event.getWhoClicked(), user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
if (!exitGUI) {
|
||||
if (!openVoteURL) {
|
||||
new VoteGUI(plugin, event.getWhoClicked(), user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
} else {
|
||||
new VoteURL(plugin, event.getWhoClicked(), user, true).open();
|
||||
}
|
||||
} else {
|
||||
new VoteURL(plugin, event.getWhoClicked(), user, true).open();
|
||||
event.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,12 +297,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting...");
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
user.setMilestoneCount(user.getTotal(TopVoter.AllTime));
|
||||
}
|
||||
plugin.getUserManager().copyColumnData(TopVoter.AllTime.getColumnName(), "MilestoneCount");
|
||||
sendMessage(sender, "&cFinished sync milestonecount with all time total");
|
||||
|
||||
}
|
||||
@@ -304,34 +332,46 @@ public class CommandLoader {
|
||||
plugin.getLogger().warning("Failed to get number from " + str);
|
||||
}
|
||||
}
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
for (int num : nums) {
|
||||
if (milestoneCount >= num) {
|
||||
if (!user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender,
|
||||
"&cMilestone " + num + " for " + user.getPlayerName()
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
for (int num : nums) {
|
||||
if (milestoneCount >= num) {
|
||||
if (!user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender, "&cMilestone " + num + " for "
|
||||
+ user.getPlayerName()
|
||||
+ " not already given when it should be, Current AllTimeTotal: "
|
||||
+ user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: "
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, true);
|
||||
}
|
||||
} else {
|
||||
if (user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender,
|
||||
"&cMilestone " + num + " for " + user.getPlayerName()
|
||||
user.setHasGotteMilestone(num, true);
|
||||
}
|
||||
} else {
|
||||
if (user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender, "&cMilestone " + num + " for "
|
||||
+ user.getPlayerName()
|
||||
+ " already given when it shouldn't be, Current AllTimeTotal: "
|
||||
+ user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: "
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, false);
|
||||
}
|
||||
user.setHasGotteMilestone(num, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
sendMessage(sender, "&cFinished");
|
||||
|
||||
}
|
||||
@@ -822,6 +862,31 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ResetAllVotedSites" },
|
||||
"VotingPlugin.Commands.AdminVote.ResetAllVotedSites|" + adminPerm, "Resets all voted") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.resetLastVoted();
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cVoted sites reset for '" + args[1] + "'"));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "ResetVotedSite", "(Sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.ResetVotedSite|" + adminPerm,
|
||||
"Resets last voted for specific site") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.resetLastVoted(plugin.getVoteSite(args[3], false));
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
.colorize("&cVoted site reset for '" + args[1] + "'" + " on " + args[3]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "AddMilestoneCount", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.AddMilestoneCount|" + adminPerm, "Add milestonecount") {
|
||||
@@ -1242,7 +1307,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VoteTester.getInstance().testVotes(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
plugin.getVoteTester().testVotes(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
if (isPlayer(sender)) {
|
||||
sendMessage(sender, "&cSee console for details");
|
||||
}
|
||||
@@ -1255,7 +1320,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VoteTester.getInstance().testSpam(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
plugin.getVoteTester().testSpam(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
if (isPlayer(sender)) {
|
||||
sendMessage(sender, "&cSee console for details");
|
||||
}
|
||||
@@ -1268,7 +1333,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VoteTester.getInstance().testRewards(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
plugin.getVoteTester().testRewards(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
if (isPlayer(sender)) {
|
||||
sendMessage(sender, "&cSee console for details");
|
||||
}
|
||||
@@ -1626,110 +1691,97 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
com.bencodez.advancedcore.thread.Thread.getInstance().run(new Runnable() {
|
||||
loadTabComplete();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
loadTabComplete();
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("Force Vote", new String[] {}, new ItemStack(Material.STONE)) {
|
||||
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("Force Vote", new String[] {}, new ItemStack(Material.STONE)) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
ArrayList<String> voteSites = new ArrayList<String>();
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
voteSites.add(voteSite.getKey());
|
||||
}
|
||||
new ValueRequest().requestString(player, "",
|
||||
ArrayUtils.getInstance().convert(voteSites), true, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
ArrayList<String> voteSites = new ArrayList<String>();
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
voteSites.add(voteSite.getKey());
|
||||
}
|
||||
new ValueRequest().requestString(player, "",
|
||||
ArrayUtils.getInstance().convert(voteSites), true,
|
||||
new StringListener() {
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(value, true),
|
||||
UserGUI.getInstance().getCurrentPlayer(player),
|
||||
plugin.getVoteSiteServiceSite(value), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
player.sendMessage("Forced vote for "
|
||||
+ UserGUI.getInstance().getCurrentPlayer(player) + " on "
|
||||
+ value);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("MileStones", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
String playerName = (String) event.getMeta(player, "Player");
|
||||
BInventory inv = new BInventory("MileStones: " + playerName);
|
||||
for (String mileStoneName : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (StringParser.getInstance().isInt(mileStoneName)) {
|
||||
int mileStone = Integer.parseInt(mileStoneName);
|
||||
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("" + mileStone, new String[] {
|
||||
"Enabled: " + plugin.getSpecialRewardsConfig()
|
||||
.getMilestoneRewardEnabled(mileStone),
|
||||
"&cClick to set wether this has been completed or not" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(value, true),
|
||||
UserGUI.getInstance().getCurrentPlayer(player),
|
||||
plugin.getVoteSiteServiceSite(value), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (StringParser.getInstance().isInt(clickEvent.getClickedItem()
|
||||
.getItemMeta().getDisplayName())) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
int mileStone = Integer.parseInt(clickEvent.getClickedItem()
|
||||
.getItemMeta().getDisplayName());
|
||||
String playerName = (String) event.getMeta(player,
|
||||
"Player");
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(playerName);
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + user.hasGottenMilestone(mileStone),
|
||||
new BooleanListener() {
|
||||
|
||||
player.sendMessage("Forced vote for "
|
||||
+ UserGUI.getInstance().getCurrentPlayer(player)
|
||||
+ " on " + value);
|
||||
@Override
|
||||
public void onInput(Player player,
|
||||
boolean value) {
|
||||
String playerName = UserGUI.getInstance()
|
||||
.getCurrentPlayer(player);
|
||||
VotingPluginUser user = UserManager
|
||||
.getInstance()
|
||||
.getVotingPluginUser(playerName);
|
||||
user.setHasGotteMilestone(mileStone, value);
|
||||
player.sendMessage(
|
||||
"Set milestone completetion to "
|
||||
+ value + " on "
|
||||
+ mileStone);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("MileStones", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
String playerName = (String) event.getMeta(player, "Player");
|
||||
BInventory inv = new BInventory("MileStones: " + playerName);
|
||||
for (String mileStoneName : plugin.getSpecialRewardsConfig()
|
||||
.getMilestoneVotes()) {
|
||||
if (StringParser.getInstance().isInt(mileStoneName)) {
|
||||
int mileStone = Integer.parseInt(mileStoneName);
|
||||
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("" + mileStone, new String[] {
|
||||
"Enabled: " + plugin.getSpecialRewardsConfig()
|
||||
.getMilestoneRewardEnabled(mileStone),
|
||||
"&cClick to set wether this has been completed or not" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (StringParser.getInstance()
|
||||
.isInt(clickEvent.getClickedItem().getItemMeta()
|
||||
.getDisplayName())) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
int mileStone = Integer
|
||||
.parseInt(clickEvent.getClickedItem()
|
||||
.getItemMeta().getDisplayName());
|
||||
String playerName = (String) event.getMeta(player,
|
||||
"Player");
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(playerName);
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + user.hasGottenMilestone(mileStone),
|
||||
new BooleanListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player,
|
||||
boolean value) {
|
||||
String playerName = UserGUI
|
||||
.getInstance()
|
||||
.getCurrentPlayer(player);
|
||||
VotingPluginUser user = UserManager
|
||||
.getInstance()
|
||||
.getVotingPluginUser(
|
||||
playerName);
|
||||
user.setHasGotteMilestone(mileStone,
|
||||
value);
|
||||
player.sendMessage(
|
||||
"Set milestone completetion to "
|
||||
+ value + " on "
|
||||
+ mileStone);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
@@ -2200,47 +2252,33 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
|
||||
int daily = 0;
|
||||
int weekly = 0;
|
||||
int month = 0;
|
||||
int all = 0;
|
||||
|
||||
if (plugin.getOptions().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
int cTotal = 0;
|
||||
ArrayList<Integer> nums = plugin.getMysql().getNumbersInColumn(top.getColumnName());
|
||||
for (Integer num : nums) {
|
||||
cTotal += num.intValue();
|
||||
}
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
all = cTotal;
|
||||
break;
|
||||
case Daily:
|
||||
daily = cTotal;
|
||||
break;
|
||||
case Monthly:
|
||||
month = cTotal;
|
||||
break;
|
||||
case Weekly:
|
||||
weekly = cTotal;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
int cTotal = 0;
|
||||
ArrayList<Integer> nums = plugin.getUserManager().getNumbersInColumn(top.getColumnName());
|
||||
for (Integer num : nums) {
|
||||
cTotal += num.intValue();
|
||||
}
|
||||
} else {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
all = cTotal;
|
||||
break;
|
||||
case Daily:
|
||||
daily = cTotal;
|
||||
break;
|
||||
case Monthly:
|
||||
month = cTotal;
|
||||
break;
|
||||
case Weekly:
|
||||
weekly = cTotal;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
for (String uuid : uuids) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
daily += user.getTotal(TopVoter.Daily);
|
||||
weekly += user.getTotal(TopVoter.Weekly);
|
||||
month += user.getTotal(TopVoter.Monthly);
|
||||
all += user.getTotal(TopVoter.AllTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +183,17 @@ public class AdminGUI {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder(Material.STONE, 1).setName("&cBackground task time").addLoreLine("&aClick to see")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().sendMessage("Last background task time: " + plugin.getLastBackgroundTaskTimeTaken());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -38,14 +38,14 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "VotingPlugin_" + identifier + " - " + placeholder.getDescription();
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "VotingPlugin_" + identifier + "";
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -56,14 +56,14 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "VotingPlugin_" + identifier + " - " + placeholder.getDescription();
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "VotingPlugin_" + identifier + "";
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -82,26 +82,26 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cPlaceholders:");
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("VotingPlugin_" + identifier + " - " + placeholder.getDescription());
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("VotingPlugin_" + identifier + "");
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("VotingPlugin_" + identifier + " - " + placeholder.getDescription());
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("VotingPlugin_" + identifier + "");
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -40,7 +40,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
@@ -78,20 +78,20 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
placeholderUser = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
@@ -100,8 +100,9 @@ public class VoteBest extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,12 +9,14 @@ import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -42,15 +44,15 @@ public class VoteGUI extends GUIHandler {
|
||||
|
||||
String str = plugin.getConfigFile().getVoteTopDefault();
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(slot, "url")) {
|
||||
lore = new String[] { "&aClick me" };
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "next")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteNext(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "last")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteLast(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "total")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteTotal(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "top")) {
|
||||
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterMonthly(1);
|
||||
@@ -136,11 +138,12 @@ public class VoteGUI extends GUIHandler {
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
|
||||
for (String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
for (final String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
ItemBuilder builder = getItemSlot(slot, player);
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 1000, 1000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -158,35 +161,15 @@ public class VoteGUI extends GUIHandler {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, slot);
|
||||
}
|
||||
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui()
|
||||
.getChestVoteGUISlotRewardsPath(slot, event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
|
||||
plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
event.getButton().getLastRewardsPath(player)),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
}
|
||||
@@ -198,12 +181,29 @@ public class VoteGUI extends GUIHandler {
|
||||
item.addPlaceholder("points", "" + user.getPoints());
|
||||
item.addPlaceholder("player", user.getPlayerName());
|
||||
item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
item.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
return item;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
String guiPath = "VoteGUI";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class VoteLast extends GUIHandler {
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
@@ -107,8 +107,9 @@ public class VoteLast extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -89,9 +89,15 @@ public class VoteNext extends GUIHandler {
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(siteNameDisplay)
|
||||
.setLore(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time", user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
@@ -116,8 +122,9 @@ public class VoteNext extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -55,6 +56,7 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
@@ -91,15 +93,15 @@ public class VoteShop extends GUIHandler {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.closeInventory();
|
||||
}
|
||||
// if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
// event.closeInventory();
|
||||
// }
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
boolean limitPass = true;
|
||||
@@ -142,6 +144,7 @@ public class VoteShop extends GUIHandler {
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,14 +157,27 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
user.sendMessage(plugin.getConfigFile().getFormatShopNotPurchasable());
|
||||
}
|
||||
|
||||
}.dontClose().addData("identifier", identifier).addData("Limit", limit));
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final String str : plugin.getGui().getChestGUIVoteShopExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIVoteShopExtraItems(str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteShopExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteShopBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
|
||||
@@ -119,7 +119,7 @@ public class VoteStreak extends GUIHandler {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
String guiPath = "VoteStreak";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
@@ -128,8 +128,9 @@ public class VoteStreak extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -126,8 +126,9 @@ public class VoteToday extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,11 +2,15 @@ package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@@ -17,6 +21,7 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -78,6 +83,15 @@ public class VoteTopVoter extends GUIHandler {
|
||||
.getTopVoter(top).clone();
|
||||
users = topVotes.entrySet();
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<Integer>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
playerSlots.addAll(customizationPlayerSlots);
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", topVoter);
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
@@ -86,6 +100,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
@@ -96,7 +111,8 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
BInventoryButton button = new BInventoryButton(playerItem
|
||||
.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
@@ -107,33 +123,85 @@ public class VoteTopVoter extends GUIHandler {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
} else {
|
||||
getInv().forceClose(clickEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey());
|
||||
|
||||
if (customzationEnabled && !playerSlots.isEmpty()) {
|
||||
button.setSlot(playerSlots.remove());
|
||||
}
|
||||
|
||||
inv.setCloseInv(plugin.getGui().getChestVoteTopCloseGUIOnClick());
|
||||
|
||||
inv.addButton(button);
|
||||
pos++;
|
||||
}
|
||||
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
TopVoter newTops = top;
|
||||
ArrayList<String> tops = plugin.getGui().getChestVoteTopSwitchItemTopVoters();
|
||||
if (!tops.isEmpty()) {
|
||||
for (String name : tops) {
|
||||
newTops.getSwitchItems().add(TopVoter.getTopVoter(name));
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
final TopVoter cur = newTops;
|
||||
if (!customzationEnabled) {
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
if (customzationEnabled) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user)
|
||||
.setSlot(customization.getInt("BackButtonSlot", 0)));
|
||||
} else {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteTop.Customization";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (customization == null || (customzationEnabled && !customization.getBoolean("RemoveBottomBar"))) {
|
||||
inv.setPages(true);
|
||||
}
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -67,7 +67,7 @@ public class VoteTotal extends GUIHandler {
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()),
|
||||
1000, 1000) {
|
||||
@@ -94,8 +94,9 @@ public class VoteTotal extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -165,7 +165,7 @@ public class VoteURL extends GUIHandler {
|
||||
if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builderAll, 5000, 5000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builderAll, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -190,7 +190,7 @@ public class VoteURL extends GUIHandler {
|
||||
startSlot++;
|
||||
}
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 5000, 5000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -221,7 +221,8 @@ public class VoteURL extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(), "CHEST.VoteURL.ExtraItems." + str + ".Rewards")
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteURL.ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class VoteURLVoteSite extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site)),
|
||||
1000, 1000) {
|
||||
|
||||
|
||||
@@ -54,10 +54,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
@ConfigDataInt(path = "PlayerDataLoadLimit")
|
||||
@Getter
|
||||
private int playerDataLoadLimit = -1;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
@@ -308,6 +304,26 @@ public class Config extends YMLFile {
|
||||
return str;
|
||||
}
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns() {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns").getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<String>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns(String placeholder) {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<String>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
|
||||
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
|
||||
}
|
||||
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
@@ -571,10 +587,11 @@ public class Config extends YMLFile {
|
||||
}
|
||||
|
||||
public String getFormatShopFailedMsg() {
|
||||
String msg = getData().getString("Format.ShopFailed", "&cYou do not have %Points% points to purhcase this!");
|
||||
|
||||
return msg;
|
||||
return getData().getString("Format.ShopFailed", "&cYou do not have %Points% points to purhcase this!");
|
||||
}
|
||||
|
||||
public String getFormatShopNotPurchasable() {
|
||||
return getData().getString("Format.ShopNotPurchasable", "&cThis item is not buyable!");
|
||||
}
|
||||
|
||||
public String getFormatShopPurchaseMsg() {
|
||||
|
||||
@@ -191,7 +191,6 @@ public class GUI extends YMLFile {
|
||||
|
||||
public String getChestShopIdentifierRewardsPath(String identifier) {
|
||||
return "CHEST.Shop." + identifier + ".Rewards";
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getChestShopIdentifiers() {
|
||||
@@ -248,8 +247,8 @@ public class GUI extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot) {
|
||||
return "CHEST.VoteGUI." + slot + ".Rewards";
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,6 +268,10 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTopCustomization() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTop.Customization");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
@@ -298,6 +301,14 @@ public class GUI extends YMLFile {
|
||||
public String getChestVoteNextName() {
|
||||
return getData().getString("CHEST.VoteNext.Name", "VoteNext: %player%");
|
||||
}
|
||||
|
||||
public String getChestVoteNextLine() {
|
||||
return getData().getString("CHEST.VoteNext.Line", "%time%");
|
||||
}
|
||||
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
public String getChestVoteRewardName() {
|
||||
return getData().getString("CHEST.VoteRewardName", "VoteReward");
|
||||
@@ -404,6 +415,10 @@ public class GUI extends YMLFile {
|
||||
return getData().getBoolean("CHEST.VoteTop.OpenMainGUIOnClick", true);
|
||||
}
|
||||
|
||||
public boolean getChestVoteTopCloseGUIOnClick() {
|
||||
return getData().getBoolean("CHEST.VoteTop.CloseGUIOnClick", true);
|
||||
}
|
||||
|
||||
public int getChestVoteTopSize() {
|
||||
return getData().getInt("CHEST.VoteTop.Size", 27);
|
||||
}
|
||||
@@ -412,6 +427,11 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteTop.SwitchItem");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteTopSwitchItemTopVoters() {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteTop.SwitchItem.TopVoters", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalAllTimeTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.AllTimeTotal.Item");
|
||||
}
|
||||
@@ -506,6 +526,17 @@ public class GUI extends YMLFile {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteShopExtraItems." + item);
|
||||
}
|
||||
|
||||
public Set<String> getChestGUIVoteShopExtraItems() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteShopExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteShopExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
|
||||
}
|
||||
|
||||
@@ -30,12 +30,26 @@ public class ServerData {
|
||||
|
||||
public void addAutoCachedPlaceholder(String placeholder) {
|
||||
List<String> p = getAutoCachedPlaceholder();
|
||||
|
||||
if (!ArrayUtils.getInstance().containsIgnoreCase(p, placeholder)) {
|
||||
p.add(placeholder);
|
||||
setAutoCachedPlaceholder(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlaceholders() {
|
||||
boolean data = getData().getBoolean("AutoCacheUpdated", false);
|
||||
if (!data) {
|
||||
List<String> placeholders = getAutoCachedPlaceholder();
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
placeholders.set(i, placeholders.get(i).toLowerCase());
|
||||
}
|
||||
setAutoCachedPlaceholder(placeholders);
|
||||
getData().set("AutoCacheUpdated", true);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
|
||||
@@ -122,7 +122,6 @@ public class PlayerVoteListener implements Listener {
|
||||
final String uuid = user.getUUID();
|
||||
|
||||
// reupdate cache
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
user.updateName(true);
|
||||
@@ -228,7 +227,6 @@ public class PlayerVoteListener implements Listener {
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
|
||||
plugin.extraDebug("Finished vote processing: " + playerName + "/" + uuid);
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -51,6 +52,12 @@ public class PlaceHolders {
|
||||
|
||||
public void reload() {
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
onUpdate();
|
||||
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
@@ -64,9 +71,11 @@ public class PlaceHolders {
|
||||
return getPlaceHolder(p, identifier, true);
|
||||
}
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier, boolean javascript) {
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier1, boolean javascript) {
|
||||
boolean forceProcess = false;
|
||||
boolean useCache = true;
|
||||
String identifier = identifier1.toLowerCase();
|
||||
boolean custom = false;
|
||||
if (identifier.endsWith("_process")) {
|
||||
forceProcess = true;
|
||||
identifier = identifier.replaceAll("_process", "");
|
||||
@@ -79,6 +88,26 @@ public class PlaceHolders {
|
||||
useCache = false;
|
||||
}
|
||||
|
||||
if (identifier.startsWith("custom_")) {
|
||||
custom = true;
|
||||
identifier = identifier.replaceAll("custom_", "");
|
||||
}
|
||||
|
||||
if (custom && plugin.getConfigFile().getCustomPlaceholderReturns().contains(identifier)) {
|
||||
String str = getPlaceholderValue(p, identifier, javascript, true, useCache);
|
||||
String returnStr = plugin.getConfigFile().getCustomPlaceholderReturns(identifier, str);
|
||||
if (!returnStr.isEmpty()) {
|
||||
return returnStr;
|
||||
}
|
||||
return str;
|
||||
} else {
|
||||
return getPlaceholderValue(p, identifier, javascript, forceProcess, useCache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getPlaceholderValue(OfflinePlayer p, String identifier, boolean javascript, boolean forceProcess,
|
||||
boolean useCache) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript && p != null) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
@@ -169,7 +198,6 @@ public class PlaceHolders {
|
||||
}
|
||||
|
||||
return "Not a valid placeholder";
|
||||
|
||||
}
|
||||
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
@@ -226,6 +254,47 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("User milestonecount").updateDataKey("MilestoneCount"));
|
||||
|
||||
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
for (String vote : mVotes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
|
||||
final int num = Integer.parseInt(vote);
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("milestone_numberofvotesuntil_" + num) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int toGo = num - user.getMilestoneCount();
|
||||
if (toGo >= 0) {
|
||||
return "" + toGo;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
}.withDescription("Get number of votes until milestone").updateDataKey("MilestoneCount"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("nextmilestone_votes_required") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getNextAvailableMileStone();
|
||||
}
|
||||
}.withDescription("Get number of votes required for next available milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("nextmilestone_votes_until") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int toGo = user.getNextAvailableMileStone() - user.getMilestoneCount();
|
||||
if (toGo >= 0) {
|
||||
return "" + toGo;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
}.withDescription("Get number of votes until next available milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestShopIdentifierLimit(identifier) > 0) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
|
||||
@@ -422,6 +491,18 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("EnoughPoints_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int number = Integer.parseInt(identifier.split("_")[1]);
|
||||
if (user.getPoints() >= number) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
}.withDescription("Return true/false if player has said points").updateDataKey("Points").useStartsWith());
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_AllVotes_") {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.bencodez.votingplugin.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -8,18 +10,17 @@ import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTester {
|
||||
|
||||
private static VoteTester instance = new VoteTester();
|
||||
|
||||
public static VoteTester getInstance() {
|
||||
return instance;
|
||||
public VoteTester(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public void testRewards(int amount, String name, String rewardName) {
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
@@ -59,6 +60,47 @@ public class VoteTester {
|
||||
|
||||
}
|
||||
|
||||
private String getSaltString() {
|
||||
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
StringBuilder salt = new StringBuilder();
|
||||
Random rnd = new Random();
|
||||
while (salt.length() < 18) { // length of the random string.
|
||||
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
|
||||
salt.append(SALTCHARS.charAt(index));
|
||||
}
|
||||
String saltStr = salt.toString();
|
||||
return saltStr;
|
||||
|
||||
}
|
||||
|
||||
public void generatePlayers(int numberOfPlayers) {
|
||||
if (plugin.getOptions().getDebug().isDebug()) {
|
||||
int num = 1;
|
||||
String salt = getSaltString();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < numberOfPlayers; i++) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
if (!plugin.getUserManager().userExist(uuid)) {
|
||||
String playerName = salt + num;
|
||||
if (!plugin.getUserManager().userExist(playerName)) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid,
|
||||
playerName);
|
||||
user.dontCache();
|
||||
user.setPoints(random.nextInt(100));
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
user.setTotal(top, random.nextInt(1000));
|
||||
}
|
||||
user.setMilestoneCount(random.nextInt(100));
|
||||
user.setPlayerName(playerName);
|
||||
user.updateName(true);
|
||||
num++;
|
||||
plugin.debug("Generated user " + uuid.toString() + "/" + playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testVotes(int amount, String name, String site) {
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.ArrayList;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum TopVoter {
|
||||
AllTime, Monthly, Weekly, Daily;
|
||||
|
||||
@@ -44,7 +46,7 @@ public enum TopVoter {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getLastColumnName() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
@@ -61,6 +63,9 @@ public enum TopVoter {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ArrayList<TopVoter> switchItems = new ArrayList<TopVoter>();
|
||||
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return VotingPluginMain.plugin.getConfigFile().getFormatTopVoterMonthly();
|
||||
@@ -75,18 +80,23 @@ public enum TopVoter {
|
||||
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
if (switchItems != null && !switchItems.isEmpty()) {
|
||||
list.addAll(switchItems);
|
||||
} else {
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int next = i + 1;
|
||||
@@ -101,17 +111,21 @@ public enum TopVoter {
|
||||
|
||||
public TopVoter prev() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
if (switchItems != null && !switchItems.isEmpty()) {
|
||||
list.addAll(switchItems);
|
||||
} else {
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
if (list.get(i).equals(this)) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.PreDateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
@@ -87,14 +88,26 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
plugin.getLastMonthTopVoter().clear();
|
||||
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user.getTopVoterPlayer(), total);
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getLastMonthTopVoter().putAll(sortByValues(totals, false));
|
||||
|
||||
@@ -113,7 +126,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@@ -127,11 +139,12 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Daily.getColumnName(), TopVoter.Daily.getLastColumnName());
|
||||
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
|
||||
if (user.getDayVoteStreak() != 0) {
|
||||
@@ -147,6 +160,8 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -186,15 +201,6 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.getBungeeSettings().isGloblalDataEnabled() && plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
// give time for other servers to catch up
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
@@ -211,7 +217,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
@@ -229,11 +234,12 @@ public class TopVoterHandler implements Listener {
|
||||
TopVoter.Monthly.getLastColumnName());
|
||||
}
|
||||
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
@@ -259,6 +265,8 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -285,7 +293,6 @@ public class TopVoterHandler implements Listener {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
|
||||
user.giveMonthlyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
@@ -324,7 +331,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
}
|
||||
@@ -348,11 +354,12 @@ public class TopVoterHandler implements Listener {
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Weekly.getColumnName(),
|
||||
TopVoter.Weekly.getLastColumnName());
|
||||
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
@@ -374,6 +381,8 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -430,7 +439,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
@@ -523,11 +531,15 @@ public class TopVoterHandler implements Listener {
|
||||
for (TopVoter cTop : TopVoter.values()) {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int cTotal = 0;
|
||||
ArrayList<Integer> nums = plugin.getMysql().getNumbersInColumn(cTop.getColumnName());
|
||||
for (Integer num : nums) {
|
||||
cTotal += num.intValue();
|
||||
try {
|
||||
ArrayList<Integer> nums = plugin.getUserManager().getNumbersInColumn(cTop.getColumnName());
|
||||
for (Integer num : nums) {
|
||||
cTotal += num.intValue();
|
||||
}
|
||||
topVoters.add("Combined total: " + cTotal);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
topVoters.add("Combined total: " + cTotal);
|
||||
if (plugin.getTopVoter().containsKey(cTop)) {
|
||||
|
||||
int count = 1;
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -271,10 +272,24 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() || now.getYear() != lastVote.getYear()) {
|
||||
return true;
|
||||
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
|
||||
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
|
||||
if (!now.isBefore(offsetoclocktoday)) {
|
||||
if (!lastVote.isBefore(offsetoclocktoday)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!lastVote.isBefore(offsetoclockyesterday)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -1000,6 +1015,40 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
|
||||
public int getNextAvailableMileStone() {
|
||||
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
int mileStoneCount = getMilestoneCount();
|
||||
HashMap<String, Boolean> gottenMileStones = getHasGottenMilestone();
|
||||
for (String vote : mVotes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
final int num = Integer.parseInt(vote);
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
|
||||
if (gottenMileStones.containsKey("" + num)) {
|
||||
if (!gottenMileStones.get("" + num).booleanValue()) {
|
||||
nums.add(Integer.valueOf(num));
|
||||
}
|
||||
} else {
|
||||
nums.add(Integer.valueOf(num));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int lowestNum = -1;
|
||||
|
||||
for (Integer num : nums) {
|
||||
if (mileStoneCount < num.intValue()) {
|
||||
if (lowestNum == -1 || num.intValue() < lowestNum) {
|
||||
lowestNum = num.intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lowestNum;
|
||||
|
||||
}
|
||||
|
||||
public void setReminded(boolean reminded) {
|
||||
getUserData().setString("Reminded", "" + reminded);
|
||||
}
|
||||
@@ -1380,4 +1429,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return shortest;
|
||||
}
|
||||
|
||||
public void resetLastVoted() {
|
||||
HashMap<VoteSite, Long> map = getLastVotes();
|
||||
for (Entry<VoteSite, Long> e : map.entrySet()) {
|
||||
e.setValue(0l);
|
||||
}
|
||||
setLastVotes(map);
|
||||
}
|
||||
|
||||
public void resetLastVoted(VoteSite site) {
|
||||
HashMap<VoteSite, Long> map = getLastVotes();
|
||||
map.put(site, 0l);
|
||||
setLastVotes(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.voteparty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -186,15 +187,29 @@ public class VoteParty implements Listener {
|
||||
.setServer(useBungee).send(user);
|
||||
}
|
||||
|
||||
public String getRandomPlayerName() {
|
||||
ArrayList<String> allPlayers = new ArrayList<String>();
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
allPlayers.add(players.getName());
|
||||
}
|
||||
if (allPlayers.size() == 0) {
|
||||
return "No Player";
|
||||
}
|
||||
int random = new Random().nextInt(allPlayers.size());
|
||||
return allPlayers.get(random);
|
||||
}
|
||||
|
||||
public void giveRewards(VotingPluginUser orgUser, boolean forceBungee) {
|
||||
MiscUtils.getInstance().broadcast(plugin.getSpecialRewardsConfig().getVotePartyBroadcast());
|
||||
|
||||
String player = getRandomPlayerName();
|
||||
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
|
||||
StringParser.getInstance().replacePlaceHolder(cmd, "randomonlineplayer", player));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user