1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Options options options

options for furnace and brewing stands defaults values and save behavior
option to remove different percentage after player reaches max level
This commit is contained in:
Zrips 2018-01-22 13:12:23 +02:00
parent 0f8d2c12dd
commit 8809a33c4e
7 changed files with 171 additions and 110 deletions

View File

@ -782,7 +782,6 @@ public class Jobs extends JavaPlugin {
YmlMaker jobShopItems = new YmlMaker(this, "shopItems.yml");
jobShopItems.saveDefaultConfig();
FurnaceBrewingHandling.load();
setPermissionHandler(new PermissionHandler(this));
setJobsClassloader();
@ -834,12 +833,16 @@ public class Jobs extends JavaPlugin {
dao.loadBlockProtection();
getExplore().load();
FurnaceBrewingHandling.load();
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Plugin has been enabled succesfully.");
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message);
lManager.reload();
cManager.fillCommands();
} catch (Exception e) {
System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled.");
e.printStackTrace();

View File

@ -764,12 +764,12 @@ public class ConfigManager {
quests.add(quest);
} catch (Exception e) {
Jobs.getPluginLogger().warning("Cant load " + one + " quest for " + jobName);
Jobs.consoleMsg("&c[Jobs] Cant load " + one + " quest for " + jobName);
e.printStackTrace();
}
}
Jobs.getPluginLogger().warning("Loaded " + quests.size() + " quests for " + jobName);
Jobs.consoleMsg("&e[Jobs] Loaded " + quests.size() + " quests for " + jobName);
job.setQuests(quests);
}
job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1));

View File

@ -70,7 +70,7 @@ public class GeneralConfigManager {
public boolean PaymentMethodsPoints;
public boolean PaymentMethodsExp;
public int getSelectionTooldID;
private int ResetTimeHour;
private int ResetTimeMinute;
@ -86,6 +86,9 @@ public class GeneralConfigManager {
public Double TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier;
public String localeString = "EN";
private boolean FurnacesReassign, BrewingStandsReassign;
private int FurnacesMaxDefault, BrewingStandsMaxDefault;
public boolean useBlockProtection;
public int BlockProtectionDays;
@ -102,7 +105,7 @@ public class GeneralConfigManager {
public ItemStack guiBackButton;
public ItemStack guiFiller;
public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume,
public Integer levelLossPercentageFromMax, levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume,
SoundTitleChangePitch, ToplistInScoreboardInterval;
public double MinimumOveralPaymentLimit;
public double MinimumOveralPointsLimit;
@ -725,6 +728,25 @@ public class GeneralConfigManager {
"Set to 0 if you want to disable timer");
CowMilkingTimer = c.get("Economy.MilkingCow.Timer", 30) * 1000;
c.getW().addComment("ExploitProtections.Furnaces.Reassign",
"When enabled, players interacted furnaces will be saved into file and will be reassigned after restart to keep giving out money",
"Players will no longer need to click on furnace to get paid from it after server restart");
FurnacesReassign = c.get("ExploitProtections.Furnaces.Reassign", true);
c.getW().addComment("ExploitProtections.Furnaces.MaxDefaultAvailable",
"Defines max avaible furnaces each player can have to get paid from",
"This can be ovveriden with jobs.maxfurnaces.[amount] permission node");
FurnacesMaxDefault = c.get("ExploitProtections.Furnaces.MaxDefaultAvailable", 20);
c.getW().addComment("ExploitProtections.BrewingStands.Reassign",
"When enabled, players interacted brewing stands will be saved into file and will be reassigned after restart to keep giving out money",
"Players will no longer need to click on brewing stand to get paid from it after server restart");
BrewingStandsReassign = c.get("ExploitProtections.BrewingStands.Reassign", true);
c.getW().addComment("ExploitProtections.BrewingStands.MaxDefaultAvailable",
"Defines max avaible brewing stands each player can have to get paid from",
"Set to 0 if you want to disable this limitation",
"This can be ovveriden with jobs.maxbrewingstands.[amount] permission node");
BrewingStandsMaxDefault = c.get("ExploitProtections.BrewingStands.MaxDefaultAvailable", 20);
c.getW().addComment("ExploitProtections.General.PlaceAndBreakProtection",
"Enable blocks protection, like ore, from exploiting by placing and destroying same block again and again.",
"Modify restrictedBlocks.yml for blocks you want to protect");
@ -783,6 +805,10 @@ public class GeneralConfigManager {
"You can fix players level if hes job level is at max level");
levelLossPercentage = c.get("old-job.level-loss-percentage", 30);
fixAtMaxLevel = c.get("old-job.fix-at-max-level", true);
c.getW().addComment("old-job.level-loss-from-max-level",
"Percentage to loose when leaving job at max level",
"Only works when fix-at-max-level is set to false");
levelLossPercentageFromMax = c.get("old-job.level-loss-from-max-level", levelLossPercentage);
c.getW().addComment("ActionBars.Messages.EnabledByDefault", "When this set to true player will see action bar messages by default");
ActionBarsMessageByDefault = c.get("ActionBars.Messages.EnabledByDefault", true);
@ -892,4 +918,20 @@ public class GeneralConfigManager {
public void setResetTimeMinute(int resetTimeMinute) {
ResetTimeMinute = resetTimeMinute;
}
public boolean isFurnacesReassign() {
return FurnacesReassign;
}
public boolean isBrewingStandsReassign() {
return BrewingStandsReassign;
}
public int getFurnacesMaxDefault() {
return FurnacesMaxDefault;
}
public int getBrewingStandsMaxDefault() {
return BrewingStandsMaxDefault;
}
}

View File

@ -478,7 +478,7 @@ public class ShopManager {
}
if (!list.isEmpty())
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] " + list.size() + " shop items loaded!");
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + list.size() + " shop items!");
return;
}

View File

@ -421,8 +421,16 @@ public class JobsPlayer {
Job job = jp.getJob();
int maxLevel = this.getMaxJobLevelAllowed(job);
if (Jobs.getGCManager().fixAtMaxLevel && jp.getLevel() == maxLevel)
level = jp.getLevel();
if (jp.getLevel() == maxLevel) {
if (Jobs.getGCManager().fixAtMaxLevel) {
level = jp.getLevel();
} else {
level = jp.getLevel();
level = (int) ((level - (level * (Jobs.getGCManager().levelLossPercentageFromMax / 100.0))));
if (level < 1)
level = 1;
}
}
return level;
}
@ -436,7 +444,14 @@ public class JobsPlayer {
exp = max.doubleValue();
if (exp > 0) {
exp = (exp - (exp * (Jobs.getGCManager().levelLossPercentage / 100.0)));
Job job = jp.getJob();
int maxLevel = this.getMaxJobLevelAllowed(job);
if (jp.getLevel() == maxLevel) {
if (!Jobs.getGCManager().fixAtMaxLevel)
exp = (exp - (exp * (Jobs.getGCManager().levelLossPercentageFromMax / 100.0)));
} else {
exp = (exp - (exp * (Jobs.getGCManager().levelLossPercentage / 100.0)));
}
}
return exp.intValue();
}

View File

@ -1827,7 +1827,7 @@ public abstract class JobsDAO {
Jobs.getBpManager().timer += System.currentTimeMillis() - t;
}
if (i > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] loaded " + i + " block protection entries. " + Jobs.getBpManager().timer);
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Loaded " + i + " block protection entries. " + Jobs.getBpManager().timer);
Bukkit.getServer().getConsoleSender().sendMessage(message);
}
} catch (SQLException e) {

View File

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
@ -35,80 +34,88 @@ public class FurnaceBrewingHandling {
FileConfiguration config = f.getConfig();
if (config.contains("Furnace")) {
ConfigurationSection section = config.getConfigurationSection("Furnace");
int totalf = 0;
int totalb = 0;
try {
for (String one : section.getKeys(false)) {
String value = section.getString(one);
List<String> ls = new ArrayList<String>();
if (value.contains(";"))
ls.addAll(Arrays.asList(value.split(";")));
else
ls.add(value);
UUID uuid = UUID.fromString(one);
if (Jobs.getGCManager().isFurnacesReassign())
if (config.contains("Furnace")) {
ConfigurationSection section = config.getConfigurationSection("Furnace");
if (uuid == null)
continue;
List<blockLoc> blist = new ArrayList<blockLoc>();
for (String oneL : ls) {
blockLoc bl = new blockLoc(oneL);
Block block = bl.getBlock();
if (block == null)
try {
for (String one : section.getKeys(false)) {
String value = section.getString(one);
List<String> ls = new ArrayList<String>();
if (value.contains(";"))
ls.addAll(Arrays.asList(value.split(";")));
else
ls.add(value);
UUID uuid = UUID.fromString(one);
if (uuid == null)
continue;
List<blockLoc> blist = new ArrayList<blockLoc>();
for (String oneL : ls) {
blockLoc bl = new blockLoc(oneL);
Block block = bl.getBlock();
if (block == null)
continue;
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
blist.add(bl);
}
if (!blist.isEmpty()) {
furnaceMap.put(uuid, blist);
totalf += blist.size();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (Jobs.getGCManager().isBrewingStandsReassign())
if (config.contains("Brewing")) {
ConfigurationSection section = config.getConfigurationSection("Brewing");
try {
for (String one : section.getKeys(false)) {
String value = section.getString(one);
List<String> ls = new ArrayList<String>();
if (value.contains(";"))
ls.addAll(Arrays.asList(value.split(";")));
else
ls.add(value);
UUID uuid = UUID.fromString(one);
if (uuid == null)
continue;
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
List<blockLoc> blist = new ArrayList<blockLoc>();
for (String oneL : ls) {
blockLoc bl = new blockLoc(oneL);
Block block = bl.getBlock();
if (block == null)
continue;
Debug.D("set meta " + block.getLocation().toString() + " " + one);
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
blist.add(bl);
}
if (!blist.isEmpty()) {
Debug.D("adding furnace " + uuid.toString() + " " + blist.size());
furnaceMap.put(uuid, blist);
blist.add(bl);
}
if (!blist.isEmpty()) {
brewingMap.put(uuid, blist);
totalb += blist.size();
}
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (config.contains("Brewing")) {
ConfigurationSection section = config.getConfigurationSection("Brewing");
try {
for (String one : section.getKeys(false)) {
String value = section.getString(one);
List<String> ls = new ArrayList<String>();
if (value.contains(";"))
ls.addAll(Arrays.asList(value.split(";")));
else
ls.add(value);
UUID uuid = UUID.fromString(one);
if (uuid == null)
continue;
List<blockLoc> blist = new ArrayList<blockLoc>();
for (String oneL : ls) {
blockLoc bl = new blockLoc(oneL);
Block block = bl.getBlock();
if (block == null)
continue;
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
blist.add(bl);
}
if (!blist.isEmpty())
brewingMap.put(uuid, blist);
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (totalf > 0 || totalb > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + totalf + " furnaces and " + totalb + " brewing stands for reassigning");
}
public static void save() {
@ -120,38 +127,38 @@ public class FurnaceBrewingHandling {
f.saveDefaultConfig();
FileConfiguration config = f.getConfig();
for (Entry<UUID, List<blockLoc>> one : furnaceMap.entrySet()) {
if (Jobs.getGCManager().isFurnacesReassign())
for (Entry<UUID, List<blockLoc>> one : furnaceMap.entrySet()) {
String full = "";
String full = "";
for (blockLoc oneL : one.getValue()) {
for (blockLoc oneL : one.getValue()) {
if (!full.isEmpty())
full += ";";
full += oneL.toString();
}
if (!full.isEmpty()) {
config.set("Furnace." + one.getKey().toString(), full);
}
}
if (Jobs.getGCManager().isBrewingStandsReassign())
for (Entry<UUID, List<blockLoc>> one : brewingMap.entrySet()) {
String full = "";
for (blockLoc oneL : one.getValue()) {
if (!full.isEmpty())
full += ";";
full += oneL.toString();
}
if (!full.isEmpty())
full += ";";
full += oneL.toString();
config.set("Brewing." + one.getKey().toString(), full);
}
if (!full.isEmpty()) {
config.set("Furnace." + one.getKey().toString(), full);
}
}
for (Entry<UUID, List<blockLoc>> one : brewingMap.entrySet()) {
String full = "";
Debug.D("saving brewing stands " + one.getValue().size());
for (blockLoc oneL : one.getValue()) {
if (!full.isEmpty())
full += ";";
full += oneL.toString();
}
if (!full.isEmpty())
config.set("Brewing." + one.getKey().toString(), full);
}
f.saveConfig();
@ -237,7 +244,7 @@ public class FurnaceBrewingHandling {
Double maxV = Jobs.getPermissionManager().getMaxPermission(Jobs.getPlayerManager().getJobsPlayer(player), "jobs.maxfurnaces");
if (maxV == null)
maxV = 0D;
maxV = (double) Jobs.getGCManager().getFurnacesMaxDefault();
int max = maxV.intValue();
@ -267,9 +274,6 @@ public class FurnaceBrewingHandling {
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), player.getUniqueId().toString()));
// if (max == 0)
// return true;
List<blockLoc> ls = furnaceMap.get(player.getUniqueId());
if (ls == null)
ls = new ArrayList<blockLoc>();
@ -288,7 +292,7 @@ public class FurnaceBrewingHandling {
Double maxV = Jobs.getPermissionManager().getMaxPermission(Jobs.getPlayerManager().getJobsPlayer(player), "jobs.maxbrewingstands");
if (maxV == null)
maxV = 0D;
maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault();
int max = maxV.intValue();
@ -318,9 +322,6 @@ public class FurnaceBrewingHandling {
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), player.getUniqueId().toString()));
// if (max == 0)
// return true;
List<blockLoc> ls = brewingMap.get(player.getUniqueId());
if (ls == null)
ls = new ArrayList<blockLoc>();