Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gmail.KrzysiekRysiek;
- import java.util.List;
- import java.util.Set;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.ConfigurationSection;
- import org.bukkit.entity.Player;
- public class Configi implements CommandExecutor{
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if(cmd.getName().equalsIgnoreCase("config")){
- if(args.length !=1){
- return true;
- }
- if(!(sender instanceof Player)){
- return true;
- }
- Player p = (Player) sender;
- if(args[0].equalsIgnoreCase("set")){
- String pn = p.getName().toLowerCase();
- String ip = p.getAddress().getAddress().toString().replaceAll("/", "");
- String uuid = p.getUniqueId().toString();
- Main.getInst().getConfig().set("players." + pn + ".uuid", uuid);
- Main.getInst().getConfig().set("players." + pn + ".ip", ip);
- Main.getInst().saveConfig();
- return true;
- }
- if(args[0].equalsIgnoreCase("get")){
- String pn = p.getName().toLowerCase();
- if(Main.getInst().getConfig().get("players." + pn) !=null){
- p.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "IP ADRESS: " + ChatColor.GOLD + Main.getInst().getConfig().getString("players." + pn + ".ip"));
- p.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "UUID: " + ChatColor.GOLD + Main.getInst().getConfig().getString("players." + pn + ".uuid"));
- }
- return true;
- }
- }
- if(cmd.getName().equalsIgnoreCase("spawn")){
- if(args.length !=1){
- return true;
- }
- Player g = (Player) sender;
- if(args.length == 0){
- if(sender instanceof Player){
- double x = Main.getInst().getConfig().getDouble("spawn-locX");
- double y = Main.getInst().getConfig().getDouble("spawn-locY");
- double z = Main.getInst().getConfig().getDouble("spawn-locZ");
- String wName = Main.getInst().getConfig().getString("spawn-locWorld");
- Location l = new Location(Bukkit.getWorld(wName),x,y,z);
- g.teleport(l);
- g.sendMessage(ChatColor.GRAY + "Przeteleportowano!");
- return true;
- }
- }
- if(!(sender instanceof Player)){
- return true;
- }
- if(args.length == 1){
- Player p = (Player) sender;
- if(args[0].equalsIgnoreCase("set")){
- Location l = p.getLocation();
- Main.getInst().getConfig().set("spawn-locX", l.getX());
- Main.getInst().getConfig().set("spawn-locY", l.getY());
- Main.getInst().getConfig().set("spawn-locZ", l.getZ());
- Main.getInst().getConfig().set("spawn-locWorld", l.getWorld().getName());
- Main.getInst().saveConfig();
- return true;
- }
- }
- }
- if(cmd.getName().equalsIgnoreCase("warp")){
- if(!(sender instanceof Player)){
- sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Nie jestes graczem!");
- return true;
- }
- if(args.length == 0){
- Set<String> keys = Main.getInst().getConfig().getKeys(false);
- String lista = "";
- for(String s : keys){
- if(!s.equals("autoMsg")){
- lista += ", " + s;
- }
- }
- sender.sendMessage(ChatColor.GREEN + "Warpy: " + ChatColor.WHITE + lista.replaceFirst(", ", ""));
- }
- if(args.length < 1){
- sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Uzycie: /warp <nazwawarpu>");
- return true;
- }
- String warpName = args[0].toLowerCase();
- if(!Main.getInst().getConfig().contains(warpName)){
- sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Nie ma takiego warpu!");
- return true;
- }
- ConfigurationSection warpData = Main.getInst().getConfig().getConfigurationSection(warpName);
- Location warpLocation = new Location(Bukkit.getWorld(warpData.getString("world")), warpData.getInt("x"), warpData.getInt("y"), warpData.getInt("z"));
- ((Player) sender).teleport(warpLocation);
- sender.sendMessage(ChatColor.GRAY + "Przetelportowano!");
- }
- if(cmd.getName().equalsIgnoreCase("setwarp")){
- if(Main.getInst().getConfig().get(args[1]) !=null){
- return true;
- }
- Main.getInst().getConfig().set(args[1] + ".x", 0);
- Main.getInst().getConfig().set(args[1] + ".y", 100);
- Main.getInst().getConfig().set(args[1] + ".z", 0);
- Main.getInst().getConfig().set(args[1] + ".world", "world");
- Main.getInst().saveConfig();
- }
- if(cmd.getName().equalsIgnoreCase("delwarp")){
- if(Main.getInst().getConfig().get(args[1]) !=null){
- Main.getInst().getConfig().set(args[1], null);
- Main.getInst().saveConfig();
- }
- }
- if(cmd.getName().equalsIgnoreCase("automsg")){
- if(!sender.hasPermission("ServerEssentials.automsg")){
- sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Nie masz dostepu do tej komedy!");
- return true;
- }
- if(args.length == 0){
- sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Za malo argumentow!");
- return true;
- }
- if(args.length == 1){
- if(args[0].equalsIgnoreCase("list")){
- for(int i = 0; i<Main.getInst().msgs.size(); i++){
- sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "ID " + ChatColor.DARK_GRAY + i + ChatColor.RED + ": " + Main.getInst().msgs.get(i));
- }
- }
- }
- if(args.length == 2){
- if(args[0].equalsIgnoreCase("remove")){
- int numer = Integer.parseInt(args[1]);
- Main.getInst().msgs.remove(numer);
- Main.getInst().getConfig().set("autoMsg", Main.getInst().msgs);
- }
- } else{
- if(args[0].equalsIgnoreCase("add")){
- String msg = "";
- for(int i = 1; i<args.length; i++){
- msg += " " + args[i];
- Main.getInst().saveConfig();
- }
- msg.replaceFirst(" ", "");
- List<String> msgs = Main.getInst().getConfig().getStringList("autoMsg");
- msgs.add(msg);
- Main.getInst().msgs = msgs;
- Main.getInst().getConfig().set("autoMsg", msgs);
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment