Skip to content

Commit 37932f5

Browse files
authored
Merge pull request #322 from Ben12345rocks/5.12
5.12
2 parents 7372612 + 1c834a4 commit 37932f5

File tree

19 files changed

+434
-167
lines changed

19 files changed

+434
-167
lines changed

VotingPlugin/Resources/Config.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,6 @@ GUI:
343343
Amount: 1
344344
Name: '&4Vote Shop'
345345
Slot: 6
346-
# /vote Reward gui item
347-
# Uncomment to use, most likely will be unused
348-
#Rewards:
349-
# Item:
350-
# Material: 'DIAMOND'
351-
# Data: 0
352-
# Amount: 1
353-
# Name: '&4Voting Rewards'
354-
# Slot: 7
355346

356347
# GUI for /vote url
357348
# And /vote if enabled in Config.yml
@@ -609,12 +600,16 @@ VoteParty:
609600
GiveAllPlayers: false
610601
# If true, the vote count will reset each day
611602
ResetEachDay: false
603+
# Reset at the end of the month
604+
ResetMonthly: false
612605
# Count votes from /av vote?
613606
CountFakeVotes: true
614607
# Number of user votes that apply to vote party total the user needs to get rewards
615608
UserVotesRequired: 0
616609
# Broadcast when vote party reached
617610
Broadcast: '&cReached the vote party amount!'
611+
# List of commands to execute, these only execute once.
612+
Commands: []
618613
# Reward files to give
619614
Rewards: []
620615

@@ -671,6 +666,7 @@ VoteStreak:
671666
# IT WILL ONLY RUN ONE TIME FOR ANY NUMBER OF OFFLINE VOTES
672667
# Any reward files listed here are ran on vote of any site
673668
# It is recommended to add rewards to each site instead of here
669+
# Using forceoffline won't work here
674670
AnySiteRewards: []
675671

676672

@@ -754,9 +750,13 @@ DailyAwards:
754750
# Set to 0 to give no points
755751
PointsOnVote: 1
756752

757-
# Wether or not to check on world change
758-
# Should only be used if you do per world rewards
759-
CheckOnWorldChange: false
753+
# Set this to false to disable the plugin adding totals
754+
# Not really recommended
755+
AddTotals: true
756+
757+
# Disable checking on world change
758+
# May improve performance
759+
DisableCheckOnWorldChange: false
760760

761761
# Debug
762762
Debug: false

VotingPlugin/Resources/VoteSites.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,26 @@ VoteSites:
3131
# Reset vote delay each day (for certain sites that do this)
3232
VoteDelayDaily: false
3333

34-
# If true, rewards can be executed offline (required ForceOffline to be true in the reward)
35-
GiveOffline: false
34+
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
35+
# Setting this to true will execute the reward offline, NOT WHEN THE PLAYER IS OFFLINE
36+
# This basiclly disables offline voting if set to true, don't misinterpret this option
37+
ForceOffline: false
3638

3739
# VoteSite Material for GUI's
40+
# Removing this may result in an error, required on each site
3841
Item:
3942
Material: 'DIAMOND'
4043
Amount: 1
4144

42-
# List of reward files to give to voter
45+
# Rewards to give
46+
# https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards
4347
Rewards:
44-
- 'ExampleReward'
48+
Commands:
49+
- 'say hello'
50+
Messages:
51+
Player: 'You voted'
4552

4653
# Reward for any site
4754
# Similar to AnySiteReward
55+
# This requires the site to be configured in order to get the reward.
4856
EverySiteReward: []

VotingPlugin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.Ben12345rocks</groupId>
55
<artifactId>VotingPlugin</artifactId>
6-
<version>5.11</version>
6+
<version>5.12</version>
77
<packaging>jar</packaging>
88
<name>VotingPlugin</name>
99
<properties>
@@ -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-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/Commands/CommandLoader.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,25 @@ public void execute(CommandSender sender, String[] args) {
466466
}
467467
});
468468

469+
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "ClearOfflineRewards" },
470+
"VotingPlugin.Commands.AdminVote.ClearOfflineRewards|" + adminPerm, "Reset offline votes/rewards") {
471+
472+
@Override
473+
public void execute(CommandSender sender, String[] args) {
474+
if (sender instanceof Player) {
475+
sender.sendMessage(
476+
StringUtils.getInstance().colorize("&cThis command can not be done from ingame"));
477+
return;
478+
}
479+
480+
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
481+
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
482+
user.clearOfflineRewards();
483+
}
484+
sender.sendMessage(StringUtils.getInstance().colorize("&cCleared totals for everyone"));
485+
}
486+
});
487+
469488
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "ConvertFromData", "(userstorage)" },
470489
"VotingPlugin.Commands.AdminVote.ConvertFromData",
471490
"Convert from selected user storage to current user storage") {

VotingPlugin/src/com/Ben12345rocks/VotingPlugin/Commands/Commands.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ public String voteCommandNextInfo(User user, VoteSite voteSite) {
679679
timeMsg = StringUtils.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
680680
Long.toString(diffMinutes));
681681
info = timeMsg;
682-
682+
683683
}
684684
}
685685
} else {
@@ -834,6 +834,7 @@ public String[] voteURLs(User user) {
834834
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%num%", Integer.toString(counter));
835835
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%url%", voteURL);
836836
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%SiteName%", voteSite.getDisplayName());
837+
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%player%", user.getPlayerName());
837838
sites.add(msg);
838839
}
839840
}

