mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Fixed jobs GUI when opened showing the same action names
- Optimized the shooting of firework random
This commit is contained in:
parent
14d60ff63d
commit
3a7eb65472
@ -1,3 +1,6 @@
|
||||
# 4.15.0
|
||||
- Fixed issue for jobs browse when opened and showing the same actions.
|
||||
|
||||
# 4.14.0
|
||||
- Fixed %titlename% placeholder does not showed anything
|
||||
- Re-added Cat, Cat is ALIVE!!
|
||||
|
@ -17,16 +17,9 @@ import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.Reflections;
|
||||
|
||||
|
||||
public class GUIListener implements Listener {
|
||||
Jobs plugin;
|
||||
|
||||
public GUIListener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onNormalInventoryClose(InventoryCloseEvent event) {
|
||||
|
@ -30,7 +30,7 @@ public class GUIManager {
|
||||
}
|
||||
|
||||
public static void registerListener() {
|
||||
Jobs.getInstance().getServer().getPluginManager().registerEvents(new GUIListener(Jobs.getInstance()), Jobs.getInstance());
|
||||
Jobs.getInstance().getServer().getPluginManager().registerEvents(new GUIListener(), Jobs.getInstance());
|
||||
}
|
||||
|
||||
public enum GUIButtonLocation {
|
||||
@ -340,16 +340,12 @@ public class GUIManager {
|
||||
for (Entry<Integer, CMIGuiButton> one : gui.getButtons().entrySet()) {
|
||||
if (one.getKey() > GuiInv.getSize())
|
||||
continue;
|
||||
try {
|
||||
ItemStack item = one.getValue().getItem(gui.getPlayer());
|
||||
item = item == null ? null : item.clone();
|
||||
if (item != null && one.getValue().isLocked()) {
|
||||
item = Reflections.setNbt(item, CMIGUIIcon, LIProtection);
|
||||
}
|
||||
GuiInv.setItem(one.getKey(), item);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
break;
|
||||
ItemStack item = one.getValue().getItem(gui.getPlayer());
|
||||
item = item == null ? null : item.clone();
|
||||
if (item != null && one.getValue().isLocked()) {
|
||||
item = Reflections.setNbt(item, CMIGUIIcon, LIProtection);
|
||||
}
|
||||
GuiInv.setItem(one.getKey(), item);
|
||||
}
|
||||
gui.setInv(GuiInv);
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
package com.gamingmesh.jobs.Gui;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
|
||||
public class GuiInfoList {
|
||||
|
||||
private String name;
|
||||
private HashMap<Integer, Job> jobList = new HashMap<>();
|
||||
private Boolean jobInfo = false;
|
||||
private int backButton = 27;
|
||||
private Inventory inv = null;
|
||||
|
||||
public GuiInfoList(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getbackButton() {
|
||||
return backButton;
|
||||
}
|
||||
|
||||
public void setbackButton(int backButton) {
|
||||
this.backButton = backButton;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Job> getJobList() {
|
||||
return jobList;
|
||||
}
|
||||
|
||||
public void addJob(int slot, Job job) {
|
||||
this.jobList.put(slot, job);
|
||||
}
|
||||
|
||||
public void setJobInfo(Boolean jobInfo) {
|
||||
this.jobInfo = jobInfo;
|
||||
}
|
||||
|
||||
public Boolean isJobInfo() {
|
||||
return jobInfo;
|
||||
}
|
||||
|
||||
public Inventory getInv() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void setInv(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
}
|
@ -166,9 +166,7 @@ public class GuiManager {
|
||||
public void openJobsBrowseGUI(Player player, Job job) {
|
||||
Inventory tempInv = Bukkit.createInventory(player, 54, "");
|
||||
|
||||
ItemStack GuiItem = job.getGuiItem();
|
||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(JPlayer, job);
|
||||
|
||||
int level = 1;
|
||||
@ -176,9 +174,9 @@ public class GuiManager {
|
||||
if (prog != null)
|
||||
level = prog.getLevel();
|
||||
|
||||
ItemStack GuiItem = job.getGuiItem();
|
||||
int numjobs = JPlayer.getJobProgression().size();
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (ActionType actionType : ActionType.values()) {
|
||||
List<JobInfo> info = job.getJobInfo(actionType);
|
||||
@ -188,37 +186,43 @@ public class GuiManager {
|
||||
|
||||
ArrayList<String> Lore = new ArrayList<>();
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||
|
||||
int y = 1;
|
||||
for (int z = 0; z < info.size(); z++) {
|
||||
JobInfo jInfo = info.get(z);
|
||||
if (jInfo == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String itemName = info.get(z).getRealisticName();
|
||||
|
||||
double income = info.get(z).getIncome(level, numjobs);
|
||||
|
||||
double income = jInfo.getIncome(level, numjobs);
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = info.get(z).getExperience(level, numjobs);
|
||||
double xp = jInfo.getExperience(level, numjobs);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
|
||||
double points = info.get(z).getPoints(level, numjobs);
|
||||
double points = jInfo.getPoints(level, numjobs);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
|
||||
|
||||
if (income == 0D && points == 0D && xp == 0D)
|
||||
continue;
|
||||
|
||||
String itemName = jInfo.getRealisticName();
|
||||
String val = "";
|
||||
|
||||
if (income != 0.0)
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor + String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income));
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor +
|
||||
String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income));
|
||||
|
||||
if (points != 0.0)
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor + String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points));
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor
|
||||
+ String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points));
|
||||
|
||||
if (xp != 0.0)
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor + String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp));
|
||||
val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor
|
||||
+ String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp));
|
||||
|
||||
Lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val);
|
||||
|
||||
@ -227,11 +231,11 @@ public class GuiManager {
|
||||
|
||||
if (z == info.size() - 1)
|
||||
continue;
|
||||
|
||||
ItemMeta meta = GuiItem.getItemMeta();
|
||||
meta.setDisplayName(job.getChatColor() + job.getName());
|
||||
meta.setLore(Lore);
|
||||
GuiItem.setItemMeta(meta);
|
||||
//GuiInv.setItem(i, GuiItem);
|
||||
tempInv.setItem(i, GuiItem.clone());
|
||||
|
||||
GuiItem = job.getGuiItem();
|
||||
@ -245,11 +249,11 @@ public class GuiManager {
|
||||
meta.setDisplayName(job.getChatColor() + job.getName());
|
||||
meta.setLore(Lore);
|
||||
GuiItem.setItemMeta(meta);
|
||||
//GuiInv.setItem(i, GuiItem);
|
||||
tempInv.setItem(i, GuiItem.clone());
|
||||
i++;
|
||||
}
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for (ItemStack one : tempInv.getContents()) {
|
||||
if (one != null)
|
||||
items.add(one);
|
||||
@ -264,7 +268,7 @@ public class GuiManager {
|
||||
gui.setInvSize(GuiSize);
|
||||
|
||||
for (int i1 = 0; i1 < items.size(); i1++) {
|
||||
gui.addButton(new CMIGuiButton(i1, GuiItem));
|
||||
gui.addButton(new CMIGuiButton(i1, items.get(i1)));
|
||||
}
|
||||
|
||||
ItemStack skull = Jobs.getGCManager().guiBackButton;
|
||||
|
@ -1265,7 +1265,7 @@ public class Jobs extends JavaPlugin {
|
||||
if (expAmount != 0D)
|
||||
payments.put(CurrencyType.EXP, expAmount);
|
||||
|
||||
FastPayment.put(jPlayer.getPlayerUUID(), new FastPayment(jPlayer, info, new BufferedPayment(jPlayer.getPlayer(), payments), prog
|
||||
FastPayment.put(jPlayer.getUniqueId(), new FastPayment(jPlayer, info, new BufferedPayment(jPlayer.getPlayer(), payments), prog
|
||||
.getJob()));
|
||||
|
||||
economy.pay(jPlayer, payments);
|
||||
|
@ -22,10 +22,10 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -244,7 +244,7 @@ public class PlayerManager {
|
||||
if (!jPlayer.isOnline() && jPlayer.isSaved())
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
|
||||
Jobs.getBpManager().saveCache();
|
||||
}
|
||||
|
||||
@ -618,20 +618,29 @@ public class PlayerManager {
|
||||
FireworkMeta fm = f.getFireworkMeta();
|
||||
|
||||
if (Jobs.getGCManager().UseRandom) {
|
||||
Random r = new Random();
|
||||
ThreadLocalRandom r = ThreadLocalRandom.current();
|
||||
int rt = r.nextInt(4) + 1;
|
||||
Type type = Type.BALL;
|
||||
|
||||
if (rt == 1)
|
||||
switch (rt) {
|
||||
case 1:
|
||||
type = Type.BALL;
|
||||
if (rt == 2)
|
||||
break;
|
||||
case 2:
|
||||
type = Type.BALL_LARGE;
|
||||
if (rt == 3)
|
||||
break;
|
||||
case 3:
|
||||
type = Type.BURST;
|
||||
if (rt == 4)
|
||||
break;
|
||||
case 4:
|
||||
type = Type.CREEPER;
|
||||
if (rt == 5)
|
||||
break;
|
||||
case 5:
|
||||
type = Type.STAR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int r1i = r.nextInt(17) + 1;
|
||||
int r2i = r.nextInt(17) + 1;
|
||||
|
@ -21,7 +21,6 @@ import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
||||
import com.gamingmesh.jobs.config.CommentedYamlConfiguration;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
|
||||
public class SignUtil {
|
||||
|
||||
@ -291,7 +290,7 @@ public class SignUtil {
|
||||
sign.setLine(i, line);
|
||||
}
|
||||
sign.update();
|
||||
if (!UpdateHead(sign, ((TopList) PlayerList.get(0)).getPlayerName(), timelapse)) {
|
||||
if (!UpdateHead(sign, PlayerList.get(0).getPlayerName(), timelapse)) {
|
||||
timelapse--;
|
||||
}
|
||||
} else {
|
||||
|
@ -13,7 +13,6 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||
import com.gamingmesh.jobs.container.BlockProtection;
|
||||
import com.gamingmesh.jobs.container.DBAction;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
|
||||
public class BlockProtectionManager {
|
||||
|
||||
|
@ -50,7 +50,6 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
@ -982,16 +982,16 @@ public class JobsPaymentListener implements Listener {
|
||||
MetadataValue value = data.get(0);
|
||||
String playerName = value.asString();
|
||||
|
||||
Player player = null;
|
||||
UUID uuid = null;
|
||||
try {
|
||||
uuid = UUID.fromString(playerName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
|
||||
if (uuid == null)
|
||||
return;
|
||||
player = Bukkit.getPlayer(uuid);
|
||||
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user