1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Now if execute the browse cmd in console not send the raw msg

- Now /jobs quest when execute in console not send the message
- Fix brewing stand id
- Now you can set in config the amount of players to be shown in one page for /jobs top command
This commit is contained in:
montlikadani 2018-09-07 16:07:15 +02:00
parent 1e8940124f
commit 05a6b71775
10 changed files with 192 additions and 157 deletions

View File

@ -14,11 +14,8 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
@ -271,7 +268,7 @@ public class CMIItemStack {
if (item.getType() == Material.POTION || item.getType().name().contains("SPLASH_POTION") || item.getType().name().contains("TIPPED_ARROW")) {
PotionMeta meta = (PotionMeta) item.getItemMeta();
if (item.getItemMeta() instanceof PotionMeta) {
if (meta instanceof PotionMeta) {
PotionMeta potionMeta = (PotionMeta) meta;
try {
if (potionMeta != null && potionMeta.getBasePotionData() != null && potionMeta.getBasePotionData() != null && potionMeta.getBasePotionData().getType().getEffectType() != null) {

View File

@ -697,7 +697,7 @@ public class ItemManager {
BRAIN_CORAL_FAN(-1, -1, 13849, "Brain Coral Fan", ""),
BRAIN_CORAL_WALL_FAN(-1, -1, 22685, "Brain Coral Wall Fan", ""),
BREAD(297, 0, 32049, "Bread", "BREAD"),
BREWING_STAND(379, 0, 14539, "Brewing Stand", "BREWING_STAND_ITEM"),
BREWING_STAND(117, 0, 14539, "Brewing Stand", ""),
BRICK(336, 0, 6820, "Brick", "claybrick"),
BRICKS(45, 0, 14165, "Bricks", ""),
BRICK_SLAB(44, 4, 26333, "Brick Slab", "STEP"),

View File

@ -551,11 +551,11 @@ public class Jobs extends JavaPlugin {
long time = System.currentTimeMillis();
// Cloning to avoid issues
HashMap<UUID, PlayerInfo> temp = new HashMap<>(Jobs.getPlayerManager().getPlayersInfoUUIDMap());
HashMap<Integer, List<JobsDAOData>> playersJobs = Jobs.getJobsDAO().getAllJobs();
HashMap<Integer, PlayerPoints> playersPoints = Jobs.getJobsDAO().getAllPoints();
HashMap<Integer, HashMap<String, Log>> playersLogs = Jobs.getJobsDAO().getAllLogs();
HashMap<Integer, ArchivedJobs> playersArchives = Jobs.getJobsDAO().getAllArchivedJobs();
HashMap<Integer, PaymentData> playersLimits = Jobs.getJobsDAO().loadPlayerLimits();
HashMap<Integer, List<JobsDAOData>> playersJobs = dao.getAllJobs();
HashMap<Integer, PlayerPoints> playersPoints = dao.getAllPoints();
HashMap<Integer, HashMap<String, Log>> playersLogs = dao.getAllLogs();
HashMap<Integer, ArchivedJobs> playersArchives = dao.getAllArchivedJobs();
HashMap<Integer, PaymentData> playersLimits = dao.loadPlayerLimits();
Iterator<Entry<UUID, PlayerInfo>> it = temp.entrySet().iterator();
while (it.hasNext()) {
Entry<UUID, PlayerInfo> one = it.next();
@ -607,7 +607,7 @@ public class Jobs extends JavaPlugin {
Jobs.getConfigManager().reload();
usedSlots.clear();
for (Job job : jobs) {
usedSlots.put(job, getJobsDAO().getSlotsTaken(job));
usedSlots.put(job, dao.getSlotsTaken(job));
}
pManager.reload();
permissionHandler.registerPermissions();
@ -622,7 +622,7 @@ public class Jobs extends JavaPlugin {
paymentThread = new BufferedPaymentThread(GconfigManager.getEconomyBatchDelay());
paymentThread.start();
Jobs.getJobsDAO().loadPlayerData();
dao.loadPlayerData();
// Schedule
Jobs.getScheduleManager().load();

View File

@ -45,8 +45,9 @@ public class browse implements Cmd {
return true;
}
int page = 1;
Job j = null;
int page = 1;
if (sender instanceof Player) {
for (String one : args) {
if (one.startsWith("-p:")) {
try {
@ -55,6 +56,9 @@ public class browse implements Cmd {
} catch (Exception e) {
}
}
}
}
for (String one : args) {
if (one.startsWith("-j:")) {
try {
j = Jobs.getJob(one.substring("-j:".length()));
@ -64,6 +68,7 @@ public class browse implements Cmd {
}
}
if (sender instanceof Player) {
if (j == null) {
PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page);
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size()));
@ -132,10 +137,11 @@ public class browse implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100)));
}
if (!j.getFullDescription().isEmpty())
if (!j.getFullDescription().isEmpty()) {
for (String one : j.getFullDescription()) {
sender.sendMessage(one);
}
}
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.browse.output.detailed"),
@ -148,6 +154,36 @@ public class browse implements Cmd {
"jobs join " + j.getName() + " -needConfirmation");
rm.show(sender);
}
} else {
if (j == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size()));
} else {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
if (j.getMaxLevel(sender) > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", j.getMaxLevel(sender)));
}
if (Jobs.getGCManager().ShowTotalWorkers) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers()));
}
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) {
if ((int) (j.getBonus() * 100) < 0)
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1));
else
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100)));
}
if (!j.getFullDescription().isEmpty()) {
for (String one : j.getFullDescription()) {
sender.sendMessage(one);
}
}
}
}
} else {

View File

@ -51,6 +51,7 @@ public class quests implements Cmd {
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getUserName(), "[questsDone]", jPlayer.getDoneQuests()));
if (sender instanceof Player) {
for (JobProgression jobProg : jPlayer.getJobProgression()) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
for (QuestProgression q : list) {
@ -89,7 +90,7 @@ public class quests implements Cmd {
// hover += "&f" + jobProg.getJob().getName();
// if (!q.getQuest().getDescription().isEmpty()) {
//
//
// for (String one : q.getQuest().getDescription()) {
// hover += "\n&7";
// hover += one;
@ -100,6 +101,8 @@ public class quests implements Cmd {
rm.show(sender);
}
}
} else return true;
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
}

View File

@ -52,7 +52,8 @@ public class top implements Cmd {
player.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.top.error.nojob"));
return false;
}
int st = (page * 15) - 15;
int showPageNum = Jobs.getGCManager().JobsTopAmount;
int st = (page * showPageNum) - showPageNum;
List<TopList> FullList = Jobs.getJobsDAO().toplist(args[0], st);
if (FullList.size() <= 0) {
@ -95,9 +96,9 @@ public class top implements Cmd {
RawMessage rm = new RawMessage();
rm.add(Jobs.getLanguage().getMessage("command.gtop.output.prev"),
Jobs.getLanguage().getMessage("command.gtop.output.show", "[from]", prev * 15 - 15, "[until]", (prev * 15)), "jobs top " + jobName + " " + prev);
Jobs.getLanguage().getMessage("command.gtop.output.show", "[from]", prev * showPageNum - showPageNum, "[until]", (prev * showPageNum)), "jobs top " + jobName + " " + prev);
rm.add(Jobs.getLanguage().getMessage("command.gtop.output.next"),
Jobs.getLanguage().getMessage("command.gtop.output.show", "[from]", (next * 15), "[until]", (next * 15 + 15)), "jobs top " + jobName + " " + next);
Jobs.getLanguage().getMessage("command.gtop.output.show", "[from]", (next * showPageNum), "[until]", (next * showPageNum + showPageNum)), "jobs top " + jobName + " " + next);
rm.show(player);
}
return true;

View File

