Config for multiple messages
This commit is contained in:
@@ -12,6 +12,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +34,10 @@ public final class ExamplePlugin extends JavaPlugin {
|
|||||||
// Files
|
// Files
|
||||||
getConfig().options().copyDefaults();
|
getConfig().options().copyDefaults();
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
List<String> messages = (List<String>)getConfig().getList("config.plugin.messages");
|
||||||
|
for (String message : messages) {
|
||||||
|
Bukkit.getLogger().info(message);
|
||||||
|
}
|
||||||
// Plugin startup logic
|
// Plugin startup logic
|
||||||
log.info("Example plugin has loaded! (" + getDescription().getVersion() + ")");
|
log.info("Example plugin has loaded! (" + getDescription().getVersion() + ")");
|
||||||
starter = Config.Plugin.getPrefix() + " ";
|
starter = Config.Plugin.getPrefix() + " ";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package io.github.itzispyder.exampleplugin.commands;
|
package io.github.itzispyder.exampleplugin.commands;
|
||||||
|
|
||||||
import io.github.itzispyder.exampleplugin.ExamplePlugin;
|
import io.github.itzispyder.exampleplugin.ExamplePlugin;
|
||||||
|
import io.github.itzispyder.exampleplugin.data.Config;
|
||||||
import io.github.itzispyder.exampleplugin.exceptions.CmdExHandler;
|
import io.github.itzispyder.exampleplugin.exceptions.CmdExHandler;
|
||||||
import io.github.itzispyder.exampleplugin.server.util.ServerUtils;
|
import io.github.itzispyder.exampleplugin.server.util.ServerUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -13,6 +14,8 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,13 +30,17 @@ public class CommandExample implements CommandExecutor {
|
|||||||
try {
|
try {
|
||||||
Player P = (Player) sender;
|
Player P = (Player) sender;
|
||||||
Player W = Bukkit.getPlayer(args[0]);
|
Player W = Bukkit.getPlayer(args[0]);
|
||||||
for (int i = 0; i < 1; i++) {
|
"messages.get(i)".replaceAll("%player%",W.getName());
|
||||||
P.chat("§bWelcome " + W.getName() + "!");
|
List<String> messages = Config.Plugin.messages;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ExamplePlugin.getInstance(),() -> {
|
new BukkitRunnable() {
|
||||||
P.chat("§bDo /daily for a key and /kit for some free gear!");
|
int i = 0;
|
||||||
}, 20);
|
@Override
|
||||||
|
public void run() {
|
||||||
}
|
if (i >= messages.size()) this.cancel();
|
||||||
|
P.chat(messages.get(i).replaceAll("%player%",W.getName()));
|
||||||
|
i ++;
|
||||||
|
}
|
||||||
|
}.runTaskTimer(ExamplePlugin.getInstance(),0,20);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
CmdExHandler handler = new CmdExHandler(ex,command);
|
CmdExHandler handler = new CmdExHandler(ex,command);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ package io.github.itzispyder.exampleplugin.data;
|
|||||||
import io.github.itzispyder.exampleplugin.ExamplePlugin;
|
import io.github.itzispyder.exampleplugin.ExamplePlugin;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config loader
|
* Config loader
|
||||||
*/
|
*/
|
||||||
@@ -21,5 +23,6 @@ public abstract class Config {
|
|||||||
public static String getPrefix() {
|
public static String getPrefix() {
|
||||||
return config.getString("config.plugin.prefix");
|
return config.getString("config.plugin.prefix");
|
||||||
}
|
}
|
||||||
|
public static final List<String> messages = config.getStringList("config.plugin.messages");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,8 @@
|
|||||||
#
|
#
|
||||||
config:
|
config:
|
||||||
plugin:
|
plugin:
|
||||||
prefix: "§7[§aExamplePlugin§7]"
|
prefix: "§7[§aSlashWelcome§7]"
|
||||||
|
time: 24
|
||||||
|
messages:
|
||||||
|
- "Welcome to OgreDupe, %player%!"
|
||||||
|
- "Do /daily for a key and /kit for some free gear."
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ permissions:
|
|||||||
commands:
|
commands:
|
||||||
welcome:
|
welcome:
|
||||||
description: An example command.
|
description: An example command.
|
||||||
usage: /example
|
usage: /welcome <player>
|
||||||
permission-message: You do not have permission!
|
permission-message: You do not have permission!
|
||||||
Reference in New Issue
Block a user