Compare commits

..
9 Commits
Author SHA1 Message Date
Ben12345rocks 4ccc5def2b Update version number 2018-05-06 12:55:22 -04:00
Ben12345rocks 5378d4e372 Slight bug fix 2018-05-04 16:57:37 -04:00
Ben12345rocks 8d37d39b1c Update version number 2018-04-21 20:54:13 -04:00
Ben12345rocks 473a83604c Add config option for delay 2018-04-16 19:19:08 -04:00
Ben12345rocks 4f72fbab78 Bug fix 2018-04-15 21:14:38 -04:00
Ben12345rocks 1f62d68aed Add a delay 2018-04-15 20:53:35 -04:00
Ben12345rocks 7c063bbe68 Only convert 500 users at a time 2018-04-15 20:23:54 -04:00
Ben12345rocks 4c11df4b37 Bug fix 2018-04-14 21:27:11 -04:00
Ben12345rocks f859caf1ee Bug fix 2018-04-14 10:29:03 -04:00
5 changed files with 75 additions and 28 deletions

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.Ben12345rocks</groupId>
<artifactId>VotingPlugin</artifactId>
<version>5.12.8</version>
<version>5.13</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -1346,7 +1346,7 @@ public class Config extends YMLFile {
public boolean getVoteURLViewAllUrlsButtonEnabled() {
return getData().getBoolean("GUI.VoteURL.ViewAllUrlsButtonEnabled");
}
public String getWeeklyAwardRewardsPath(String path) {
return "WeeklyAwards." + path + ".Rewards";
}
@@ -1422,6 +1422,10 @@ public class Config extends YMLFile {
saveData();
}
public int getConvertDelay() {
return getData().getInt("ConvertDelay", 10000);
}
/**
* Sets the debug info ingame.
*
@@ -129,30 +129,72 @@ public class Main extends JavaPlugin {
}
UserStorage cur = AdvancedCoreHook.getInstance().getStorageType();
AdvancedCoreHook.getInstance().setStorageType(from);
AdvancedCoreHook.getInstance().reload();
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));
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
&& AdvancedCoreHook.getInstance().getMysql() != null) {
AdvancedCoreHook.getInstance().getMysql().clearCache();
}
ArrayList<String> uuids = new ArrayList<String>(UserManager.getInstance().getAllUUIDs());
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);
debug("[Convert] Added " + uuid);
} catch (Exception e) {
AdvancedCoreHook.getInstance().debug(e);
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
+ ", turn debug on to see full stack traces");
while (uuids.size() > 0) {
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
AdvancedCoreHook.getInstance().setStorageType(from);
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
&& AdvancedCoreHook.getInstance().getMysql() != null)
{
AdvancedCoreHook.getInstance().getMysql().clearCache();
}
ArrayList<String> converted = new ArrayList<String>();
int i = 0;
while (i < 500 && i < uuids.size()) {
String uuid = uuids.get(i);
try {
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
HashMap<String, String> values = new HashMap<String, String>();
for (String key : user.getData().getKeys()) {
values.put(key, user.getData().getString(key));
}
i++;
converted.add(uuid);
data.put(user, values);
debug("[Convert] Added " + uuid);
} catch (Exception e) {
AdvancedCoreHook.getInstance().debug(e);
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
+ ", turn debug on to see full stack traces");
}
}
try {
wait(Config.getInstance().getConvertDelay());
} catch (Exception e) {
e.printStackTrace();
}
uuids.removeAll(converted);
plugin.getLogger()
.info("Finished getting data from " + from.toString() + " Converting " + data.size() + " users");
AdvancedCoreHook.getInstance().setStorageType(to);
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
&& AdvancedCoreHook.getInstance().getMysql() != null)
{
AdvancedCoreHook.getInstance().getMysql().clearCache();
}
writeConvertData(data);
}
plugin.getLogger().info("Finished getting data from " + from.toString());
AdvancedCoreHook.getInstance().setStorageType(to);
AdvancedCoreHook.getInstance().setStorageType(cur);
AdvancedCoreHook.getInstance().reload();
plugin.getLogger().info("Finished convertting");
}
private void writeConvertData(HashMap<User, HashMap<String, String>> data) {
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
try {
for (Entry<String, String> values : entry.getValue().entrySet()) {
@@ -164,10 +206,6 @@ public class Main extends JavaPlugin {
+ e.getMessage() + ", turn debug on to see full stack traces");
}
}
AdvancedCoreHook.getInstance().setStorageType(cur);
AdvancedCoreHook.getInstance().reload();
plugin.getLogger().info("Finished convertting");
}
public ArrayList<User> convertSet(Set<User> set) {
@@ -776,8 +814,8 @@ public class Main extends JavaPlugin {
@Override
public void run() {
plugin.getLogger()
.warning("Detected an issue with voting sites, check the plugin startup log for more details");
plugin.getLogger().warning(
"Detected an issue with voting sites, check the plugin startup log for more details");
}
}, 30l);
}
@@ -204,7 +204,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
return now.isAfter(nextvote);
} else {
if (now.getDayOfYear() != lastVote.getDayOfYear() && now.getYear() != lastVote.getYear()) {
if (now.getDayOfYear() != lastVote.getDayOfYear() || now.getYear() != lastVote.getYear()) {
return true;
}
return false;
@@ -129,7 +129,12 @@ public class VoteParty implements Listener {
}
public int getVotesRequired() {
return Config.getInstance().getVotePartyVotesRequired() + ServerData.getInstance().getVotePartyExtraRequired();
int required = Config.getInstance().getVotePartyVotesRequired();
int extra = ServerData.getInstance().getVotePartyExtraRequired();
if (extra > 0) {
return required + extra;
}
return required;
}
/**