Skip to content

Instantly share code, notes, and snippets.

@PaulBGD
Last active December 21, 2015 18:28
Show Gist options
  • Save PaulBGD/6347103 to your computer and use it in GitHub Desktop.
Save PaulBGD/6347103 to your computer and use it in GitHub Desktop.
Plugin for poi
package me.ultimate.OWK;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.lol768.LiteKits.API.KitCheckEvent;
public class OnceWorldKits extends JavaPlugin implements Listener {
List<String> used = new ArrayList<String>();
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
if(!getConfig().isSet("Message")){
getConfig().set("Message", "You have already used this kit in this world!");
}
}
@EventHandler
public void onKitCheck(KitCheckEvent event) {
if (used.contains(event.getPlayer().getName())) {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + getConfig().getString("Message", "You have already used this kit in this world!"));
} else {
used.add(event.getPlayer().getName());
}
}
@EventHandler
public void onPlayerChangeWorld(PlayerChangedWorldEvent event){
if (used.contains(event.getPlayer().getName()))
used.remove(event.getPlayer().getName());
}
@EventHandler
public void onPlayerLogout(PlayerQuitEvent event) {
if (used.contains(event.getPlayer().getName()))
used.remove(event.getPlayer().getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment