1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-18 05:11:32 +01:00

Fix some issues related to ownership handling when disabled

Closes #972
This commit is contained in:
montlikadani 2020-10-22 12:26:32 +02:00
parent 0c4a43e6cc
commit b00a8762f3
10 changed files with 29 additions and 45 deletions

Binary file not shown.

10
pom.xml
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.16.2</version> <version>4.16.3</version>
<name>Jobs</name> <name>Jobs</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
@ -21,14 +21,6 @@
<version>1.16.3-R0.1-SNAPSHOT</version> <version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Boss -->
<dependency>
<groupId>org.mineacademy.boss.api</groupId>
<artifactId>boss-api</artifactId>
<version>3.1.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/BossAPI_3.1.0.jar</systemPath>
</dependency>
<!-- MyPet --> <!-- MyPet -->
<dependency> <dependency>
<groupId>de.keyle</groupId> <groupId>de.keyle</groupId>

View File

@ -2625,7 +2625,7 @@ public enum CMIMaterial {
} }
if (newName.matches("(?i)^(WHITE|ORANGE|MAGENTA|YELLOW|LIME|PINK|GRAY|CYAN|PURPLE|BLUE|BROWN|GREEN|RED|BLACK|" + if (newName.matches("(?i)^(WHITE|ORANGE|MAGENTA|YELLOW|LIME|PINK|GRAY|CYAN|PURPLE|BLUE|BROWN|GREEN|RED|BLACK|" +
"LIGHT_GRAY|LIGHT_BLUE|)$")) { "LIGHT_GRAY|LIGHT_BLUE)$")) {
return "color"; return "color";
} }

View File

@ -34,7 +34,7 @@ public class TitleMessageManager {
getHandle = typeCraftPlayer.getMethod("getHandle"); getHandle = typeCraftPlayer.getMethod("getHandle");
playerConnection = typeNMSPlayer.getField("playerConnection"); playerConnection = typeNMSPlayer.getField("playerConnection");
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName("net.minecraft.server." + version + ".Packet")); sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName("net.minecraft.server." + version + ".Packet"));
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | NoSuchFieldException ex) { } catch (ReflectiveOperationException | SecurityException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex); Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
} }
@ -45,7 +45,7 @@ public class TitleMessageManager {
nmsPacketPlayOutTitle = typePacketPlayOutTitle.getConstructor(enumTitleAction, nmsIChatBaseComponent); nmsPacketPlayOutTitle = typePacketPlayOutTitle.getConstructor(enumTitleAction, nmsIChatBaseComponent);
nmsPacketPlayOutTimes = typePacketPlayOutTitle.getConstructor(int.class, int.class, int.class); nmsPacketPlayOutTimes = typePacketPlayOutTitle.getConstructor(int.class, int.class, int.class);
fromString = Class.forName("org.bukkit.craftbukkit." + version + ".util.CraftChatMessage").getMethod("fromString", String.class); fromString = Class.forName("org.bukkit.craftbukkit." + version + ".util.CraftChatMessage").getMethod("fromString", String.class);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) { } catch (ReflectiveOperationException | SecurityException ex) {
simpleTitleMessages = true; simpleTitleMessages = true;
} }
} }
@ -60,11 +60,11 @@ public class TitleMessageManager {
@Override @Override
public void run() { public void run() {
String t = title == null ? null : CMIChatColor.translate((String) title); String t = title == null ? "" : CMIChatColor.translate((String) title);
String s = subtitle == null ? null : CMIChatColor.translate((String) subtitle); String s = subtitle == null ? "" : CMIChatColor.translate((String) subtitle);
if (Version.isCurrentEqualOrLower(Version.v1_7_R4)) { if (Version.isCurrentEqualOrLower(Version.v1_7_R4)) {
ActionBarManager.send(receivingPacket, (t == null ? "" : t) + (s == null ? "" : s)); ActionBarManager.send(receivingPacket, t + s);
return; return;
} }
@ -108,7 +108,7 @@ public class TitleMessageManager {
break; break;
} }
} catch (SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchFieldException ex) { } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException ex) {
simpleTitleMessages = true; simpleTitleMessages = true;
Bukkit.getLogger().log(Level.SEVERE, "Your server can't fully support title messages. They will be shown in chat instead."); Bukkit.getLogger().log(Level.SEVERE, "Your server can't fully support title messages. They will be shown in chat instead.");
} }

View File

@ -123,10 +123,9 @@ public class Jobs extends JavaPlugin {
} }
public Optional<BlockOwnerShip> getBlockOwnerShip(CMIMaterial type, boolean addNew) { public Optional<BlockOwnerShip> getBlockOwnerShip(CMIMaterial type, boolean addNew) {
if (((type == CMIMaterial.FURNACE || type == CMIMaterial.LEGACY_BURNING_FURNACE) && !gConfigManager.isFurnacesReassign()) if (type == CMIMaterial.FURNACE || type == CMIMaterial.LEGACY_BURNING_FURNACE
|| (type == CMIMaterial.BLAST_FURNACE && !gConfigManager.BlastFurnacesReassign) || type == CMIMaterial.BLAST_FURNACE || type == CMIMaterial.BREWING_STAND
|| ((type == CMIMaterial.BREWING_STAND || type == CMIMaterial.LEGACY_BREWING_STAND) && !gConfigManager.isBrewingStandsReassign()) || type == CMIMaterial.LEGACY_BREWING_STAND || type == CMIMaterial.SMOKER) {
|| (type == CMIMaterial.SMOKER && !gConfigManager.SmokerReassign)) {
return Optional.empty(); return Optional.empty();
} }
@ -997,7 +996,7 @@ public class Jobs extends JavaPlugin {
checkDailyQuests(jPlayer, prog.getJob(), info); checkDailyQuests(jPlayer, prog.getJob(), info);
if (jobinfo == null || gConfigManager.disablePaymentIfMaxLevelReached && prog.getLevel() >= prog.getJob().getMaxLevel()) { if (jobinfo == null || (gConfigManager.disablePaymentIfMaxLevelReached && prog.getLevel() >= prog.getJob().getMaxLevel())) {
continue; continue;
} }

View File

@ -479,7 +479,7 @@ public class Placeholder {
CurrencyType.getByName(vals.get(1)))); CurrencyType.getByName(vals.get(1))));
case user_jtoplvl_$1_$2: case user_jtoplvl_$1_$2:
vals = placeHolder.getComplexValues(value); vals = placeHolder.getComplexValues(value);
if (vals.isEmpty() || vals.size() < 2) if (vals.size() < 2)
return ""; return "";
Job job = getJobFromValue(vals.get(0)); Job job = getJobFromValue(vals.get(0));
@ -614,6 +614,6 @@ public class Placeholder {
} }
private String convert(boolean state) { private String convert(boolean state) {
return state ? Jobs.getLanguage().getMessage("general.info.true") : Jobs.getLanguage().getMessage("general.info.false"); return Jobs.getLanguage().getMessage("general.info." + (state ? "true" : "false"));
} }
} }

View File

@ -389,12 +389,12 @@ public class ConfigManager {
meta = ""; meta = "";
int id = 0; int id = 0;
if (myKey.contains("-") && !myKey.endsWith("-all")) { if (myKey.contains("-")) {
// uses subType // uses subType
subType = ":" + myKey.split("-")[1]; subType = ":" + myKey.split("-")[1];
meta = myKey.split("-")[1]; meta = myKey.split("-")[1];
myKey = myKey.split("-")[0]; myKey = myKey.split("-")[0];
} else if (myKey.contains(":") && !myKey.endsWith(":all")) { // when we uses tipped arrow effect types } else if (myKey.contains(":")) { // when we uses tipped arrow effect types
String[] split = myKey.split(":"); String[] split = myKey.split(":");
meta = split.length > 1 ? split[1] : myKey; meta = split.length > 1 ? split[1] : myKey;
myKey = split[0]; myKey = split[0];
@ -611,7 +611,6 @@ public class ConfigManager {
} }
} else if (actionType == ActionType.SHEAR) { } else if (actionType == ActionType.SHEAR) {
if (myKey.startsWith("color") && (myKey.endsWith("-all") || myKey.endsWith(":all"))) { if (myKey.startsWith("color") && (myKey.endsWith("-all") || myKey.endsWith(":all"))) {
subType = ":all";
type = myKey.split(":|-")[0]; type = myKey.split(":|-")[0];
} else { } else {
type = myKey; type = myKey;

View File

@ -176,16 +176,16 @@ public class JobProgression {
boolean ret = false; boolean ret = false;
while (canLevelUp()) { while (canLevelUp()) {
int maxLevel = jPlayer.getMaxJobLevelAllowed(job);
int maxLevel = this.jPlayer.getMaxJobLevelAllowed(this.getJob());
// Don't level up at max level // Don't level up at max level
if (job.getMaxLevel() > 0 && level >= maxLevel) if (job.getMaxLevel() > 0 && level >= maxLevel)
break; break;
level++; level++;
experience -= maxExperience; experience -= maxExperience;
ret = true; ret = true;
reloadMaxExperience(); reloadMaxExperience();
this.jPlayer.reloadLimits(); jPlayer.reloadLimits();
} }
// At max level // At max level
@ -196,8 +196,8 @@ public class JobProgression {
} }
/** /**
* Performs a level up * Performs a level down
* @returns if level up was performed * @returns if level down was performed
*/ */
private boolean checkLevelDown() { private boolean checkLevelDown() {
boolean ret = false; boolean ret = false;
@ -207,9 +207,9 @@ public class JobProgression {
break; break;
level--; level--;
int exp = getMaxExperience(level); int exp = getMaxExperience(level);
experience = experience + exp; experience += exp;
ret = true; ret = true;
reloadMaxExperience(); reloadMaxExperience();
this.jPlayer.reloadLimits(); this.jPlayer.reloadLimits();
} }
return ret; return ret;
@ -236,18 +236,13 @@ public class JobProgression {
} }
public boolean canRejoin() { public boolean canRejoin() {
if (this.leftOn == null) if (leftOn == null || leftOn + job.getRejoinCd() < System.currentTimeMillis())
return true;
if (this.leftOn + this.getJob().getRejoinCd() < System.currentTimeMillis())
return true; return true;
return jPlayer != null && jPlayer.getPlayer() != null && jPlayer.getPlayer().hasPermission("jobs.rejoinbypass"); return jPlayer != null && jPlayer.getPlayer() != null && jPlayer.getPlayer().hasPermission("jobs.rejoinbypass");
} }
public String getRejoinTimeMessage() { public String getRejoinTimeMessage() {
if (leftOn == null) return leftOn == null ? "" : TimeManage.to24hourShort(leftOn + getJob().getRejoinCd() - System.currentTimeMillis());
return "";
String msg = (TimeManage.to24hourShort(leftOn + getJob().getRejoinCd() - System.currentTimeMillis()));
return msg;
} }
public Double getLastExperience() { public Double getLastExperience() {

View File

@ -939,9 +939,7 @@ public class JobsPlayer {
} }
public void getNewQuests(Job job) { public void getNewQuests(Job job) {
HashMap<String, QuestProgression> prog = qProgression.get(job.getName()); java.util.Optional.ofNullable(qProgression.get(job.getName())).ifPresent(HashMap::clear);
if (prog != null)
prog.clear();
} }
public void replaceQuest(Quest quest) { public void replaceQuest(Quest quest) {

View File

@ -319,10 +319,11 @@ public class JobsPaymentListener implements Listener {
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
return; return;
if (!block.hasMetadata(brewingOwnerMetadata)) BlockOwnerShip ownerShip = Jobs.getInstance().getBlockOwnerShip(CMIMaterial.get(block), false).orElse(null);
if (ownerShip == null || !block.hasMetadata(ownerShip.getMetadataName()))
return; return;
List<MetadataValue> data = block.getMetadata(brewingOwnerMetadata); List<MetadataValue> data = block.getMetadata(ownerShip.getMetadataName());
if (data.isEmpty()) if (data.isEmpty())
return; return;