[UNSOLVED] Config File Is Blank

Discussion in 'Plugin Development' started by leimekiller, Sep 29, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    leimekiller

    My config is blank. Does anyone know what is wrong?

    Code:
    Code:java
    1. package com.gmail.emiel.topixx;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.HashMap;
    5.  
    6. import net.milkbowl.vault.economy.Economy;
    7.  
    8. import org.bukkit.Bukkit;
    9. import org.bukkit.ChatColor;
    10. import org.bukkit.GameMode;
    11. import org.bukkit.Material;
    12. import org.bukkit.block.BlockFace;
    13. import org.bukkit.command.Command;
    14. import org.bukkit.command.CommandSender;
    15. import org.bukkit.enchantments.Enchantment;
    16. import org.bukkit.entity.Entity;
    17. import org.bukkit.entity.Player;
    18. import org.bukkit.event.EventHandler;
    19. import org.bukkit.event.Listener;
    20. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    21. import org.bukkit.event.entity.EntityDamageEvent;
    22. import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
    23. import org.bukkit.event.entity.PlayerDeathEvent;
    24. import org.bukkit.event.player.PlayerDropItemEvent;
    25. import org.bukkit.event.player.PlayerFishEvent;
    26. import org.bukkit.event.player.PlayerMoveEvent;
    27. import org.bukkit.event.player.PlayerToggleFlightEvent;
    28. import org.bukkit.inventory.ItemStack;
    29. import org.bukkit.inventory.meta.ItemMeta;
    30. import org.bukkit.plugin.RegisteredServiceProvider;
    31. import org.bukkit.plugin.java.JavaPlugin;
    32. import org.bukkit.potion.Potion;
    33. import org.bukkit.potion.PotionEffect;
    34. import org.bukkit.potion.PotionEffectType;
    35. import org.bukkit.potion.PotionType;
    36. import org.bukkit.scheduler.BukkitRunnable;
    37. import org.bukkit.util.Vector;
    38.  
    39. public class Credits extends JavaPlugin implements Listener
    40. {
    41. public int count = 0;
    42. public ArrayList<Player> fallDamage = new ArrayList<Player>();
    43. public HashMap<Player, String> playerKit = new HashMap<Player, String>();
    44. public ArrayList<Player> pEffect = new ArrayList<Player>();
    45. public ArrayList<String> kitHas = new ArrayList<String>();
    46.  
    47. @Override
    48. public void onEnable()
    49. {
    50. getServer().getPluginManager().registerEvents(this, this);
    51. getServer().getPluginManager().registerEvents(new SoupListener(), this);
    52.  
    53. getConfig().options().copyDefaults(true);
    54. saveConfig();
    55. }
    56.  
    57. @Override
    58. public void onDisable()
    59. {
    60.  
    61. }
    62.  
    63. public void giveSoup(final Player player)
    64. {
    65. new BukkitRunnable()
    66. {
    67. @Override
    68. public void run()
    69. {
    70. if(count == 36 || player.getInventory().getItem(0) == null)
    71. {
    72. count = 0;
    73. cancel();
    74. return;
    75. }
    76. player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    77. count++;
    78. }
    79. }.runTaskTimerAsynchronously(this, 1, 1);
    80. }
    81.  
    82. @SuppressWarnings("deprecation")
    83. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    84. {
    85. final Player player = (Player)sender;
    86. if(cmd.getName().equalsIgnoreCase("kit"))
    87. {
    88. if(args.length == 0)
    89. {
    90. return true;
    91. }
    92. if(args[0].equalsIgnoreCase("buy"))
    93. {
    94. if(args[1].equalsIgnoreCase("wither"))
    95. {
    96. getConfig().addDefault(player.getName(), "wither");
    97. saveConfig();
    98. }
    99. if(args[1].equalsIgnoreCase("fisher"))
    100. {
    101. getConfig().addDefault(player.getName(), "fisher");
    102. saveConfig();
    103. }
    104. /*if(args[1].equalsIgnoreCase("wither"))
    105.   {
    106.   getConfig().addDefault(player.getName(), "wither");
    107.   saveConfig();
    108.   }
    109.   if(args[1].equalsIgnoreCase("wither"))
    110.   {
    111.   getConfig().addDefault(player.getName(), "wither");
    112.   saveConfig();
    113.   }*/
    114. }
    115. if(args[0].equalsIgnoreCase("list"))
    116. {
    117. player.sendMessage(ChatColor.GREEN + "Use /kit [Kit name]");
    118. player.sendMessage(ChatColor.GREEN + "Available kits: Cactus, Chemist, Ganker, Sharpshooter, Fisher, Snowman, Dizzy, Pvp, Archer, Birdman, Ghost, Ninja, Snake, Fireman, Sniper, Tank, Killer");
    119. }
    120. if(playerKit.containsKey(player))
    121. {
    122. player.sendMessage(ChatColor.GREEN + "You have already chosen a kit!");
    123. return true;
    124. }
    125. if(args[0].equalsIgnoreCase("wither"))
    126. {
    127. playerKit.put(player, "Wither");
    128.  
    129. player.sendMessage(ChatColor.GOLD + "Successfully chosen the Wither kit!");
    130.  
    131. //beter maken
    132. player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
    133. player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
    134. player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1));
    135. player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD, 1));
    136.  
    137. giveSoup(player);
    138. }
    139. if(args[0].equalsIgnoreCase("fisher"))
    140. {
    141. playerKit.put(player, "Fisher");
    142.  
    143. player.sendMessage(ChatColor.GOLD + "Successfully chosen the Fisher kit!");
    144.  
    145. player.getInventory().addItem(new ItemStack(Material.FISHING_ROD, 1));
    146. player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD));
    147. player.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
    148.  
    149. giveSoup(player);
    150. }
    151. if(args[0].equalsIgnoreCase("jumper"))
    152. {
    153. playerKit.put(player, "Jumper");
    154. fallDamage.add(player);
    155.  
    156. ItemStack item = new ItemStack(Material.DIAMOND_BOOTS);
    157. ItemMeta itemmeta = item.getItemMeta();
    158.  
    159. itemmeta.setDisplayName(ChatColor.BOLD + "" + ChatColor.GOLD + "Jumping Boots");
    160.  
    161. itemmeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 5, true);
    162.  
    163. item.setItemMeta(itemmeta);
    164.  
    165. player.getInventory().setBoots(item);
    166.  
    167. player.sendMessage(ChatColor.GOLD + "Successfully chosen the Jumper kit!");
    168.  
    169. player.getInventory().addItem(new ItemStack(Material.IRON_SWORD, 1));
    170.  
    171. giveSoup(player);
    172. }
    173. if(args[0].equalsIgnoreCase("cactus"))
    174. {
    175. playerKit.put(player, "Cactus");
    176. ItemStack[] plate =
    177. {
    178. new ItemStack(Material.IRON_BOOTS),
    179. new ItemStack(Material.IRON_LEGGINGS),
    180. new ItemStack(Material.IRON_CHESTPLATE),
    181. new ItemStack(Material.IRON_HELMET)
    182. };
    183.  
    184. player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD, 1));
    185. player.getInventory().setArmorContents(plate);
    186.  
    187. for(ItemStack item : player.getInventory().getArmorContents())
    188. {
    189. item.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    190. item.addEnchantment(Enchantment.THORNS, 3);
    191. }
    192. giveSoup(player);
    193. player.sendMessage(ChatColor.GOLD + "Successfully chosen the Cactus kit!");
    194. }
    195. if(args[0].equalsIgnoreCase("chemist"))
    196. {
    197. playerKit.put(player, "Chemist");
    198. ItemStack[] item =
    199. {
    200. new ItemStack(Material.CHAINMAIL_BOOTS),
    201. new ItemStack(Material.CHAINMAIL_LEGGINGS),
    202. new ItemStack(Material.CHAINMAIL_CHESTPLATE),
    203. new ItemStack(Material.CHAINMAIL_HELMET)
    204. };
    205.  
    206. player.getInventory().setArmorContents(item);
    207.  
    208. for(ItemStack i : player.getInventory().getArmorContents())
    209. {
    210. i.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
    211. }
    212.  
    213. player.getInventory().addItem(new ItemStack(Material.IRON_SWORD));
    214.  
    215. Potion weak = new Potion(0);
    216. ItemStack pweak = new ItemStack(Material.POTION, 4);
    217.  
    218. weak.setSplash(true);
    219. weak.setTier(Potion.Tier.ONE);
    220. weak.setType(PotionType.WEAKNESS);
    221. weak.apply(pweak);
    222.  
    223. Potion pot = new Potion(0);
    224. ItemStack potion = new ItemStack(Material.POTION, 2);
    225.  
    226. pot.setType(PotionType.POISON);
    227. pot.setSplash(true);
    228. pot.setTier(Potion.Tier.TWO);
    229. pot.apply(potion);
    230.  
    231. Potion slow = new Potion(0);
    232. ItemStack slown = new ItemStack(Material.POTION, 2);
    233.  
    234. slow.setType(PotionType.SLOWNESS);
    235. slow.setTier(Potion.Tier.TWO);
    236. slow.setSplash(true);
    237. slow.apply(slown);
    238.  
    239. player.getInventory().addItem(potion);
    240. player.getInventory().addItem(pweak);
    241. player.getInventory().addItem(slown);
    242.  
    243. giveSoup(player);
    244.  
    245. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999999, 1, true));
    246.  
    247. player.sendMessage(ChatColor.GOLD + "Successfully chosen the Chemist kit!");
    248. }
    249. if(args[0].equalsIgnoreCase("ganker"))
    250. {
    251. playerKit.put(player, "Ganker");
    252.  
    253. ItemStack[] armor =
    254. {
    255. new ItemStack(Material.LEATHER_BOOTS),
    256. new ItemStack(Material.LEATHER_LEGGINGS),
    257. new ItemStack(Material.LEATHER_CHESTPLATE),
    258. new ItemStack(Material.LEATHER_HELMET)
    259. };
    260.  
    261. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999999, 2, true));
    262.  
    263. player.getInventory().setArmorContents(armor);
    264. player.getInventory().addItem(new ItemStack(Material.IRON_SWORD));
    265.  
    266. for(ItemStack item : player.getInventory().getArmorContents())
    267. {
    268. item.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    269. }
    270.  
    271. giveSoup(player);
    272.  
    273. player.sendMessage(ChatColor.GOLD + "Successfully chosen the Ganker kit!");
    274. }
    275. if(args[0].equalsIgnoreCase("sharpshooter"))
    276. {
    277. playerKit.put(player, "Sharp Shooter");
    278.  
    279. ItemStack[] armor =
    280. {
    281. new ItemStack(Material.IRON_BOOTS),
    282. new ItemStack(Material.IRON_LEGGINGS),
    283. new ItemStack(Material.IRON_CHESTPLATE),
    284. new ItemStack(Material.IRON_HELMET)
    285. };
    286. ItemStack bow = new ItemStack(Material.BOW);
    287.  
    288. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    289. bow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
    290.  
    291. player.getInventory().setArmorContents(armor);
    292. player.getInventory().addItem(bow);
    293. player.getInventory().addItem(new ItemStack(Material.ARROW, 1));
    294.  
    295. for(ItemStack item : player.getInventory().getArmorContents())
    296. {
    297. item.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    298. }
    299.  
    300. giveSoup(player);
    301. }
    302. if(args[0].equalsIgnoreCase("op"))
    303. {
    304. playerKit.put(player, "OP");
    305.  
    306. ItemStack[] armor =
    307. {
    308. new ItemStack(Material.DIAMOND_BOOTS),
    309. new ItemStack(Material.DIAMOND_LEGGINGS),
    310. new ItemStack(Material.DIAMOND_CHESTPLATE),
    311. new ItemStack(Material.DIAMOND_HELMET)
    312. };
    313. ItemStack dsword = new ItemStack(Material.DIAMOND_SWORD);
    314.  
    315. dsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
    316.  
    317. player.getInventory().setArmorContents(armor);
    318. player.getInventory().addItem(dsword);
    319.  
    320. for(ItemStack item : player.getInventory().getArmorContents())
    321. {
    322. item.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    323. }
    324.  
    325. giveSoup(player);
    326. }
    327. if(args[0].equalsIgnoreCase("paladin"))
    328. {
    329. playerKit.put(player, "Paladin");
    330.  
    331. ItemStack shield = new ItemStack(Material.IRON_DOOR);
    332. ItemStack[] armor =
    333. {
    334. new ItemStack(Material.DIAMOND_BOOTS),
    335. new ItemStack(Material.IRON_LEGGINGS),
    336. new ItemStack(Material.IRON_CHESTPLATE),
    337. new ItemStack(Material.IRON_HELMET)
    338. };
    339. ItemMeta itemmeta = shield.getItemMeta();
    340.  
    341. itemmeta.addEnchant(Enchantment.KNOCKBACK, 1, true);
    342. itemmeta.setDisplayName(ChatColor.GOLD + "Iron Shield");
    343. shield.setItemMeta(itemmeta);
    344.  
    345. player.getInventory().setArmorContents(armor);
    346. player.getInventory().addItem(shield);
    347. }
    348. }
    349. return true;
    350. }
    351.  
    352. @EventHandler
    353. public void onEntityKill(PlayerDeathEvent event)
    354. {
    355.  
    356. Player p = event.getEntity();
    357. Player player = event.getEntity().getKiller();
    358.  
    359. Economy econ = null;
    360. RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
    361. if(economyProvider != null)
    362. {
    363. econ = economyProvider.getProvider();
    364. }
    365. if(player == null)
    366. {
    367. for(PotionEffect effect : p.getActivePotionEffects())
    368. p.removePotionEffect(effect.getType());
    369. playerKit.remove(p);
    370. fallDamage.remove(p);
    371. return;
    372. }
    373. econ.depositPlayer(player.getName(), 100.0);
    374.  
    375. player.sendMessage(ChatColor.GREEN + getConfig().getString("Money-add-message"));
    376.  
    377. for(PotionEffect effect : p.getActivePotionEffects())
    378. p.removePotionEffect(effect.getType());
    379.  
    380. if(playerKit.get(player) == null)
    381. {
    382. Bukkit.broadcastMessage(ChatColor.GREEN + p.getName() + "(" + playerKit.get(p) + ")" + " " + getConfig().getString("Death-broadcast-message") + " " + player.getName() + "(None)");
    383. return;
    384. }
    385. if(playerKit.get(p) == null)
    386. {
    387. Bukkit.broadcastMessage(ChatColor.GREEN + p.getName() + "(None)" + " " + getConfig().getString("Death-broadcast-message") + " " + player.getName() + "(" + playerKit.get(player) + ")");
    388. return;
    389. }
    390.  
    391. Bukkit.broadcastMessage(ChatColor.GREEN + p.getName() + "(" + playerKit.get(p) + ")" + " " + getConfig().getString("Death-broadcast-message") + " " + "(" + playerKit.get(player) + ")");
    392.  
    393. playerKit.remove(p);
    394. fallDamage.remove(p);
    395.  
    396. p.setAllowFlight(false);
    397.  
    398. event.setDeathMessage(null);
    399. }
    400.  
    401. @EventHandler
    402. public void onEntityDamage(EntityDamageByEntityEvent event)
    403. {
    404. if(event.getEntity() instanceof Player && event.getDamager() instanceof Player)
    405. {
    406. if(playerKit.containsValue("Wither"))
    407. {
    408. Player player = (Player)event.getEntity();
    409. player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 100, 2));
    410. }
    411. }
    412. else
    413. {
    414. return;
    415. }
    416. if(playerKit.containsValue("Paladin"))
    417. {
    418. Player player = (Player)event.getEntity();
    419. if(player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Iron Shield"))
    420. {
    421. player.setHealth(player.getHealth() + 5);
    422. }
    423. }
    424. }
    425.  
    426. @EventHandler
    427. public void onPlayerFish(PlayerFishEvent event)
    428. {
    429. Player player = event.getPlayer();
    430. if(playerKit.containsValue("Fisher"))
    431. {
    432. if(event.getState() == PlayerFishEvent.State.CAUGHT_ENTITY)
    433. {
    434. Entity caught = event.getCaught();
    435. if(caught instanceof Player)
    436.  
    437. caught.teleport(player);
    438. }
    439. }
    440. }
    441.  
    442. @EventHandler
    443. public void onFly(PlayerToggleFlightEvent event)
    444. {
    445. final Player player = event.getPlayer();
    446. if(playerKit.containsValue("Jumper"))
    447. {
    448. if(player.getGameMode() != GameMode.CREATIVE)
    449. {
    450. if(player.getInventory().getBoots() == null)
    451. {
    452. player.setFlying(false);
    453. player.setAllowFlight(false);
    454. return;
    455. }
    456. if(player.getInventory().getBoots().getItemMeta().getDisplayName() == null)
    457. {
    458. player.setFlying(false);
    459. player.setAllowFlight(false);
    460. return;
    461. }
    462. if(player.getInventory().getBoots().getItemMeta().getDisplayName().equals(ChatColor.BOLD + "" + ChatColor.GOLD + "Jumping Boots"))
    463. {
    464. event.setCancelled(true);
    465.  
    466. player.setAllowFlight(false);
    467. player.setFlying(false);
    468. player.setVelocity(new Vector(player.getVelocity().getX(), 0.8D, player.getVelocity().getZ()));
    469. }
    470. else
    471. {
    472. player.setFlying(false);
    473. player.setAllowFlight(false);
    474. return;
    475. }
    476. }
    477. }
    478. }
    479.  
    480. @EventHandler
    481. public void onMove(final PlayerMoveEvent event)
    482. {
    483. final Player player = (Player)event.getPlayer();
    484.  
    485. if(!(playerKit.containsValue("Jumper")))
    486. {
    487. return;
    488. }
    489. if(player.getInventory().getBoots() == null)
    490. {
    491. player.setFlying(false);
    492. player.setAllowFlight(false);
    493. return;
    494. }
    495. if(player.getInventory().getBoots().getItemMeta().getDisplayName() == null)
    496. {
    497. player.setFlying(false);
    498. player.setAllowFlight(false);
    499. return;
    500. }
    501. if(player.getInventory().getBoots().getItemMeta().getDisplayName().equals(ChatColor.BOLD + "" + ChatColor.GOLD + "Jumping Boots"))
    502. {
    503. if((event.getPlayer().getGameMode() != GameMode.CREATIVE) && (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR))
    504. {
    505. event.getPlayer().setAllowFlight(true);
    506. }
    507. }
    508. else
    509. {
    510. player.setFlying(false);
    511. player.setAllowFlight(false);
    512. return;
    513. }
    514. }
    515.  
    516. @EventHandler
    517. public void onFallDamage(EntityDamageEvent event)
    518. {
    519. if(event.getCause() == DamageCause.FALL)
    520. {
    521. if(event.getEntity() instanceof Player)
    522. {
    523. Player player = (Player)event.getEntity();
    524. if(fallDamage.contains(player))
    525. {
    526. event.setCancelled(true);
    527. }
    528. }
    529. }
    530. }
    531.  
    532. @SuppressWarnings("deprecation")
    533. @EventHandler
    534. public void onPlayerDrop(PlayerDropItemEvent event)
    535. {
    536. final Player player = (Player)event.getPlayer();
    537. event.setCancelled(true);
    538.  
    539. player.updateInventory();
    540.  
    541. new BukkitRunnable()
    542. {
    543.  
    544. @Override
    545. public void run()
    546. {
    547. int count = 0;
    548. if(count == 100)
    549. {
    550. cancel();
    551. return;
    552. }
    553. player.updateInventory();
    554. count++;
    555. }
    556. }.runTaskTimer(this, 10, 10);
    557. }
    558. }
    559.  
     
  2. Offline

    Assist

    leimekiller
    Is it supposed to be blank? If not, show me your default config file.
     
  3. Offline

    Janmm14

    leimekiller
    If you have a config.yml in your project, use saveDefaultConfig();
     
  4. Offline

    leimekiller

    Janmm14 Doesn't work, still blank config (I have a config in my project btw)
     
  5. Offline

    Janmm14

    leimekiller
    Do you get an error?
    If not, check your jar if the config.yml is in the root directory (unzipper).
     
Thread Status:
Not open for further replies.

Share This Page