1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Fixing McMMO issue

This commit is contained in:
Zrips 2019-05-26 12:36:00 +03:00
parent 093db85940
commit be0bb1ef15
5 changed files with 33 additions and 24 deletions

View File

@ -176,8 +176,10 @@ public class Jobs extends JavaPlugin {
try {
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
getServer().getPluginManager().registerEvents(new McMMO2_X_listener(this), this);
consoleMsg("&e[Jobs] Registered McMMO 2.x listener");
} catch (Throwable e) {
getServer().getPluginManager().registerEvents(new McMMO1_X_listener(this), this);
consoleMsg("&e[Jobs] Registered McMMO 1.x listener");
}
}
@ -1355,7 +1357,7 @@ public class Jobs extends JavaPlugin {
public static boolean hasPermission(Object sender, String perm, boolean rawEnable) {
if (!(sender instanceof Player))
return true;
if (((Player) sender).hasPermission(perm))
return true;
if (!rawEnable) {

View File

@ -66,8 +66,9 @@ public class McMMO1_X_listener implements Listener {
try {
Object ab = event.getClass().getMethod("getAbility").invoke(event);
int maxLenght = (int) ab.getClass().getMethod("getMaxLength").invoke(ab);
InfoMap.put(String.valueOf(ab), System.currentTimeMillis() + (maxLenght * 1000));
// Lets use fixed timer as this tend to return 0
// int maxLenght = (int) ab.getClass().getMethod("getMaxLength").invoke(ab);
InfoMap.put(String.valueOf(ab), System.currentTimeMillis() + (30 * 1000));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
e.printStackTrace();
}

View File

@ -13,8 +13,10 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.actions.ItemActionInfo;
import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
public class McMMO2_X_listener implements Listener {
@ -55,6 +57,10 @@ public class McMMO2_X_listener implements Listener {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void OnAbility(McMMOPlayerAbilityEvent event) {
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
@ -62,12 +68,12 @@ public class McMMO2_X_listener implements Listener {
InfoMap = new HashMap<>();
Jobs.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
}
InfoMap.put(event.getAbility().toString(), System.currentTimeMillis() + (event.getAbility().getMaxLength() * 1000));
InfoMap.put(event.getAbility().toString(), System.currentTimeMillis() + (30 * 1000));
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
Debug.D("active " + event.getAbility());
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
if (InfoMap != null) {
InfoMap.remove(event.getAbility().toString());

View File

@ -25,46 +25,45 @@ public class McMMOManager {
HashMap<String, Long> InfoMap = map.get(player.getUniqueId());
if (InfoMap == null)
return 0D;
if (mcMMOOverHaul) {
Long t = InfoMap.get(SuperAbilityType.TREE_FELLER.getName());
Long t = InfoMap.get(SuperAbilityType.TREE_FELLER.toString());
if (t != null) {
if (t < System.currentTimeMillis())
if (t > System.currentTimeMillis())
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
InfoMap.remove(SuperAbilityType.TREE_FELLER.getName());
InfoMap.remove(SuperAbilityType.TREE_FELLER.toString());
}
t = InfoMap.get(SuperAbilityType.GIGA_DRILL_BREAKER.getName());
t = InfoMap.get(SuperAbilityType.GIGA_DRILL_BREAKER.toString());
if (t != null) {
if (t < System.currentTimeMillis())
if (t > System.currentTimeMillis())
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
InfoMap.remove(SuperAbilityType.GIGA_DRILL_BREAKER.getName());
InfoMap.remove(SuperAbilityType.GIGA_DRILL_BREAKER.toString());
}
t = InfoMap.get(SuperAbilityType.SUPER_BREAKER.getName());
t = InfoMap.get(SuperAbilityType.SUPER_BREAKER.toString());
if (t != null) {
if (t < System.currentTimeMillis())
if (t > System.currentTimeMillis())
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
InfoMap.remove(SuperAbilityType.SUPER_BREAKER.getName());
InfoMap.remove(SuperAbilityType.SUPER_BREAKER.toString());
}
} else if (mcMMOPresent) {
Long t = InfoMap.get("TREE_FELLER");
if (t != null) {
if (t < System.currentTimeMillis())
if (t > System.currentTimeMillis())
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
InfoMap.remove("TREE_FELLER");
}
t = InfoMap.get("GIGA_DRILL_BREAKER");
if (t != null) {
if (t < System.currentTimeMillis())
if (t > System.currentTimeMillis())
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
InfoMap.remove("GIGA_DRILL_BREAKER");
}
t = InfoMap.get("SUPER_BREAKER");
if (t != null) {
if (t < System.currentTimeMillis())
if (t > System.currentTimeMillis())
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
InfoMap.remove("SUPER_BREAKER");
}

View File

@ -873,11 +873,12 @@ public class ConfigManager {
ActionType actionType = ActionType.getByName(sqsection.getString("Action"));
KeyValues kv = null;
if (sqsection.isString("Target"))
if (sqsection.isString("Target")){
kv = getKeyValue(sqsection.getString("Target"), actionType, jobName);
else if (sqsection.isList("Target")) {
for (int i = 0; i < sqsection.getStringList("Target").size(); i++) {
kv = getKeyValue(sqsection.getStringList("Target").get(i), actionType, jobName);
}else if (sqsection.isList("Target")) {
List<String> list = sqsection.getStringList("Target");
for (int i = 0; i < list.size(); i++) {
kv = getKeyValue(list.get(i), actionType, jobName);
}
}