mirror of https://github.com/Zrips/Jobs.git
Compare commits
13 Commits
c96b24bb10
...
0c59223f8d
Author | SHA1 | Date |
---|---|---|
Zrips | 0c59223f8d | |
Zrips | b7cfc104bb | |
Zrips | abd04d9653 | |
Zrips | 0ab6c20d21 | |
Zrips | 85a052f855 | |
Zrips | 0a02f2a396 | |
Zrips | f5001efa96 | |
FireML | 59b610137b | |
FireML | c9f77835da | |
FireML | b328d5c9fc | |
FireML | 36c05eb0b6 | |
FireML | e0f8125e97 | |
rayanbzd | d79e0b89a5 |
Binary file not shown.
2
pom.xml
2
pom.xml
|
@ -199,7 +199,7 @@
|
|||
<artifactId>CMILib</artifactId>
|
||||
<version>latest</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/CMILib1.4.3.1.jar</systemPath>
|
||||
<systemPath>${basedir}/libs/CMILib1.4.6.2.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- WildStacker -->
|
||||
<dependency>
|
||||
|
|
|
@ -1,230 +0,0 @@
|
|||
package com.gamingmesh.jobs.CMILib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import net.Zrips.CMILib.Container.CMIText;
|
||||
|
||||
public enum CMIEnchantment {
|
||||
|
||||
AQUA_AFFINITY("WATER_WORKER"),
|
||||
BANE_OF_ARTHROPODS("DAMAGE_ARTHROPODS", "ARTHROPODS_DAMAGE"),
|
||||
BINDING_CURSE,
|
||||
BLAST_PROTECTION("PROTECTION_EXPLOSIONS", "EXPLOSION_PROTECTION", "EXPLOSIONS_PROTECTION"),
|
||||
CHANNELING,
|
||||
DEPTH_STRIDER,
|
||||
EFFICIENCY("DIG_SPEED"),
|
||||
FEATHER_FALLING("PROTECTION_FALL", "FALL_PROTECTION"),
|
||||
FIRE_ASPECT,
|
||||
FIRE_PROTECTION("PROTECTION_FIRE"),
|
||||
FLAME("ARROW_FIRE", "FIRE_ARROW"),
|
||||
FORTUNE("LOOT_BONUS_BLOCKS"),
|
||||
FROST_WALKER,
|
||||
IMPALING,
|
||||
INFINITY("ARROW_INFINITE", "INFINITE_ARROW"),
|
||||
KNOCKBACK,
|
||||
LOOTING("LOOT_BONUS_MOBS"),
|
||||
LOYALTY,
|
||||
LUCK_OF_THE_SEA("LUCK"),
|
||||
LURE,
|
||||
MENDING,
|
||||
MULTISHOT("MULTSHOT"),
|
||||
PIERCING,
|
||||
POWER("ARROW_DAMAGE"),
|
||||
PROJECTILE_PROTECTION("PROTECTION_PROJECTILE"),
|
||||
PROTECTION("PROTECTION_ENVIRONMENTAL", "ENVIRONMENTAL_PROTECTION"),
|
||||
PUNCH("ARROW_KNOCKBACK", "KNOCKBACK_ARROW"),
|
||||
QUICK_CHARGE,
|
||||
RESPIRATION("OXYGEN"),
|
||||
RIPTIDE,
|
||||
SHARPNESS("DAMAGE_ALL"),
|
||||
SILK_TOUCH,
|
||||
SMITE("DAMAGE_UNDEAD", "UNDEAD_DAMAGE"),
|
||||
SOUL_SPEED,
|
||||
SWEEPING("SWEEPING_EDGE"),
|
||||
THORNS,
|
||||
UNBREAKING("DURABILITY"),
|
||||
VANISHING_CURSE;
|
||||
|
||||
private static final Map<String, CMIEnchantment> map = new HashMap<>();
|
||||
private static final Map<Enchantment, CMIEnchantment> emap = new HashMap<>();
|
||||
private static final Map<String, Enchantment> gmap = new HashMap<>();
|
||||
|
||||
private final List<String> subName = new ArrayList<>();
|
||||
private List<String> customNames = new ArrayList<>();
|
||||
|
||||
private Enchantment enchantment;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
CMIEnchantment(String... subName) {
|
||||
if (subName != null)
|
||||
this.subName.addAll(Arrays.asList(subName));
|
||||
|
||||
String temp = toString().toLowerCase().replace("_", "");
|
||||
|
||||
for (Enchantment one : Enchantment.values()) {
|
||||
try {
|
||||
if (one.getName().toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break;
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
try {
|
||||
if (one.getKey().toString().split(":", 2)[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break;
|
||||
}
|
||||
} catch (Exception | Error ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Worst case scenario
|
||||
if (enchantment == null) {
|
||||
for (Enchantment one : Enchantment.values()) {
|
||||
if (one.toString().toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now checks for subnames
|
||||
if (enchantment == null) {
|
||||
en: for (Enchantment one : Enchantment.values()) {
|
||||
for (String subs : this.subName) {
|
||||
try {
|
||||
if (one.getName().toLowerCase().replace("_", "").equalsIgnoreCase(subs.toLowerCase().replace("_", ""))) {
|
||||
enchantment = one;
|
||||
break en;
|
||||
}
|
||||
} catch (Exception | Error e) {
|
||||
try {
|
||||
if (one.getKey().toString().split(":", 2)[1].toLowerCase().replace("_", "").equalsIgnoreCase(temp)) {
|
||||
enchantment = one;
|
||||
break en;
|
||||
}
|
||||
} catch (Exception | Error ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enchantment == null) {
|
||||
o: for (Enchantment one : Enchantment.values()) {
|
||||
for (String subs : this.subName) {
|
||||
if (one.toString().toLowerCase().replace("_", "").equalsIgnoreCase(subs.toLowerCase().replace("_", ""))) {
|
||||
enchantment = one;
|
||||
break o;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getSubNames() {
|
||||
return subName;
|
||||
}
|
||||
|
||||
private static void fillUpMap() {
|
||||
map.clear();
|
||||
emap.clear();
|
||||
|
||||
for (CMIEnchantment one : CMIEnchantment.values()) {
|
||||
map.put(one.toString().toLowerCase().replace("_", ""), one);
|
||||
for (String oneC : one.getSubNames()) {
|
||||
map.put(oneC.toLowerCase().replace("_", ""), one);
|
||||
}
|
||||
for (String oneC : one.getCustomNames()) {
|
||||
map.put(oneC.toLowerCase().replace("_", ""), one);
|
||||
}
|
||||
emap.put(one.getEnchantment(), one);
|
||||
}
|
||||
try {
|
||||
for (Enchantment one : Enchantment.values()) {
|
||||
String name = one.getKey().getKey().toLowerCase().replace("_", "").replace("minecraft:", "");
|
||||
if (!map.containsKey(name)) {
|
||||
gmap.put(name, one);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static CMIEnchantment get(String name) {
|
||||
if (map.isEmpty())
|
||||
fillUpMap();
|
||||
|
||||
String[] split = name.split(":", 2);
|
||||
|
||||
if (split.length > 0 || (split = name.split("-", 2)).length > 0) {
|
||||
name = split[0];
|
||||
}
|
||||
|
||||
return map.get(name.toLowerCase().replace("_", ""));
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantment(String name) {
|
||||
if (map.isEmpty())
|
||||
fillUpMap();
|
||||
|
||||
String[] split = name.split(":", 2);
|
||||
|
||||
if (split.length > 0 || (split = name.split("-", 2)).length > 0) {
|
||||
name = split[0];
|
||||
}
|
||||
|
||||
name = name.toLowerCase().replace("_", "");
|
||||
|
||||
CMIEnchantment ec = map.get(name);
|
||||
|
||||
if (ec == null) {
|
||||
return gmap.get(name);
|
||||
}
|
||||
|
||||
return ec.getEnchantment();
|
||||
}
|
||||
|
||||
public static CMIEnchantment get(Enchantment enchantment) {
|
||||
if (map.isEmpty())
|
||||
fillUpMap();
|
||||
|
||||
return emap.get(enchantment);
|
||||
}
|
||||
|
||||
public List<String> getCustomNames() {
|
||||
return customNames;
|
||||
}
|
||||
|
||||
public void setCustomNames(List<String> customNames) {
|
||||
this.customNames = customNames;
|
||||
fillUpMap();
|
||||
}
|
||||
|
||||
public void addCustomName(String customName) {
|
||||
this.customNames.add(customName);
|
||||
fillUpMap();
|
||||
}
|
||||
|
||||
public Enchantment getEnchantment() {
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return CMIText.firstToUpperCase(toString());
|
||||
}
|
||||
|
||||
public static String getName(Enchantment enchant) {
|
||||
CMIEnchantment ce = get(enchant);
|
||||
if (ce == null)
|
||||
return "Unknown";
|
||||
|
||||
return ce.getName();
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ import java.util.Set;
|
|||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
|
@ -19,6 +18,7 @@ import com.gamingmesh.jobs.container.JobItems;
|
|||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMIList;
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantment;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
@ -147,7 +147,7 @@ public final class ItemBoostManager {
|
|||
if (split.length == 0)
|
||||
continue;
|
||||
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
Enchantment ench = CMIEnchantment.getByName(split[0]);
|
||||
|
||||
if (ench == null)
|
||||
continue;
|
||||
|
|
|
@ -1453,7 +1453,8 @@ public final class Jobs extends JavaPlugin {
|
|||
payment.set(CurrencyType.MONEY, jobsPrePaymentEvent.getAmount());
|
||||
payment.set(CurrencyType.POINTS, jobsPrePaymentEvent.getPoints());
|
||||
|
||||
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, expPayment);
|
||||
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, expPayment,
|
||||
block, ent, victim, info);
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent);
|
||||
// If event is canceled, don't do anything
|
||||
if (jobsExpGainEvent.isCancelled())
|
||||
|
|
|
@ -1182,33 +1182,31 @@ public class PlayerManager {
|
|||
if (!Jobs.getGCManager().AutoJobJoinUse || player == null || player.isOp())
|
||||
return;
|
||||
|
||||
CMIScheduler.get().runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!player.isOnline())
|
||||
CMIScheduler.runTaskLater(() -> {
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = getJobsPlayer(player);
|
||||
if (jPlayer == null || player.hasPermission("jobs.*"))
|
||||
return;
|
||||
|
||||
int playerMaxJobs = getMaxJobs(jPlayer);
|
||||
int playerCurrentJobs = jPlayer.getJobProgression().size();
|
||||
|
||||
if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs)
|
||||
return;
|
||||
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
if (playerMaxJobs != -1 && jPlayer.getJobProgression().size() >= playerMaxJobs)
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = getJobsPlayer(player);
|
||||
if (jPlayer == null || player.hasPermission("jobs.*"))
|
||||
return;
|
||||
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
|
||||
continue;
|
||||
|
||||
int playerMaxJobs = getMaxJobs(jPlayer);
|
||||
int playerCurrentJobs = jPlayer.getJobProgression().size();
|
||||
|
||||
if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs)
|
||||
return;
|
||||
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
if (playerMaxJobs != -1 && jPlayer.getJobProgression().size() >= playerMaxJobs)
|
||||
return;
|
||||
|
||||
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
|
||||
continue;
|
||||
|
||||
if (!jPlayer.isInJob(one) && player.hasPermission("jobs.autojoin." + one.getName().toLowerCase()))
|
||||
joinJob(jPlayer, one);
|
||||
}
|
||||
if (!jPlayer.isInJob(one) && player.hasPermission("jobs.autojoin." + one.getName().toLowerCase()))
|
||||
joinJob(jPlayer, one);
|
||||
}
|
||||
|
||||
}, Jobs.getGCManager().AutoJobJoinDelay * 20L);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
@ -17,6 +18,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.list.gtop;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
|
||||
|
|
|
@ -12,144 +12,146 @@ public class jobsSign {
|
|||
|
||||
private String worldName;
|
||||
|
||||
private Integer x, y, z;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private World world;
|
||||
private Location loc;
|
||||
|
||||
private Integer number;
|
||||
private int number = 0;
|
||||
private String jobName;
|
||||
private boolean special = false;
|
||||
private SignTopType type;
|
||||
|
||||
public void setSpecial(boolean special) {
|
||||
this.special = special;
|
||||
this.special = special;
|
||||
}
|
||||
|
||||
public boolean isSpecial() {
|
||||
return special;
|
||||
return special;
|
||||
}
|
||||
|
||||
public void setJobName(String jobName) {
|
||||
this.jobName = jobName;
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
public String getJobName() {
|
||||
return jobName;
|
||||
return jobName;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setZ(int z) {
|
||||
this.z = z;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setWorldName(String worldName) {
|
||||
this.worldName = worldName;
|
||||
this.worldName = worldName;
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return worldName;
|
||||
return worldName;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
if (loc != null)
|
||||
return loc;
|
||||
if (worldName == null)
|
||||
return null;
|
||||
if ((world = Bukkit.getWorld(worldName)) == null)
|
||||
return null;
|
||||
return loc = new Location(world, x, y, z);
|
||||
if (loc != null)
|
||||
return loc;
|
||||
if (worldName == null)
|
||||
return null;
|
||||
if ((world = Bukkit.getWorld(worldName)) == null)
|
||||
return null;
|
||||
return loc = new Location(world, x, y, z);
|
||||
}
|
||||
|
||||
public void setNumber(int number) {
|
||||
this.number = number;
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return number;
|
||||
return number;
|
||||
}
|
||||
|
||||
public String locToBlockString() {
|
||||
return worldName + ";" + x + ";" + y + ";" + z;
|
||||
return worldName + ";" + x + ";" + y + ";" + z;
|
||||
}
|
||||
|
||||
public static String locToBlockString(Location loc) {
|
||||
return loc == null ? "" : loc.getWorld().getName() + ";" + loc.getBlockX() + ";" + loc.getBlockY() + ";" + loc.getBlockZ();
|
||||
return loc == null ? "" : loc.getWorld().getName() + ";" + loc.getBlockX() + ";" + loc.getBlockY() + ";" + loc.getBlockZ();
|
||||
}
|
||||
|
||||
public void setLoc(Location loc) {
|
||||
if (loc == null)
|
||||
return;
|
||||
this.worldName = loc.getWorld().getName();
|
||||
this.x = loc.getBlockX();
|
||||
this.y = loc.getBlockY();
|
||||
this.z = loc.getBlockZ();
|
||||
this.world = loc.getWorld();
|
||||
this.loc = loc;
|
||||
if (loc == null)
|
||||
return;
|
||||
this.worldName = loc.getWorld().getName();
|
||||
this.x = loc.getBlockX();
|
||||
this.y = loc.getBlockY();
|
||||
this.z = loc.getBlockZ();
|
||||
this.world = loc.getWorld();
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
public void setLoc(String string) {
|
||||
if (!string.contains(";"))
|
||||
return;
|
||||
if (!string.contains(";"))
|
||||
return;
|
||||
|
||||
String[] split = string.replace(',', '.').split(";", 4);
|
||||
String[] split = string.replace(',', '.').split(";", 4);
|
||||
|
||||
int x = 0, y = 0, z = 0;
|
||||
int x = 0, y = 0, z = 0;
|
||||
|
||||
if (split.length > 0)
|
||||
try {
|
||||
x = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
return;
|
||||
}
|
||||
if (split.length > 0)
|
||||
try {
|
||||
x = Integer.parseInt(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (split.length > 1)
|
||||
try {
|
||||
y = Integer.parseInt(split[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
return;
|
||||
}
|
||||
if (split.length > 1)
|
||||
try {
|
||||
y = Integer.parseInt(split[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (split.length > 2)
|
||||
try {
|
||||
z = Integer.parseInt(split[3]);
|
||||
} catch (NumberFormatException e) {
|
||||
return;
|
||||
}
|
||||
if (split.length > 2)
|
||||
try {
|
||||
z = Integer.parseInt(split[3]);
|
||||
} catch (NumberFormatException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
World world = CMIWorld.getWorld(split[0]);
|
||||
if (world == null)
|
||||
return;
|
||||
World world = CMIWorld.getWorld(split[0]);
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
setLoc(new Location(world, x, y, z));
|
||||
setLoc(new Location(world, x, y, z));
|
||||
}
|
||||
|
||||
public SignTopType getType() {
|
||||
return type == null ? SignTopType.toplist : type;
|
||||
return type == null ? SignTopType.toplist : type;
|
||||
}
|
||||
|
||||
public void setType(SignTopType type) {
|
||||
this.type = type;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
SignTopType type = getType();
|
||||
SignTopType type = getType();
|
||||
|
||||
if (type != SignTopType.toplist)
|
||||
return type.toString();
|
||||
if (type != SignTopType.toplist)
|
||||
return type.toString();
|
||||
|
||||
return jobName != null ? jobName + ":" + type.toString() : type.toString();
|
||||
return jobName != null ? jobName + ":" + type.toString() : type.toString();
|
||||
}
|
||||
|
||||
public static String getIdentifier(Job job, SignTopType type) {
|
||||
if (type != SignTopType.toplist)
|
||||
return type.toString();
|
||||
return job != null ? job.getName() + ":" + type.toString() : type.toString();
|
||||
if (type != SignTopType.toplist)
|
||||
return type.toString();
|
||||
return job != null ? job.getName() + ":" + type.toString() : type.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.gamingmesh.jobs.api;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
public class JobsBlockOwnershipRegisterEvent extends BaseEvent implements Cancellable{
|
||||
|
||||
private boolean cancelled = false;
|
||||
private final Player player;
|
||||
private final Block block;
|
||||
|
||||
public JobsBlockOwnershipRegisterEvent(Player player, Block block) {
|
||||
this.player = player;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who try to register a block ownership.
|
||||
*
|
||||
* @return {@link Player}
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block which the player tried to register.
|
||||
*
|
||||
* @return {@link Block}
|
||||
*/
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
}
|
|
@ -24,20 +24,15 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
|
||||
private boolean cancelled = false;
|
||||
|
||||
public JobsExpGainEvent(OfflinePlayer offlinePlayer, Job job, double exp) {
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
this.job = job;
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
public JobsExpGainEvent(OfflinePlayer offlinePlayer, Job job, double exp, Block block,
|
||||
Entity entity, LivingEntity living, ActionInfo info) {
|
||||
this(offlinePlayer, job, exp);
|
||||
|
||||
this.block = block;
|
||||
this.entity = entity;
|
||||
this.living = living;
|
||||
this.info = info;
|
||||
Entity entity, LivingEntity living, ActionInfo info) {
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
this.job = job;
|
||||
this.exp = exp;
|
||||
this.block = block;
|
||||
this.entity = entity;
|
||||
this.living = living;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +41,7 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @return {@link OfflinePlayer}
|
||||
*/
|
||||
public OfflinePlayer getPlayer() {
|
||||
return offlinePlayer;
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +50,7 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @return {@link Job}
|
||||
*/
|
||||
public Job getJob() {
|
||||
return job;
|
||||
return job;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,7 +59,7 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @return the amount of experience the player got
|
||||
*/
|
||||
public double getExp() {
|
||||
return exp;
|
||||
return exp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +68,7 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @param exp the new value
|
||||
*/
|
||||
public void setExp(double exp) {
|
||||
this.exp = exp;
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,7 +77,7 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @return {@link Block}
|
||||
*/
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +88,7 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @return {@link Entity}
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +97,7 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @return {@link LivingEntity}
|
||||
*/
|
||||
public LivingEntity getLivingEntity() {
|
||||
return living;
|
||||
return living;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,16 +106,16 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
|
|||
* @return {@link ActionInfo}
|
||||
*/
|
||||
public ActionInfo getActionInfo() {
|
||||
return info;
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -28,6 +27,7 @@ import com.gamingmesh.jobs.i18n.Language;
|
|||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMIArray;
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
|
@ -373,15 +373,15 @@ public class JobsCommands implements CommandExecutor {
|
|||
double income = info.getIncome(level, numjobs, player.maxJobsEquation);
|
||||
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
String incomeColor = income >= 0 ? "" : CMIChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = info.getExperience(level, numjobs, player.maxJobsEquation);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
String xpColor = xp >= 0 ? "" : CMIChatColor.GRAY.toString();
|
||||
|
||||
double points = info.getPoints(level, numjobs, player.maxJobsEquation);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
|
||||
String pointsColor = xp >= 0 ? "" : CMIChatColor.RED.toString();
|
||||
|
||||
if (income == 0D && points == 0D && xp == 0D)
|
||||
continue;
|
||||
|
@ -390,7 +390,7 @@ public class JobsCommands implements CommandExecutor {
|
|||
|
||||
message.append(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", materialName));
|
||||
if (prog != null && !info.isInLevelRange(prog.getLevel()))
|
||||
message.append(ChatColor.RED + " -> ");
|
||||
message.append(CMIChatColor.RED + " -> ");
|
||||
else
|
||||
message.append(" -> ");
|
||||
|
||||
|
@ -417,19 +417,27 @@ public class JobsCommands implements CommandExecutor {
|
|||
return message.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String jobStatsMessage(JobProgression jobProg) {
|
||||
return jobStatsMessage(jobProg, null, true);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String jobStatsMessage(JobProgression jobProg, boolean progressBar) {
|
||||
return jobStatsMessage(jobProg, null, progressBar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays job stats about a particular player's job
|
||||
* @param jobProg - the job progress of the players job
|
||||
* @param jPlayer - the player of the job
|
||||
* @param progressBar - if the progress bar should be displayed
|
||||
* @return the message
|
||||
*/
|
||||
public String jobStatsMessage(JobProgression jobProg) {
|
||||
return jobStatsMessage(jobProg, true);
|
||||
}
|
||||
public String jobStatsMessage(JobProgression jobProg, JobsPlayer jPlayer, boolean progressBar) {
|
||||
|
||||
public String jobStatsMessage(JobProgression jobProg, boolean progressBar) {
|
||||
boolean isMaxLevelReached = jobProg.getLevel() == jobProg.getJob().getMaxLevel();
|
||||
String path = "command.stats.output." + (isMaxLevelReached ? "max-level"
|
||||
: "message");
|
||||
boolean isMaxLevelReached = jobProg.getLevel() >= (jPlayer == null ? jobProg.getJob().getMaxLevel() : jPlayer.getMaxJobLevelAllowed(jobProg.getJob()));
|
||||
String path = "command.stats.output." + (isMaxLevelReached ? "max-level" : "message");
|
||||
|
||||
Title title = Jobs.getTitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName());
|
||||
String message = Jobs.getLanguage().getMessage(path,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/howmuch.java
|
|
@ -102,21 +102,24 @@ public class exp implements Cmd {
|
|||
JobProgression prog = jPlayer.getJobProgression(job);
|
||||
|
||||
switch (action) {
|
||||
case Add:
|
||||
int oldLevel = prog.getLevel();
|
||||
if (prog.addExperience(amount))
|
||||
Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
|
||||
break;
|
||||
case Set:
|
||||
prog.setExperience(amount);
|
||||
break;
|
||||
case Take:
|
||||
prog.takeExperience(amount);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case Add:
|
||||
int oldLevel = prog.getLevel();
|
||||
if (prog.addExperience(amount))
|
||||
Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
|
||||
break;
|
||||
case Set:
|
||||
prog.setExperience(amount);
|
||||
break;
|
||||
case Take:
|
||||
prog.takeExperience(amount);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
jPlayer.setSaved(false);
|
||||
jPlayer.save(true);
|
||||
|
||||
Player player = jPlayer.getPlayer();
|
||||
if (player == null) {
|
||||
Language.sendMessage(sender, "general.give.output.notonline");
|
||||
|
|
|
@ -103,7 +103,7 @@ public class gtop implements Cmd {
|
|||
pi.autoPagination(sender, "jobs gtop");
|
||||
}
|
||||
|
||||
private static boolean hasToBeSeenInGlobalTop(TopList topList) {
|
||||
public static boolean hasToBeSeenInGlobalTop(TopList topList) {
|
||||
Player player = topList.getPlayerInfo().getJobsPlayer().getPlayer();
|
||||
if (player != null)
|
||||
return !player.hasPermission("jobs.hidegtop");
|
||||
|
|
|
@ -110,6 +110,9 @@ public class level implements Cmd {
|
|||
break;
|
||||
}
|
||||
|
||||
jPlayer.setSaved(false);
|
||||
jPlayer.save(true);
|
||||
|
||||
Player player = jPlayer.getPlayer();
|
||||
if (player != null)
|
||||
Language.sendMessage(player, "command.level.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevel(),
|
||||
|
|
|
@ -47,7 +47,7 @@ public class stats implements Cmd {
|
|||
String pref = JobsCommands.LABEL + " " + info.class.getSimpleName() + " ";
|
||||
|
||||
for (JobProgression jobProg : jPlayer.getJobProgression()) {
|
||||
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg, sender instanceof Player).split("\n")) {
|
||||
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg, jPlayer, sender instanceof Player).split("\n")) {
|
||||
new RawMessage().addText(msg).addHover(leftClick).addCommand(pref + jobProg.getJob().getName()).show(sender);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
|||
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.Gui.GuiItem;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BoostMultiplier;
|
||||
|
@ -57,6 +56,7 @@ import com.gamingmesh.jobs.stuff.Util;
|
|||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMIList;
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantment;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.Equations.ParseError;
|
||||
import net.Zrips.CMILib.Equations.Parser;
|
||||
|
@ -624,8 +624,8 @@ public class ConfigManager {
|
|||
}
|
||||
|
||||
if (matId != null && (material = CMIMaterial.get(matId)) != CMIMaterial.NONE) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
|
||||
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
|
||||
CMIMessages.consoleMessage("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
|
||||
CMIMessages.consoleMessage("Please use the Material name instead: " + material.toString() + "!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,7 +638,7 @@ public class ConfigManager {
|
|||
return null;
|
||||
|
||||
if (material.getMaterial() != null && material.isAir()) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " can't recognize material! (" + myKey + ")");
|
||||
CMIMessages.consoleMessage("Job " + jobName + " " + actionType.getName() + " can't recognize material! (" + myKey + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ public class ConfigManager {
|
|||
// These actions MUST be blocks
|
||||
if (actionType == ActionType.BREAK || actionType == ActionType.PLACE || actionType == ActionType.STRIPLOGS) {
|
||||
if (!material.isBlock() || material.getMaterial().toString().equalsIgnoreCase("AIR")) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + material
|
||||
CMIMessages.consoleMessage("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + material
|
||||
+ " (" + myKey + ")! Material must be a block! Use \"/jobs blockinfo\" on a target block");
|
||||
return null;
|
||||
}
|
||||
|
@ -693,14 +693,14 @@ public class ConfigManager {
|
|||
* configurations broken.
|
||||
*/
|
||||
if (material == CMIMaterial.REDSTONE_ORE && actionType == ActionType.BREAK && Version.isCurrentLower(Version.v1_13_R1)) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||
Jobs.getPluginLogger().warning("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||
Jobs.getPluginLogger().warning("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||
Jobs.getPluginLogger().warning("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
||||
CMIMessages.consoleMessage("Job " + jobName + " is using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE.");
|
||||
CMIMessages.consoleMessage("Automatically changing block to GLOWING_REDSTONE_ORE. Please update your configuration.");
|
||||
CMIMessages.consoleMessage("In vanilla minecraft, REDSTONE_ORE changes to GLOWING_REDSTONE_ORE when interacted with.");
|
||||
CMIMessages.consoleMessage("In the future, Jobs using REDSTONE_ORE instead of GLOWING_REDSTONE_ORE may fail to work correctly.");
|
||||
material = CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE;
|
||||
} else if (material == CMIMaterial.LEGACY_GLOWING_REDSTONE_ORE && actionType == ActionType.BREAK && Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
|
||||
Jobs.getPluginLogger().warning("Automatically changing block to REDSTONE_ORE. Please update your configuration.");
|
||||
CMIMessages.consoleMessage("Job " + jobName + " is using GLOWING_REDSTONE_ORE instead of REDSTONE_ORE.");
|
||||
CMIMessages.consoleMessage("Automatically changing block to REDSTONE_ORE. Please update your configuration.");
|
||||
material = CMIMaterial.REDSTONE_ORE;
|
||||
}
|
||||
// END HACK
|
||||
|
@ -777,16 +777,15 @@ public class ConfigManager {
|
|||
}
|
||||
}
|
||||
} else if (actionType == ActionType.ENCHANT) {
|
||||
Enchantment enchant = CMIEnchantment.getEnchantment(myKey);
|
||||
|
||||
if (enchant == null && material == CMIMaterial.NONE) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
CMIEnchantment cmiEnchant = CMIEnchantment.getCMIByName(myKey);
|
||||
|
||||
if (cmiEnchant == null && material == CMIMaterial.NONE) {
|
||||
CMIMessages.consoleMessage("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
CMIEnchantment cmiEnchant = CMIEnchantment.get(enchant);
|
||||
|
||||
type = cmiEnchant != null ? cmiEnchant.toString() : enchant == null ? myKey : enchant.getKey().getKey().toLowerCase().replace("_", "").replace("minecraft:", "");
|
||||
type = cmiEnchant != null ? cmiEnchant.getKeyName() : myKey;
|
||||
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.COLLECT || actionType == ActionType.MMKILL
|
||||
|| actionType == ActionType.BAKE || actionType == ActionType.SMELT) {
|
||||
|
@ -798,7 +797,7 @@ public class ConfigManager {
|
|||
try {
|
||||
amount = Integer.valueOf(myKey);
|
||||
} catch (NumberFormatException e) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
CMIMessages.consoleMessage("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -822,7 +821,7 @@ public class ConfigManager {
|
|||
}
|
||||
|
||||
if (type == null) {
|
||||
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
CMIMessages.consoleMessage("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1214,10 +1213,10 @@ public class ConfigManager {
|
|||
CMIMessages.consoleMessage("&5Update " + jobConfigName + " jobs gui item section to use `ItemStack` instead of `Item` sections format. More information inside _EXAMPLE job file");
|
||||
informedGUI = true;
|
||||
}
|
||||
|
||||
|
||||
gItem.setGuiItem(guiItem);
|
||||
} else if (guiSection.isInt("Id") && guiSection.isInt("Data")) {
|
||||
guiItem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||
guiItem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||
gItem.setGuiItem(guiItem);
|
||||
CMIMessages.consoleMessage("Update " + jobConfigName + " jobs gui item section to use `Item` instead of `Id` and `Data` sections");
|
||||
} else
|
||||
|
@ -1230,7 +1229,7 @@ public class ConfigManager {
|
|||
if (id.length < 2)
|
||||
continue;
|
||||
|
||||
Enchantment enchant = CMIEnchantment.getEnchantment(id[0]);
|
||||
Enchantment enchant = CMIEnchantment.getByName(id[0]);
|
||||
if (enchant == null)
|
||||
continue;
|
||||
|
||||
|
@ -1369,7 +1368,7 @@ public class ConfigManager {
|
|||
if (split.length == 0)
|
||||
continue;
|
||||
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
Enchantment ench = CMIEnchantment.getByName(split[0]);
|
||||
if (ench == null)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -35,12 +35,12 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.container.CurrencyLimit;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
|
||||
import net.Zrips.CMILib.CMILib;
|
||||
import net.Zrips.CMILib.Container.CMIList;
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantment;
|
||||
import net.Zrips.CMILib.Equations.Parser;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
|
@ -582,7 +582,7 @@ public class GeneralConfigManager {
|
|||
|
||||
Enchantment enchant = null;
|
||||
if (ench != null) {
|
||||
enchant = CMIEnchantment.getEnchantment(ench);
|
||||
enchant = CMIEnchantment.getByName(ench);
|
||||
}
|
||||
|
||||
Integer level = null;
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.bukkit.entity.EntityType;
|
|||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.NameList;
|
||||
|
@ -23,6 +22,7 @@ import com.gamingmesh.jobs.hooks.HookManager;
|
|||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.Container.CMIText;
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantment;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
|
@ -28,6 +27,7 @@ import com.gamingmesh.jobs.stuff.GiveItem;
|
|||
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMIList;
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantment;
|
||||
import net.Zrips.CMILib.GUI.CMIGui;
|
||||
import net.Zrips.CMILib.GUI.CMIGuiButton;
|
||||
import net.Zrips.CMILib.GUI.GUIManager.GUIClickType;
|
||||
|
@ -494,7 +494,7 @@ public class ShopManager {
|
|||
if (split.length == 0)
|
||||
continue;
|
||||
|
||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||
Enchantment ench = CMIEnchantment.getByName(split[0]);
|
||||
if (ench == null)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.gamingmesh.jobs.api.JobsBlockOwnershipRegisterEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -39,402 +40,410 @@ public class BlockOwnerShip {
|
|||
private final Jobs plugin = org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class);
|
||||
|
||||
public BlockOwnerShip(CMIMaterial type) {
|
||||
// Type should be any type of furnace, smoker or brewing stand
|
||||
if (type != CMIMaterial.FURNACE && type != CMIMaterial.LEGACY_BURNING_FURNACE
|
||||
&& type != CMIMaterial.BLAST_FURNACE && type != CMIMaterial.SMOKER && type != CMIMaterial.BREWING_STAND
|
||||
&& type != CMIMaterial.LEGACY_BREWING_STAND) {
|
||||
throw new IllegalArgumentException("Material types should be any type of furnace, smoker or brewing stand");
|
||||
}
|
||||
// Type should be any type of furnace, smoker or brewing stand
|
||||
if (type != CMIMaterial.FURNACE && type != CMIMaterial.LEGACY_BURNING_FURNACE
|
||||
&& type != CMIMaterial.BLAST_FURNACE && type != CMIMaterial.SMOKER && type != CMIMaterial.BREWING_STAND
|
||||
&& type != CMIMaterial.LEGACY_BREWING_STAND) {
|
||||
throw new IllegalArgumentException("Material types should be any type of furnace, smoker or brewing stand");
|
||||
}
|
||||
|
||||
material = type;
|
||||
material = type;
|
||||
|
||||
switch (this.type = BlockTypes.getFromCMIMaterial(type)) {
|
||||
case BLAST_FURNACE:
|
||||
metadataName = "jobsBlastFurnaceOwner";
|
||||
break;
|
||||
case BREWING_STAND:
|
||||
metadataName = "jobsBrewingOwner";
|
||||
break;
|
||||
case FURNACE:
|
||||
metadataName = "jobsFurnaceOwner";
|
||||
break;
|
||||
case SMOKER:
|
||||
metadataName = "jobsSmokerOwner";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (this.type = BlockTypes.getFromCMIMaterial(type)) {
|
||||
case BLAST_FURNACE:
|
||||
metadataName = "jobsBlastFurnaceOwner";
|
||||
break;
|
||||
case BREWING_STAND:
|
||||
metadataName = "jobsBrewingOwner";
|
||||
break;
|
||||
case FURNACE:
|
||||
metadataName = "jobsFurnaceOwner";
|
||||
break;
|
||||
case SMOKER:
|
||||
metadataName = "jobsSmokerOwner";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockTypes getType() {
|
||||
return type;
|
||||
return type;
|
||||
}
|
||||
|
||||
public CMIMaterial getMaterial() {
|
||||
return material;
|
||||
return material;
|
||||
}
|
||||
|
||||
public String getMetadataName() {
|
||||
return metadataName;
|
||||
return metadataName;
|
||||
}
|
||||
|
||||
public Map<UUID, HashMap<String, blockLoc>> getBlockOwnerShips() {
|
||||
return blockOwnerShips;
|
||||
return blockOwnerShips;
|
||||
}
|
||||
|
||||
public boolean isDisabled(UUID uuid, Location loc) {
|
||||
HashMap<String, blockLoc> records = getBlockOwnerShips().get(uuid);
|
||||
if (records == null)
|
||||
return false;
|
||||
HashMap<String, blockLoc> records = getBlockOwnerShips().get(uuid);
|
||||
if (records == null)
|
||||
return false;
|
||||
|
||||
blockLoc old = records.get(CMILocation.toString(loc, ":", true, true));
|
||||
if (old == null)
|
||||
return false;
|
||||
blockLoc old = records.get(CMILocation.toString(loc, ":", true, true));
|
||||
if (old == null)
|
||||
return false;
|
||||
|
||||
return old.isDisabled();
|
||||
return old.isDisabled();
|
||||
}
|
||||
|
||||
public ownershipFeedback register(Player player, Block block) {
|
||||
if (type != BlockTypes.getFromCMIMaterial(CMIMaterial.get(block))) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
if (type != BlockTypes.getFromCMIMaterial(CMIMaterial.get(block))) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
|
||||
UUID ownerUUID = this.getOwnerByLocation(block.getLocation());
|
||||
JobsBlockOwnershipRegisterEvent jobsBlockOwnershipRegisterEvent = new JobsBlockOwnershipRegisterEvent(player, block);
|
||||
Bukkit.getServer().getPluginManager().callEvent(jobsBlockOwnershipRegisterEvent);
|
||||
if (jobsBlockOwnershipRegisterEvent.isCancelled()) {
|
||||
return ownershipFeedback.invalid;
|
||||
}
|
||||
|
||||
if (ownerUUID != null && ownerUUID.equals(player.getUniqueId())) {
|
||||
HashMap<String, blockLoc> records = getBlockOwnerShips().get(ownerUUID);
|
||||
if (records != null) {
|
||||
blockLoc old = records.get(CMILocation.toString(block.getLocation(), ":", true, true));
|
||||
if (old != null && old.isDisabled()) {
|
||||
old.setDisabled(false);
|
||||
return ownershipFeedback.reenabled;
|
||||
}
|
||||
}
|
||||
return ownershipFeedback.old;
|
||||
}
|
||||
UUID ownerUUID = this.getOwnerByLocation(block.getLocation());
|
||||
|
||||
if (ownerUUID != null && !ownerUUID.equals(player.getUniqueId())) {
|
||||
if (Jobs.getGCManager().blockOwnershipTakeOver) {
|
||||
// Removing ownership to record new player
|
||||
this.remove(ownerUUID, CMILocation.toString(block.getLocation(), ":", true, true));
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
if (ownerUUID != null && ownerUUID.equals(player.getUniqueId())) {
|
||||
HashMap<String, blockLoc> records = getBlockOwnerShips().get(ownerUUID);
|
||||
if (records != null) {
|
||||
blockLoc old = records.get(CMILocation.toString(block.getLocation(), ":", true, true));
|
||||
if (old != null && old.isDisabled()) {
|
||||
old.setDisabled(false);
|
||||
return ownershipFeedback.reenabled;
|
||||
}
|
||||
}
|
||||
return ownershipFeedback.old;
|
||||
}
|
||||
|
||||
Player owningPlayer = Bukkit.getPlayer(ownerUUID);
|
||||
if (ownerUUID != null && !ownerUUID.equals(player.getUniqueId())) {
|
||||
if (Jobs.getGCManager().blockOwnershipTakeOver) {
|
||||
// Removing ownership to record new player
|
||||
this.remove(ownerUUID, CMILocation.toString(block.getLocation(), ":", true, true));
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
|
||||
if (owningPlayer != null && owningPlayer.isOnline()) {
|
||||
owningPlayer.sendMessage(Jobs.getLanguage().getMessage("command.clearownership.output.lost", "[type]", CMIMaterial.get(type.toString()).getName(), "[location]", CMILocation.toString(
|
||||
block.getLocation(), ":",
|
||||
true, true)));
|
||||
}
|
||||
Player owningPlayer = Bukkit.getPlayer(ownerUUID);
|
||||
|
||||
} else
|
||||
return ownershipFeedback.notOwn;
|
||||
}
|
||||
if (owningPlayer != null && owningPlayer.isOnline()) {
|
||||
owningPlayer.sendMessage(Jobs.getLanguage().getMessage("command.clearownership.output.lost", "[type]", CMIMaterial.get(type.toString()).getName(), "[location]", CMILocation.toString(
|
||||
block.getLocation(), ":",
|
||||
true, true)));
|
||||
}
|
||||
|
||||
int max = jPlayer.getMaxOwnerShipAllowed(type);
|
||||
int have = getTotal(jPlayer.getUniqueId());
|
||||
} else
|
||||
return ownershipFeedback.notOwn;
|
||||
}
|
||||
|
||||
boolean owner = false;
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
if (have > max && max > 0) {
|
||||
remove(block);
|
||||
}
|
||||
owner = true;
|
||||
}
|
||||
int max = jPlayer.getMaxOwnerShipAllowed(type);
|
||||
int have = getTotal(jPlayer.getUniqueId());
|
||||
|
||||
if (owner)
|
||||
return ownershipFeedback.old;
|
||||
boolean owner = false;
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
if (have > max && max > 0) {
|
||||
remove(block);
|
||||
}
|
||||
owner = true;
|
||||
}
|
||||
|
||||
if (have >= max && max > 0)
|
||||
return ownershipFeedback.tooMany;
|
||||
if (owner)
|
||||
return ownershipFeedback.old;
|
||||
|
||||
block.setMetadata(metadataName, new FixedMetadataValue(plugin, jPlayer.getUniqueId().toString()));
|
||||
if (have >= max && max > 0)
|
||||
return ownershipFeedback.tooMany;
|
||||
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign() && !Jobs.getGCManager().isFurnacesReassign()
|
||||
&& !Jobs.getGCManager().BlastFurnacesReassign && !Jobs.getGCManager().SmokerReassign) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
block.setMetadata(metadataName, new FixedMetadataValue(plugin, jPlayer.getUniqueId().toString()));
|
||||
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(jPlayer.getUniqueId(), new HashMap<String, blockLoc>());
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign() && !Jobs.getGCManager().isFurnacesReassign()
|
||||
&& !Jobs.getGCManager().BlastFurnacesReassign && !Jobs.getGCManager().SmokerReassign) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
String locString = CMILocation.toString(block.getLocation(), ":", true, true);
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(jPlayer.getUniqueId(), new HashMap<String, blockLoc>());
|
||||
|
||||
if (ls.containsKey(locString))
|
||||
return ownershipFeedback.old;
|
||||
String locString = CMILocation.toString(block.getLocation(), ":", true, true);
|
||||
|
||||
blockLoc bloc = new blockLoc(block.getLocation());
|
||||
if (ls.containsKey(locString))
|
||||
return ownershipFeedback.old;
|
||||
|
||||
ls.put(locString, bloc);
|
||||
blockOwnerShips.put(jPlayer.getUniqueId(), ls);
|
||||
blockLoc bloc = new blockLoc(block.getLocation());
|
||||
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.getOrDefault(block.getLocation().getWorld().getName(), new HashMap<String, UUID>());
|
||||
oldRecord.put(bloc.toVectorString(), jPlayer.getUniqueId());
|
||||
ownerMapByLocation.put(block.getLocation().getWorld().getName(), oldRecord);
|
||||
ls.put(locString, bloc);
|
||||
blockOwnerShips.put(jPlayer.getUniqueId(), ls);
|
||||
|
||||
return ownershipFeedback.newReg;
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.getOrDefault(block.getLocation().getWorld().getName(), new HashMap<String, UUID>());
|
||||
oldRecord.put(bloc.toVectorString(), jPlayer.getUniqueId());
|
||||
ownerMapByLocation.put(block.getLocation().getWorld().getName(), oldRecord);
|
||||
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
public boolean disable(Block block) {
|
||||
UUID uuid = getOwnerByLocation(block.getLocation());
|
||||
if (uuid == null) {
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
try {
|
||||
uuid = UUID.fromString(data.get(0).asString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
return disable(uuid, block);
|
||||
UUID uuid = getOwnerByLocation(block.getLocation());
|
||||
if (uuid == null) {
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
try {
|
||||
uuid = UUID.fromString(data.get(0).asString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
return disable(uuid, block);
|
||||
}
|
||||
|
||||
public boolean disable(UUID uuid, Block block) {
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new HashMap<String, blockLoc>());
|
||||
String blockLoc = CMILocation.toString(block.getLocation(), ":", true, true);
|
||||
blockLoc rec = ls.get(blockLoc);
|
||||
if (rec != null) {
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new HashMap<String, blockLoc>());
|
||||
String blockLoc = CMILocation.toString(block.getLocation(), ":", true, true);
|
||||
blockLoc rec = ls.get(blockLoc);
|
||||
if (rec != null) {
|
||||
|
||||
if (rec.isDisabled())
|
||||
return false;
|
||||
if (rec.isDisabled())
|
||||
return false;
|
||||
|
||||
rec.setDisabled(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
rec.setDisabled(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean remove(Block block) {
|
||||
UUID uuid = getOwnerByLocation(block.getLocation());
|
||||
UUID uuid = getOwnerByLocation(block.getLocation());
|
||||
|
||||
if (uuid == null) {
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
try {
|
||||
uuid = UUID.fromString(data.get(0).asString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
return remove(uuid, block);
|
||||
if (uuid == null) {
|
||||
List<MetadataValue> data = getBlockMetadatas(block);
|
||||
if (!data.isEmpty()) {
|
||||
try {
|
||||
uuid = UUID.fromString(data.get(0).asString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
return remove(uuid, block);
|
||||
}
|
||||
|
||||
public boolean remove(UUID uuid, Block block) {
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new HashMap<String, blockLoc>());
|
||||
String blockLoc = CMILocation.toString(block.getLocation(), ":", true, true);
|
||||
com.gamingmesh.jobs.stuff.blockLoc removed = ls.remove(blockLoc);
|
||||
if (removed != null) {
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(block.getLocation().getWorld().getName());
|
||||
if (oldRecord != null)
|
||||
oldRecord.remove(block.getLocation().getBlockX() + ":" + block.getLocation().getBlockY() + ":" + block.getLocation().getBlockZ());
|
||||
}
|
||||
return removed != null;
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new HashMap<String, blockLoc>());
|
||||
String blockLoc = CMILocation.toString(block.getLocation(), ":", true, true);
|
||||
com.gamingmesh.jobs.stuff.blockLoc removed = ls.remove(blockLoc);
|
||||
if (removed != null) {
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(block.getLocation().getWorld().getName());
|
||||
if (oldRecord != null)
|
||||
oldRecord.remove(block.getLocation().getBlockX() + ":" + block.getLocation().getBlockY() + ":" + block.getLocation().getBlockZ());
|
||||
}
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
public UUID getOwnerByLocation(Location loc) {
|
||||
Map<String, UUID> record = ownerMapByLocation.get(loc.getWorld().getName());
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
blockLoc bl = new blockLoc(loc);
|
||||
return record.get(bl.toVectorString());
|
||||
Map<String, UUID> record = ownerMapByLocation.get(loc.getWorld().getName());
|
||||
if (record == null)
|
||||
return null;
|
||||
|
||||
blockLoc bl = new blockLoc(loc);
|
||||
return record.get(bl.toVectorString());
|
||||
}
|
||||
|
||||
public int clear(UUID uuid) {
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.remove(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.remove(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
|
||||
for (blockLoc one : ls.values()) {
|
||||
one.getBlock().removeMetadata(metadataName, plugin);
|
||||
for (blockLoc one : ls.values()) {
|
||||
if (one.getBlock() == null)
|
||||
continue;
|
||||
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getWorldName());
|
||||
if (oldRecord != null)
|
||||
oldRecord.remove(one.toVectorString());
|
||||
one.getBlock().removeMetadata(metadataName, plugin);
|
||||
|
||||
}
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getWorldName());
|
||||
if (oldRecord != null)
|
||||
oldRecord.remove(one.toVectorString());
|
||||
}
|
||||
|
||||
return ls.size();
|
||||
return ls.size();
|
||||
}
|
||||
|
||||
public int remove(UUID uuid, String location) {
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.get(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.get(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
|
||||
for (Entry<String, blockLoc> one : new HashMap<String, blockLoc>(ls).entrySet()) {
|
||||
for (Entry<String, blockLoc> one : new HashMap<String, blockLoc>(ls).entrySet()) {
|
||||
|
||||
if (!one.getKey().equalsIgnoreCase(location))
|
||||
continue;
|
||||
if (!one.getKey().equalsIgnoreCase(location))
|
||||
continue;
|
||||
|
||||
one.getValue().getBlock().removeMetadata(metadataName, plugin);
|
||||
one.getValue().getBlock().removeMetadata(metadataName, plugin);
|
||||
|
||||
ls.remove(one.getKey());
|
||||
ls.remove(one.getKey());
|
||||
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getValue().getWorldName());
|
||||
if (oldRecord != null)
|
||||
oldRecord.remove(one.getValue().toVectorString());
|
||||
}
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getValue().getWorldName());
|
||||
if (oldRecord != null)
|
||||
oldRecord.remove(one.getValue().toVectorString());
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public List<MetadataValue> getBlockMetadatas(Block block) {
|
||||
return block.getMetadata(metadataName);
|
||||
return block.getMetadata(metadataName);
|
||||
}
|
||||
|
||||
public int getTotal(UUID uuid) {
|
||||
HashMap<String, blockLoc> list = blockOwnerShips.get(uuid);
|
||||
return list == null ? 0 : list.size();
|
||||
HashMap<String, blockLoc> list = blockOwnerShips.get(uuid);
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
YmlMaker f2 = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
if (!f.exists() && !f2.exists())
|
||||
return;
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
YmlMaker f2 = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
if (!f.exists() && !f2.exists())
|
||||
return;
|
||||
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(f2.getConfigFile());
|
||||
}
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(f2.getConfigFile());
|
||||
}
|
||||
|
||||
f = f2;
|
||||
f = f2;
|
||||
|
||||
String path = "";
|
||||
switch (type) {
|
||||
case BLAST_FURNACE:
|
||||
path = "BlastFurnace";
|
||||
break;
|
||||
case BREWING_STAND:
|
||||
path = "Brewing";
|
||||
break;
|
||||
case FURNACE:
|
||||
path = "Furnace";
|
||||
break;
|
||||
case SMOKER:
|
||||
path = "Smoker";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
String path = "";
|
||||
switch (type) {
|
||||
case BLAST_FURNACE:
|
||||
path = "BlastFurnace";
|
||||
break;
|
||||
case BREWING_STAND:
|
||||
path = "Brewing";
|
||||
break;
|
||||
case FURNACE:
|
||||
path = "Furnace";
|
||||
break;
|
||||
case SMOKER:
|
||||
path = "Smoker";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (isReassignDisabled())
|
||||
return;
|
||||
if (isReassignDisabled())
|
||||
return;
|
||||
|
||||
ConfigurationSection section = f.getConfig().getConfigurationSection(path);
|
||||
if (section == null) {
|
||||
return;
|
||||
}
|
||||
ConfigurationSection section = f.getConfig().getConfigurationSection(path);
|
||||
if (section == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
int total = 0;
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(one);
|
||||
} catch (IllegalArgumentException e) {
|
||||
continue;
|
||||
}
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(one);
|
||||
} catch (IllegalArgumentException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
HashMap<String, blockLoc> blist = new HashMap<String, blockLoc>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
CMILocation cmil = CMILocation.fromString(oneL, ":");
|
||||
HashMap<String, blockLoc> blist = new HashMap<String, blockLoc>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
CMILocation cmil = CMILocation.fromString(oneL, ":");
|
||||
|
||||
blist.put(CMILocation.toString(cmil, ":", true, true), bl);
|
||||
blist.put(CMILocation.toString(cmil, ":", true, true), bl);
|
||||
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.getOrDefault(bl.getWorldName(), new HashMap<String, UUID>());
|
||||
oldRecord.put(bl.toVectorString(), uuid);
|
||||
ownerMapByLocation.put(bl.getWorldName(), oldRecord);
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.getOrDefault(bl.getWorldName(), new HashMap<String, UUID>());
|
||||
oldRecord.put(bl.toVectorString(), uuid);
|
||||
ownerMapByLocation.put(bl.getWorldName(), oldRecord);
|
||||
|
||||
total++;
|
||||
}
|
||||
total++;
|
||||
}
|
||||
|
||||
if (!blist.isEmpty()) {
|
||||
blockOwnerShips.put(uuid, blist);
|
||||
}
|
||||
}
|
||||
if (!blist.isEmpty()) {
|
||||
blockOwnerShips.put(uuid, blist);
|
||||
}
|
||||
}
|
||||
|
||||
if (total > 0) {
|
||||
CMIMessages.consoleMessage("&eLoaded &6" + total + " " + path.toLowerCase() + " &efor reassigning.");
|
||||
}
|
||||
if (total > 0) {
|
||||
CMIMessages.consoleMessage("&eLoaded &6" + total + " " + path.toLowerCase() + " &efor reassigning.");
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(new File(Jobs.getFolder(), "blockOwnerShips.yml"));
|
||||
}
|
||||
YmlMaker f = new YmlMaker(Jobs.getFolder(), "furnaceBrewingStands.yml");
|
||||
if (f.exists()) {
|
||||
f.getConfigFile().renameTo(new File(Jobs.getFolder(), "blockOwnerShips.yml"));
|
||||
}
|
||||
|
||||
f = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
f = new YmlMaker(Jobs.getFolder(), "blockOwnerShips.yml");
|
||||
|
||||
if (blockOwnerShips.isEmpty() && f.getConfigFile().length() == 0L) {
|
||||
f.getConfigFile().delete();
|
||||
return;
|
||||
}
|
||||
if (blockOwnerShips.isEmpty() && f.getConfigFile().length() == 0L) {
|
||||
f.getConfigFile().delete();
|
||||
return;
|
||||
}
|
||||
|
||||
f.createNewFile();
|
||||
f.saveDefaultConfig();
|
||||
f.createNewFile();
|
||||
f.saveDefaultConfig();
|
||||
|
||||
if (isReassignDisabled()) {
|
||||
return;
|
||||
}
|
||||
if (isReassignDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
f.getConfig().set(path, null);
|
||||
String path = (type == BlockTypes.FURNACE ? "Furnace"
|
||||
: type == BlockTypes.BLAST_FURNACE ? "BlastFurnace"
|
||||
: type == BlockTypes.BREWING_STAND ? "Brewing" : type == BlockTypes.SMOKER ? "Smoker" : "");
|
||||
f.getConfig().set(path, null);
|
||||
|
||||
for (Entry<UUID, HashMap<String, blockLoc>> one : blockOwnerShips.entrySet()) {
|
||||
StringBuilder full = new StringBuilder();
|
||||
for (Entry<UUID, HashMap<String, blockLoc>> one : blockOwnerShips.entrySet()) {
|
||||
StringBuilder full = new StringBuilder();
|
||||
|
||||
for (String oneL : one.getValue().keySet()) {
|
||||
if (!full.toString().isEmpty())
|
||||
full.append(";");
|
||||
for (String oneL : one.getValue().keySet()) {
|
||||
if (!full.toString().isEmpty())
|
||||
full.append(";");
|
||||
|
||||
full.append(oneL);
|
||||
}
|
||||
full.append(oneL);
|
||||
}
|
||||
|
||||
if (!full.toString().isEmpty())
|
||||
f.getConfig().set(path + "." + one.getKey().toString(), full.toString());
|
||||
}
|
||||
if (!full.toString().isEmpty())
|
||||
f.getConfig().set(path + "." + one.getKey().toString(), full.toString());
|
||||
}
|
||||
|
||||
f.saveConfig();
|
||||
f.saveConfig();
|
||||
}
|
||||
|
||||
public boolean isReassignDisabled() {
|
||||
return (type == BlockTypes.FURNACE && !Jobs.getGCManager().isFurnacesReassign())
|
||||
|| (type == BlockTypes.BLAST_FURNACE && !Jobs.getGCManager().BlastFurnacesReassign)
|
||||
|| (type == BlockTypes.BREWING_STAND && !Jobs.getGCManager().isBrewingStandsReassign())
|
||||
|| (type == BlockTypes.SMOKER && !Jobs.getGCManager().SmokerReassign);
|
||||
return (type == BlockTypes.FURNACE && !Jobs.getGCManager().isFurnacesReassign())
|
||||
|| (type == BlockTypes.BLAST_FURNACE && !Jobs.getGCManager().BlastFurnacesReassign)
|
||||
|| (type == BlockTypes.BREWING_STAND && !Jobs.getGCManager().isBrewingStandsReassign())
|
||||
|| (type == BlockTypes.SMOKER && !Jobs.getGCManager().SmokerReassign);
|
||||
}
|
||||
|
||||
public enum ownershipFeedback {
|
||||
invalid, tooMany, newReg, old, notOwn, reenabled
|
||||
invalid, tooMany, newReg, old, notOwn, reenabled
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.entity.SlimeSplitEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
|
@ -77,6 +75,7 @@ import org.bukkit.event.inventory.PrepareAnvilEvent;
|
|||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.inventory.AnvilInventory;
|
||||
|
@ -90,12 +89,10 @@ import org.bukkit.inventory.meta.PotionMeta;
|
|||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.bgsoftware.wildstacker.api.enums.StackSplit;
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.actions.BlockActionInfo;
|
||||
import com.gamingmesh.jobs.actions.BlockCollectInfo;
|
||||
import com.gamingmesh.jobs.actions.CustomKillInfo;
|
||||
|
@ -128,6 +125,8 @@ import net.Zrips.CMILib.CMILib;
|
|||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMILocation;
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantEnum;
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantment;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMC;
|
||||
|
@ -469,7 +468,7 @@ public final class JobsPaymentListener implements Listener {
|
|||
|
||||
if (item.getType() != Material.AIR && Jobs.getBpManager().isInBp(block)) {
|
||||
for (Enchantment one : item.getEnchantments().keySet()) {
|
||||
if (CMIEnchantment.get(one) == CMIEnchantment.SILK_TOUCH) {
|
||||
if (CMIEnchantment.get(one).equalEnum(CMIEnchantEnum.SILK_TOUCH)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -840,13 +839,11 @@ public final class JobsPaymentListener implements Listener {
|
|||
private static String getEnchantName(Enchantment enchant) {
|
||||
try {
|
||||
return enchant.getKey().getKey().toLowerCase().replace("_", "").replace("minecraft:", "");
|
||||
|
||||
} catch (Throwable e) {
|
||||
CMIEnchantment cmiEnchant = CMIEnchantment.get(enchant);
|
||||
if (cmiEnchant != null)
|
||||
return cmiEnchant.toString();
|
||||
return cmiEnchant.getKeyName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -906,6 +903,7 @@ public final class JobsPaymentListener implements Listener {
|
|||
|
||||
Inventory inv = event.getInventory();
|
||||
|
||||
int slotToCheck = 2;
|
||||
// must be an inventory
|
||||
if (!(inv instanceof AnvilInventory) && (Version.isCurrentEqualOrHigher(Version.v1_14_R1)
|
||||
&& !(inv instanceof GrindstoneInventory) && !(inv instanceof StonecutterInventory))
|
||||
|
@ -913,8 +911,14 @@ public final class JobsPaymentListener implements Listener {
|
|||
&& (Version.isCurrentEqualOrHigher(Version.v1_16_R1) && !(inv instanceof SmithingInventory)))
|
||||
return;
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1) && (inv instanceof StonecutterInventory))
|
||||
slotToCheck = 1;
|
||||
else if (Version.isCurrentEqualOrHigher(Version.v1_16_R1) && (inv instanceof SmithingInventory))
|
||||
slotToCheck = 3;
|
||||
|
||||
int slot = event.getSlot();
|
||||
if (event.getSlotType() != SlotType.RESULT || (slot != 2 && slot != 1))
|
||||
|
||||
if (event.getSlotType() != SlotType.RESULT || (slot != slotToCheck))
|
||||
return;
|
||||
|
||||
if (((Version.isCurrentEqualOrHigher(Version.v1_14_R1) && !(inv instanceof StonecutterInventory))
|
||||
|
|
|
@ -35,10 +35,10 @@ import org.bukkit.potion.PotionType;
|
|||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.CMILib.CMIEnchantment;
|
||||
import com.gamingmesh.jobs.actions.EnchantActionInfo;
|
||||
import com.gamingmesh.jobs.container.JobsWorld;
|
||||
|
||||
import net.Zrips.CMILib.Enchants.CMIEnchantment;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
|
@ -382,8 +382,8 @@ public final class Util {
|
|||
}
|
||||
|
||||
public static boolean enchantMatchesActionInfo(String enchant, EnchantActionInfo actionInfo) {
|
||||
CMIEnchantment e = CMIEnchantment.get(actionInfo.getName());
|
||||
String enchantName = e != null ? CMIEnchantment.get(actionInfo.getName()).toString() : actionInfo.getName();
|
||||
CMIEnchantment e = CMIEnchantment.getCMIByName(actionInfo.getName());
|
||||
String enchantName = e != null ? e.getKeyName() : actionInfo.getName();
|
||||
|
||||
return (
|
||||
// Enchantment without level e.g. silk_touch
|
||||
|
|
Loading…
Reference in New Issue