forked from Upstream/mmocore
m
This commit is contained in:
commit
e884770528
11
pom.xml
11
pom.xml
@ -145,12 +145,6 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${basedir}/lib/Citizens.jar</systemPath>
|
<systemPath>${basedir}/lib/Citizens.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>me.clip</groupId>
|
|
||||||
<artifactId>placeholderapi</artifactId>
|
|
||||||
<version>2.10.3</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
@ -163,5 +157,10 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${basedir}/lib/PlaceholderAPI.jar</systemPath>
|
<systemPath>${basedir}/lib/PlaceholderAPI.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>19.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,43 @@
|
|||||||
|
package net.Indyuce.mmocore.api.player.profess.event.trigger;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
public class MultipleLevelUpEventTrigger implements EventTriggerHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handles(String event) {
|
||||||
|
return event.startsWith("level-up-multiple");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void a(PlayerLevelUpEvent event) {
|
||||||
|
PlayerData player = event.getData();
|
||||||
|
PlayerClass profess = player.getProfess();
|
||||||
|
for (String t : profess.getEventTriggers()){
|
||||||
|
if (t.startsWith("level-up-multiple")) {
|
||||||
|
String[] split = t.split("-");
|
||||||
|
double multiple = Double.parseDouble(split[split.length-1]);
|
||||||
|
if (event.getNewLevel()/multiple % 1 == 0) {
|
||||||
|
DecimalFormat f = new DecimalFormat("#");
|
||||||
|
if (event.hasProfession()) {
|
||||||
|
processTrigger(player, profess, "level-up-multiple-" + event.getProfession().getId().toLowerCase() + "-" + f.format(multiple));
|
||||||
|
} else {
|
||||||
|
processTrigger(player, profess, "level-up-multiple-" + f.format(multiple));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTrigger(PlayerData player, PlayerClass profess, String trigger) {
|
||||||
|
if(profess.hasEventTriggers(trigger)) profess.getEventTriggers(trigger).getTriggers().forEach(t -> t.apply(player));
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.api.player.profess.event.trigger.*;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -19,11 +20,6 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.AttackEventTrigger;
|
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.BlockBrokenTrigger;
|
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.BlockPlacedTrigger;
|
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.ClassChosenEventTrigger;
|
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.LevelUpEventTrigger;
|
|
||||||
|
|
||||||
public class ClassManager extends MMOManager {
|
public class ClassManager extends MMOManager {
|
||||||
private final Map<String, PlayerClass> map = new HashMap<>();
|
private final Map<String, PlayerClass> map = new HashMap<>();
|
||||||
@ -46,6 +42,7 @@ public class ClassManager extends MMOManager {
|
|||||||
registerEvent(new ClassChosenEventTrigger());
|
registerEvent(new ClassChosenEventTrigger());
|
||||||
registerEvent(new BlockBrokenTrigger());
|
registerEvent(new BlockBrokenTrigger());
|
||||||
registerEvent(new BlockPlacedTrigger());
|
registerEvent(new BlockPlacedTrigger());
|
||||||
|
registerEvent(new MultipleLevelUpEventTrigger());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEvent(EventTriggerHandler handler) {
|
public void registerEvent(EventTriggerHandler handler) {
|
||||||
|
Loading…
Reference in New Issue
Block a user