@ -114,6 +114,8 @@ public class GeneralConfigManager {
public ItemStack guiBackButton;
public ItemStack guiFiller;
public int JobsTopAmount;
public Integer levelLossPercentageFromMax, levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume,
SoundTitleChangePitch, ToplistInScoreboardInterval;
public double MinimumOveralPaymentLimit;
@ -925,6 +927,9 @@ public class GeneralConfigManager {
c.getW().addComment("JobsGUI.SkipAmount", "Defines By how many slot we need to skip after group");
JobsGUISkipAmount = c.get("JobsGUI.SkipAmount", 2);
c.getW().addComment("JobsTop.AmountToShow", "Defines amount of players to be shown in one page for /jobs top");
JobsTopAmount = c.get("JobsTop.AmountToShow", 15);
Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN"));
guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0));
tmat = Material.getMaterial(c.get("JobsGUI.Filler.Material", "STAINED_GLASS_PANE"));

View File

@ -149,7 +149,7 @@ public class NameTranslatorManager {
if (ItemFile.getConfig().isConfigurationSection("EntityList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("EntityList");
Set<String>keys = section.getKeys(false);
Set<String> keys = section.getKeys(false);
ListOfEntities.clear();
for (String one : keys) {
String id = one.contains(":") ? one.split(":")[0] : one;
@ -165,7 +165,7 @@ public class NameTranslatorManager {
if (ItemFile.getConfig().isConfigurationSection("EnchantList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("EnchantList");
Set<String>keys = section.getKeys(false);
Set<String> keys = section.getKeys(false);
ListOfEnchants.clear();
for (String one : keys) {
String id = one.contains(":") ? one.split(":")[0] : one;
@ -181,7 +181,7 @@ public class NameTranslatorManager {
if (ItemFile.getConfig().isConfigurationSection("ColorList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("ColorList");
Set<String>keys = section.getKeys(false);
Set<String> keys = section.getKeys(false);
ListOfColors.clear();
for (String one : keys) {
String id = one.contains(":") ? one.split(":")[0] : one;
@ -197,7 +197,7 @@ public class NameTranslatorManager {
if (ItemFile.getConfig().isConfigurationSection("PotionNamesList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("PotionNamesList");
Set<String>keys = section.getKeys(false);
Set<String> keys = section.getKeys(false);
ListOfPotionNames.clear();
for (String one : keys) {
String id = one.contains(":") ? one.split(":")[0] : one;

View File

@ -1808,9 +1808,7 @@ public abstract class JobsDAO {
conn.setAutoCommit(true);
if (i > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Saved " + i + " new explorer entries.");
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message);
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Saved " + i + " new explorer entries."));
}
} catch (SQLException e) {
e.printStackTrace();
@ -1857,9 +1855,7 @@ public abstract class JobsDAO {
conn.setAutoCommit(true);
if (i > 0) {
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Updated " + i + " explorer entries.");
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message);
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Updated " + i + " explorer entries."));
}
} catch (SQLException e) {
e.printStackTrace();

View File

@ -913,20 +913,17 @@ public class JobsListener implements Listener {
@EventHandler
public void JobsArmorChangeEvent(JobsArmorChangeEvent event) {
Player player = event.getPlayer();
Jobs.getPlayerManager().resetiItemBonusCache(player.getUniqueId());
Jobs.getPlayerManager().resetiItemBonusCache(event.getPlayer().getUniqueId());
}
@EventHandler
public void PlayerItemHeldEvent(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
Jobs.getPlayerManager().resetiItemBonusCache(player.getUniqueId());
Jobs.getPlayerManager().resetiItemBonusCache(event.getPlayer().getUniqueId());
}
@EventHandler
public void PlayerItemBreakEvent(PlayerItemBreakEvent event) {
Player player = event.getPlayer();
Jobs.getPlayerManager().resetiItemBonusCache(player.getUniqueId());
Jobs.getPlayerManager().resetiItemBonusCache(event.getPlayer().getUniqueId());
}
@EventHandler