VotingPlugin/src/com/Ben12345rocks/VotingPlugin/Commands/GUI/PlayerGUIs.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,12 @@ public void onClick(ClickEvent event) {
535535
if (player != null) {
536536
player.closeInventory();
537537
User user = UserManager.getInstance().getVotingPluginUser(player);
538-
user.sendMessage(StringUtils.getInstance()
539-
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
540-
Config.getInstance().getGUIVoteURLURLText(), "voteurl", voteSite.getVoteURL()),
541-
"sitename", voteSite.getDisplayName()));
538+
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
539+
StringUtils.getInstance()
540+
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
541+
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
542+
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
543+
"player", player.getName()));
542544

543545
}
544546

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public boolean getBroadCastVotesEnabled() {
110110
return getData().getBoolean("BroadcastVote", true);
111111
}
112112

113-
public boolean getCheckOnWorldChange() {
114-
return getData().getBoolean("CheckOnWorldChange");
113+
public boolean getDisableCheckOnWorldChange() {
114+
return getData().getBoolean("DisableCheckOnWorldChange");
115115
}
116116

117117
public boolean getClearCacheOnUpdate() {
@@ -1112,6 +1112,14 @@ public boolean getVotePartyResetEachDay() {
11121112
return getData().getBoolean("VoteParty.ResetEachDay");
11131113
}
11141114

1115+
public boolean getAddTotals() {
1116+
return getData().getBoolean("AddTotals", true);
1117+
}
1118+
1119+
public boolean getVotePartyResetMontly() {
1120+
return getData().getBoolean("VoteParty.ResetMonthly");
1121+
}
1122+
11151123
/**
11161124
* Gets the vote party rewards.
11171125
*
@@ -1121,6 +1129,11 @@ public String getVotePartyRewardsPath() {
11211129
return "VoteParty.Rewards";
11221130
}
11231131

1132+
@SuppressWarnings("unchecked")
1133+
public ArrayList<String> getVotePartyCommands() {
1134+
return (ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>());
1135+
}
1136+
11241137
/**
11251138
* Gets the vote party votes required.
11261139
*

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public void generateVoteSite(String siteName) {
6060
setServiceSite(siteName, org);
6161
setVoteURL(siteName, "VoteURL");
6262
setVoteDelay(siteName, 24);
63+
set(siteName, "Item.Material", "GRASS");
64+
set(siteName, "Item.Amount", 1);
6365
set(siteName, "Rewards.Messages.Player", "&aThanks for voting on %ServiceSite%!");
6466

6567
plugin.loadVoteSites();
@@ -167,7 +169,7 @@ public File getVoteSiteFile(String siteName) {
167169
}
168170

169171
public boolean getVoteSiteGiveOffline(String site) {
170-
return getData(site).getBoolean("GiveOffline");
172+
return getData(site).getBoolean("ForceOffline", getData(site).getBoolean("GiveOffline"));
171173
}
172174

173175
public boolean getVoteSiteResetVoteDelayDaily(String siteName) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ public void run() {
5353

5454
if (player != null) {
5555
User user = UserManager.getInstance().getVotingPluginUser(player);
56+
57+
// run remind
58+
user.loginMessage();
59+
5660
if (UserManager.getInstance().getAllUUIDs().contains(player.getUniqueId().toString())) {
5761
// give offline vote (if they voted
5862
// offline)
63+
5964
user.offVote();
65+
6066
}
6167

62-
// run remind
63-
user.loginMessage();
6468
}
6569

6670
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.Ben12345rocks.VotingPlugin.Events;
2+
3+
import org.bukkit.event.Event;
4+
import org.bukkit.event.HandlerList;
5+
6+
import com.Ben12345rocks.VotingPlugin.Objects.User;
7+
8+
// TODO: Auto-generated Javadoc
9+
/**
10+
* The Class PlayerVoteEvent.
11+
*/
12+
public class PlayerVoteAllSitesEvent extends Event {
13+
14+
/** The Constant handlers. */
15+
private static final HandlerList handlers = new HandlerList();
16+
17+
/**
18+
* Gets the handler list.
19+
*
20+
* @return the handler list
21+
*/
22+
public static HandlerList getHandlerList() {
23+
return handlers;
24+
}
25+
26+
private User user;
27+
28+
/** The cancelled. */
29+
private boolean cancelled;
30+
31+
public PlayerVoteAllSitesEvent(User user) {
32+
super();
33+
setUser(user);
34+
}
35+
36+
/**
37+
* @return the user
38+
*/
39+
public User getUser() {
40+
return user;
41+
}
42+
43+
/**
44+
* @param user
45+
* the user to set
46+
*/
47+
public void setUser(User user) {
48+
this.user = user;
49+
}
50+
51+
/*
52+
* (non-Javadoc)
53+
*
54+
* @see org.bukkit.event.Event#getHandlers()
55+
*/
56+
@Override
57+
public HandlerList getHandlers() {
58+
return handlers;
59+
}
60+
61+
/**
62+
* Checks if is cancelled.
63+
*
64+
* @return true, if is cancelled
65+
*/
66+
public boolean isCancelled() {
67+
return cancelled;
68+
}
69+
70+
/**
71+
* Sets the cancelled.
72+
*
73+
* @param bln
74+
* the new cancelled
75+
*/
76+
public void setCancelled(boolean bln) {
77+
cancelled = bln;
78+
}
79+
80+
}

0 commit comments

Comments
 (0)