Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. joinevent
  2.  
  3. @EventHandler
  4. public void onJoinFFA(PlayerJoinEvent e){
  5. Player p = e.getPlayer();
  6.  
  7. String message = cfg.getString("messages.JoinMessage");
  8. message = message.replaceAll("%player%", p.getName());
  9. e.setJoinMessage(ChatColor.translateAlternateColorCodes('&', message));
  10.  
  11. main
  12.  
  13. package de.manugun.ffa;
  14.  
  15. import java.io.File;
  16. import java.io.IOException;
  17.  
  18. import org.bukkit.configuration.file.YamlConfiguration;
  19. import org.bukkit.plugin.java.JavaPlugin;
  20.  
  21. public class Main extends JavaPlugin{
  22.  
  23. public static String prefix = "§8[§aFFA§8] §7";
  24.  
  25. public void onEnable(){
  26. loadListeners();
  27. loadCommands();
  28. createFile();
  29. }
  30.  
  31. private void loadCommands() {
  32. getCommand("reload").setExecutor(new ReloadCommand());
  33. getCommand("setspawn").setExecutor(new SetSpawnCommand());
  34. getCommand("spawn").setExecutor(new SpawnCommand());
  35. getCommand("ping").setExecutor(new PingCommand());
  36. getCommand("ffa").setExecutor(new FFACommand());
  37. getCommand("shop").setExecutor(new ShopCommand());
  38. getCommand("addcoins").setExecutor(new AddCoinsCommand());
  39. getCommand("stats").setExecutor(new StatsCommand());
  40. getCommand("coins").setExecutor(new CoinsCommand());
  41. getCommand("setshop").setExecutor(new setVillagerShop());
  42. }
  43.  
  44. private void loadListeners() {
  45.  
  46. getServer().getPluginManager().registerEvents(new JoinEvent(), this);
  47. getServer().getPluginManager().registerEvents(new BuildEvent(), this);
  48. getServer().getPluginManager().registerEvents(new FoodEvent(), this);
  49. getServer().getPluginManager().registerEvents(new KillEvent(), this);
  50. getServer().getPluginManager().registerEvents(new RespawnListener(), this);
  51. getServer().getPluginManager().registerEvents(new KillstreakEvent(), this);
  52. getServer().getPluginManager().registerEvents(new ShopCommand(), this);
  53. getServer().getPluginManager().registerEvents(new VillagerShop(), this);
  54.  
  55.  
  56. getServer().getPluginManager().registerEvents(new CoinManager(), this);
  57. getServer().getPluginManager().registerEvents(new StatsManager(), this);
  58. }
  59.  
  60. public static void createFile() {
  61. File file = new File("plugins//FFA//messages.yml");
  62. File ordner = new File("plugins//FFA");
  63.  
  64. if(!ordner.exists()) {
  65. ordner.mkdirs();
  66. }
  67. if(!file.exists()) {
  68. try {
  69. file.createNewFile();
  70. } catch (IOException e) {
  71. e.printStackTrace();
  72. }
  73. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  74.  
  75. cfg.addDefault("Messages.JoinMessage", "&8[&aFFA&8] &a%player% &7hat FFA betreten");
  76.  
  77. cfg.options().copyDefaults(true);
  78.  
  79. try {
  80. cfg.save(file);
  81. } catch (IOException e) {
  82. e.printStackTrace();
  83. }
  84. }
  85.  
  86. }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement