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

Added new placeholder: %jobsr_user_job%

This placeholder will show the player job, which job is specified in the placeholder value.
This commit is contained in:
montlikadani 2019-09-11 16:33:35 +02:00
parent ab9ae0da1b
commit cfc0453cfc
6 changed files with 44 additions and 70 deletions

View File

@ -3285,6 +3285,35 @@ public class ItemManager {
return false;
}
public static byte getBlockData(Block block) {
@SuppressWarnings("deprecation")
byte data = block.getData();
if (block.getType() == CMIMaterial.COCOA.getMaterial())
switch (data) {
case 0:
case 1:
case 2:
case 3:
data = 0;
break;
case 4:
case 5:
case 6:
case 7:
data = 1;
break;
case 8:
case 9:
case 10:
case 11:
data = 2;
break;
default:
break;
}
return data;
}
public static SlabType getSlabType(Block block) {
if (!isSlab(block.getType()))
return SlabType.NOTSLAB;

View File

@ -75,7 +75,7 @@ public class ItemBoostManager {
cfg = null;
try {
cfg = new ConfigReader("boostedItems.yml");
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
if (cfg == null)

View File

@ -52,6 +52,7 @@ public class Placeholder {
user_jexp_$1("jname/number"),
user_jmaxexp_$1("jname/number"),
user_jmaxlvl_$1("jname/number"),
user_job$1("jname/number"),
maxjobs,
@ -441,6 +442,8 @@ public class Placeholder {
return "";
Job jobs = getJobFromValue(vals.get(0));
return jobs == null ? "" : convert(user.isInJob(jobs));
case user_job$1:
return j == null ? "" : j.getJob().getName();
case maxjobs:
Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max");

View File

@ -18,41 +18,14 @@
package com.gamingmesh.jobs.actions;
import org.bukkit.Material;
import org.bukkit.block.Block;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.container.ActionInfo;
import com.gamingmesh.jobs.container.ActionType;
public class BlockActionInfo extends MaterialActionInfo implements ActionInfo {
public BlockActionInfo(Block block, ActionType type) {
super(block.getType(), getData(block), type);
}
private static byte getData(Block block) {
@SuppressWarnings("deprecation")
byte data = block.getData();
if (block.getType() == Material.COCOA)
switch (data) {
case 0:
case 1:
case 2:
case 3:
data = 0;
break;
case 4:
case 5:
case 6:
case 7:
data = 1;
break;
case 8:
case 9:
case 10:
case 11:
data = 2;
break;
}
return data;
super(block.getType(), CMIMaterial.getBlockData(block), type);
}
}

View File

@ -1,10 +1,10 @@
package com.gamingmesh.jobs.commands.list;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
@ -15,7 +15,7 @@ public class blockinfo implements Cmd {
@Override
@SuppressWarnings("deprecation")
@JobCommand(1472)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
return false;
@ -29,16 +29,16 @@ public class blockinfo implements Cmd {
Player player = (Player) sender;
Block block = Util.getTargetBlock(player, 15);
if (block == null || block.getState().getType() == Material.AIR)
if (block == null || CMIMaterial.isAir(block.getState().getType()))
return true;
String dataString = getData(block) == 0 ? "" : "-" + getData(block);
String dataString = CMIMaterial.getBlockData(block) == 0 ? "" : "-" + CMIMaterial.getBlockData(block);
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.name", "%blockname%", block.getType().name()));
if (Version.isCurrentEqualOrLower(Version.v1_13_R2))
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getType().getId()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", getData(block)));
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", CMIMaterial.getBlockData(block)));
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1))
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", "",
"%second%", block.getType().name() + dataString));
@ -49,32 +49,4 @@ public class blockinfo implements Cmd {
return true;
}
private static byte getData(Block block) {
@SuppressWarnings("deprecation")
byte data = block.getData();
if (block.getType() == Material.COCOA)
switch (data) {
case 0:
case 1:
case 2:
case 3:
data = 0;
break;
case 4:
case 5:
case 6:
case 7:
data = 1;
break;
case 8:
case 9:
case 10:
case 11:
data = 2;
break;
}
return data;
}
}

View File

@ -98,7 +98,7 @@ public class ConfigManager {
conf.load(s);
if (s != null)
s.close();
} catch (Throwable e) {
} catch (Exception e) {
Jobs.getPluginLogger().severe("==================== Jobs ====================");
Jobs.getPluginLogger().severe("Unable to load jobConfig.yml!");
Jobs.getPluginLogger().severe("Check your config for formatting issues!");
@ -291,10 +291,7 @@ public class ConfigManager {
// check entities
EntityType entity = EntityType.fromName(myKey.toUpperCase());
if (entity == null) {
try {
entity = EntityType.valueOf(myKey.toUpperCase());
} catch (IllegalArgumentException e) {
}
entity = EntityType.valueOf(myKey.toUpperCase());
}
if (entity != null && entity.isAlive()) {
@ -635,7 +632,7 @@ public class ConfigManager {
try {
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(skullOwner));
skullMeta.setOwner(offPlayer.getName());
} catch (Throwable e) {
} catch (IllegalArgumentException e) {
}
} else
skullMeta.setOwner(skullOwner);
@ -664,7 +661,7 @@ public class ConfigManager {
try {
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(UUID.fromString(skullOwner));
skullMeta.setOwner(offPlayer.getName());
} catch (Throwable e) {
} catch (IllegalArgumentException e) {
}
} else
skullMeta.setOwner(skullOwner);