1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00
This commit is contained in:
Zrips 2022-03-08 16:19:52 +02:00
parent dfa564aa74
commit ba16c1a68e
4 changed files with 159 additions and 165 deletions

View File

@ -98,7 +98,7 @@ public class JobsPlayer {
this.userName = player.getName() == null ? "Unknown" : player.getName();
this.playerUUID = player.getUniqueId();
}
public JobsPlayer(Player player) {
this.userName = player.getName() == null ? "Unknown" : player.getName();
this.playerUUID = player.getUniqueId();
@ -398,16 +398,10 @@ public class JobsPlayer {
}
public int getPlayerMaxQuest(String jobName) {
int m1 = (int) Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest." + jobName, false, true);
int max = m1;
m1 = (int) Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest.all", false, true);
if (m1 != 0 && (m1 > max || m1 < max)) {
max = m1;
}
return max;
int m1 = (int) Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest.all", false, true);
if (m1 != 0)
return m1;
return (int) Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest." + jobName, false, true);
}
/**

View File

@ -13,53 +13,53 @@ import org.bukkit.inventory.meta.ItemMeta;
@SuppressWarnings("deprecation")
public final class Complement1 implements Complement {
@Override
public String getDisplayName(ItemMeta meta) {
return meta.getDisplayName();
}
@Override
public String getDisplayName(ItemMeta meta) {
return meta.getDisplayName();
}
@Override
public String getLine(SignChangeEvent event, int line) {
return event.getLine(line);
}
@Override
public String getLine(SignChangeEvent event, int line) {
return event.getLine(line);
}
@Override
public void setLine(SignChangeEvent event, int line, String text) {
event.setLine(line, text);
}
@Override
public void setLine(SignChangeEvent event, int line, String text) {
event.setLine(line, text);
}
@Override
public String getLine(Sign sign, int line) {
return sign.getLine(line);
}
@Override
public String getLine(Sign sign, int line) {
return sign.getLine(line);
}
@Override
public Inventory createInventory(InventoryHolder owner, int size, String title) {
return Bukkit.createInventory(owner, size, title);
}
@Override
public Inventory createInventory(InventoryHolder owner, int size, String title) {
return Bukkit.createInventory(owner, size, title);
}
@Override
public void setLore(ItemMeta meta, List<String> lore) {
meta.setLore(lore);
}
@Override
public void setLore(ItemMeta meta, List<String> lore) {
meta.setLore(lore);
}
@Override
public void setDisplayName(ItemMeta meta, String name) {
meta.setDisplayName(name);
}
@Override
public void setDisplayName(ItemMeta meta, String name) {
meta.setDisplayName(name);
}
@Override
public String getDisplayName(Player player) {
return player.getDisplayName();
}
@Override
public String getDisplayName(Player player) {
return player.getDisplayName();
}
@Override
public void setLine(Sign sign, int line, String text) {
sign.setLine(line, text);
}
@Override
public void setLine(Sign sign, int line, String text) {
sign.setLine(line, text);
}
@Override
public List<String> getLore(ItemMeta meta) {
return meta.getLore();
}
@Override
public List<String> getLore(ItemMeta meta) {
return meta.getLore();
}
}

View File

@ -17,83 +17,83 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
public class Complement2 implements Complement {
protected String serialize(Component component) {
return LegacyComponentSerializer.legacyAmpersand().serialize(component);
protected String serialize(Component component) {
return LegacyComponentSerializer.legacyAmpersand().serialize(component);
}
protected TextComponent deserialize(String t) {
return LegacyComponentSerializer.legacyAmpersand().deserialize(t);
}
@Override
public String getDisplayName(ItemMeta meta) {
Component dName = null;
try {
dName = meta.displayName();
} catch (NoSuchMethodError e) {
}
protected TextComponent deserialize(String t) {
return LegacyComponentSerializer.legacyAmpersand().deserialize(t);
return dName == null ? "" : serialize(dName);
}
@Override
public String getLine(SignChangeEvent event, int line) {
Component l = event.line(line);
return l == null ? "" : serialize(l);
}
@Override
public void setLine(SignChangeEvent event, int line, String text) {
event.line(line, deserialize(text));
}
@Override
public String getLine(Sign sign, int line) {
return serialize(sign.line(line));
}
@Override
public Inventory createInventory(InventoryHolder owner, int size, String title) {
return Bukkit.createInventory(owner, size, deserialize(title));
}
@Override
public void setLore(ItemMeta meta, List<String> lore) {
List<Component> l = new ArrayList<>();
for (String e : lore) {
l.add(deserialize(e));
}
@Override
public String getDisplayName(ItemMeta meta) {
Component dName = null;
meta.lore(l);
}
try {
dName = meta.displayName();
} catch (NoSuchMethodError e) {
}
@Override
public void setDisplayName(ItemMeta meta, String name) {
meta.displayName(deserialize(name));
}
return dName == null ? "" : serialize(dName);
@Override
public String getDisplayName(Player player) {
return serialize(player.displayName());
}
@Override
public void setLine(Sign sign, int line, String text) {
sign.line(line, deserialize(text));
}
@Override
public List<String> getLore(ItemMeta meta) {
List<String> lore = new ArrayList<>();
if (meta.hasLore()) {
for (Component comp : meta.lore()) {
lore.add(serialize(comp));
}
}
@Override
public String getLine(SignChangeEvent event, int line) {
Component l = event.line(line);
return l == null ? "" : serialize(l);
}
@Override
public void setLine(SignChangeEvent event, int line, String text) {
event.line(line, deserialize(text));
}
@Override
public String getLine(Sign sign, int line) {
return serialize(sign.line(line));
}
@Override
public Inventory createInventory(InventoryHolder owner, int size, String title) {
return Bukkit.createInventory(owner, size, deserialize(title));
}
@Override
public void setLore(ItemMeta meta, List<String> lore) {
List<Component> l = new ArrayList<>();
for (String e : lore) {
l.add(deserialize(e));
}
meta.lore(l);
}
@Override
public void setDisplayName(ItemMeta meta, String name) {
meta.displayName(deserialize(name));
}
@Override
public String getDisplayName(Player player) {
return serialize(player.displayName());
}
@Override
public void setLine(Sign sign, int line, String text) {
sign.line(line, deserialize(text));
}
@Override
public List<String> getLore(ItemMeta meta) {
List<String> lore = new ArrayList<>();
if (meta.hasLore()) {
for (Component comp : meta.lore()) {
lore.add(serialize(comp));
}
}
return lore;
}
return lore;
}
}

View File

@ -12,56 +12,56 @@ import com.gamingmesh.jobs.stuff.Util;
@SuppressWarnings("deprecation")
public class JobsChatEvent implements Listener {
private Jobs plugin;
private Jobs plugin;
public JobsChatEvent(Jobs plugin) {
this.plugin = plugin;
public JobsChatEvent(Jobs plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.NORMAL)
public void asyncPlayerChatEvent(final AsyncPlayerChatEvent event) {
if (event.isCancelled() || Util.getJobsEditorMap().isEmpty())
return;
final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId());
if (msg != null) {
plugin.getServer().getScheduler().runTask(plugin,
() -> event.getPlayer().performCommand(msg + event.getMessage()));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void asyncPlayerChatEvent(final AsyncPlayerChatEvent event) {
if (event.isCancelled() || Util.getJobsEditorMap().isEmpty())
return;
// Adding to chat prefix job name
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!Jobs.getGCManager().getModifyChat())
return;
final String msg = Util.getJobsEditorMap().remove(event.getPlayer().getUniqueId());
if (msg != null) {
plugin.getServer().getScheduler().runTask(plugin,
() -> event.getPlayer().performCommand(msg + event.getMessage()));
event.setCancelled(true);
}
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equals(" "))
honorific = "";
// Adding to chat prefix job name
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!Jobs.getGCManager().getModifyChat())
return;
event.setFormat(event.getFormat().replace("%1$s", honorific + "%1$s"));
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equals(" "))
honorific = "";
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChatLow(AsyncPlayerChatEvent event) {
onPlayerChatHigh(event);
}
event.setFormat(event.getFormat().replace("%1$s", honorific + "%1$s"));
}
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatHigh(AsyncPlayerChatEvent event) {
if (Jobs.getGCManager().getModifyChat())
return;
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChatLow(AsyncPlayerChatEvent event) {
onPlayerChatHigh(event);
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equals(" "))
honorific = "";
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatHigh(AsyncPlayerChatEvent event) {
if (Jobs.getGCManager().getModifyChat())
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
if (honorific.equals(" "))
honorific = "";
event.setFormat(event.getFormat().replace("{jobs}", honorific));
}
event.setFormat(event.getFormat().replace("{jobs}", honorific));
}
}