1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Remove HookPlugin abstract class

This commit is contained in:
montlikadani 2021-04-29 19:28:59 +02:00
parent 36075276f8
commit 81ed5d14af
17 changed files with 78 additions and 72 deletions

View File

@ -1178,25 +1178,37 @@ public class Jobs extends JavaPlugin {
if (!jPlayer.isUnderLimit(CurrencyType.MONEY, income)) {
income = 0D;
if (gConfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.EXP))
CurrencyLimit cLimit = gConfigManager.getLimit(CurrencyType.MONEY);
if (cLimit.getStopWith().contains(CurrencyType.EXP))
expAmount = 0D;
if (gConfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.POINTS))
if (cLimit.getStopWith().contains(CurrencyType.POINTS))
pointAmount = 0D;
}
if (!jPlayer.isUnderLimit(CurrencyType.EXP, expAmount)) {
expAmount = 0D;
if (gConfigManager.getLimit(CurrencyType.EXP).getStopWith().contains(CurrencyType.MONEY))
CurrencyLimit cLimit = gConfigManager.getLimit(CurrencyType.EXP);
if (cLimit.getStopWith().contains(CurrencyType.MONEY))
income = 0D;
if (gConfigManager.getLimit(CurrencyType.EXP).getStopWith().contains(CurrencyType.POINTS))
if (cLimit.getStopWith().contains(CurrencyType.POINTS))
pointAmount = 0D;
}
if (!jPlayer.isUnderLimit(CurrencyType.POINTS, pointAmount)) {
pointAmount = 0D;
if (gConfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.MONEY))
CurrencyLimit cLimit = gConfigManager.getLimit(CurrencyType.POINTS);
if (cLimit.getStopWith().contains(CurrencyType.MONEY))
income = 0D;
if (gConfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.EXP))
if (cLimit.getStopWith().contains(CurrencyType.EXP))
expAmount = 0D;
}

View File

@ -59,7 +59,9 @@ public class SignUtil {
if (jSign == null)
return;
signsByLocation.put(jSign.locToBlockString(), jSign);
String locToBlockString = jSign.locToBlockString();
signsByLocation.put(locToBlockString, jSign);
String identifier = jSign.getIdentifier().toLowerCase();
Map<String, jobsSign> old = signsByType.get(identifier);
@ -68,8 +70,7 @@ public class SignUtil {
signsByType.put(identifier, old);
}
old.put(jSign.locToBlockString(), jSign);
old.put(locToBlockString, jSign);
signsByType.put(identifier, old);
}

View File

