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
|
# 4.14.0
|
||||||
- Fixed %titlename% placeholder does not showed anything
|
- Fixed %titlename% placeholder does not showed anything
|
||||||
- Re-added Cat, Cat is ALIVE!!
|
- 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.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
|
||||||
import com.gamingmesh.jobs.CMILib.Reflections;
|
import com.gamingmesh.jobs.CMILib.Reflections;
|
||||||
|
|
||||||
|
|
||||||
public class GUIListener implements Listener {
|
public class GUIListener implements Listener {
|
||||||
Jobs plugin;
|
|
||||||
|
|
||||||
public GUIListener(Jobs plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onNormalInventoryClose(InventoryCloseEvent event) {
|
public void onNormalInventoryClose(InventoryCloseEvent event) {
|
||||||
|
@ -30,7 +30,7 @@ public class GUIManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void registerListener() {
|
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 {
|
public enum GUIButtonLocation {
|
||||||
@ -340,16 +340,12 @@ public class GUIManager {
|
|||||||
for (Entry<Integer, CMIGuiButton> one : gui.getButtons().entrySet()) {
|
for (Entry<Integer, CMIGuiButton> one : gui.getButtons().entrySet()) {
|
||||||
if (one.getKey() > GuiInv.getSize())
|
if (one.getKey() > GuiInv.getSize())
|
||||||
continue;
|
continue;
|
||||||
try {
|
|
||||||
ItemStack item = one.getValue().getItem(gui.getPlayer());
|
ItemStack item = one.getValue().getItem(gui.getPlayer());
|
||||||
item = item == null ? null : item.clone();
|
item = item == null ? null : item.clone();
|
||||||
if (item != null && one.getValue().isLocked()) {
|
if (item != null && one.getValue().isLocked()) {
|
||||||
item = Reflections.setNbt(item, CMIGUIIcon, LIProtection);
|
item = Reflections.setNbt(item, CMIGUIIcon, LIProtection);
|
||||||
}
|
}
|
||||||
GuiInv.setItem(one.getKey(), item);
|
GuiInv.setItem(one.getKey(), item);
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
gui.setInv(GuiInv);
|
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) {
|
public void openJobsBrowseGUI(Player player, Job job) {
|
||||||
Inventory tempInv = Bukkit.createInventory(player, 54, "");
|
Inventory tempInv = Bukkit.createInventory(player, 54, "");
|
||||||
|
|
||||||
ItemStack GuiItem = job.getGuiItem();
|
|
||||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
|
|
||||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(JPlayer, job);
|
Boost boost = Jobs.getPlayerManager().getFinalBonus(JPlayer, job);
|
||||||
|
|
||||||
int level = 1;
|
int level = 1;
|
||||||
@ -176,9 +174,9 @@ public class GuiManager {
|
|||||||
if (prog != null)
|
if (prog != null)
|
||||||
level = prog.getLevel();
|
level = prog.getLevel();
|
||||||
|
|
||||||
|
ItemStack GuiItem = job.getGuiItem();
|
||||||
int numjobs = JPlayer.getJobProgression().size();
|
int numjobs = JPlayer.getJobProgression().size();
|
||||||
|
|
||||||
List<ItemStack> items = new ArrayList<>();
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ActionType actionType : ActionType.values()) {
|
for (ActionType actionType : ActionType.values()) {
|
||||||
List<JobInfo> info = job.getJobInfo(actionType);
|
List<JobInfo> info = job.getJobInfo(actionType);
|
||||||
@ -188,37 +186,43 @@ public class GuiManager {
|
|||||||
|
|
||||||
ArrayList<String> Lore = new ArrayList<>();
|
ArrayList<String> Lore = new ArrayList<>();
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
Lore.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".info"));
|
||||||
|
|
||||||
int y = 1;
|
int y = 1;
|
||||||
for (int z = 0; z < info.size(); z++) {
|
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 = jInfo.getIncome(level, numjobs);
|
||||||
|
|
||||||
double income = info.get(z).getIncome(level, numjobs);
|
|
||||||
|
|
||||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
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);
|
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
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);
|
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||||
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
|
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
|
||||||
|
|
||||||
if (income == 0D && points == 0D && xp == 0D)
|
if (income == 0D && points == 0D && xp == 0D)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
String itemName = jInfo.getRealisticName();
|
||||||
String val = "";
|
String val = "";
|
||||||
|
|
||||||
if (income != 0.0)
|
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)
|
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)
|
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);
|
Lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val);
|
||||||
|
|
||||||
@ -227,11 +231,11 @@ public class GuiManager {
|
|||||||
|
|
||||||
if (z == info.size() - 1)
|
if (z == info.size() - 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemMeta meta = GuiItem.getItemMeta();
|
ItemMeta meta = GuiItem.getItemMeta();
|
||||||
meta.setDisplayName(job.getChatColor() + job.getName());
|
meta.setDisplayName(job.getChatColor() + job.getName());
|
||||||
meta.setLore(Lore);
|
meta.setLore(Lore);
|
||||||
GuiItem.setItemMeta(meta);
|
GuiItem.setItemMeta(meta);
|
||||||
//GuiInv.setItem(i, GuiItem);
|
|
||||||
tempInv.setItem(i, GuiItem.clone());
|
tempInv.setItem(i, GuiItem.clone());
|
||||||
|
|
||||||
GuiItem = job.getGuiItem();
|
GuiItem = job.getGuiItem();
|
||||||
@ -245,11 +249,11 @@ public class GuiManager {
|
|||||||
meta.setDisplayName(job.getChatColor() + job.getName());
|
meta.setDisplayName(job.getChatColor() + job.getName());
|
||||||
meta.setLore(Lore);
|
meta.setLore(Lore);
|
||||||
GuiItem.setItemMeta(meta);
|
GuiItem.setItemMeta(meta);
|
||||||
//GuiInv.setItem(i, GuiItem);
|
|
||||||
tempInv.setItem(i, GuiItem.clone());
|
tempInv.setItem(i, GuiItem.clone());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ItemStack> items = new ArrayList<>();
|
||||||
for (ItemStack one : tempInv.getContents()) {
|
for (ItemStack one : tempInv.getContents()) {
|
||||||
if (one != null)
|
if (one != null)
|
||||||
items.add(one);
|
items.add(one);
|
||||||
@ -264,7 +268,7 @@ public class GuiManager {
|
|||||||
gui.setInvSize(GuiSize);
|
gui.setInvSize(GuiSize);
|
||||||
|
|
||||||
for (int i1 = 0; i1 < items.size(); i1++) {
|
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;
|
ItemStack skull = Jobs.getGCManager().guiBackButton;
|
||||||
|
@ -1265,7 +1265,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
if (expAmount != 0D)
|
if (expAmount != 0D)
|
||||||
payments.put(CurrencyType.EXP, expAmount);
|
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()));
|
.getJob()));
|
||||||
|
|
||||||
economy.pay(jPlayer, payments);
|
economy.pay(jPlayer, payments);
|
||||||
|
@ -22,10 +22,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -618,20 +618,29 @@ public class PlayerManager {
|
|||||||
FireworkMeta fm = f.getFireworkMeta();
|
FireworkMeta fm = f.getFireworkMeta();
|
||||||
|
|
||||||
if (Jobs.getGCManager().UseRandom) {
|
if (Jobs.getGCManager().UseRandom) {
|
||||||
Random r = new Random();
|
ThreadLocalRandom r = ThreadLocalRandom.current();
|
||||||
int rt = r.nextInt(4) + 1;
|
int rt = r.nextInt(4) + 1;
|
||||||
Type type = Type.BALL;
|
Type type = Type.BALL;
|
||||||
|
|
||||||
if (rt == 1)
|
switch (rt) {
|
||||||
|
case 1:
|
||||||
type = Type.BALL;
|
type = Type.BALL;
|
||||||
if (rt == 2)
|
break;
|
||||||
|
case 2:
|
||||||
type = Type.BALL_LARGE;
|
type = Type.BALL_LARGE;
|
||||||
if (rt == 3)
|
break;
|
||||||
|
case 3:
|
||||||
type = Type.BURST;
|
type = Type.BURST;
|
||||||
if (rt == 4)
|
break;
|
||||||
|
case 4:
|
||||||
type = Type.CREEPER;
|
type = Type.CREEPER;
|
||||||
if (rt == 5)
|
break;
|
||||||
|
case 5:
|
||||||
type = Type.STAR;
|
type = Type.STAR;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int r1i = r.nextInt(17) + 1;
|
int r1i = r.nextInt(17) + 1;
|
||||||
int r2i = 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.config.CommentedYamlConfiguration;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.TopList;
|
import com.gamingmesh.jobs.container.TopList;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
|
|
||||||
public class SignUtil {
|
public class SignUtil {
|
||||||
|
|
||||||
@ -291,7 +290,7 @@ public class SignUtil {
|
|||||||
sign.setLine(i, line);
|
sign.setLine(i, line);
|
||||||
}
|
}
|
||||||
sign.update();
|
sign.update();
|
||||||
if (!UpdateHead(sign, ((TopList) PlayerList.get(0)).getPlayerName(), timelapse)) {
|
if (!UpdateHead(sign, PlayerList.get(0).getPlayerName(), timelapse)) {
|
||||||
timelapse--;
|
timelapse--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,7 +13,6 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
|
||||||
import com.gamingmesh.jobs.container.BlockProtection;
|
import com.gamingmesh.jobs.container.BlockProtection;
|
||||||
import com.gamingmesh.jobs.container.DBAction;
|
import com.gamingmesh.jobs.container.DBAction;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
|
|
||||||
public class BlockProtectionManager {
|
public class BlockProtectionManager {
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
@ -982,16 +982,16 @@ public class JobsPaymentListener implements Listener {
|
|||||||
MetadataValue value = data.get(0);
|
MetadataValue value = data.get(0);
|
||||||
String playerName = value.asString();
|
String playerName = value.asString();
|
||||||
|
|
||||||
Player player = null;
|
|
||||||
UUID uuid = null;
|
UUID uuid = null;
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(playerName);
|
uuid = UUID.fromString(playerName);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uuid == null)
|
if (uuid == null)
|
||||||
return;
|
return;
|
||||||
player = Bukkit.getPlayer(uuid);
|
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
if (player == null || !player.isOnline())
|
if (player == null || !player.isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user