Vinetos

Créer un plugin BungeeCord | #08 - Configurations

Jul 6th, 2016
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. import net.md_5.bungee.api.CommandSender;
  2. import net.md_5.bungee.api.ProxyServer;
  3. import net.md_5.bungee.api.chat.TextComponent;
  4. import net.md_5.bungee.api.plugin.Command;
  5. import net.md_5.bungee.config.ConfigurationProvider;
  6. import net.md_5.bungee.config.YamlConfiguration;
  7.  
  8. import java.io.File;
  9. import java.io.IOException;
  10.  
  11. /**
  12.  * The MIT License (MIT)
  13.  * Created on 06/07/2016.
  14.  * Copyright (c) 2016 @author Vinetos
  15.  */
  16. public class TestCommand extends Command {
  17.  
  18.     public TestCommand() {
  19.         super("test");
  20.     }
  21.  
  22.     private final File file = new File(ProxyServer.getInstance().getPluginManager().getPlugin("EP08").getDataFolder(), "messages.yml");
  23.  
  24.  
  25.     @Override
  26.     public void execute(CommandSender sender, String[] args) {
  27.         try {
  28.             sender.sendMessage(new TextComponent(BungeeMain.getConfiguration().getString("message")));
  29.             sender.sendMessage(new TextComponent(BungeeMain.getConfiguration().getString("test.message")));
  30.  
  31.             if(args.length == 1 && args[0].equalsIgnoreCase("reload"))
  32.                 BungeeMain.reloadConfig(file);
  33.             else if (args.length == 2) {
  34.                 BungeeMain.getConfiguration().set("message", "Changement de message");
  35.                 ConfigurationProvider.getProvider(YamlConfiguration.class).save(BungeeMain.getConfiguration(), file);
  36.                 BungeeMain.reloadConfig(file);
  37.             }
  38.  
  39.         } catch (IOException e) {
  40.             e.printStackTrace();
  41.         }
  42.  
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment