1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +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>
<groupId>Jobs</groupId>
<artifactId>jobs</artifactId>
<version>4.16.2</version>
<version>4.16.3</version>
<name>Jobs</name>
<url>http://maven.apache.org</url>
@ -21,14 +21,6 @@
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</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 -->
<dependency>
<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|" +
"LIGHT_GRAY|LIGHT_BLUE|)$")) {
"LIGHT_GRAY|LIGHT_BLUE)$")) {
return "color";
}

View File

@ -34,7 +34,7 @@ public class TitleMessageManager {
getHandle = typeCraftPlayer.getMethod("getHandle");
playerConnection = typeNMSPlayer.getField("playerConnection");
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);
}
@ -45,7 +45,7 @@ public class TitleMessageManager {
nmsPacketPlayOutTitle = typePacketPlayOutTitle.getConstructor(enumTitleAction, nmsIChatBaseComponent);
nmsPacketPlayOutTimes = typePacketPlayOutTitle.getConstructor(int.class, int.class, int.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;
}
}
@ -60,11 +60,11 @@ public class TitleMessageManager {
@Override
public void run() {
String t = title == null ? null : CMIChatColor.translate((String) title);
String s = subtitle == null ? null : CMIChatColor.translate((String) subtitle);
String t = title == null ? "" : CMIChatColor.translate((String) title);
String s = subtitle == null ? "" : CMIChatColor.translate((String) subtitle);
if (Version.isCurrentEqualOrLower(Version.v1_7_R4)) {
ActionBarManager.send(receivingPacket, (t == null ? "" : t) + (s == null ? "" : s));
ActionBarManager.send(receivingPacket, t + s);
return;
}
@ -108,7 +108,7 @@ public class TitleMessageManager {
break;
}
} catch (SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchFieldException ex) {
} catch (ReflectiveOperationException | SecurityException | IllegalArgumentException ex) {
simpleTitleMessages = true;
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) {
if (((type == CMIMaterial.FURNACE || type == CMIMaterial.LEGACY_BURNING_FURNACE) && !gConfigManager.isFurnacesReassign())
|| (type == CMIMaterial.BLAST_FURNACE && !gConfigManager.BlastFurnacesReassign)
|| ((type == CMIMaterial.BREWING_STAND || type == CMIMaterial.LEGACY_BREWING_STAND) && !gConfigManager.isBrewingStandsReassign())
|| (type == CMIMaterial.SMOKER && !gConfigManager.SmokerReassign)) {
if (type == CMIMaterial.FURNACE || type == CMIMaterial.LEGACY_BURNING_FURNACE
|| type == CMIMaterial.BLAST_FURNACE || type == CMIMaterial.BREWING_STAND
|| type == CMIMaterial.LEGACY_BREWING_STAND || type == CMIMaterial.SMOKER) {
return Optional.empty();
}
@ -997,7 +996,7 @@ public class Jobs extends JavaPlugin {
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;
}

View File

@ -479,7 +479,7 @@ public class Placeholder {
CurrencyType.getByName(vals.get(1))));
case user_jtoplvl_$1_$2:
vals = placeHolder.getComplexValues(value);
if (vals.isEmpty() || vals.size() < 2)
if (vals.size() < 2)
return "";
Job job = getJobFromValue(vals.get(0));
@ -614,6 +614,6 @@ public class Placeholder {
}
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 = "";
int id = 0;
if (myKey.contains("-") && !myKey.endsWith("-all")) {
if (myKey.contains("-")) {
// uses subType
subType = ":" + myKey.split("-")[1];
meta = myKey.split("-")[1];
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(":");
meta = split.length > 1 ? split[1] : myKey;
myKey = split[0];
@ -611,7 +611,6 @@ public class ConfigManager {
}
} else if (actionType == ActionType.SHEAR) {
if (myKey.startsWith("color") && (myKey.endsWith("-all") || myKey.endsWith(":all"))) {
subType = ":all";
type = myKey.split(":|-")[0];
} else {
type = myKey;

View File

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

View File

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

View File

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