ソースを参照

Config & project layout

Finished basic config and defined most of the commands
lennartVH01 9 年 前
コミット
d9447c3114
4 ファイル変更147 行追加1 行削除
  1. 2 1
      .gitignore
  2. 24 0
      plugin.yml
  3. 27 0
      src/me/lennartVH01/AbbaGame.java
  4. 94 0
      src/me/lennartVH01/Main.java

+ 2 - 1
.gitignore

@@ -65,4 +65,5 @@ $RECYCLE.BIN/
 # Eclipse Files
 .classpath
 .project
-.settings
+.settings
+/bin/

+ 24 - 0
plugin.yml

@@ -0,0 +1,24 @@
+name: AbbaCaving
+main: me.lennartVH01.Main
+version: 0.1
+description: Abba Caving Management Plugin
+commands:
+  abba:
+    description: Abba hub command
+permissions:
+  AbbaCaving.join:
+    default: true
+  AbbaCaving.leave:
+    default: true
+  AbbaCaving.info:
+    default: true
+  AbbaCaving.create:
+    default: op
+  AbbaCaving.remove:
+    default: op
+  AbbaCaving.open:
+    default: op
+  AbbaCaving.close:
+    default: op
+  AbbaCaving.joinClosed:
+    default: op

+ 27 - 0
src/me/lennartVH01/AbbaGame.java

@@ -0,0 +1,27 @@
+package me.lennartVH01;
+
+import org.bukkit.Location;
+
+public class AbbaGame {
+	public boolean open = false;
+	public String name;
+	public Location spawn;
+	public AbbaGame(Location spawn, String name){
+		this.spawn = spawn;
+		this.name = name;
+	}
+	
+	
+	
+	
+	
+	public void open(){
+		open = true;
+	}
+	public void close(){
+		open = false;
+	}
+	public boolean isOpen(){
+		return open;
+	}
+}

+ 94 - 0
src/me/lennartVH01/Main.java

@@ -1,7 +1,101 @@
 package me.lennartVH01;
 
+import java.util.logging.Logger;
+
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.PluginDescriptionFile;
 import org.bukkit.plugin.java.JavaPlugin;
 
 public class Main extends JavaPlugin{
+	public final Logger logger = Logger.getLogger("Minecraft");
+	public final FileConfiguration config = this.getConfig();
+	
+	public static Main plugin;
+	
+	
+	
+	@Override
+	public void onEnable(){
+		//Config
+		if(!config.contains("BlockValues")){
+			config.addDefault("BlockValues.iron_ore", 1);
+			config.addDefault("BlockValues.redstone_ore", 2);
+			config.addDefault("BlockValues.gold_ore", 4);
+			config.addDefault("BlockValues.lapis_ore", 8);
+			config.addDefault("BlockValues.diamond_ore", 10);
+			config.addDefault("BlockValues.emerald_ore", 10);
+		}
+		
+		config.addDefault("GameIndex", 1);
+		config.options().copyDefaults(true);
+		this.saveConfig();
+		
+		
+		
+		
+		
+		PluginDescriptionFile pluginDescFile = this.getDescription();
+		this.logger.info(pluginDescFile.getName() + " [" + pluginDescFile.getVersion() + "] Initialized");
+	}
+	@Override
+	public void onDisable(){
+		
+	}
 	
+	public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args){
+		if(cmdLabel.equalsIgnoreCase("abba")){
+			Player p;
+			if(sender instanceof Player){
+				p = (Player) sender;
+			}else{
+				logger.info("Must be ingame to use commands");
+				return false;
+			}
+			if(args.length == 0){
+				args = new String[]{"help"};
+			}
+			switch(args[0].toLowerCase()){
+			case "join":
+				
+				break;
+			case "leave":
+				
+				break;
+			case "info":
+				
+				break;
+			
+			//Admin commands
+			case "create":
+				if(p.hasPermission("AbbaCaving.create")){
+					String gameName;
+					if(args.length > 1){
+						gameName = args[1];
+					}else{
+						gameName = "Abba" + config.getInt("GameIndex");
+					}
+					config.set("GameIndex", config.getInt("GameIndex") + 1);
+					AbbaGame abbaGame = new AbbaGame(p.getLocation(), gameName);
+					
+				}
+				break;
+			case "remove":
+				
+				break;
+			
+			//Abba help
+			default:
+				p.sendMessage("Usage:\n - §aabba join§r: Joins the Abba Match\n - §aabba leave§f: Leaves current Abba Game\n - §aabba info§f: Displays info about an Abba Match\n - §aabba create§f: Creates an Abba Game at current location\n - §aabba remove§f: Stops game\n - §aabba open§f: Opens a game\n - §aabba close§f: Closes a game");
+				return false;
+			}
+		}
+		
+		
+		
+		
+		return false;
+	}
 }