Advertisement
djslin99

Bukkit PLugin: Trouble in MineVille

Apr 11th, 2013
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.26 KB | None | 0 0
  1. package me.djslin99.totl;
  2.  
  3. //imports
  4. import java.io.File;
  5. import java.io.IOException;
  6. import java.util.HashMap;
  7.  
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.ChatColor;
  10. import org.bukkit.GameMode;
  11. import org.bukkit.Location;
  12. import org.bukkit.World;
  13. import org.bukkit.command.Command;
  14. import org.bukkit.command.CommandSender;
  15. import org.bukkit.configuration.file.FileConfiguration;
  16. import org.bukkit.configuration.file.YamlConfiguration;
  17. import org.bukkit.entity.Player;
  18. import org.bukkit.plugin.java.JavaPlugin;
  19.  
  20. public class TroubleonTheLard extends JavaPlugin {
  21.     private File pointsfile = new File("plugins/TroubleonTheLard/points/",
  22.             "points.yml");
  23.     private FileConfiguration pointfileConfiguration = YamlConfiguration
  24.             .loadConfiguration(this.pointsfile);
  25.    
  26.     // HashMap erstellen
  27.     public HashMap<Integer, Player> players = new HashMap<Integer, Player>();
  28.     int PlayerAnzahl = players.size();
  29.  
  30.     @Override
  31.     public void onEnable() { // onEnabel Anfang
  32.  
  33.     } // onEnabel Ende
  34.  
  35.     @Override
  36.     public void onDisable() { // onDisable Anfang
  37.        
  38.  
  39.     } // onDisable Ende
  40.  
  41.  
  42.  
  43.     // Befehls-Variablen
  44.  
  45.     public boolean onCommand(CommandSender sender, Command cmd, String label,
  46.             String[] args) { // Befehle start
  47.         Player p = (Player) sender;
  48.  
  49.         // Befehl: Totl
  50.         if (cmd.getName().equalsIgnoreCase("totl")) {// /totl Befehl Anfang
  51.             // Bei 0 Argumenten Info Page
  52.             if (args.length == 0) { // 0 Argumente Anfang
  53.                 p.sendMessage("Willkommen bei " + ChatColor.AQUA
  54.                         + "Trouble on TheLard");
  55.                 p.sendMessage("Hier wird eine Beschreibung stehen");
  56.                 p.sendMessage("Um Hilfe zu den Plugins zu bekommen, '/totl hilfe' eingeben");
  57.  
  58.             } // 0 Argumente Ende
  59.             else { // Mehr als 0 Argumente
  60.  
  61.                 if (args.length == 1) {
  62.                     // Hilfe
  63.                     if (args[0].equalsIgnoreCase("hilfe")) {
  64.                         // ///////////////////////////////
  65.                         // Noch die Hilfe-Page eintragen//
  66.                         // ///////////////////////////////
  67.                         p.sendMessage(ChatColor.GOLD + "-----"
  68.                                 + ChatColor.GREEN + "Trouble on TheLard-Hilfe"
  69.                                 + ChatColor.GOLD + "-----");
  70.                         p.sendMessage("Hier wird eine Hilfepage kommen");
  71.                     } else if (args[0].equalsIgnoreCase("admin")) {
  72.                         if (!p.hasPermission("totl.admin")) {
  73.                             p.sendMessage(ChatColor.RED
  74.                                     + "Du hast nicht die Erlaubnis, einen Admin-Befehl auszuführen");
  75.                             return true;
  76.                         } else {
  77.                             p.sendMessage(ChatColor.GOLD + "-----"
  78.                                     + ChatColor.GREEN
  79.                                     + "Trouble on TheLard - Admin-Hilfe"
  80.                                     + ChatColor.GOLD + "-----");
  81.                             p.sendMessage(ChatColor.GOLD
  82.                                     + "/admin setjoinpoint"
  83.                                     + ChatColor.WHITE
  84.                                     + "    Gebe diesen Befehl ein, um die Punkte, auf denen die Spieler joinen sollen, wenn sie das spiel betreten, zu setzen.");
  85.                         }
  86.                     } else if (args[0].equalsIgnoreCase("join")) {
  87.                         p.getInventory().clear();
  88.                         p.setGameMode(GameMode.ADVENTURE);
  89.  
  90.                         // ///////////////
  91.                         // spiel betrten//
  92.                         // ///////////////
  93.  
  94.                         players.put(1, p);
  95.                         p.sendMessage(ChatColor.AQUA + "[TOTL] "
  96.                                 + ChatColor.GREEN + "Willkommen bei "
  97.                                 + ChatColor.AQUA + "Traouble on TheLard");
  98.                         if (!(players.containsValue(p))) {
  99.                             System.out.println("Keine Nummer gefunden!");
  100.                             return true;
  101.                         }
  102.                         System.out.println(p.getName() + " hat die Nummer "
  103.                                 + players.get(p));
  104.                     }
  105.                 } else if (args[0].equalsIgnoreCase("start")) {
  106.  
  107.                     p.sendMessage("Start");
  108.  
  109.                 }
  110.             }
  111.  
  112.         }// Ende 1 Argument
  113.         else {
  114.             // Anfang zwei Argumente
  115.             if (args.length == 2) {
  116.                 //
  117.                 if (args[0].equalsIgnoreCase("admin")) {
  118.                     // Alle Admin Argumente
  119.                     if (args[1].equalsIgnoreCase("setpoint")) {
  120.                         if (!p.hasPermission("totl.admin.setpoint")) {
  121.                             p.sendMessage(ChatColor.AQUA
  122.                                     + "[TOTL]"
  123.                                     + ChatColor.RED
  124.                                     + "Du hast nicht die Erlaubnis, einen Admin-Befehl auszuführen");
  125.                             return true;
  126.                         } else {
  127.                             p.sendMessage(ChatColor.AQUA + "[TOTL]"
  128.                                     + ChatColor.RED
  129.                                     + "Bitte etwas nach diesem Befehl angeben");
  130.                             p.sendMessage(ChatColor.AQUA
  131.                                     + "[TOTL]"
  132.                                     + ChatColor.YELLOW
  133.                                     + "Du musst '/totl admin setjoinpoint <Name>' eingeben");
  134.                             return true;
  135.                         }
  136.  
  137.                     }
  138.  
  139.                 }
  140.  
  141.             } // Ende 2 Argumente
  142.             else {
  143.                 // Anfang 3 Arugmente
  144.                 if (args.length == 3) {
  145.                     if (args[0].equalsIgnoreCase("admin")) {
  146.                         // /////////////////////
  147.                         // Subcommand setpoint//
  148.                         // /////////////////////
  149.  
  150.                         if (args[1].equalsIgnoreCase("setpoint")) {
  151.  
  152.                             if (p.hasPermission("totl.admin.setpoint")) {
  153.                                 Location loc = p.getLocation();
  154.                                 String str = "points." + args[2] + ".";
  155.                                 this.pointfileConfiguration.set("points."
  156.                                         + args[2] + ".world", loc.getWorld()
  157.                                         .getName());
  158.                                 this.pointfileConfiguration.set(str + "x",
  159.                                         loc.getX());
  160.                                 this.pointfileConfiguration.set(str + "y",
  161.                                         loc.getY());
  162.                                 this.pointfileConfiguration.set(str + "z",
  163.                                         loc.getZ());
  164.                                 this.pointfileConfiguration.set(str + "yaw",
  165.                                         loc.getYaw());
  166.                                 this.pointfileConfiguration.set(str + "pitch",
  167.                                         loc.getPitch());
  168.                                 try {
  169.                                     this.pointfileConfiguration
  170.                                             .save(this.pointsfile);
  171.                                     p.sendMessage(ChatColor.AQUA + "[TOTL] "
  172.                                             + ChatColor.GREEN + "Punkt "
  173.                                             + args[2] + " erfolgreich gesetzt.");
  174.                                     p.sendMessage(ChatColor.AQUA
  175.                                             + "[TOTL] "
  176.                                             + ChatColor.RED
  177.                                             + "ACHTUNG!!! Bei nächster eingabe des Befehls(/totl admin setpoint "
  178.                                             + args[2]
  179.                                             + ") , wird dieser Punkt überschrieben.");
  180.                                     return true;
  181.  
  182.                                 } catch (IOException e) {
  183.  
  184.                                     e.printStackTrace();
  185.                                 }
  186.  
  187.                             }
  188.                         }
  189.                         return true;
  190.                     } else {
  191.                         p.sendMessage(ChatColor.AQUA
  192.                                 + "[TOTL] "
  193.                                 + ChatColor.RED
  194.                                 + "Du hast nicht die Eralubnis, einen Administratoren-Befehl auszuführen.");
  195.                     }
  196.  
  197.                 }
  198.  
  199.                 else {
  200.                     p.sendMessage(ChatColor.AQUA + "[TOTL]" + ChatColor.RED
  201.                             + "Den Befehl '/totl " + args[0] + args[1]
  202.                             + args[2] + "' gibt es nicht.");
  203.                 }
  204.             } // Ende 3 Argumente
  205.  
  206.         } // '/totl' Ende
  207.  
  208.         // Variablen ende
  209.         return true;
  210.         // Variablen Ende
  211.     }
  212. }// Plugin Ende
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement