mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
parent
9aa07160eb
commit
1170086166
@ -292,82 +292,6 @@ public class CMIChatColor {
|
||||
}
|
||||
}
|
||||
|
||||
// if (text.contains(colorCodePrefix)) {
|
||||
// String t = text;
|
||||
// Matcher match = postGradientPattern.matcher(t);
|
||||
// double prevDist = Double.MAX_VALUE;
|
||||
// StringBuilder endTest = new StringBuilder();
|
||||
// String prevG9 = "";
|
||||
// while (match.find()) {
|
||||
// String g1 = match.group(1);
|
||||
//
|
||||
// if (!t.startsWith(g1)) {
|
||||
// CMIDebug.d("Not start ", t, g1);
|
||||
// prevDist = Double.MAX_VALUE;
|
||||
// }
|
||||
//
|
||||
// String g9 = match.group(9);
|
||||
// String g8 = match.group(8);
|
||||
// CMIChatColor h1 = getColor(g1);
|
||||
// CMIChatColor h2 = getColor(g9);
|
||||
//
|
||||
//
|
||||
// if (h1.getHex() == null || h2.getHex() == null)
|
||||
// continue;
|
||||
//
|
||||
// java.awt.Color c1 = null;
|
||||
// try {
|
||||
// c1 = new java.awt.Color(
|
||||
// Integer.valueOf(h1.getHex().substring(0, 2), 16),
|
||||
// Integer.valueOf(h1.getHex().substring(2, 4), 16),
|
||||
// Integer.valueOf(h1.getHex().substring(4, 6), 16));
|
||||
// } catch (Throwable e) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// java.awt.Color c2 = null;
|
||||
// try {
|
||||
// c2 = new java.awt.Color(
|
||||
// Integer.valueOf(h2.getHex().substring(0, 2), 16),
|
||||
// Integer.valueOf(h2.getHex().substring(2, 4), 16),
|
||||
// Integer.valueOf(h2.getHex().substring(4, 6), 16));
|
||||
// } catch (Throwable e) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// int red1 = c1.getRed();
|
||||
// int red2 = c2.getRed();
|
||||
// int rmean = (red1 + red2) >> 1;
|
||||
// int r = red1 - red2;
|
||||
// int g = c1.getGreen() - c2.getGreen();
|
||||
// int b = c1.getBlue() - c2.getBlue();
|
||||
// double dist = Math.sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8));
|
||||
//
|
||||
// String[] split = t.split(escape(g1) + match.group(8).replace("|", "\\|"), 2);
|
||||
// t = split[1];
|
||||
//
|
||||
// endTest.append(split[0]);
|
||||
// if (prevDist == Double.MAX_VALUE)
|
||||
// endTest.append(g1 + match.group(8));
|
||||
// else {
|
||||
// if (prevDist - dist <= 3)
|
||||
// endTest.append(match.group(8));
|
||||
// else
|
||||
// endTest.append(g1 + match.group(8));
|
||||
// }
|
||||
// prevG9 = g9;
|
||||
//
|
||||
// prevDist = dist;
|
||||
//
|
||||
// match = postGradientPattern.matcher(t);
|
||||
//
|
||||
// CMIDebug.d("Distance ", g8, g1, g9, (int) (dist * 100) / 100D, prevDist - dist <= 2 ? "OK" : "FAIL");
|
||||
// }
|
||||
// endTest.append(prevG9);
|
||||
//
|
||||
// CMIDebug.d("endString: " + endTest);
|
||||
// }
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,10 @@ public class Placeholder {
|
||||
user_maxbstandcount,
|
||||
user_furncount,
|
||||
user_maxfurncount,
|
||||
user_smokercount,
|
||||
user_maxsmokercount,
|
||||
user_blastcount,
|
||||
user_maxblastcount,
|
||||
user_doneq,
|
||||
user_dailyquests_pending,
|
||||
user_dailyquests_completed,
|
||||
@ -422,6 +426,16 @@ public class Placeholder {
|
||||
return Integer.toString(user.getFurnaceCount());
|
||||
case user_maxfurncount:
|
||||
return Integer.toString(user.getMaxOwnerShipAllowed(BlockTypes.FURNACE));
|
||||
case user_smokercount:
|
||||
return !plugin.getBlockOwnerShip(BlockTypes.SMOKER).isPresent() ? "0"
|
||||
: Integer.toString(plugin.getBlockOwnerShip(BlockTypes.SMOKER).get().getTotal(uuid));
|
||||
case user_maxsmokercount:
|
||||
return Integer.toString(user.getMaxOwnerShipAllowed(BlockTypes.SMOKER));
|
||||
case user_blastcount:
|
||||
return !plugin.getBlockOwnerShip(BlockTypes.BLAST_FURNACE).isPresent() ? "0"
|
||||
: Integer.toString(plugin.getBlockOwnerShip(BlockTypes.BLAST_FURNACE).get().getTotal(uuid));
|
||||
case user_maxblastcount:
|
||||
return Integer.toString(user.getMaxOwnerShipAllowed(BlockTypes.BLAST_FURNACE));
|
||||
case user_doneq:
|
||||
return Integer.toString(user.getDoneQuests());
|
||||
case user_seen:
|
||||
|
@ -50,6 +50,9 @@ public class JobItems {
|
||||
item = mat.newItemStack();
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name != null)
|
||||
meta.setDisplayName(CMIChatColor.translate(name));
|
||||
@ -88,6 +91,10 @@ public class JobItems {
|
||||
|
||||
ItemStack item = this.item.clone();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
if (meta.hasDisplayName())
|
||||
meta.setDisplayName(CMIChatColor.translate(meta.getDisplayName().replace("[player]", player.getName())));
|
||||
|
||||
|
@ -60,30 +60,35 @@ public class JobLimitedItems {
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(Player player) {
|
||||
try {
|
||||
mat = CMIMaterial.get(id, data);
|
||||
ItemStack item = mat.newItemStack();
|
||||
item.setAmount(amount);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (this.name != null)
|
||||
meta.setDisplayName(CMIChatColor.translate(name));
|
||||
if (lore != null && !lore.isEmpty()) {
|
||||
List<String> TranslatedLore = new ArrayList<>();
|
||||
for (String oneLore : lore) {
|
||||
TranslatedLore.add(CMIChatColor.translate(oneLore.replace("[player]", player.getName())));
|
||||
}
|
||||
meta.setLore(TranslatedLore);
|
||||
}
|
||||
if (enchants != null)
|
||||
for (Entry<Enchantment, Integer> OneEnchant : enchants.entrySet()) {
|
||||
meta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
mat = CMIMaterial.get(id, data);
|
||||
|
||||
ItemStack item = mat.newItemStack();
|
||||
item.setAmount(amount);
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) {
|
||||
return item;
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
return null;
|
||||
|
||||
if (this.name != null)
|
||||
meta.setDisplayName(CMIChatColor.translate(name));
|
||||
|
||||
if (lore != null && !lore.isEmpty()) {
|
||||
List<String> translatedLore = new ArrayList<>();
|
||||
for (String oneLore : lore) {
|
||||
translatedLore.add(CMIChatColor.translate(oneLore.replace("[player]", player.getName())));
|
||||
}
|
||||
|
||||
meta.setLore(translatedLore);
|
||||
}
|
||||
|
||||
if (enchants != null)
|
||||
for (Entry<Enchantment, Integer> oneEnchant : enchants.entrySet()) {
|
||||
meta.addEnchant(oneEnchant.getKey(), oneEnchant.getValue(), true);
|
||||
}
|
||||
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -189,8 +189,7 @@ public class JobsPlayer {
|
||||
|
||||
public double percentOverLimit(CurrencyType type) {
|
||||
Integer value = limits.get(type);
|
||||
PaymentData data = getPaymentLimit();
|
||||
return data.percentOverLimit(type, value == null ? 0 : value);
|
||||
return getPaymentLimit().percentOverLimit(type, value == null ? 0 : value);
|
||||
}
|
||||
|
||||
public void loadLogFromDao() {
|
||||
|
@ -241,8 +241,8 @@ public class JobsListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Sign sign = (Sign) block.getState();
|
||||
String FirstLine = sign.getLine(0);
|
||||
if (FirstLine.contains(Jobs.getLanguage().getMessage("signs.topline")) && !player.hasPermission("jobs.command.signs")) {
|
||||
String firstLine = sign.getLine(0);
|
||||
if (firstLine.contains(Jobs.getLanguage().getMessage("signs.topline")) && !player.hasPermission("jobs.command.signs")) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("signs.cantdestroy"));
|
||||
return;
|
||||
@ -276,8 +276,7 @@ public class JobsListener implements Listener {
|
||||
if (!CMIChatColor.stripColor(event.getLine(0)).equalsIgnoreCase("[Jobs]"))
|
||||
return;
|
||||
|
||||
final String signtype = CMIChatColor.stripColor(event.getLine(1));
|
||||
final SignTopType type = SignTopType.getType(signtype);
|
||||
final SignTopType type = SignTopType.getType(CMIChatColor.stripColor(event.getLine(1)));
|
||||
if (type == null)
|
||||
return;
|
||||
|
||||
@ -337,7 +336,7 @@ public class JobsListener implements Listener {
|
||||
if (CMIChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))) && !CMIChatColor.stripColor(event
|
||||
.getLine(1))
|
||||
.equalsIgnoreCase("toplist"))
|
||||
event.setLine(0, Convert(Jobs.getLanguage().getMessage("signs.topline")));
|
||||
event.setLine(0, convert(Jobs.getLanguage().getMessage("signs.topline")));
|
||||
else
|
||||
return;
|
||||
|
||||
@ -350,7 +349,7 @@ public class JobsListener implements Listener {
|
||||
String command = CMIChatColor.stripColor(event.getLine(1)).toLowerCase();
|
||||
for (String key : Jobs.getGCManager().keys) {
|
||||
if (command.equalsIgnoreCase(CMIChatColor.stripColor(Jobs.getLanguage().getMessage("signs.secondline." + key)))) {
|
||||
event.setLine(1, Convert(Jobs.getLanguage().getMessage("signs.secondline." + key)));
|
||||
event.setLine(1, convert(Jobs.getLanguage().getMessage("signs.secondline." + key)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -360,12 +359,11 @@ public class JobsListener implements Listener {
|
||||
return;
|
||||
|
||||
String color = Jobs.getGCManager().SignsColorizeJobName ? job.getChatColor().toString() : "";
|
||||
event.setLine(2, Convert(color + job.getName()));
|
||||
event.setLine(2, convert(color + job.getName()));
|
||||
}
|
||||
|
||||
private static String Convert(String line) {
|
||||
Pattern ReplacePatern = Pattern.compile("&([0-9a-fk-or])");
|
||||
return ReplacePatern.matcher(CMIChatColor.translate(line)).replaceAll("\u00a7$1");
|
||||
private String convert(String line) {
|
||||
return Pattern.compile("&([0-9a-fk-or])").matcher(CMIChatColor.translate(line)).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
// Adding to chat prefix job name
|
||||
@ -379,9 +377,7 @@ public class JobsListener implements Listener {
|
||||
if (honorific.equals(" "))
|
||||
honorific = "";
|
||||
|
||||
String format = event.getFormat();
|
||||
format = format.replace("%1$s", honorific + "%1$s");
|
||||
event.setFormat(format);
|
||||
event.setFormat(event.getFormat().replace("%1$s", honorific + "%1$s"));
|
||||
}
|
||||
|
||||
// Changing chat prefix variable to job name
|
||||
@ -396,11 +392,9 @@ public class JobsListener implements Listener {
|
||||
honorific = "";
|
||||
|
||||
String format = event.getFormat();
|
||||
if (!format.contains("{jobs}"))
|
||||
return;
|
||||
|
||||
format = format.replace("{jobs}", honorific);
|
||||
event.setFormat(format);
|
||||
if (format.contains("{jobs}")) {
|
||||
event.setFormat(format.replace("{jobs}", honorific));
|
||||
}
|
||||
}
|
||||
|
||||
// Changing chat prefix variable to job name
|
||||
@ -415,11 +409,9 @@ public class JobsListener implements Listener {
|
||||
honorific = "";
|
||||
|
||||
String format = event.getFormat();
|
||||
if (!format.contains("{jobs}"))
|
||||
return;
|
||||
|
||||
format = format.replace("{jobs}", honorific);
|
||||
event.setFormat(format);
|
||||
if (format.contains("{jobs}")) {
|
||||
event.setFormat(format.replace("{jobs}", honorific));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@ -432,11 +424,9 @@ public class JobsListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onCropGrown(final BlockGrowEvent event) {
|
||||
//disabling plugin in world
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> Jobs.getBpManager().remove(event.getBlock()), 1L);
|
||||
if (Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> Jobs.getBpManager().remove(event.getBlock()), 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
@ -524,8 +514,7 @@ public class JobsListener implements Listener {
|
||||
if (from == to)
|
||||
return;
|
||||
|
||||
JobsChunkChangeEvent jobsChunkChangeEvent = new JobsChunkChangeEvent(event.getPlayer(), from, to);
|
||||
plugin.getServer().getPluginManager().callEvent(jobsChunkChangeEvent);
|
||||
plugin.getServer().getPluginManager().callEvent(new JobsChunkChangeEvent(event.getPlayer(), from, to));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -724,7 +713,6 @@ public class JobsListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void PlayerItemBreakEvent(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
Jobs.getPlayerManager().resetiItemBonusCache(player.getUniqueId());
|
||||
Jobs.getPlayerManager().resetiItemBonusCache(((Player) event.getWhoClicked()).getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -876,8 +876,7 @@ public class JobsPaymentListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
// Fix money dupping issue when clicking continuously in the result item, but if in the
|
||||
// cursor have item, then dupping the money, #438
|
||||
// Possible payment exploit when clicking continuously in the result item #438
|
||||
if (event.isLeftClick() && event.getCursor().getType() != Material.AIR)
|
||||
return;
|
||||
|
||||
@ -1519,9 +1518,7 @@ public class JobsPaymentListener implements Listener {
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
// Item in hand
|
||||
ItemStack item = Jobs.getNms().getItemInMainHand(player);
|
||||
Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.EAT));
|
||||
Jobs.action(jPlayer, new ItemActionInfo(Jobs.getNms().getItemInMainHand(player), ActionType.EAT));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
@ -17,14 +17,8 @@ public class PistonProtectionListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void OnBlockMove(BlockPistonExtendEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
//disabling plugin in world
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().useBlockProtection)
|
||||
if (event.isCancelled() || !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())
|
||||
|| !Jobs.getGCManager().useBlockProtection)
|
||||
return;
|
||||
|
||||
BlockFace dir = event.getDirection();
|
||||
@ -46,14 +40,8 @@ public class PistonProtectionListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void OnBlockRetractMove(BlockPistonRetractEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
//disabling plugin in world
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()))
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().useBlockProtection)
|
||||
if (event.isCancelled() || !Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())
|
||||
|| !Jobs.getGCManager().useBlockProtection)
|
||||
return;
|
||||
|
||||
BlockFace dir = event.getDirection();
|
||||
|
Loading…
Reference in New Issue
Block a user