mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-01-07 07:17:46 +01:00
triggers.yml where you can reference some triggers.
This commit is contained in:
parent
f3b8db1383
commit
5ef636f5b9
@ -52,7 +52,7 @@ public class BlockInfo {
|
||||
|
||||
for (String key : list)
|
||||
try {
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load trigger '" + key + "' from block info '" + block.generateKey() + "': " + exception.getMessage());
|
||||
|
@ -43,30 +43,43 @@ import java.util.logging.Level;
|
||||
public class DefaultMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
if (config.getKey().equals("from")) {
|
||||
String source = config.getString("source");
|
||||
ConfigFile configFile = new ConfigFile("triggers");
|
||||
if (!configFile.getConfig().contains(source)) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Couldn't find " + source + " in experience-sources.yml");
|
||||
return null;
|
||||
}
|
||||
List<Trigger> list = new ArrayList<>();
|
||||
for (String trigger : configFile.getConfig().getStringList(source)) {
|
||||
list.addAll(loadTrigger(new MMOLineConfig(trigger)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
if (config.getKey().equals("message"))
|
||||
return new MessageTrigger(config);
|
||||
return Arrays.asList(new MessageTrigger(config));
|
||||
|
||||
if (config.getKey().equals("sound") || config.getKey().equals("playsound"))
|
||||
return new SoundTrigger(config);
|
||||
return Arrays.asList(new SoundTrigger(config));
|
||||
|
||||
if (config.getKey().equals("mana"))
|
||||
return new ManaTrigger(config);
|
||||
return Arrays.asList(new ManaTrigger(config));
|
||||
|
||||
if (config.getKey().equals("stamina"))
|
||||
return new StaminaTrigger(config);
|
||||
return Arrays.asList(new StaminaTrigger(config));
|
||||
|
||||
if (config.getKey().equals("stellium"))
|
||||
return new StelliumTrigger(config);
|
||||
return Arrays.asList(new StelliumTrigger(config));
|
||||
|
||||
if (config.getKey().equals("command"))
|
||||
return new CommandTrigger(config);
|
||||
return Arrays.asList(new CommandTrigger(config));
|
||||
|
||||
if (config.getKey().equals("item") || config.getKey().equals("vanilla"))
|
||||
return new ItemTrigger(config);
|
||||
return Arrays.asList(new ItemTrigger(config));
|
||||
|
||||
if (config.getKey().equals("exp") || config.getKey().equals("experience"))
|
||||
return new ExperienceTrigger(config);
|
||||
return Arrays.asList(new ExperienceTrigger(config));
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -126,19 +139,18 @@ public class DefaultMMOLoader extends MMOLoader {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ExperienceSource<?>> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
if(config.getKey().equals("from")) {
|
||||
String source=config.getString("source");
|
||||
ConfigFile configFile= new ConfigFile("exp-sources");
|
||||
if(!configFile.getConfig().contains(source)) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,"Couldn't find "+source+" in experience-sources.yml");
|
||||
if (config.getKey().equals("from")) {
|
||||
String source = config.getString("source");
|
||||
ConfigFile configFile = new ConfigFile("exp-sources");
|
||||
if (!configFile.getConfig().contains(source)) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Couldn't find " + source + " in experience-sources.yml");
|
||||
return null;
|
||||
}
|
||||
List<ExperienceSource<?>> list= new ArrayList<>();
|
||||
for(String expSource: configFile.getConfig().getStringList(source)) {
|
||||
list.addAll(loadExperienceSource(new MMOLineConfig(expSource),dispenser));
|
||||
List<ExperienceSource<?>> list = new ArrayList<>();
|
||||
for (String expSource : configFile.getConfig().getStringList(source)) {
|
||||
list.addAll(loadExperienceSource(new MMOLineConfig(expSource), dispenser));
|
||||
}
|
||||
return list;
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class MMOLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class EventTrigger {
|
||||
|
||||
for (String format : list)
|
||||
try {
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format)));
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load trigger '" + format + "' from event trigger '" + event + "': " + exception.getMessage());
|
||||
|
@ -30,7 +30,7 @@ public abstract class Objective {
|
||||
|
||||
for (String key : config.getStringList("triggers"))
|
||||
try {
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load trigger '" + key + "' from objective '" + id + "': " + exception.getMessage());
|
||||
|
@ -16,10 +16,10 @@ import java.util.List;
|
||||
public class MythicMobsMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill"))
|
||||
return new MythicSkillTrigger(config);
|
||||
return Arrays.asList(new MythicSkillTrigger(config));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -4,13 +4,16 @@ import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class VaultMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("money"))
|
||||
return new MoneyTrigger(config);
|
||||
return Arrays.asList(new MoneyTrigger(config));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class ExperienceItem {
|
||||
triggers = new ArrayList<>();
|
||||
|
||||
for (String triggerFormat : config.getStringList("triggers"))
|
||||
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(triggerFormat)));
|
||||
triggers.addAll(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(triggerFormat)));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -100,7 +100,7 @@ public abstract class GeneratedInventory extends PluginInventory {
|
||||
return;
|
||||
|
||||
if (item instanceof TriggerItem)
|
||||
((TriggerItem) item).getTrigger().apply(getPlayerData());
|
||||
((TriggerItem) item).getTriggers().forEach(trigger->trigger.apply(getPlayerData()));
|
||||
else
|
||||
whenClicked(event, item);
|
||||
}
|
||||
|
@ -6,13 +6,15 @@ import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TriggerItem extends InventoryItem {
|
||||
private final Trigger trigger;
|
||||
private final List<Trigger> triggers;
|
||||
|
||||
public TriggerItem(ConfigurationSection config, String format) {
|
||||
super(config);
|
||||
|
||||
trigger = MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format));
|
||||
triggers = MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(format));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -20,7 +22,7 @@ public class TriggerItem extends InventoryItem {
|
||||
return new Placeholders();
|
||||
}
|
||||
|
||||
public Trigger getTrigger() {
|
||||
return trigger;
|
||||
public List<Trigger> getTriggers() {
|
||||
return triggers;
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ public class ConfigManager {
|
||||
loadDefaultFile("commands.yml");
|
||||
loadDefaultFile("exp-tables.yml");
|
||||
loadDefaultFile("exp-sources.yml");
|
||||
loadDefaultFile("triggers.yml");
|
||||
loadDefaultFile("guilds.yml");
|
||||
|
||||
commandVerbose.reload(MMOCore.plugin.getConfig().getConfigurationSection("command-verbose"));
|
||||
|
@ -50,8 +50,8 @@ public class MMOLoadManager {
|
||||
return load(List.class, config, loader -> loader.loadExperienceSource(config, dispenser));
|
||||
}
|
||||
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
return load(Trigger.class, config, loader -> loader.loadTrigger(config));
|
||||
public List<Trigger> loadTrigger(MMOLineConfig config) {
|
||||
return load(List.class, config, loader -> loader.loadTrigger(config));
|
||||
}
|
||||
|
||||
public DropItem loadDropItem(MMOLineConfig config) {
|
||||
|
@ -0,0 +1,8 @@
|
||||
#A list of experience source that can be loaded using 'from{source="test-exp-source"}'
|
||||
test-exp-source:
|
||||
- 'damagedealt{type=physical;amount=250}'
|
||||
- 'move{type=WALK;amount=300}'
|
||||
- 'from{source=test2}'
|
||||
|
||||
test2:
|
||||
- 'eat{type=CARROT;amount="50"}'
|
0
src/main/resources/default/triggers.yml
Normal file
0
src/main/resources/default/triggers.yml
Normal file
Loading…
Reference in New Issue
Block a user