Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ab78f30d5 | ||
|
|
668bc34157 | ||
|
|
5f89b30628 | ||
|
|
2145c9bc40 | ||
|
|
fdb3bca7f8 | ||
|
|
c96610d137 | ||
|
|
be6414602d | ||
|
|
a7b2d8010c |
No files matched your search
@@ -530,6 +530,7 @@ BackButton:
|
||||
Name: '&8Back to VoteGUI'
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
@@ -546,6 +547,8 @@ Shop:
|
||||
- '&c&lCost: &c3 Voting Points'
|
||||
# Number of voting points this cost
|
||||
Cost: 3
|
||||
# Permission required, leave blank for no permission
|
||||
Permission: ''
|
||||
# Rewards to run if player buys succesfully
|
||||
Rewards:
|
||||
Items:
|
||||
@@ -839,7 +842,7 @@ PurgeMin: 90
|
||||
|
||||
# Whether or not to disable checking names on mojang, disable if you hit the rate limit
|
||||
# Shouldn't make a noticeable impact if set to false
|
||||
CheckNameMojang: true
|
||||
CheckNameMojang: false
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get saved)
|
||||
CreateBackups: true
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.13</version>
|
||||
<version>5.13.3</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
|
||||
@@ -158,6 +158,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("Commands.UseGUI.Vote", true);
|
||||
}
|
||||
|
||||
public int getConvertDelay() {
|
||||
return getData().getInt("ConvertDelay", 10000);
|
||||
}
|
||||
|
||||
public boolean getCountFakeVotes() {
|
||||
return getData().getBoolean("CountFakeVotes", true);
|
||||
}
|
||||
@@ -1052,10 +1056,6 @@ public class Config extends YMLFile {
|
||||
return getData().getInt("VoteParty.UserVotesRequired");
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRquired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
@@ -1139,6 +1139,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.GiveAllPlayers");
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRquired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
@@ -1214,10 +1218,18 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteShopBackButton", true);
|
||||
}
|
||||
|
||||
public boolean getVoteShopEnabled() {
|
||||
return getData().getBoolean("VoteShopEnabled", true);
|
||||
}
|
||||
|
||||
public String getVoteShopName() {
|
||||
return getData().getString("GUI.VoteShopName", "VoteShop");
|
||||
}
|
||||
|
||||
public String getVoteShopPermission(String ident) {
|
||||
return getData().getString("Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site items.
|
||||
*
|
||||
@@ -1422,10 +1434,6 @@ public class Config extends YMLFile {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getConvertDelay() {
|
||||
return getData().getInt("ConvertDelay", 10000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug info ingame.
|
||||
*
|
||||
|
||||
@@ -103,15 +103,6 @@ public class ServerData {
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign data.
|
||||
*
|
||||
@@ -160,6 +151,10 @@ public class ServerData {
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
@@ -247,6 +242,11 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
|
||||
@@ -194,20 +194,6 @@ public class Main extends JavaPlugin {
|
||||
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()) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<User> convertSet(Set<User> set) {
|
||||
return new ArrayList<User>(set);
|
||||
}
|
||||
@@ -730,6 +716,7 @@ public class Main extends JavaPlugin {
|
||||
|
||||
setupFiles();
|
||||
loadVoteSites();
|
||||
AdvancedCoreHook.getInstance().setJenkinsSite("ben12345rocks.com");
|
||||
updateAdvancedCoreHook();
|
||||
AdvancedCoreHook.getInstance().loadHook(this);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
@@ -782,6 +769,15 @@ public class Main extends JavaPlugin {
|
||||
|
||||
loadTimer();
|
||||
|
||||
// set columns
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("Reminded", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DailyTotal", "VARCHAR(10)");
|
||||
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
|
||||
boolean hasRewards = RewardHandler.getInstance().hasRewards(ConfigVoteSites.getInstance().getData(),
|
||||
@@ -994,4 +990,18 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
}
|
||||
|
||||
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()) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,6 +77,26 @@ public class TopVoterHandler implements Listener {
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
private HashMap<Integer, String> handlePlaces(Set<String> places) {
|
||||
HashMap<Integer, String> place = new HashMap<Integer, String>();
|
||||
for (String p : places) {
|
||||
String[] data = p.split("-");
|
||||
try {
|
||||
if (data.length > 1) {
|
||||
for (int i = Integer.parseInt(data[0]); i < Integer.parseInt(data[1]); i++) {
|
||||
place.put(i, p);
|
||||
}
|
||||
} else {
|
||||
place.put(Integer.parseInt(data[0]), p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return place;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onDateChanged(DateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
@@ -182,26 +202,6 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<Integer, String> handlePlaces(Set<String> places) {
|
||||
HashMap<Integer, String> place = new HashMap<Integer, String>();
|
||||
for (String p : places) {
|
||||
String[] data = p.split("-");
|
||||
try {
|
||||
if (data.length > 1) {
|
||||
for (int i = Integer.parseInt(data[0]); i < Integer.parseInt(data[1]); i++) {
|
||||
place.put(i, p);
|
||||
}
|
||||
} else {
|
||||
place.put(Integer.parseInt(data[0]), p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return place;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPreDateChanged(PreDateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
|
||||
+17
-11
@@ -2,6 +2,7 @@ package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
@@ -50,9 +51,19 @@ public class PlaceHolders {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
public synchronized String getPlaceHolder(Player p, String identifier) {
|
||||
public synchronized String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
// vote party rewards
|
||||
if (identifier.equalsIgnoreCase("VotePartyVotesNeeded")) {
|
||||
return Integer.toString(VoteParty.getInstance().getNeededVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesCurrent")) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesRequired")) {
|
||||
return Integer.toString(VoteParty.getInstance().getVotesRequired());
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
|
||||
// %VotingPlugin_total% - Total votes of all vote sites
|
||||
@@ -102,16 +113,6 @@ public class PlaceHolders {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
// vote party rewards
|
||||
if (identifier.equalsIgnoreCase("VotePartyVotesNeeded")) {
|
||||
return Integer.toString(VoteParty.getInstance().getNeededVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesCurrent")) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesRequired")) {
|
||||
return Integer.toString(VoteParty.getInstance().getVotesRequired());
|
||||
}
|
||||
|
||||
// %VotingPlugin_canvote% - Whether or not a player can vote on all
|
||||
// sites
|
||||
if (identifier.equalsIgnoreCase("canvote")) {
|
||||
@@ -229,6 +230,11 @@ public class PlaceHolders {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
}
|
||||
|
||||
public String playerLastVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
|
||||
@@ -128,15 +128,6 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotesRequired() {
|
||||
int required = Config.getInstance().getVotePartyVotesRequired();
|
||||
int extra = ServerData.getInstance().getVotePartyExtraRequired();
|
||||
if (extra > 0) {
|
||||
return required + extra;
|
||||
}
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the needed votes.
|
||||
*
|
||||
@@ -172,6 +163,15 @@ public class VoteParty implements Listener {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
public int getVotesRequired() {
|
||||
int required = Config.getInstance().getVotePartyVotesRequired();
|
||||
int extra = ServerData.getInstance().getVotePartyExtraRequired();
|
||||
if (extra > 0) {
|
||||
return required + extra;
|
||||
}
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give reward.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.GUI.PlayerGUIs;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
@@ -30,35 +31,49 @@ public class VoteShop {
|
||||
}
|
||||
|
||||
public void voteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
|
||||
if (hasPerm) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
|
||||
if (identifier != null) {
|
||||
if (user.removePoints(points)) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier));
|
||||
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getFormatShopFailedMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
|
||||
if (identifier != null) {
|
||||
if (user.removePoints(points)) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier));
|
||||
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getFormatShopFailedMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
|
||||
Reference in new issue
Block a user