1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 07:01:22 +01:00

Check for null if possible

- Fix NPE when a item not found in enchant_table
- Melon can be used for now as melon_block
- We needs the redstone_lamp_on material, #440
This commit is contained in:
montlikadani 2019-05-30 18:40:41 +02:00
parent 1db6723904
commit 23e349bd10
23 changed files with 82 additions and 168 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>Jobs</groupId> <groupId>Jobs</groupId>
<artifactId>jobs</artifactId> <artifactId>jobs</artifactId>
<version>4.11.2</version> <version>4.12.0</version>
<name>Jobs</name> <name>Jobs</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<properties> <properties>
@ -16,16 +16,16 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.14.1-R0.1-SNAPSHOT</version> <version>1.14.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- MyPet --> <!-- MyPet -->
<dependency> <dependency>
<groupId>de.Keyle.MyPet</groupId> <groupId>de.Keyle.MyPet</groupId>
<artifactId>MyPet</artifactId> <artifactId>MyPet</artifactId>
<version>3.0-SNAPSHOT</version> <version>3.1-SNAPSHOT-B1433</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${basedir}/libs/MyPet-3.0-SNAPSHOT.jar</systemPath> <systemPath>${basedir}/libs/MyPet-3.1-SNAPSHOT-B1433.jar</systemPath>
</dependency> </dependency>
<!-- McMMO --> <!-- McMMO -->
<dependency> <dependency>

View File

@ -1534,7 +1534,7 @@ public class ItemManager {
MAGMA_CREAM(378, 0, 25097, "Magma Cream"), MAGMA_CREAM(378, 0, 25097, "Magma Cream"),
MAGMA_CUBE_SPAWN_EGG(383, 62, 26638, "Spawn Magma Cube", "Magma Cube Spawn Egg"), MAGMA_CUBE_SPAWN_EGG(383, 62, 26638, "Spawn Magma Cube", "Magma Cube Spawn Egg"),
MAP(395, 0, 21655, "Empty Map"), MAP(395, 0, 21655, "Empty Map"),
MELON(103, 0, 25172, "Melon", "Melon_Block"), MELON_BLOCK(103, 0, 25172, "Melon"),
MELON_SEEDS(362, 0, 18340, "Melon Seeds"), MELON_SEEDS(362, 0, 18340, "Melon Seeds"),
MELON_SLICE(360, 0, 5347, "Melon Slice"), MELON_SLICE(360, 0, 5347, "Melon Slice"),
MELON_STEM(105, 0, 8247, "Melon Stem"), MELON_STEM(105, 0, 8247, "Melon Stem"),
@ -2035,7 +2035,7 @@ public class ItemManager {
LEGACY_DIODE_BLOCK_ON(94, 0, null, "Diode Block On"), LEGACY_DIODE_BLOCK_ON(94, 0, null, "Diode Block On"),
LEGACY_BREWING_STAND(117, null, null, "Brewing Stand"), LEGACY_BREWING_STAND(117, null, null, "Brewing Stand"),
// LEGACY_CAULDRON(118, 0, null, "LEGACY_CAULDRON", ""), // LEGACY_CAULDRON(118, 0, null, "LEGACY_CAULDRON", ""),
// LEGACY_REDSTONE_LAMP_ON(124, null, null, "LEGACY_REDSTONE_LAMP_ON", ""), LEGACY_REDSTONE_LAMP_ON(124, 0, null, "LEGACY_REDSTONE_LAMP_ON"),
// LEGACY_WOOD_DOUBLE_STEP(125, null, null, "LEGACY_WOOD_DOUBLE_STEP", ""), // LEGACY_WOOD_DOUBLE_STEP(125, null, null, "LEGACY_WOOD_DOUBLE_STEP", ""),
// LEGACY_FLOWER_POT(140, null, null, "LEGACY_FLOWER_POT", ""), // LEGACY_FLOWER_POT(140, null, null, "LEGACY_FLOWER_POT", ""),
LEGACY_REDSTONE_COMPARATOR_OFF(149, 0, null, "Redstone Comparator Off", ""), LEGACY_REDSTONE_COMPARATOR_OFF(149, 0, null, "Redstone Comparator Off", ""),

View File

@ -18,7 +18,6 @@ public class McMMOManager {
private HashMap<UUID, HashMap<String, Long>> map = new HashMap<>(); private HashMap<UUID, HashMap<String, Long>> map = new HashMap<>();
public double getMultiplier(Player player) { public double getMultiplier(Player player) {
if (player == null) if (player == null)
return 0D; return 0D;

View File

@ -0,0 +1,18 @@
package com.gamingmesh.jobs.api;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class BaseEvent extends Event {
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -1,13 +1,10 @@
package com.gamingmesh.jobs.api; package com.gamingmesh.jobs.api;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gamingmesh.jobs.container.CuboidArea; import com.gamingmesh.jobs.container.CuboidArea;
public final class JobsAreaSelectionEvent extends Event { public final class JobsAreaSelectionEvent extends BaseEvent {
private static final HandlerList handlers = new HandlerList();
private CuboidArea area; private CuboidArea area;
private Player player; private Player player;
@ -23,13 +20,4 @@ public final class JobsAreaSelectionEvent extends Event {
public CuboidArea getArea() { public CuboidArea getArea() {
return area; return area;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -3,11 +3,8 @@ package com.gamingmesh.jobs.api;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public final class JobsChunkChangeEvent extends Event implements Cancellable { public final class JobsChunkChangeEvent extends BaseEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Player player; private Player player;
private Chunk oldChunk; private Chunk oldChunk;
private Chunk newChunk; private Chunk newChunk;
@ -40,13 +37,4 @@ public final class JobsChunkChangeEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -2,13 +2,10 @@ package com.gamingmesh.jobs.api;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
public final class JobsExpGainEvent extends Event implements Cancellable { public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private OfflinePlayer offlinePlayer; private OfflinePlayer offlinePlayer;
private double exp; private double exp;
private Job job; private Job job;
@ -45,13 +42,4 @@ public final class JobsExpGainEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -1,14 +1,11 @@
package com.gamingmesh.jobs.api; package com.gamingmesh.jobs.api;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
public final class JobsJoinEvent extends Event implements Cancellable { public final class JobsJoinEvent extends BaseEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private JobsPlayer player; private JobsPlayer player;
private Job job; private Job job;
private boolean cancelled = false; private boolean cancelled = false;
@ -35,13 +32,4 @@ public final class JobsJoinEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -1,14 +1,11 @@
package com.gamingmesh.jobs.api; package com.gamingmesh.jobs.api;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
public final class JobsLeaveEvent extends Event implements Cancellable { public final class JobsLeaveEvent extends BaseEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private JobsPlayer player; private JobsPlayer player;
private Job job; private Job job;
private boolean cancelled = false; private boolean cancelled = false;
@ -35,13 +32,4 @@ public final class JobsLeaveEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -2,14 +2,11 @@ package com.gamingmesh.jobs.api;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Title; import com.gamingmesh.jobs.container.Title;
public final class JobsLevelUpEvent extends Event implements Cancellable { public final class JobsLevelUpEvent extends BaseEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private JobsPlayer player; private JobsPlayer player;
private String JobName; private String JobName;
private Title OldTitle; private Title OldTitle;
@ -157,13 +154,4 @@ public final class JobsLevelUpEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -2,11 +2,8 @@ package com.gamingmesh.jobs.api;
import com.gamingmesh.jobs.container.Schedule; import com.gamingmesh.jobs.container.Schedule;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class JobsScheduleStartEvent extends Event implements Cancellable { public class JobsScheduleStartEvent extends BaseEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false; private boolean cancelled = false;
private Schedule schedule; private Schedule schedule;
@ -27,13 +24,4 @@ public class JobsScheduleStartEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -2,11 +2,8 @@ package com.gamingmesh.jobs.api;
import com.gamingmesh.jobs.container.Schedule; import com.gamingmesh.jobs.container.Schedule;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class JobsScheduleStopEvent extends Event implements Cancellable { public class JobsScheduleStopEvent extends BaseEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false; private boolean cancelled = false;
private Schedule schedule; private Schedule schedule;
@ -27,13 +24,4 @@ public class JobsScheduleStopEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -16,7 +16,6 @@ import com.gamingmesh.jobs.container.QuestObjective;
import com.gamingmesh.jobs.container.QuestProgression; import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.CMILib.RawMessage; import com.gamingmesh.jobs.CMILib.RawMessage;
import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.TimeManage;
import com.gamingmesh.jobs.stuff.Util;
public class quests implements Cmd { public class quests implements Cmd {
@ -81,18 +80,14 @@ public class quests implements Cmd {
} }
for (Entry<String, QuestObjective> oneObjective : q.getQuest().getObjectives().entrySet()) { for (Entry<String, QuestObjective> oneObjective : q.getQuest().getObjectives().entrySet()) {
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " + hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue() Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
.getTargetMeta(), oneObjective.getValue().getTargetName()) .getTargetMeta(), oneObjective.getValue().getTargetName())
+ " " + q.getAmountDone(oneObjective.getValue()) + "/" + " " + q.getAmountDone(oneObjective.getValue()) + "/"
+ oneObjective.getValue().getAmount()); + oneObjective.getValue().getAmount());
} }
String hover = ""; String hover = "";
for (String one : hoverList) { for (String one : hoverList) {
if (!hover.isEmpty()) if (!hover.isEmpty())
hover += "\n"; hover += "\n";

View File

@ -33,7 +33,6 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling; import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.TimeManage;

View File

@ -24,8 +24,8 @@ public class Quest {
private List<String> rewardCmds = new ArrayList<>(); private List<String> rewardCmds = new ArrayList<>();
private List<String> rewards = new ArrayList<>(); private List<String> rewards = new ArrayList<>();
private HashMap<String, QuestObjective> objectives = new HashMap<String, QuestObjective>(); private HashMap<String, QuestObjective> objectives = new HashMap<>();
private Set<ActionType> actions = new HashSet<ActionType>(); private Set<ActionType> actions = new HashSet<>();
public Quest(String questName, Job job) { public Quest(String questName, Job job) {
this.questName = questName; this.questName = questName;

View File

@ -12,7 +12,7 @@ public class QuestProgression {
// private int amountDone = 0; // private int amountDone = 0;
private Long validUntil; private Long validUntil;
private boolean givenReward = false; private boolean givenReward = false;
private HashMap<QuestObjective, Integer> done = new HashMap<QuestObjective, Integer>(); private HashMap<QuestObjective, Integer> done = new HashMap<>();
public QuestProgression(Quest quest) { public QuestProgression(Quest quest) {
this.quest = quest; this.quest = quest;

View File

@ -715,7 +715,6 @@ public class JobsPaymentListener implements Listener {
return stack != null && stack.getAmount() > 0; return stack != null && stack.getAmount() > 0;
} }
@SuppressWarnings("deprecation")
private static boolean hasSameItem(ItemStack a, ItemStack b) { private static boolean hasSameItem(ItemStack a, ItemStack b) {
if (a == null) if (a == null)
return b == null; return b == null;
@ -723,8 +722,8 @@ public class JobsPaymentListener implements Listener {
return false; return false;
CMIMaterial mat1 = CMIMaterial.get(a); CMIMaterial mat1 = CMIMaterial.get(a);
CMIMaterial mat2 = CMIMaterial.get(b); CMIMaterial mat2 = CMIMaterial.get(b);
return mat1 == mat2 && a.getDurability() == b.getDurability() && Objects.equal(a.getData(), b.getData()) && Objects.equal(a.getEnchantments(), b return mat1 == mat2 && Jobs.getNms().getDurability(a) == Jobs.getNms().getDurability(b) && Objects.equal(a.getData(), b.getData()) &&
.getEnchantments()); Objects.equal(a.getEnchantments(), b.getEnchantments());
} }
private static boolean isStackSumLegal(ItemStack a, ItemStack b) { private static boolean isStackSumLegal(ItemStack a, ItemStack b) {
@ -812,7 +811,7 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null) if (jPlayer == null)
return; return;
if (Jobs.getGCManager().PayForEnchantingOnAnvil && inv.getItem(1).getType().equals(Material.ENCHANTED_BOOK)) { if (Jobs.getGCManager().PayForEnchantingOnAnvil && inv.getItem(1) != null && inv.getItem(1).getType().equals(Material.ENCHANTED_BOOK)) {
Map<Enchantment, Integer> enchants = resultStack.getEnchantments(); Map<Enchantment, Integer> enchants = resultStack.getEnchantments();
for (Entry<Enchantment, Integer> oneEnchant : enchants.entrySet()) { for (Entry<Enchantment, Integer> oneEnchant : enchants.entrySet()) {
Enchantment enchant = oneEnchant.getKey(); Enchantment enchant = oneEnchant.getKey();