Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dca689ec37 | ||
|
|
ee4d52377f | ||
|
|
ac41c9413c | ||
|
|
596968f869 | ||
|
|
0d2221d195 | ||
|
|
23fa59f98f | ||
|
|
cb81b61096 | ||
|
|
186917992c | ||
|
|
6b70e4fee4 | ||
|
|
79c98c8b86 | ||
|
|
b8e0830b0b | ||
|
|
1cd1a0ab75 | ||
|
|
481510a1e8 | ||
|
|
3a95ef9b23 | ||
|
|
f7af9210cb | ||
|
|
9f5fe338f4 | ||
|
|
967be0aa19 | ||
|
|
6e0b62a1dd | ||
|
|
a8ec557c9e | ||
|
|
252263da74 | ||
|
|
e7696bed25 | ||
|
|
064451d2b5 | ||
|
|
daa25805fa | ||
|
|
cc010d9738 | ||
|
|
cbe58a1f18 | ||
|
|
c29247d2a0 | ||
|
|
a28cdfc6bf | ||
|
|
7db5cd59da | ||
|
|
0ebb0c9a70 | ||
|
|
9ba20ddd02 | ||
|
|
7fddc0af12 | ||
|
|
475e6059eb | ||
|
|
b552928b8c |
No files matched your search
@@ -17,6 +17,7 @@ https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/LICENSE.t
|
||||
<groupId>com.github.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
Versions:
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.jboss.ide.eclipse.as.core.singledeployable.deployableList=\n
|
||||
Binary file not shown.
@@ -70,7 +70,7 @@ VoteReminding:
|
||||
# Can add titles and more in the reward file
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aRemeber to vote!'
|
||||
Player: '&aRemember to vote!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
@@ -319,13 +319,22 @@ GUI:
|
||||
Amount: 1
|
||||
Name: '&4Today'
|
||||
Slot: 5
|
||||
Rewards:
|
||||
Shop:
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Voting Rewards'
|
||||
Name: '&4Vote Shop'
|
||||
Slot: 6
|
||||
# /vote Reward gui item
|
||||
# Uncomment to use, most likely will be unused
|
||||
#Rewards:
|
||||
# Item:
|
||||
# Material: 'DIAMOND'
|
||||
# Data: 0
|
||||
# Amount: 1
|
||||
# Name: '&4Voting Rewards'
|
||||
# Slot: 7
|
||||
|
||||
# GUI for /vote url
|
||||
# And /vote if enabled in Config.yml
|
||||
@@ -564,9 +573,14 @@ VoteParty:
|
||||
ResetEachDay: false
|
||||
# Number of user votes that apply to vote party total the user needs to get rewards
|
||||
UserVotesRequired: 0
|
||||
# Broadcast when vote party reached
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# Reward files to give
|
||||
Rewards: []
|
||||
|
||||
# Reset milestons at end of the month
|
||||
ResetMilestonesMonthly: false
|
||||
|
||||
MileStones:
|
||||
# Number of votes required
|
||||
# Allows multiple milestones
|
||||
@@ -577,7 +591,6 @@ MileStones:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %milestone% milestone votes!'
|
||||
ResetMonthly: false
|
||||
|
||||
VoteStreak:
|
||||
# Valid options: Day, Week, Month
|
||||
@@ -693,6 +706,10 @@ DailyAwards:
|
||||
# Most of these values can be left untouched
|
||||
# ------------------------------------------------
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
|
||||
# Wether or not to check on world change
|
||||
# Should only be used if you do per world rewards
|
||||
CheckOnWorldChange: false
|
||||
|
||||
@@ -35,4 +35,8 @@ VoteSites:
|
||||
|
||||
# List of reward files to give to voter
|
||||
Rewards:
|
||||
- 'ExampleReward'
|
||||
- 'ExampleReward'
|
||||
|
||||
# Reward for any site
|
||||
# Similar to AnySiteReward
|
||||
EverySiteReward: []
|
||||
+14
-7
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.8.2</version>
|
||||
<version>5.9</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -55,25 +55,25 @@
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>com.Ben12345rocks.AdvancedCore</pattern>
|
||||
<shadedPattern>${groupId}.${artifactId}.AdvancedCore</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.AdvancedCore</shadedPattern>
|
||||
</relocation>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${groupId}.${artifactId}</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.mrten.mysqlapi</pattern>
|
||||
<shadedPattern>${groupId}.${artifactId}.mysqlapi</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.mysqlapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.HikariCP</pattern>
|
||||
<shadedPattern>${groupId}.${artifactId}.HikariCP</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.HikariCP</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j.slf4j-simple</pattern>
|
||||
<shadedPattern>${groupId}.${artifactId}.slf4j-simple</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.slf4j-simple</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
@@ -162,7 +162,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.11.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -179,5 +179,12 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/GAListener.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mythicacraft</groupId>
|
||||
<artifactId>voteroulette</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/VoteRoulette.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -2,10 +2,14 @@ package com.Ben12345rocks.VotingPlugin.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -40,6 +44,14 @@ import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteShop.VoteShop;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.common.collect.Table.Cell;
|
||||
import com.mythicacraft.voteroulette.VoteRoulette;
|
||||
import com.mythicacraft.voteroulette.Voter;
|
||||
import com.swifteh.GAL.GAL;
|
||||
import com.swifteh.GAL.GALVote;
|
||||
import com.swifteh.GAL.VoteType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -122,6 +134,71 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "ConvertFrom", "GAL" },
|
||||
"VotingPlugin.Commands.AdminVote.ConvertFrom.GAL|" + adminPerm, "Convert from GAL") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("GAListener") != null) {
|
||||
Table<String, Integer, Long> totals = GAL.p.db.getTotals();
|
||||
for (Cell<String, Integer, Long> entry : totals.cellSet()) {
|
||||
String name = entry.getRowKey();
|
||||
int total = entry.getColumnKey();
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
user.setAllTimeTotal(user.getAllTimeTotal() + total);
|
||||
}
|
||||
sender.sendMessage("Totals added");
|
||||
|
||||
ListMultimap<VoteType, GALVote> votes = GAL.p.galVote;
|
||||
for (Entry<VoteType, GALVote> entry : votes.entries()) {
|
||||
if (entry.getKey().equals(VoteType.NORMAL)) {
|
||||
String msg = entry.getValue().message;
|
||||
List<String> cmds = entry.getValue().commands;
|
||||
String service = entry.getValue().key;
|
||||
if (service.equalsIgnoreCase("default")) {
|
||||
|
||||
} else {
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
if (site == null) {
|
||||
sender.sendMessage("Failed to create vote site, autogeneratesites false?");
|
||||
return;
|
||||
}
|
||||
ConfigurationSection data = configVoteSites.getData()
|
||||
.getConfigurationSection(configVoteSites.getRewardsPath(site.getKey()));
|
||||
data.set("Commands.Console", cmds);
|
||||
data.set("Messages.Player", msg);
|
||||
configVoteSites.saveData();
|
||||
sender.sendMessage("created vote site: " + site.getKey());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("GAL not loaded");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "ConvertFrom", "VoteRoulette" },
|
||||
"VotingPlugin.Commands.AdminVote.ConvertFrom.GAL|" + adminPerm, "Convert from VoteRoulette") {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("VoteRoulette") != null) {
|
||||
for (OfflinePlayer offPlayer : Bukkit.getOfflinePlayers()) {
|
||||
Voter voter = VoteRoulette.getInstance().getVoterManager().getVoter(offPlayer.getUniqueId(),
|
||||
offPlayer.getName());
|
||||
User user = UserManager.getInstance().getVotingPluginUser(offPlayer);
|
||||
user.setAllTimeTotal(user.getAllTimeTotal() + voter.getStatSheet().getLifetimeVotes());
|
||||
user.setMonthTotal(user.getMonthTotal() + voter.getStatSheet().getCurrentMonthVotes());
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("VoteRoulette not loaded");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "SetPoints", "(player)", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetPoints|" + adminPerm, "Set players voting points") {
|
||||
|
||||
@@ -279,8 +356,10 @@ public class CommandLoader {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sender.sendMessage("Starting to convert");
|
||||
UserStorage prevStorage = UserStorage.valueOf(args[1].toUpperCase());
|
||||
plugin.convertDataStorage(prevStorage, AdvancedCoreHook.getInstance().getStorageType());
|
||||
sender.sendMessage("Finished converting!");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListene
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
@@ -59,7 +58,7 @@ public class AdminGUI {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
player.closeInventory();
|
||||
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
|
||||
@Override
|
||||
@@ -76,19 +75,6 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
lore = new ArrayList<String>();
|
||||
buttons.add(new BInventoryButton("&cConfig", ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIConfig(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lore = new ArrayList<String>();
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE, 1, (short) 3)) {
|
||||
@@ -108,39 +94,6 @@ public class AdminGUI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI config.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public void openAdminGUIConfig(Player player) {
|
||||
BInventory inv = new BInventory("Config");
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("BroadcastVote",
|
||||
new String[] { "Currently: " + Config.getInstance().getBroadCastVotesEnabled() },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestBoolean(player, "" + Config.getInstance().getBroadCastVotesEnabled(),
|
||||
new BooleanListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, boolean value) {
|
||||
Config.getInstance().setBroadcastVoteEnabled(value);
|
||||
player.sendMessage("Value set");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote sites.
|
||||
*
|
||||
@@ -215,7 +168,7 @@ public class AdminGUI {
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
player.closeInventory();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null,
|
||||
new StringListener() {
|
||||
|
||||
@@ -239,7 +192,6 @@ public class AdminGUI {
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
player.closeInventory();
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
@@ -262,7 +214,7 @@ public class AdminGUI {
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
player.closeInventory();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getVoteURL(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -25,6 +24,7 @@ import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoterHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteShop.VoteShop;
|
||||
|
||||
public class PlayerGUIs {
|
||||
static PlayerGUIs instance = new PlayerGUIs();
|
||||
@@ -130,9 +130,7 @@ public class PlayerGUIs {
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
lore = Commands.getInstance().voteToday();
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
ArrayList<String> loreSt = new ArrayList<String>();
|
||||
loreSt = ArrayUtils.getInstance().comptoString(Commands.getInstance().voteHelpText(player));
|
||||
lore = ArrayUtils.getInstance().convert(loreSt);
|
||||
lore = new String[] {"Click to view help"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +159,9 @@ public class PlayerGUIs {
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
openVoteToday(player);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("v help");
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
VoteShop.getInstance().voteShop(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -804,8 +804,8 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("LogVotesToFile");
|
||||
}
|
||||
|
||||
public boolean getMilestoneResetMonthly(int milestones) {
|
||||
return getData().getBoolean("MileStones." + milestones + ".ResetMonthly");
|
||||
public boolean getResetMilestonesMonthly() {
|
||||
return getData().getBoolean("ResetMilestonesMonthly");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1054,6 +1054,14 @@ public class Config extends YMLFile {
|
||||
return "VoteParty.Rewards";
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party votes required.
|
||||
*
|
||||
|
||||
@@ -66,31 +66,6 @@ public class ConfigVoteSites extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative rewards.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the cumulative rewards
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getCumulativeRewards(String siteName) {
|
||||
|
||||
return (ArrayList<String>) getData(siteName).getList("Cumulative.Rewards", new ArrayList<String>());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative reward votes amount.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the cumulative reward votes amount
|
||||
*/
|
||||
public int getCumulativeRewardVotesAmount(String siteName) {
|
||||
return getData(siteName).getInt("Cumulative.Votes");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
@@ -99,8 +74,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData(String siteName) {
|
||||
ConfigurationSection data = getData().getConfigurationSection("VoteSites." + siteName);
|
||||
return data;
|
||||
return getData().getConfigurationSection("VoteSites." + siteName);
|
||||
}
|
||||
|
||||
public String getDisplayName(String site) {
|
||||
@@ -132,6 +106,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
public String getRewardsPath(String siteName) {
|
||||
return "VoteSites." + siteName + ".Rewards";
|
||||
}
|
||||
|
||||
public String getEverySiteRewardPath() {
|
||||
return "EverySiteReward";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service site.
|
||||
@@ -272,9 +250,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return true, if is service site good
|
||||
*/
|
||||
public boolean isServiceSiteGood(String siteName) {
|
||||
if (getServiceSite(siteName) == null) {
|
||||
return false;
|
||||
} else if (getServiceSite(siteName).equalsIgnoreCase("")) {
|
||||
if (getServiceSite(siteName) == null || getServiceSite(siteName).equals("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -288,9 +264,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return true, if is vote URL good
|
||||
*/
|
||||
public boolean isVoteURLGood(String siteName) {
|
||||
if (getVoteURL(siteName) == null) {
|
||||
return false;
|
||||
} else if (getVoteURL(siteName).equalsIgnoreCase("")) {
|
||||
if (getVoteURL(siteName) == null || getVoteURL(siteName).equals("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class VotiferEvent implements Listener {
|
||||
public void run() {
|
||||
synchronized (plugin) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
if (!user.hasJoinedBefore() && !config.allowUnJoined()) {
|
||||
if (!user.hasLoggedOnBefore() && !config.allowUnJoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
|
||||
@@ -9,18 +9,19 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.Reward;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
@@ -125,69 +126,39 @@ public class Main extends JavaPlugin {
|
||||
throw new RuntimeException("Invalid Storage Method");
|
||||
}
|
||||
UserStorage cur = AdvancedCoreHook.getInstance().getStorageType();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
loadMySQL();
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
try {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
|
||||
ArrayList<String> choiceRewards = user.getChoiceRewards();
|
||||
String inputMethod = user.getInputMethod();
|
||||
ArrayList<String> offlineRewards = user.getOfflineRewards();
|
||||
HashMap<Reward, ArrayList<Long>> timed = user.getTimedRewards();
|
||||
int allTime = user.getAllTimeTotal();
|
||||
int dailyTotal = user.getDailyTotal();
|
||||
HashMap<String, Boolean> mileStone = user.getHasGottenMilestone();
|
||||
HashMap<VoteSite, Long> lastVotes = user.getLastVotes();
|
||||
int monthTotals = user.getMonthTotal();
|
||||
ArrayList<String> otherRewards = user.getOfflineOtherRewards();
|
||||
ArrayList<String> offlineVotes = user.getOfflineVotes();
|
||||
int points = user.getPoints();
|
||||
int votePartyVotes = user.getVotePartyVotes();
|
||||
int weeklyTotal = user.getWeeklyTotal();
|
||||
|
||||
int highestDailyTotal = user.getHighestDailyTotal();
|
||||
int highestWeeklyTotal = user.getHighestWeeklyTotal();
|
||||
int highestMonthlyTotal = user.getHighestMonthlyTotal();
|
||||
int voteStreakDay = user.getDayVoteStreak();
|
||||
int voteStreakWeek = user.getWeekVoteStreak();
|
||||
int voteStreakMonth = user.getMonthVoteStreak();
|
||||
int bestVoteStreakDay = user.getBestDayVoteStreak();
|
||||
int bestVoteStreakWeek = user.getBestWeekVoteStreak();
|
||||
int bestVoteStreakMonth = user.getBestMonthVoteStreak();
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
|
||||
user.setChoiceRewards(choiceRewards);
|
||||
user.setInputMethod(inputMethod);
|
||||
user.setOfflineRewards(offlineRewards);
|
||||
user.setTimedRewards(timed);
|
||||
user.setAllTimeTotal(allTime);
|
||||
user.setDailyTotal(dailyTotal);
|
||||
user.setHasGottenMilestone(mileStone);
|
||||
user.setLastVotes(lastVotes);
|
||||
user.setMonthTotal(monthTotals);
|
||||
user.setOfflineOtherRewards(otherRewards);
|
||||
user.setOfflineVotes(offlineVotes);
|
||||
user.setPoints(points);
|
||||
user.setVotePartyVotes(votePartyVotes);
|
||||
user.setWeeklyTotal(weeklyTotal);
|
||||
|
||||
user.setHighestDailyTotal(highestDailyTotal);
|
||||
user.setHighestWeeklyTotal(highestWeeklyTotal);
|
||||
user.setHighestMonthlyTotal(highestMonthlyTotal);
|
||||
user.setDayVoteStreak(voteStreakDay);
|
||||
user.setWeekVoteStreak(voteStreakWeek);
|
||||
user.setMonthVoteStreak(voteStreakMonth);
|
||||
user.setBestDayVoteStreak(bestVoteStreakDay);
|
||||
user.setBestWeekVoteStreak(bestVoteStreakWeek);
|
||||
user.setBestMonthVoteStreak(bestVoteStreakMonth);
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
values.put(key, user.getData().getString(key));
|
||||
}
|
||||
data.put(user, values);
|
||||
} catch (Exception e) {
|
||||
AdvancedCoreHook.getInstance().debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
loadMySQL();
|
||||
|
||||
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
entry.getKey().getData().setString(values.getKey(), values.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().warning("Exception occoured for '" + entry.getKey().getUUID() + "': "
|
||||
+ e.getMessage() + ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
AdvancedCoreHook.getInstance().setStorageType(cur);
|
||||
}
|
||||
|
||||
@@ -338,13 +309,7 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
BStatsMetrics metrics = new BStatsMetrics(this);
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("requestapi_defaultmethod") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return Config.getInstance().getRequestAPIDefaultMethod();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_firstvote") {
|
||||
|
||||
@Override
|
||||
@@ -357,6 +322,18 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(ConfigVoteSites.getInstance().getData(),
|
||||
ConfigVoteSites.getInstance().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites") {
|
||||
|
||||
@Override
|
||||
@@ -631,6 +608,7 @@ public class Main extends JavaPlugin {
|
||||
Signs.getInstance().storeSigns();
|
||||
}
|
||||
}, 0);
|
||||
HandlerList.unregisterAll(plugin);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
@@ -788,31 +766,33 @@ public class Main extends JavaPlugin {
|
||||
/**
|
||||
* Update.
|
||||
*/
|
||||
public synchronized void update() {
|
||||
public void update() {
|
||||
if (update && plugin != null) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
synchronized (plugin) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
plugin.debug("Starting background task");
|
||||
try {
|
||||
TopVoterHandler.getInstance().updateTopVoters();
|
||||
Commands.getInstance().updateVoteToday();
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
plugin.debug("Background task ran");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
plugin.debug("Starting background task");
|
||||
try {
|
||||
TopVoterHandler.getInstance().updateTopVoters();
|
||||
Commands.getInstance().updateVoteToday();
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
plugin.debug("Background task ran");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -826,6 +806,21 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().allowDownloadingFromSpigot(15358);
|
||||
AdvancedCoreHook.getInstance().setExtraDebug(Config.getInstance().getExtraDebug());
|
||||
AdvancedCoreHook.getInstance().setStorageType(UserStorage.valueOf(Config.getInstance().getDataStorage()));
|
||||
loadMySQL();
|
||||
|
||||
AdvancedCoreHook.getInstance().setCheckOnWorldChange(Config.getInstance().getCheckOnWorldChange());
|
||||
AdvancedCoreHook.getInstance().setDebug(Config.getInstance().getDebugEnabled());
|
||||
AdvancedCoreHook.getInstance().setDebugIngame(Config.getInstance().getDebugInfoIngame());
|
||||
AdvancedCoreHook.getInstance().setDefaultRequestMethod(Config.getInstance().getRequestAPIDefaultMethod());
|
||||
AdvancedCoreHook.getInstance().setDisabledRequestMethods(Config.getInstance().getRequestAPIDisabledMethods());
|
||||
AdvancedCoreHook.getInstance().setFormatNoPerms(Config.getInstance().getFormatNoPerms());
|
||||
AdvancedCoreHook.getInstance().setFormatNotNumber(Config.getInstance().getFormatNotNumber());
|
||||
AdvancedCoreHook.getInstance().setHelpLine(Config.getInstance().getFormatHelpLine());
|
||||
AdvancedCoreHook.getInstance().setLogDebugToFile(Config.getInstance().getLogDebugToFile());
|
||||
AdvancedCoreHook.getInstance().setSendScoreboards(Config.getInstance().getSendScoreboards());
|
||||
}
|
||||
|
||||
private void loadMySQL() {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
Thread.getInstance().run(new Runnable() {
|
||||
|
||||
@@ -840,17 +835,6 @@ public class Main extends JavaPlugin {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
AdvancedCoreHook.getInstance().setCheckOnWorldChange(Config.getInstance().getCheckOnWorldChange());
|
||||
AdvancedCoreHook.getInstance().setDebug(Config.getInstance().getDebugEnabled());
|
||||
AdvancedCoreHook.getInstance().setDebugIngame(Config.getInstance().getDebugInfoIngame());
|
||||
AdvancedCoreHook.getInstance().setDefaultRequestMethod(Config.getInstance().getRequestAPIDefaultMethod());
|
||||
AdvancedCoreHook.getInstance().setDisabledRequestMethods(Config.getInstance().getRequestAPIDisabledMethods());
|
||||
AdvancedCoreHook.getInstance().setFormatNoPerms(Config.getInstance().getFormatNoPerms());
|
||||
AdvancedCoreHook.getInstance().setFormatNotNumber(Config.getInstance().getFormatNotNumber());
|
||||
AdvancedCoreHook.getInstance().setHelpLine(Config.getInstance().getFormatHelpLine());
|
||||
AdvancedCoreHook.getInstance().setLogDebugToFile(Config.getInstance().getLogDebugToFile());
|
||||
AdvancedCoreHook.getInstance().setSendScoreboards(Config.getInstance().getSendScoreboards());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
* Adds the points.
|
||||
*/
|
||||
public void addPoints() {
|
||||
setPoints(getPoints() + 1);
|
||||
addPoints(Config.getInstance().getPointsOnVote());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,6 +156,14 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
public void addWeekVoteStreak() {
|
||||
setWeekVoteStreak(getWeekVoteStreak() + 1);
|
||||
}
|
||||
|
||||
public int getMilestoneCount() {
|
||||
return getData().getInt("MilestoneCount",getAllTimeTotal());
|
||||
}
|
||||
|
||||
public void setMilestoneCount(int value) {
|
||||
getData().setInt("MilestoneCount", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can vote all.
|
||||
|
||||
@@ -149,6 +149,10 @@ public class VoteSite {
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getRewardsPath(key)).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getEverySiteRewardPath()).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.Ben12345rocks.VotingPlugin.OtherRewards;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -155,7 +156,7 @@ public class OtherVoteReward implements Listener {
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getMilestoneRewardsPath(votesRequired))) {
|
||||
|
||||
int userVotesTotal = user.getAllTimeTotal();
|
||||
int userVotesTotal = user.getMilestoneCount();
|
||||
if (userVotesTotal >= votesRequired && !user.hasGottenMilestone(votesRequired)) {
|
||||
giveMilestoneVoteReward(user, user.isOnline(), votesRequired);
|
||||
user.setHasGotteMilestone(votesRequired, true);
|
||||
@@ -270,25 +271,13 @@ public class OtherVoteReward implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
Set<String> votes = Config.getInstance().getMilestoneVotes();
|
||||
for (String vote : votes) {
|
||||
if (StringUtils.getInstance().isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
plugin.debug("Is int: " + vote);
|
||||
if (votesRequired != 0) {
|
||||
plugin.debug("not 0");
|
||||
if (Config.getInstance().getMilestoneRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getMilestoneRewardsPath(votesRequired))) {
|
||||
if (Config.getInstance().getMilestoneResetMonthly(votesRequired)) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setHasGotteMilestone(votesRequired, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Config.getInstance().getResetMilestonesMonthly()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setMilestoneCount(0);
|
||||
user.setHasGottenMilestone(new HashMap<String, Boolean>());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.Updater;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
@@ -58,8 +61,27 @@ public class CheckUpdate {
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger().info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion());
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkUpdateBasic() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -77,6 +99,14 @@ public class CheckUpdate {
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdate();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdateBasic();
|
||||
}
|
||||
}, 1000 * 60 * 1200, 1000 * 60 * 1200);
|
||||
|
||||
}
|
||||
}, 10l);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.Ben12345rocks.AdvancedCore.Listeners.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
@@ -84,6 +85,7 @@ public class VoteParty implements Listener {
|
||||
if (getTotalVotes() >= Config.getInstance().getVotePartyVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - Config.getInstance().getVotePartyVotesRequired());
|
||||
giveRewards();
|
||||
MiscUtils.getInstance().broadcast(Config.getInstance().getVotePartyBroadcast());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class VoteShop {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier),
|
||||
new BInventoryButton(builder.toItemStack()) {
|
||||
new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -61,6 +61,6 @@ public class VoteShop {
|
||||
});
|
||||
}
|
||||
|
||||
BInventory.openInventory(player, inv);
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user