Skip to content

Commit

Permalink
Fixing stats command when reaching max level limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Zrips committed Apr 15, 2024
1 parent abd04d9 commit b7cfc10
Show file tree
Hide file tree
Showing 8 changed files with 437 additions and 426 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/gamingmesh/jobs/Jobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ public static void perform(JobsPlayer jPlayer, ActionInfo info, BufferedPayment
payment.set(CurrencyType.POINTS, jobsPrePaymentEvent.getPoints());

JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, expPayment,
block, ent, victim, info);
block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent);
// If event is canceled, don't do anything
if (jobsExpGainEvent.isCancelled())
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand All @@ -17,6 +18,7 @@
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;

Expand Down
132 changes: 67 additions & 65 deletions src/main/java/com/gamingmesh/jobs/Signs/jobsSign.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
36 changes: 18 additions & 18 deletions src/main/java/com/gamingmesh/jobs/api/JobsExpGainEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public final class JobsExpGainEvent extends BaseEvent implements Cancellable {
private boolean cancelled = false;

public JobsExpGainEvent(OfflinePlayer offlinePlayer, Job job, double exp, Block block,
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;
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;
}

/**
Expand All @@ -41,7 +41,7 @@ public JobsExpGainEvent(OfflinePlayer offlinePlayer, Job job, double exp, Block
* @return {@link OfflinePlayer}
*/
public OfflinePlayer getPlayer() {
return offlinePlayer;
return offlinePlayer;
}

/**
Expand All @@ -50,7 +50,7 @@ public OfflinePlayer getPlayer() {
* @return {@link Job}
*/
public Job getJob() {
return job;
return job;
}

/**
Expand All @@ -59,7 +59,7 @@ public Job getJob() {
* @return the amount of experience the player got
*/
public double getExp() {
return exp;
return exp;
}

/**
Expand All @@ -68,7 +68,7 @@ public double getExp() {
* @param exp the new value
*/
public void setExp(double exp) {
this.exp = exp;
this.exp = exp;
}

/**
Expand All @@ -77,7 +77,7 @@ public void setExp(double exp) {
* @return {@link Block}
*/
public Block getBlock() {
return block;
return block;
}

/**
Expand All @@ -88,7 +88,7 @@ public Block getBlock() {
* @return {@link Entity}
*/
public Entity getEntity() {
return entity;
return entity;
}

/**
Expand All @@ -97,7 +97,7 @@ public Entity getEntity() {
* @return {@link LivingEntity}
*/
public LivingEntity getLivingEntity() {
return living;
return living;
}

/**
Expand All @@ -106,16 +106,16 @@ public LivingEntity getLivingEntity() {
* @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;
}
}
Loading

0 comments on commit b7cfc10

Please sign in to comment.