Skip to content

Commit 898b298

Browse files
authored
Merge pull request #339 from Ben12345rocks/5.12.2
5.12.2
2 parents 2693874 + cd7fa2c commit 898b298

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

VotingPlugin/Resources/Config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,11 @@ DelayBetweenUpdates: 3
798798
# Clear cache on update, setting to true reduces performance
799799
ClearCacheOnUpdate: false
800800

801+
# Clears cache for the player who voted only
802+
# Only effects if using mysql
803+
# Would recommend for some bungee setups
804+
ClearCacheOnVote: false
805+
801806
# Set to true to disable no service site message on voting
802807
# You should never have to touch this if everything is setup properly
803808
# Will also disable a few other warnings about vote sites

VotingPlugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
<dependency>
155155
<groupId>com.github.Ben12345rocks</groupId>
156156
<artifactId>AdvancedCore</artifactId>
157-
<version>master-SNAPSHOT</version>
157+
<version>2.12.2-SNAPSHOT</version>
158158
</dependency>
159159
<!-- <dependency> <groupId>com.Ben12345rocks</groupId> <artifactId>AdvancedCore</artifactId>
160160
<version>LATEST</version> <scope>compile</scope> </dependency> -->

VotingPlugin/src/com/Ben12345rocks/VotingPlugin/Config/Config.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,4 +1478,8 @@ public void setVoteRemindingRewards(ArrayList<String> value) {
14781478
saveData();
14791479
}
14801480

1481+
public boolean getClearCacheOnVote() {
1482+
return getData().getBoolean("ClearCacheOnVote");
1483+
}
1484+
14811485
}

VotingPlugin/src/com/Ben12345rocks/VotingPlugin/Events/PlayerJoinEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void run() {
5757
// run remind
5858
user.loginMessage();
5959

60-
if (UserManager.getInstance().getAllUUIDs().contains(player.getUniqueId().toString())) {
60+
if (user.getData().hasData()) {
6161
// give offline vote (if they voted
6262
// offline)
6363

VotingPlugin/src/com/Ben12345rocks/VotingPlugin/Events/VotiferEvent.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.bukkit.event.EventPriority;
88
import org.bukkit.event.Listener;
99

10+
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
11+
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
1012
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
1113
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
1214
import com.Ben12345rocks.VotingPlugin.Main;
@@ -115,6 +117,12 @@ public static void playerVote(final String playerName, final String voteSiteURL,
115117
OtherVoteReward.getInstance().checkAllSites(user);
116118
OtherVoteReward.getInstance().checkCumualativeVotes(user);
117119
OtherVoteReward.getInstance().checkMilestone(user);
120+
121+
if (Config.getInstance().getClearCacheOnVote()) {
122+
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
123+
AdvancedCoreHook.getInstance().getMysql().removePlayer(user.getUUID());
124+
}
125+
}
118126
}
119127

120128
plugin.setUpdate(true);
@@ -177,6 +185,7 @@ public void run() {
177185
plugin.getServer().getPluginManager().callEvent(voteEvent);
178186

179187
if (voteEvent.isCancelled()) {
188+
plugin.debug("Vote cancelled");
180189
return;
181190
}
182191

VotingPlugin/src/com/Ben12345rocks/VotingPlugin/Main.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,16 @@ public void convertDataStorage(UserStorage from, UserStorage to) {
142142
values.put(key, user.getData().getString(key));
143143
}
144144
data.put(user, values);
145+
debug("[Convert] Added " + uuid);
145146
} catch (Exception e) {
146147
AdvancedCoreHook.getInstance().debug(e);
147148
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
148149
+ ", turn debug on to see full stack traces");
149150
}
150151
}
151152

153+
plugin.getLogger().info("Finished getting data from " + from.toString());
154+
152155
AdvancedCoreHook.getInstance().setStorageType(to);
153156
loadMySQL();
154157

@@ -164,6 +167,8 @@ public void convertDataStorage(UserStorage from, UserStorage to) {
164167
}
165168
}
166169
AdvancedCoreHook.getInstance().setStorageType(cur);
170+
171+
plugin.getLogger().info("Finished convertting");
167172
}
168173

169174
public ArrayList<User> convertSet(Set<User> set) {
@@ -281,13 +286,20 @@ public void run() {
281286
}
282287

283288
private void loadTimer() {
284-
AdvancedCoreHook.getInstance().getTimer().schedule(new TimerTask() {
289+
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
285290

286291
@Override
287292
public void run() {
288-
update();
293+
AdvancedCoreHook.getInstance().getTimer().schedule(new TimerTask() {
294+
295+
@Override
296+
public void run() {
297+
update();
298+
}
299+
}, 1000, 1000 * 60 * Config.getInstance().getDelayBetweenUpdates());
289300
}
290-
}, 1000, 1000 * 60 * Config.getInstance().getDelayBetweenUpdates());
301+
});
302+
291303
}
292304

293305
/**
@@ -699,14 +711,22 @@ public Object getObject(OfflinePlayer player) {
699711

700712
loadTimer();
701713

702-
plugin.getLogger().info("Enabled VotingPlgin " + plugin.getDescription().getVersion());
714+
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
703715

716+
ArrayList<String> services = ServerData.getInstance().getServiceSites();
704717
for (VoteSite site : getVoteSites()) {
705718
if (!site.hasRewards()) {
706719
plugin.getLogger().warning("No rewards detected for the site: " + site.getKey()
707720
+ ". See https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards on how to add rewards");
708721
}
709-
if (!ServerData.getInstance().getServiceSites().contains(site.getServiceSite())) {
722+
723+
boolean contains = false;
724+
for (String service : services) {
725+
if (service.equalsIgnoreCase(site.getServiceSite())) {
726+
contains = true;
727+
}
728+
}
729+
if (!contains) {
710730
plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite()
711731
+ ", may be an invalid service site. Vote on the site and look in console for a service site, if you get nothing then there is an issue with votifier");
712732
}
@@ -825,7 +845,7 @@ public void reload() {
825845
updateAdvancedCoreHook();
826846
plugin.loadVoteSites();
827847
AdvancedCoreHook.getInstance().reload();
828-
loadTimer();
848+
// loadTimer();
829849

830850
}
831851

@@ -900,6 +920,8 @@ public void update() {
900920
if (uuid != null && !uuid.isEmpty()) {
901921
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
902922
users.add(user);
923+
// AdvancedCoreHook.getInstance().extraDebug("Loading " + uuid);
924+
// java.lang.Thread.sleep(5000);
903925
}
904926
}
905927
update = false;

0 commit comments

Comments
 (0)