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:
parent
093db85940
commit
be0bb1ef15
@ -176,8 +176,10 @@ public class Jobs extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||||
getServer().getPluginManager().registerEvents(new McMMO2_X_listener(this), this);
|
getServer().getPluginManager().registerEvents(new McMMO2_X_listener(this), this);
|
||||||
|
consoleMsg("&e[Jobs] Registered McMMO 2.x listener");
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
getServer().getPluginManager().registerEvents(new McMMO1_X_listener(this), this);
|
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) {
|
public static boolean hasPermission(Object sender, String perm, boolean rawEnable) {
|
||||||
if (!(sender instanceof Player))
|
if (!(sender instanceof Player))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (((Player) sender).hasPermission(perm))
|
if (((Player) sender).hasPermission(perm))
|
||||||
return true;
|
return true;
|
||||||
if (!rawEnable) {
|
if (!rawEnable) {
|
||||||
|
@ -66,8 +66,9 @@ public class McMMO1_X_listener implements Listener {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Object ab = event.getClass().getMethod("getAbility").invoke(event);
|
Object ab = event.getClass().getMethod("getAbility").invoke(event);
|
||||||
int maxLenght = (int) ab.getClass().getMethod("getMaxLength").invoke(ab);
|
// Lets use fixed timer as this tend to return 0
|
||||||
InfoMap.put(String.valueOf(ab), System.currentTimeMillis() + (maxLenght * 1000));
|
// 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) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,10 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
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.McMMOPlayerAbilityActivateEvent;
|
||||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityEvent;
|
||||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||||
|
|
||||||
public class McMMO2_X_listener implements Listener {
|
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));
|
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)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
||||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
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<>();
|
InfoMap = new HashMap<>();
|
||||||
Jobs.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
Jobs.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
||||||
}
|
}
|
||||||
|
InfoMap.put(event.getAbility().toString(), System.currentTimeMillis() + (30 * 1000));
|
||||||
InfoMap.put(event.getAbility().toString(), System.currentTimeMillis() + (event.getAbility().getMaxLength() * 1000));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
|
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
|
||||||
|
Debug.D("active " + event.getAbility());
|
||||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||||
if (InfoMap != null) {
|
if (InfoMap != null) {
|
||||||
InfoMap.remove(event.getAbility().toString());
|
InfoMap.remove(event.getAbility().toString());
|
||||||
|
@ -25,46 +25,45 @@ public class McMMOManager {
|
|||||||
HashMap<String, Long> InfoMap = map.get(player.getUniqueId());
|
HashMap<String, Long> InfoMap = map.get(player.getUniqueId());
|
||||||
if (InfoMap == null)
|
if (InfoMap == null)
|
||||||
return 0D;
|
return 0D;
|
||||||
|
|
||||||
if (mcMMOOverHaul) {
|
if (mcMMOOverHaul) {
|
||||||
Long t = InfoMap.get(SuperAbilityType.TREE_FELLER.getName());
|
Long t = InfoMap.get(SuperAbilityType.TREE_FELLER.toString());
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
if (t < System.currentTimeMillis())
|
if (t > System.currentTimeMillis())
|
||||||
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
|
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 != null) {
|
||||||
if (t < System.currentTimeMillis())
|
if (t > System.currentTimeMillis())
|
||||||
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
|
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 != null) {
|
||||||
if (t < System.currentTimeMillis())
|
if (t > System.currentTimeMillis())
|
||||||
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
||||||
InfoMap.remove(SuperAbilityType.SUPER_BREAKER.getName());
|
InfoMap.remove(SuperAbilityType.SUPER_BREAKER.toString());
|
||||||
}
|
}
|
||||||
} else if (mcMMOPresent) {
|
} else if (mcMMOPresent) {
|
||||||
Long t = InfoMap.get("TREE_FELLER");
|
Long t = InfoMap.get("TREE_FELLER");
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
if (t < System.currentTimeMillis())
|
if (t > System.currentTimeMillis())
|
||||||
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
|
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
|
||||||
InfoMap.remove("TREE_FELLER");
|
InfoMap.remove("TREE_FELLER");
|
||||||
}
|
}
|
||||||
|
|
||||||
t = InfoMap.get("GIGA_DRILL_BREAKER");
|
t = InfoMap.get("GIGA_DRILL_BREAKER");
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
if (t < System.currentTimeMillis())
|
if (t > System.currentTimeMillis())
|
||||||
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
|
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
|
||||||
InfoMap.remove("GIGA_DRILL_BREAKER");
|
InfoMap.remove("GIGA_DRILL_BREAKER");
|
||||||
}
|
}
|
||||||
|
|
||||||
t = InfoMap.get("SUPER_BREAKER");
|
t = InfoMap.get("SUPER_BREAKER");
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
if (t < System.currentTimeMillis())
|
if (t > System.currentTimeMillis())
|
||||||
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
||||||
InfoMap.remove("SUPER_BREAKER");
|
InfoMap.remove("SUPER_BREAKER");
|
||||||
}
|
}
|
||||||
|
@ -873,11 +873,12 @@ public class ConfigManager {
|
|||||||
|
|
||||||
ActionType actionType = ActionType.getByName(sqsection.getString("Action"));
|
ActionType actionType = ActionType.getByName(sqsection.getString("Action"));
|
||||||
KeyValues kv = null;
|
KeyValues kv = null;
|
||||||
if (sqsection.isString("Target"))
|
if (sqsection.isString("Target")){
|
||||||
kv = getKeyValue(sqsection.getString("Target"), actionType, jobName);
|
kv = getKeyValue(sqsection.getString("Target"), actionType, jobName);
|
||||||
else if (sqsection.isList("Target")) {
|
}else if (sqsection.isList("Target")) {
|
||||||
for (int i = 0; i < sqsection.getStringList("Target").size(); i++) {
|
List<String> list = sqsection.getStringList("Target");
|
||||||
kv = getKeyValue(sqsection.getStringList("Target").get(i), actionType, jobName);
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
kv = getKeyValue(list.get(i), actionType, jobName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user