@ -88,19 +88,21 @@ public class skipquest implements Cmd {
double amount = Jobs.getGCManager().skipQuestCost;
BufferedEconomy econ = Jobs.getEconomy();
Player player = jPlayer.getPlayer();
if (amount > 0) {
if (!econ.getEconomy().hasMoney(jPlayer.getPlayer(), amount)) {
if (!econ.getEconomy().hasMoney(player, amount)) {
sender.sendMessage(Jobs.getLanguage().getMessage("economy.error.nomoney"));
return false;
}
econ.getEconomy().withdrawPlayer(jPlayer.getPlayer(), amount);
econ.getEconomy().withdrawPlayer(player, amount);
}
jPlayer.replaceQuest(old);
if (jPlayer.isOnline())
Bukkit.dispatchCommand(jPlayer.getPlayer(), "jobs quests");
if (player.isOnline())
Bukkit.dispatchCommand(player, "jobs quests");
if (amount > 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.skipquest.output.questSkipForCost", "%amount%", amount));

View File

@ -30,18 +30,23 @@ public class stats implements Cmd {
return true;
}
if (jPlayer.getJobProgression().isEmpty()) {
java.util.List<JobProgression> progressions = jPlayer.getJobProgression();
if (progressions.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.stats.error.nojob"));
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName()));
for (JobProgression jobProg : jPlayer.getJobProgression()) {
String leftClick = Jobs.getLanguage().getMessage("command.info.gui.leftClick");
for (JobProgression jobProg : progressions) {
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg).split("\n")) {
new RawMessage().addText(msg).addHover(Jobs.getLanguage().getMessage("command.info.gui.leftClick"))
.addCommand("jobs info " + jobProg.getJob().getName()).show(sender);
new RawMessage().addText(msg).addHover(leftClick).addCommand("jobs info " + jobProg.getJob().getName()).show(sender);
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
}

View File

@ -395,7 +395,7 @@ public class NameTranslatorManager {
if (enchName == null)
continue;
String name = Util.firstToUpperCase(enchName).replace('_', ' ');
String name = Util.firstToUpperCase(enchName);
ConfigurationSection section = c.getC().getConfigurationSection("EnchantList");
if (section != null) {

View File

@ -43,7 +43,7 @@ import com.gamingmesh.jobs.resources.jfep.Parser;
public class Job {
private EnumMap<ActionType, List<JobInfo>> jobInfo = new EnumMap<>(ActionType.class);
private Map<ActionType, List<JobInfo>> jobInfo = new EnumMap<>(ActionType.class);
private List<JobPermission> jobPermissions;
private List<JobCommands> jobCommands;
@ -253,7 +253,7 @@ public class Job {
* Gets the job info list
* @return Job info list
*/
public EnumMap<ActionType, List<JobInfo>> getJobInfoList() {
public Map<ActionType, List<JobInfo>> getJobInfoList() {
return jobInfo;
}

View File

@ -208,9 +208,12 @@ public class JobsPlayer {
* @param amount amount of points
* @return true if it is under
*/
public boolean isUnderLimit(CurrencyType type, Double amount) {
public boolean isUnderLimit(CurrencyType type, double amount) {
if (amount == 0)
return true;
Player player = getPlayer();
if (player == null || amount == 0)
if (player == null)
return true;
CurrencyLimit limit = Jobs.getGCManager().getLimit(type);
@ -231,14 +234,19 @@ public class JobsPlayer {
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reached" + name + "limit"));
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reached" + name + "limit2"));
}
data.setInformed(true);
}
if (data.isAnnounceTime(limit.getAnnouncementDelay()) && player.isOnline())
ActionBarManager.send(player, Jobs.getLanguage().getMessage("command.limit.output." + name + "time", "%time%", TimeManage.to24hourShort(data.getLeftTime(type))));
if (data.isReseted(type))
data.setReseted(type, false);
return false;
}
data.addAmount(type, amount);
return true;
}

View File

@ -22,18 +22,18 @@ public class NameList {
private String id;
private String meta;
private String Name;
private String MinecraftName;
private String name;
private String minecraftName;
public NameList(String id, String meta, String Name, String MinecraftName) {
public NameList(String id, String meta, String name, String minecraftName) {
this.id = id;
this.meta = meta;
this.Name = Name;
this.MinecraftName = MinecraftName;
this.name = name;
this.minecraftName = minecraftName;
}
public String getName() {
return Name;
return name;
}
public String getId() {
@ -45,6 +45,6 @@ public class NameList {
}
public String getMinecraftName() {
return MinecraftName;
return minecraftName;
}
}

View File

@ -92,13 +92,15 @@ public class QuestProgression {
if (quest.isStopped() || !quest.hasAction(action.getType()))
return;
Map<String, QuestObjective> map = quest.getObjectives().get(action.getType());
if (map == null || (!map.containsKey(action.getNameWithSub()) && !map.containsKey(action.getName())))
Map<String, QuestObjective> byAction = quest.getObjectives().get(action.getType());
if (byAction != null && !byAction.containsKey(action.getNameWithSub()) && !byAction.containsKey(action.getName()))
return;
org.bukkit.entity.Player player = jPlayer.getPlayer();
for (String area : quest.getRestrictedAreas()) {
for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) {
if (a.getKey().equalsIgnoreCase(area) && a.getValue().inRestrictedArea(jPlayer.getPlayer().getLocation())) {
if (a.getKey().equalsIgnoreCase(area) && a.getValue().inRestrictedArea(player.getLocation())) {
return;
}
}
@ -113,8 +115,6 @@ public class QuestProgression {
}
if (!isCompleted()) {
Map<String, QuestObjective> byAction = quest.getObjectives().get(action.getType());
QuestObjective objective = null;
if (byAction != null) {
objective = byAction.get(action.getName());
@ -130,7 +130,7 @@ public class QuestProgression {
jPlayer.setSaved(false);
if (!isCompleted() || !jPlayer.isOnline() || givenReward)
if (!isCompleted() || !player.isOnline() || givenReward)
return;
givenReward = true;
@ -138,7 +138,7 @@ public class QuestProgression {
jPlayer.addDoneQuest(questJob);
for (String one : quest.getRewardCmds()) {
ServerCommandEvent ev = new ServerCommandEvent(Bukkit.getConsoleSender(), one.replace("[playerName]", jPlayer.getPlayer().getName()));
ServerCommandEvent ev = new ServerCommandEvent(Bukkit.getConsoleSender(), one.replace("[playerName]", player.getName()));
Bukkit.getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ev.getCommand().startsWith("/") ? ev.getCommand().substring(1) : ev.getCommand());

View File

@ -81,8 +81,8 @@ public class PaymentData {
payments.put(type, new LimitsData(type, time == null ? System.currentTimeMillis() : time, Payment));
}
public void addAmount(CurrencyType type, Double Payment) {
payments.get(type).addAmount(Payment);
public void addAmount(CurrencyType type, double payment) {
payments.get(type).addAmount(payment);
}
public long getLeftTime(CurrencyType type) {

View File

@ -1,8 +0,0 @@
package com.gamingmesh.jobs.hooks;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class HookPlugin {
public abstract JavaPlugin getPlugin();
}

View File

@ -1,6 +1,5 @@
package com.gamingmesh.jobs.hooks;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.gamingmesh.jobs.Jobs;
@ -17,8 +16,7 @@ public enum JobsHook {
public boolean isEnabled() {
if (enabled == null) {
PluginManager pluginManager = JavaPlugin.getPlugin(Jobs.class).getServer().getPluginManager();
enabled = pluginManager.getPlugin(name()) != null && pluginManager.isPluginEnabled(name());
enabled = JavaPlugin.getPlugin(Jobs.class).getServer().getPluginManager().isPluginEnabled(name());
}
return enabled;

View File

@ -4,18 +4,14 @@ import java.util.UUID;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.gamingmesh.jobs.hooks.HookPlugin;
import de.Keyle.MyPet.MyPetApi;
import de.Keyle.MyPet.MyPetPlugin;
import de.Keyle.MyPet.api.entity.MyPet;
import de.Keyle.MyPet.api.entity.MyPetBukkitEntity;
import de.Keyle.MyPet.api.player.MyPetPlayer;
import de.Keyle.MyPet.api.repository.PlayerManager;
public class MyPetManager extends HookPlugin {
public class MyPetManager {
private final PlayerManager mp = MyPetApi.getPlayerManager();
@ -49,9 +45,4 @@ public class MyPetManager extends HookPlugin {
return null;
}
}
@Override
public MyPetPlugin getPlugin() {
return JavaPlugin.getPlugin(MyPetPlugin.class);
}
}

View File

@ -12,7 +12,6 @@ import org.bukkit.plugin.Plugin;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.container.RestrictedArea;
import com.gamingmesh.jobs.hooks.HookPlugin;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
@ -21,7 +20,7 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
public class WorldGuardManager extends HookPlugin {
public class WorldGuardManager {
private WorldGuardPlugin wg;
private boolean useOld = false;
@ -37,7 +36,6 @@ public class WorldGuardManager extends HookPlugin {
}
}
@Override
public WorldGuardPlugin getPlugin() {
return wg;
}

View File

@ -5,12 +5,10 @@ import java.util.Collection;
import org.bukkit.entity.LivingEntity;
import org.bukkit.plugin.java.JavaPlugin;
import com.gamingmesh.jobs.hooks.HookPlugin;
import uk.antiperson.stackmob.StackMob;
import uk.antiperson.stackmob.entity.StackEntity;
public class StackMobHandler extends HookPlugin {
public class StackMobHandler {
public boolean isStacked(LivingEntity entity) {
return getPlugin().getEntityManager().isStackedEntity(entity);
@ -20,7 +18,6 @@ public class StackMobHandler extends HookPlugin {
return getPlugin().getEntityManager().getStackEntities();
}
@Override
public StackMob getPlugin() {
return JavaPlugin.getPlugin(StackMob.class);
}

View File

@ -735,7 +735,8 @@ public class JobsPaymentListener implements Listener {
final ItemStack[] preInv = player.getInventory().getContents();
// Clone the array. The content may (was for me) be mutable.
for (int i = 0; i < preInv.length; i++) {
preInv[i] = preInv[i] != null ? preInv[i].clone() : null;
if (preInv[i] != null)
preInv[i] = preInv[i].clone();
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

View File

@ -480,10 +480,10 @@ exampleJob:
DIG_SPEED-1:
income: 3.0
experience: 10.0
DIG_SPEED-2:
dig_speed-2:
income: 6.0
experience: 20.0
# Brewing potions
# Brewing miscellaneous items
Brew:
nether_stalk:
income: 5.0
@ -492,7 +492,8 @@ exampleJob:
income: 5.0
experience: 3.0
# Explore options. Each number represents players number in exploring that chunk
# 1 means that player is first in this chunk, 2 is second and so on, so you can give money not only for first player who discovers that chunk
# 1 means that player is first in this chunk, 2 is second and so on,
# so you can give money not only for first player who discovers that chunk
Explore:
1:
income: 5.0
@ -509,7 +510,7 @@ exampleJob:
5:
income: 0.1
experience: 0.1
# permissions granted for joining class
# permissions granted for joining to a job
permissions:
# example node
# Any name can be accepted
@ -528,7 +529,7 @@ exampleJob:
# Permission granted when reaching level 10
level: 10
# Permissions granted when particular conditions are meet
# Permissions granted when particular conditions are met
conditions:
# Condition name, irrelevant, you can write anything in here
first: