mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-30 21:07:48 +01:00
Misc improvements
This commit is contained in:
parent
28b9ebfab3
commit
70ba4ec203
@ -72,18 +72,23 @@ public class PermissionManager {
|
||||
|
||||
private static List<String> remade(String perm) {
|
||||
List<String> perms = new ArrayList<>();
|
||||
|
||||
for (Job oneJ : Jobs.getJobs()) {
|
||||
String t = perm;
|
||||
|
||||
if (t.contains("%JOBNAME%"))
|
||||
t = t.replace("%JOBNAME%", oneJ.getName().toLowerCase());
|
||||
if (t.contains("%AMOUNT%"))
|
||||
t = t.replace("%AMOUNT%", "");
|
||||
|
||||
t = t.replace("%AMOUNT%", "");
|
||||
|
||||
perms.add(t);
|
||||
}
|
||||
|
||||
if (perm.contains("%WORLDNAME%"))
|
||||
for (World oneJ : Bukkit.getWorlds()) {
|
||||
perms.add(perm.replace("%WORLDNAME%", oneJ.getName().toLowerCase()));
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
|
@ -84,13 +84,12 @@ public class Placeholder {
|
||||
user_archived_jobs_exp_$1("jname/number"),
|
||||
|
||||
maxjobs,
|
||||
total_workers,
|
||||
|
||||
limit_$1("money/exp/points"),
|
||||
plimit_$1("money/exp/points"),
|
||||
plimit_tleft_$1("money/exp/points"),
|
||||
|
||||
total_workers,
|
||||
|
||||
name_$1("jname/number"),
|
||||
shortname_$1("jname/number"),
|
||||
chatcolor_$1("jname/number"),
|
||||
@ -105,7 +104,6 @@ public class Placeholder {
|
||||
private String[] vars;
|
||||
private List<Integer> groups = new ArrayList<>();
|
||||
private ChatFilterRule rule;
|
||||
private boolean hidden = false;
|
||||
|
||||
JobsPlaceHolders(String... vars) {
|
||||
Matcher matcher = numericalRule.getMatcher(toString());
|
||||
@ -126,7 +124,6 @@ public class Placeholder {
|
||||
}
|
||||
|
||||
this.vars = vars;
|
||||
this.hidden = false;
|
||||
}
|
||||
|
||||
public static JobsPlaceHolders getByName(String name) {
|
||||
@ -249,7 +246,8 @@ public class Placeholder {
|
||||
|
||||
public List<String> getComplexValues(String text) {
|
||||
List<String> lsInLs = new ArrayList<>();
|
||||
if (!isComplex() || text == null)
|
||||
|
||||
if (text == null || !isComplex())
|
||||
return lsInLs;
|
||||
|
||||
Matcher matcher = rule.getMatcher(text);
|
||||
@ -276,10 +274,6 @@ public class Placeholder {
|
||||
public void setRule(ChatFilterRule rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> updatePlaceHolders(Player player, List<String> messages) {
|
||||
@ -393,7 +387,7 @@ public class Placeholder {
|
||||
int id = Integer.parseInt(value);
|
||||
if (id > 0)
|
||||
return Jobs.getJobs().get(id - 1);
|
||||
} catch (Exception e) {
|
||||
} catch (IndexOutOfBoundsException | NumberFormatException e) {
|
||||
return Jobs.getJob(value);
|
||||
}
|
||||
return null;
|
||||
|
@ -90,9 +90,11 @@ public class expboost implements Cmd {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (time.contains("h") || time.contains("hour")) {
|
||||
String[] split = time.split("h|hour", 2);
|
||||
|
||||
if (split.length > 0) {
|
||||
try {
|
||||
arr[2] = Integer.parseInt(time.split("h|hour", 2)[0]);
|
||||
arr[2] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[2] = 0;
|
||||
}
|
||||
@ -100,9 +102,9 @@ public class expboost implements Cmd {
|
||||
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
|
||||
}
|
||||
|
||||
if (time.contains("m") || time.contains("minute")) {
|
||||
if ((split = time.split("m|minute", 2)).length > 0) {
|
||||
try {
|
||||
arr[1] = Integer.parseInt(time.split("m|minute", 2)[0]);
|
||||
arr[1] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[1] = 0;
|
||||
}
|
||||
@ -110,9 +112,9 @@ public class expboost implements Cmd {
|
||||
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
|
||||
}
|
||||
|
||||
if (time.contains("s") || time.contains("second")) {
|
||||
if ((split = time.split("s|second", 2)).length > 0) {
|
||||
try {
|
||||
arr[0] = Integer.parseInt(time.split("s|second", 2)[0]);
|
||||
arr[0] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[0] = 0;
|
||||
}
|
||||
|
@ -29,13 +29,16 @@ public class explored implements Cmd {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.error.noexplore"));
|
||||
return false;
|
||||
}
|
||||
if (chunk.isFullyExplored() && Jobs.getGCManager().ExploreCompact) {
|
||||
|
||||
if (Jobs.getGCManager().ExploreCompact && chunk.isFullyExplored()) {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.fullExplore"));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < chunk.getPlayers().size(); i++) {
|
||||
PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(chunk.getPlayers().get(i));
|
||||
java.util.List<Integer> players = chunk.getPlayers();
|
||||
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
PlayerInfo ji = Jobs.getPlayerManager().getPlayerInfo(players.get(i));
|
||||
if (ji != null)
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("command.explored.list", "%place%", i, "%playername%", ji.getName()));
|
||||
}
|
||||
|
@ -46,19 +46,15 @@ public class info implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
int page = 1;
|
||||
String type = "";
|
||||
if (args.length >= 2) {
|
||||
try {
|
||||
Integer.parseInt(args[1]);
|
||||
page = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
type = args[1];
|
||||
}
|
||||
}
|
||||
int page = 1;
|
||||
try {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
Jobs.getCommandManager().jobInfoMessage(pSender, jPlayer, job, type, page);
|
||||
return true;
|
||||
|
@ -14,6 +14,7 @@ import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||
@ -41,10 +42,9 @@ public class itembonus implements Cmd {
|
||||
if (iih != null && iih.getType() != Material.AIR)
|
||||
items.add(iih);
|
||||
|
||||
for (ItemStack OneArmor : player.getInventory().getArmorContents()) {
|
||||
if (OneArmor == null || OneArmor.getType() == Material.AIR)
|
||||
continue;
|
||||
items.add(OneArmor);
|
||||
for (ItemStack oneArmor : player.getInventory().getArmorContents()) {
|
||||
if (oneArmor != null && oneArmor.getType() != Material.AIR)
|
||||
items.add(oneArmor);
|
||||
}
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));
|
||||
@ -55,12 +55,15 @@ public class itembonus implements Cmd {
|
||||
continue;
|
||||
|
||||
for (Job one : jitem.getJobs()) {
|
||||
BoostMultiplier boost = !jPlayer.isInJob(one) ? jitem.getBoost() : jitem.getBoost(jPlayer.getJobProgression(one));
|
||||
JobProgression prog = jPlayer.getJobProgression(one);
|
||||
BoostMultiplier boost = prog == null ? jitem.getBoost() : jitem.getBoost(prog);
|
||||
|
||||
boolean any = false;
|
||||
for (CurrencyType oneC : CurrencyType.values()) {
|
||||
if (boost.get(oneC) != 0D)
|
||||
if (boost.get(oneC) != 0D) {
|
||||
any = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!any)
|
||||
@ -71,7 +74,7 @@ public class itembonus implements Cmd {
|
||||
ec = CMIChatColor.YELLOW.toString(),
|
||||
msg = null;
|
||||
|
||||
if (jPlayer.isInJob(one))
|
||||
if (prog != null)
|
||||
msg = Jobs.getLanguage().getMessage("command.itembonus.output.list",
|
||||
"[jobname]", one.getName(),
|
||||
"%money%", mc + formatText((int) (boost.get(CurrencyType.MONEY) * 100)),
|
||||
|
@ -20,13 +20,11 @@ public class iteminfo implements Cmd {
|
||||
}
|
||||
|
||||
if (args.length != 0) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "blockinfo");
|
||||
Jobs.getCommandManager().sendUsage(sender, "iteminfo");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand((Player) sender);
|
||||
|
||||
if (iih == null || iih.getType() == Material.AIR)
|
||||
return true;
|
||||
@ -39,14 +37,15 @@ public class iteminfo implements Cmd {
|
||||
EnchantmentTarget.FISHING_ROD.includes(iih))
|
||||
tool = true;
|
||||
|
||||
String dataString = iih.getData().getData() == 0 ? "" : "-" + iih.getData().getData();
|
||||
byte data = iih.getData().getData();
|
||||
String dataString = data == 0 ? "" : "-" + data;
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.name", "%itemname%", iih.getType().name()));
|
||||
if (Version.isCurrentEqualOrLower(Version.v1_13_R2))
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.id", "%itemid%", iih.getType().getId()));
|
||||
if (!tool)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.data", "%itemdata%", iih.getData().getData()));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.data", "%itemdata%", data));
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1))
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.usage", "%first%", "",
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -26,7 +25,7 @@ public class join implements Cmd {
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
Bukkit.dispatchCommand(sender, "jobs browse");
|
||||
plugin.getServer().dispatchCommand(sender, "jobs browse");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,11 @@ public class moneyboost implements Cmd {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (time.contains("h") || time.contains("hour")) {
|
||||
String[] split = time.split("h|hour", 2);
|
||||
|
||||
if (split.length > 0) {
|
||||
try {
|
||||
arr[2] = Integer.parseInt(time.split("h|hour", 2)[0]);
|
||||
arr[2] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[2] = 0;
|
||||
}
|
||||
@ -100,9 +102,9 @@ public class moneyboost implements Cmd {
|
||||
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
|
||||
}
|
||||
|
||||
if (time.contains("m") || time.contains("minute")) {
|
||||
if ((split = time.split("m|minute", 2)).length > 0) {
|
||||
try {
|
||||
arr[1] = Integer.parseInt(time.split("m|minute", 2)[0]);
|
||||
arr[1] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[1] = 0;
|
||||
}
|
||||
@ -110,9 +112,9 @@ public class moneyboost implements Cmd {
|
||||
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
|
||||
}
|
||||
|
||||
if (time.contains("s") || time.contains("second")) {
|
||||
if ((split = time.split("s|second", 2)).length > 0) {
|
||||
try {
|
||||
arr[0] = Integer.parseInt(time.split("s|second", 2)[0]);
|
||||
arr[0] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[0] = 0;
|
||||
}
|
||||
|
@ -52,8 +52,6 @@ public class placeholders implements Cmd {
|
||||
PageInfo pi = new PageInfo(isPlayer ? Jobs.getGCManager().PlaceholdersPage : values.length, values.length, page);
|
||||
|
||||
for (JobsPlaceHolders one : values) {
|
||||
if (one.isHidden())
|
||||
continue;
|
||||
if (pi.isBreak())
|
||||
break;
|
||||
|
||||
|
@ -28,21 +28,17 @@ public class playerinfo implements Cmd {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||
return true;
|
||||
}
|
||||
|
||||
int page = 1;
|
||||
String type = "";
|
||||
if (args.length >= 3) {
|
||||
try {
|
||||
Integer.parseInt(args[2]);
|
||||
page = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
type = args[2];
|
||||
}
|
||||
}
|
||||
|
||||
int page = 1;
|
||||
try {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
Jobs.getCommandManager().jobInfoMessage(sender, jPlayer, job, type, page);
|
||||
return true;
|
||||
}
|
||||
|
@ -90,9 +90,11 @@ public class pointboost implements Cmd {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (time.contains("h") || time.contains("hour")) {
|
||||
String[] split = time.split("h|hour", 2);
|
||||
|
||||
if (split.length > 0) {
|
||||
try {
|
||||
arr[2] = Integer.parseInt(time.split("h|hour", 2)[0]);
|
||||
arr[2] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[2] = 0;
|
||||
}
|
||||
@ -100,9 +102,9 @@ public class pointboost implements Cmd {
|
||||
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
|
||||
}
|
||||
|
||||
if (time.contains("m") || time.contains("minute")) {
|
||||
if ((split = time.split("m|minute", 2)).length > 0) {
|
||||
try {
|
||||
arr[1] = Integer.parseInt(time.split("m|minute", 2)[0]);
|
||||
arr[1] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[1] = 0;
|
||||
}
|
||||
@ -110,9 +112,9 @@ public class pointboost implements Cmd {
|
||||
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
|
||||
}
|
||||
|
||||
if (time.contains("s") || time.contains("second")) {
|
||||
if ((split = time.split("s|second", 2)).length > 0) {
|
||||
try {
|
||||
arr[0] = Integer.parseInt(time.split("s|second", 2)[0]);
|
||||
arr[0] = Integer.parseInt(split[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
arr[0] = 0;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -65,8 +64,10 @@ public class skipquest implements Cmd {
|
||||
Quest old = null;
|
||||
|
||||
for (QuestProgression one : quests) {
|
||||
if (one.getQuest().getQuestName().equalsIgnoreCase(questName) || one.getQuest().getConfigName().equalsIgnoreCase(questName)) {
|
||||
old = one.getQuest();
|
||||
Quest q = one.getQuest();
|
||||
|
||||
if (q.getQuestName().equalsIgnoreCase(questName) || q.getConfigName().equalsIgnoreCase(questName)) {
|
||||
old = q;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -90,7 +91,7 @@ public class skipquest implements Cmd {
|
||||
BufferedEconomy econ = Jobs.getEconomy();
|
||||
Player player = jPlayer.getPlayer();
|
||||
|
||||
if (amount > 0) {
|
||||
if (amount > 0 && player != null) {
|
||||
if (!econ.getEconomy().hasMoney(player, amount)) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("economy.error.nomoney"));
|
||||
return false;
|
||||
@ -101,8 +102,8 @@ public class skipquest implements Cmd {
|
||||
|
||||
jPlayer.replaceQuest(old);
|
||||
|
||||
if (player.isOnline())
|
||||
Bukkit.dispatchCommand(player, "jobs quests");
|
||||
if (player != null)
|
||||
plugin.getServer().dispatchCommand(player, "jobs quests");
|
||||
|
||||
if (amount > 0) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.skipquest.output.questSkipForCost", "%amount%", amount));
|
||||
|
@ -328,7 +328,7 @@ public class JobsPlayer {
|
||||
public double getBoost(String jobName, CurrencyType type, boolean force) {
|
||||
double boost = 0D;
|
||||
|
||||
if (!isOnline() || type == null)
|
||||
if (type == null || !isOnline())
|
||||
return boost;
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
|
@ -1557,7 +1557,6 @@ public abstract class JobsDAO {
|
||||
if (conn == null)
|
||||
return false;
|
||||
PreparedStatement prest = null;
|
||||
boolean ok = true;
|
||||
try {
|
||||
prest = conn.prepareStatement("DELETE FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.userid.getCollumn() + "` = ? AND `" + JobsTableFields.jobid.getCollumn()
|
||||
+ "` = ?;");
|
||||
@ -1566,11 +1565,11 @@ public abstract class JobsDAO {
|
||||
prest.execute();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
ok = false;
|
||||
return false;
|
||||
} finally {
|
||||
close(prest);
|
||||
}
|
||||
return ok;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1630,13 +1629,15 @@ public abstract class JobsDAO {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
int jobsTopAmount = Jobs.getGCManager().JobsTopAmount * 2;
|
||||
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
|
||||
prest = conn.prepareStatement("SELECT " + JobsTableFields.userid.getCollumn()
|
||||
+ ", COUNT(*) AS amount, sum(" + JobsTableFields.level.getCollumn() + ") AS totallvl FROM `" + getJobsTableName()
|
||||
+ "` GROUP BY userid ORDER BY totallvl DESC LIMIT " + start + "," + (Jobs.getGCManager().JobsTopAmount * 2) + ";");
|
||||
+ "` GROUP BY userid ORDER BY totallvl DESC LIMIT " + start + "," + jobsTopAmount + ";");
|
||||
res = prest.executeQuery();
|
||||
|
||||
while (res.next()) {
|
||||
@ -1646,7 +1647,7 @@ public abstract class JobsDAO {
|
||||
|
||||
names.add(new TopList(info, res.getInt("totallvl"), 0));
|
||||
|
||||
if (names.size() >= Jobs.getGCManager().JobsTopAmount * 2)
|
||||
if (names.size() >= jobsTopAmount)
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
@ -84,7 +84,6 @@ public final class JobsPayment14Listener implements Listener {
|
||||
camps.remove(camp);
|
||||
|
||||
if (camps.isEmpty()) {
|
||||
campPlayers.remove(event.getPlayer().getUniqueId());
|
||||
campPlayers.remove(playerUId);
|
||||
} else {
|
||||
campPlayers.put(playerUId, camps);
|
||||
|
@ -94,7 +94,9 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class JobsPaymentListener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
private final Jobs plugin;
|
||||
private final String blockMetadata = "BlockOwner";
|
||||
|
||||
private final Cache<UUID, Double> damageDealtByPlayers = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.weakKeys()
|
||||
@ -105,8 +107,6 @@ public class JobsPaymentListener implements Listener {
|
||||
.build();
|
||||
private Cache<UUID, Long> cowMilkingTimer;
|
||||
|
||||
private final String blockMetadata = "BlockOwner";
|
||||
|
||||
public JobsPaymentListener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@ -131,10 +131,10 @@ public class JobsPaymentListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
|
||||
if (event.getInventory().getType() != InventoryType.MERCHANT || event.getSlot() != 2 || event.getSlotType() != SlotType.RESULT)
|
||||
return;
|
||||
|
||||
if (event.getInventory().getType() != InventoryType.MERCHANT || event.getSlot() != 2 || event.getSlotType() != SlotType.RESULT)
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
|
||||
return;
|
||||
|
||||
ItemStack resultStack = event.getClickedInventory().getItem(2);
|
||||
@ -207,18 +207,13 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCowMilking(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!player.isOnline() || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
if (!(event.getRightClicked() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
Entity cow = event.getRightClicked();
|
||||
|
||||
if (cow.getType() != EntityType.COW && cow.getType() != EntityType.MUSHROOM_COW)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ItemStack itemInHand = Jobs.getNms().getItemInMainHand(player);
|
||||
if (itemInHand.getType() != Material.BUCKET && itemInHand.getType() != Material.BOWL) {
|
||||
return;
|
||||
@ -228,6 +223,9 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (!payIfCreative(player))
|
||||
return;
|
||||
@ -250,7 +248,7 @@ public class JobsPaymentListener implements Listener {
|
||||
if (time != null) {
|
||||
if (System.currentTimeMillis() < time + Jobs.getGCManager().CowMilkingTimer) {
|
||||
long timer = ((Jobs.getGCManager().CowMilkingTimer - (System.currentTimeMillis() - time)) / 1000);
|
||||
jPlayer.getPlayer().sendMessage(Jobs.getLanguage().getMessage("message.cowtimer", "%time%", timer));
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("message.cowtimer", "%time%", timer));
|
||||
|
||||
if (Jobs.getGCManager().CancelCowMilking)
|
||||
event.setCancelled(true);
|
||||
@ -268,10 +266,7 @@ public class JobsPaymentListener implements Listener {
|
||||
public void onEntityShear(PlayerShearEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!player.isOnline() || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Sheep))
|
||||
if (!(event.getEntity() instanceof Sheep) || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
Sheep sheep = (Sheep) event.getEntity();
|
||||
@ -345,12 +340,12 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(uuid);
|
||||
if (jPlayer == null || !jPlayer.isOnline())
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Player player = jPlayer.getPlayer();
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
if (!player.isOnline() || !Jobs.getPermissionHandler().hasWorldPermission(player))
|
||||
return;
|
||||
|
||||
// check if player is riding
|
||||
|
Loading…
Reference in New Issue
Block a user