Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lele.SimpleBroadCaster;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.Reader;
- import java.io.UnsupportedEncodingException;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.java.JavaPlugin;
- import lele.SimpleBroadCaster.comandos.MainCommand;
- public class SimpleBroadcaster extends JavaPlugin{
- public String rutaconfig;
- PluginDescriptionFile pdffile = getDescription();
- public String version = pdffile.getVersion();
- public String nombre = "["+ChatColor.GREEN+pdffile.getName()+ChatColor.RESET+"]"+ChatColor.RESET;
- private FileConfiguration messages = null;
- private File messagesFile = null;
- //
- //MENSAJES PARA ACTIVADO Y DESACTIVADO
- //
- public void onEnable(){
- Bukkit.getConsoleSender().sendMessage(nombre+ChatColor.GREEN+"Enabled. Version: "+ChatColor.YELLOW+version);
- Bukkit.getConsoleSender().sendMessage(nombre+"Thank you for using my plugin!");
- Bukkit.getConsoleSender().sendMessage(nombre+"Please consider subscribing to my yt channel to show your support");
- Bukkit.getConsoleSender().sendMessage(nombre+ChatColor.RED+"https://www.youtube.com/channel/UC_S4D7348gQh8BYD1Vxl0Sw");
- Bukkit.getConsoleSender().sendMessage(nombre+"SimpleBroadcaster By lelesape");
- registrarconfig();
- registerMessages();
- registercommands();
- }
- public void onDisable(){
- Bukkit.getConsoleSender().sendMessage(nombre+ChatColor.RED+"Disabled. Version: "+ChatColor.YELLOW+version);
- Bukkit.getConsoleSender().sendMessage(nombre+"Thank you for using my plugin!");
- Bukkit.getConsoleSender().sendMessage(nombre+"Please consider subscribing to my yt channel to show your support");
- Bukkit.getConsoleSender().sendMessage(nombre+ChatColor.RED+"https://www.youtube.com/channel/UC_S4D7348gQh8BYD1Vxl0Sw");
- Bukkit.getConsoleSender().sendMessage(nombre+"SimpleBroadcaster By lelesape");
- }
- //
- //REGISTRAR COMANDOS
- //
- //sin argumentos, list, crear sin argumentos, crear
- public void registercommands() {
- this.getCommand("sbc").setExecutor(new MainCommand(this));
- }
- //
- //registrar la config
- //
- public void registrarconfig() {
- File config = new File(this.getDataFolder(),"config.yml");
- rutaconfig = config.getPath();
- if(!config.exists()) {
- this.getConfig().options().copyDefaults(true);
- saveConfig();
- }
- }
- //
- //OTROS YML
- //
- //Mensajes yml
- public FileConfiguration getMessages(){
- if(messages == null){
- reloadMessages();
- }
- return messages;
- }
- public void reloadMessages(){
- if(messages == null){
- messagesFile = new File(getDataFolder(),"messages.yml");
- }
- messages = YamlConfiguration.loadConfiguration(messagesFile);
- Reader defConfigStream;
- try{
- defConfigStream = new InputStreamReader(this.getResource("messages.yml"),"UTF8");
- if(defConfigStream != null){
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- messages.setDefaults(defConfig);
- }
- }catch(UnsupportedEncodingException e){
- e.printStackTrace();
- }
- }
- public void saveMessages(){
- try{
- messages.save(messagesFile);
- }catch(IOException e){
- e.printStackTrace();
- }
- }
- public void registerMessages(){
- messagesFile = new File(this.getDataFolder(),"messages.yml");
- if(!messagesFile.exists()){
- this.getMessages().options().copyDefaults(true);
- saveMessages();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement