Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sikkshotzxx.resistance;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.event.player.PlayerQuitEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- public class Resistance extends JavaPlugin implements Listener {
- public void onEnable() {
- System.out.println("[Resistance] v0.1 has been enabled!");
- Bukkit.getPluginManager().registerEvents(this, this);
- saveDefaultConfig();
- }
- public void onDisable() {
- System.out.println("[Resistance] v0.1 has been disabled!");
- }
- //Adds the water invincibility potion effect.
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event) {
- Player player = event.getPlayer();
- if(this.getConfig().getString("WaterInvincibilityToggle").equalsIgnoreCase("true")) {
- if(player.hasPermission("resistance.drown")) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 52560000, 0), true);
- if(this.getConfig().getString("WaterMessageToggle").equalsIgnoreCase("true")) {
- player.sendMessage("You are invinsible to " + ChatColor.BLUE + "water!");
- }
- }
- }
- }
- //Adds the lava/fire resistance effect.
- @EventHandler
- public void onPlayerJoin2(PlayerJoinEvent event) {
- Player player = event.getPlayer();
- if(this.getConfig().getString("FireInvincibilityToggle").equalsIgnoreCase("true")) {
- if(player.hasPermission("resistance.burn")) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 52560000, 0), true);
- if(this.getConfig().getString("FireMessageToggle").equalsIgnoreCase("true")) {
- player.sendMessage("You are invinsible to " + ChatColor.RED + "fire!");
- }
- }
- }
- }
- //Removes the water breathing effect.
- @EventHandler
- public void onPlayerQuit(PlayerQuitEvent event) {
- Player player = event.getPlayer();
- if(player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
- player.removePotionEffect(PotionEffectType.WATER_BREATHING);
- }
- }
- //Removes the fire resistance effect.
- @EventHandler
- public void onPlayerQuit2(PlayerQuitEvent event) {
- Player player = event.getPlayer();
- if(player.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) {
- player.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment