From 980d8fb374e6f9ef18145392989938aaa44f3af5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 4 Feb 2011 13:57:42 -0800 Subject: [PATCH] My top secret project. --- .../bukkit/nossr50/mcMMO/mcBlockListener.java | 48 +++ mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java | 35 ++ .../nossr50/mcMMO/mcEntityListener.java | 65 +++ mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java | 46 +++ .../nossr50/mcMMO/mcPlayerListener.java | 181 +++++++++ mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java | 374 ++++++++++++++++++ mcMMO/plugin.yml | 3 + 7 files changed, 752 insertions(+) create mode 100644 mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java create mode 100644 mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java create mode 100644 mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java create mode 100644 mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java create mode 100644 mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java create mode 100644 mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java create mode 100644 mcMMO/plugin.yml diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java new file mode 100644 index 000000000..420318e05 --- /dev/null +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java @@ -0,0 +1,48 @@ +package com.bukkit.nossr50.mcMMO; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockListener; + +public class mcBlockListener extends BlockListener { + private final mcMMO plugin; + + public mcBlockListener(final mcMMO plugin) { + this.plugin = plugin; + } + //put all Block related code here + public void onBlockDamage(BlockDamageEvent event) { + //STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2); + Player player = event.getPlayer(); + Block block = event.getBlock(); + int dmg = event.getDamageLevel().getLevel(); + if(dmg == 3){ + mcUsers.getProfile(player).addgather(1); + //GOLD ORE = 14 + //DIAMOND ORE = 56 + //REDSTONE = 73 && 74 + + if(block.getTypeId() == 1){ + int t = player.getItemInHand().getTypeId(); + int q; + //If stone tools + if(t == 272 || t == 273 || t == 274 || t == 275){ + q = 3; + //If iron tools + } else if (t == 256 || t == 257 || t == 258 || t == 267){ + q = 2; + //If wooden tools + } else if (t == 268 || t == 269 || t == 270 || t == 271){ + q = 4; + //If Diamond tools + } else if (t == 276 || t == 277 || t == 278 || t == 279){ + q = 1; + } else { + q = 5; + } + + } + } + } +} \ No newline at end of file diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java new file mode 100644 index 000000000..f7dfc9975 --- /dev/null +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcConfig.java @@ -0,0 +1,35 @@ +package com.bukkit.nossr50.mcMMO; + +import java.util.ArrayList; + +public class mcConfig { + private static volatile mcConfig instance; + static ArrayList adminChatList = new ArrayList(); + static ArrayList partyChatList = new ArrayList(); + public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);} + public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);} + public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));} + public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));} + public void addPartyToggled(String playerName) {partyChatList.add(playerName);} + public void addAdminToggled(String playerName) {adminChatList.add(playerName);} + public static mcConfig getInstance() { + if (instance == null) { + instance = new mcConfig(); + } + return instance; + } + public void toggleAdminChat(String playerName){ + if(isAdminToggled(playerName)){ + removeAdminToggled(playerName); + } else { + addAdminToggled(playerName); + } + } + public void togglePartyChat(String playerName){ + if(isPartyToggled(playerName)){ + removePartyToggled(playerName); + } else { + addPartyToggled(playerName); + } + } +} \ No newline at end of file diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java new file mode 100644 index 000000000..dafd3556f --- /dev/null +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcEntityListener.java @@ -0,0 +1,65 @@ +package com.bukkit.nossr50.mcMMO; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityListener; +import org.bukkit.inventory.ItemStack; + +public class mcEntityListener extends EntityListener { + private final mcMMO plugin; + + public mcEntityListener(final mcMMO plugin) { + this.plugin = plugin; + } + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + Entity x = event.getEntity(); //Defender + Entity y = event.getDamager(); //Attacker + //If attacker is player... + if(y instanceof Player){ + Player attacker = (Player)y; + //If defender is player + if(x instanceof Player){ + Player defender = (Player)x; + if(mcUsers.getProfile(defender).getParty().equals(mcUsers.getProfile(attacker).getParty())){ + event.setCancelled(true); + } + } + } + } + public void onEntityDamage(EntityDamageEvent event) { + //Thanks to TimberJaw for sharing his source code! + Entity x = event.getEntity(); + if(x instanceof Player){ + Player player = (Player)x; + if((player.getHealth() - event.getDamage()) <= 0){ + Location deathLoc = player.getLocation(); + ItemStack[] items = player.getInventory().getContents(); + for(int i = 0; i < items.length; i++) + { + ItemStack is = items[i]; + if(is != null && is.getAmount() > 0) + { + player.getWorld().dropItemNaturally(deathLoc, is); + } + } + player.setHealth(20); + player.teleportTo(mcUsers.getProfile(player).getMySpawn(player)); + for(Player derp : plugin.getServer().getOnlinePlayers()){ + derp.sendMessage(ChatColor.GRAY+player.getName() + " has died."); + } + } + } + } + public boolean isPlayer(Entity entity){ + if (entity instanceof Player) { + return true; + } else{ + return false; + } + } +} diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java new file mode 100644 index 000000000..71574b596 --- /dev/null +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcMMO.java @@ -0,0 +1,46 @@ +package com.bukkit.nossr50.mcMMO; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import org.bukkit.event.player.*; +import org.bukkit.Server; +import org.bukkit.event.Event.Priority; +import org.bukkit.event.Event; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.PluginLoader; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.PluginManager; +import org.bukkit.entity.Player; + + +public class mcMMO extends JavaPlugin { + private final mcPlayerListener playerListener = new mcPlayerListener(this); + private final mcBlockListener blockListener = new mcBlockListener(this); + private final mcEntityListener entityListener = new mcEntityListener(this); + private final HashMap debugees = new HashMap(); + private final String name = "mcMMO"; + + public mcMMO(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) { + super(pluginLoader, instance, desc, folder, plugin, cLoader); + } + + public void onEnable() { + mcUsers.getInstance().loadUsers(); + PluginManager pm = getServer().getPluginManager(); + pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this); + pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this); + pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); + pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this); + pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this); + pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Monitor, this); + pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this); + pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this); + //Displays a message when plugin is loaded + PluginDescriptionFile pdfFile = this.getDescription(); + System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); + } + public void onDisable() { + System.out.println("mcMMO disabled."); + } +} diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java new file mode 100644 index 000000000..c75a09359 --- /dev/null +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java @@ -0,0 +1,181 @@ +package com.bukkit.nossr50.mcMMO; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerListener; + +public class mcPlayerListener extends PlayerListener { + public Location spawn = null; + private static mcMMO plugin; + + public mcPlayerListener(mcMMO instance) { + plugin = instance; + } + public void onPlayerJoin(PlayerEvent event) { + Player player = event.getPlayer(); + mcUsers.addUser(player); + player.sendMessage(ChatColor.GREEN+"Welcome to /v/ - Minecraft"); + player.sendMessage(ChatColor.GREEN+"Steam Group: vminecraft"); + player.sendMessage(ChatColor.AQUA + "This server is running mcMMO type /stats for your information"); + player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/party "+ChatColor.WHITE+"to create/join parties."); + player.sendMessage(ChatColor.GREEN + "Use "+ChatColor.YELLOW+"/p"+ChatColor.WHITE+" to toggle party chat"); + player.sendMessage("Set your spawn with "+ChatColor.YELLOW+"/setmyspawn"+ChatColor.WHITE+", Travel to it with /myspawn"); + player.sendMessage(ChatColor.RED+"WARNING: "+ChatColor.DARK_GRAY+ "Using /myspawn will clear your inventory!"); + } + public void onPlayerCommand(PlayerChatEvent event) { + Player player = event.getPlayer(); + String[] split = event.getMessage().split(" "); + String playerName = player.getName(); + //mcMMO command + if(split[0].equalsIgnoreCase("/whereis")){ + if(!player.isOp()) + return; + if(split.length == 1){ + player.sendMessage("Usage is /whereis [player]"); + return; + } + for(Player derp : plugin.getServer().getOnlinePlayers()){ + if(derp.getName().toLowerCase().equals(split[2].toLowerCase())){ + Location loc = derp.getLocation(); + player.sendMessage("Player " + derp.getName() + " Coordinates"); + player.sendMessage("X: " + String(loc.getX())); + player.sendMessage("Y: " + String(loc.getY())); + player.sendMessage("Z: " + String(loc.getZ())); + } + } + } + if(split[0].equalsIgnoreCase("/setmyspawn")){ + double x = player.getLocation().getX(); + double y = player.getLocation().getY(); + double z = player.getLocation().getZ(); + mcUsers.getProfile(player).setMySpawn(x, y, z); + player.sendMessage(ChatColor.DARK_AQUA + "Myspawn has been set to your current location."); + } + if(player.isOp() && split[0].equalsIgnoreCase("/setspawn")){ + spawn = event.getPlayer().getLocation(); + player.sendMessage("Spawn set to current location"); + } + if(split[0].equalsIgnoreCase("/stats")){ + event.setCancelled(true); + player.sendMessage(ChatColor.DARK_GREEN + "mcMMO stats"); + player.sendMessage(ChatColor.DARK_GREEN + "Gathering Skill: " + mcUsers.getProfile(player).getgather()); + player.sendMessage(ChatColor.GRAY + "Increases as you gather materials from the world"); + player.sendMessage(ChatColor.GRAY + "Effect: Increases chance to gather more than one of a rare material"); + } + //Party command + if(split[0].equalsIgnoreCase("/party")){ + event.setCancelled(true); + if(split.length == 1){ + player.sendMessage("Proper usage is /party or 'q' to quit"); + return; + } + if(split[1].equals("q") && mcUsers.getProfile(player).inParty()){ + mcUsers.getProfile(player).removeParty(); + informPartyMembersQuit(player); + return; + } + mcUsers.getProfile(player).setParty(split[1]); + player.sendMessage("Joined Party: " + split[1]); + informPartyMembers(player); + } + if(split[0].equalsIgnoreCase("/p")){ + if(mcConfig.getInstance().isAdminToggled(player.getName())) + mcConfig.getInstance().toggleAdminChat(playerName); + mcConfig.getInstance().togglePartyChat(playerName); + if(mcConfig.getInstance().isPartyToggled(playerName)){ + player.sendMessage(ChatColor.GREEN + "Party Chat Toggled On"); + } else { + player.sendMessage(ChatColor.GREEN + "Party Chat Toggled " + ChatColor.RED + "Off"); + } + } + if(split[0].equalsIgnoreCase("/a") && player.isOp()){ + if(mcConfig.getInstance().isPartyToggled(player.getName())) + mcConfig.getInstance().togglePartyChat(playerName); + mcConfig.getInstance().toggleAdminChat(playerName); + if(mcConfig.getInstance().isAdminToggled(playerName)){ + player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On"); + } else { + player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off"); + } + } + if(split[0].equalsIgnoreCase("/myspawn")){ + player.getInventory().clear(); + player.setHealth(20); + player.teleportTo(mcUsers.getProfile(player).getMySpawn(player)); + player.sendMessage("Inventory cleared & health restored"); + } + if(split[0].equalsIgnoreCase("/spawn")){ + if(spawn != null){ + player.teleportTo(spawn); + player.sendMessage("Welcome to spawn, home of the dumbfucks"); + return; + } + player.sendMessage("Spawn isn't configured. Have an OP set it with /setspawn"); + } + } + private String String(double x) { + // TODO Auto-generated method stub + return null; + } + public void onPlayerChat(PlayerChatEvent event) { + Player player = event.getPlayer(); + String[] split = event.getMessage().split(" "); + String x = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") "; + String y = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} "; + if(mcConfig.getInstance().isPartyToggled(player.getName())){ + event.setCancelled(true); + for(Player herp : plugin.getServer().getOnlinePlayers()){ + if(mcUsers.getProfile(herp).inParty()){ + if(inSameParty(herp, player)){ + herp.sendMessage(x+event.getMessage()); + } + } + } + return; + } + if(player.isOp() && mcConfig.getInstance().isAdminToggled(player.getName())){ + event.setCancelled(true); + for(Player herp : plugin.getServer().getOnlinePlayers()){ + if(herp.isOp()){ + herp.sendMessage(y+event.getMessage()); + } + } + return; + } + if(player.isOp()){ + event.setCancelled(true); + for(Player derp : plugin.getServer().getOnlinePlayers()){ + String z = ChatColor.RED + "<" + ChatColor.WHITE + player.getName() + ChatColor.RED + "> "+ChatColor.WHITE; + derp.sendMessage(z+event.getMessage()); + } + } + } + public static void informPartyMembers(Player player){ + int x = 0; + for(Player p : plugin.getServer().getOnlinePlayers()){ + if(inSameParty(player, p) && !p.getName().equals(player.getName())){ + p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party"); + x++; + } + } + } + public static void informPartyMembersQuit(Player player){ + int x = 0; + for(Player p : plugin.getServer().getOnlinePlayers()){ + if(inSameParty(player, p) && !p.getName().equals(player.getName())){ + p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party"); + x++; + } + } + } + public static boolean inSameParty(Player playera, Player playerb){ + if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){ + return true; + } else { + return false; + } + } +} \ No newline at end of file diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java new file mode 100644 index 000000000..445bf502e --- /dev/null +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcUsers.java @@ -0,0 +1,374 @@ +package com.bukkit.nossr50.mcMMO; + +import java.io.*; +import java.util.ArrayList; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.bukkit.Location; +import org.bukkit.entity.*; + +public class mcUsers { + private static volatile mcUsers instance; + protected static final Logger log = Logger.getLogger("Minecraft"); + String location = "mcMMO.users"; + public static PlayerList players = new PlayerList(); + private Properties properties = new Properties(); + + //To load + public void load() throws IOException { + properties.load(new FileInputStream(location)); + } + //To save + public void save() { + try { + properties.store(new FileOutputStream(location), null); + }catch(IOException ex) { + } + } + + + public void loadUsers(){ + File theDir = new File(location); + if(!theDir.exists()){ + //properties = new PropertiesFile(location); + FileWriter writer = null; + try { + writer = new FileWriter(location); + writer.write("#Storage place for user information\r\n"); + writer.write("#username:nickname:suffix:tag:ignore,list,names:alias,commands,here\r\n"); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while creating " + location, e); + } finally { + try { + if (writer != null) { + writer.close(); + } + } catch (IOException e) { + log.log(Level.SEVERE, "Exception while closing writer for " + location, e); + } + } + + } else { + //properties = new PropertiesFile(location); + try { + load(); + } catch (IOException e) { + log.log(Level.SEVERE, "Exception while loading " + location, e); + } + } + } + + //===================================================================== + //Function: addUser + //Input: Player player: The player to create a profile for + //Output: none + //Use: Loads the profile for the specified player + //===================================================================== + public static void addUser(Player player){ + players.addPlayer(player); + } + + //===================================================================== + //Function: removeUser + //Input: Player player: The player to stop following + //Output: none + //Use: Creates the player profile + //===================================================================== + public static void removeUser(Player player){ + players.removePlayer(player); + } + + //===================================================================== + //Function: getProfile + //Input: Player player: The player to find the profile for + //Output: PlayerList.PlayerProfile: The profile + //Use: Gets the player profile + //===================================================================== + public static PlayerList.PlayerProfile getProfile(Player player){ + return players.findProfile(player); + } + + public static mcUsers getInstance() { + if (instance == null) { + instance = new mcUsers(); + } + return instance; + } + public static void getRow(){ + + } +} +class PlayerList +{ + protected static final Logger log = Logger.getLogger("Minecraft"); + ArrayList players; + + //===================================================================== + //Function: PlayerList + //Input: Player player: The player to create a profile object for + //Output: none + //Use: Initializes the ArrayList + //===================================================================== + public PlayerList() { players = new ArrayList(); } + + //===================================================================== + //Function: addPlayer + //Input: Player player: The player to add + //Output: None + //Use: Add a profile of the specified player + //===================================================================== + public void addPlayer(Player player) + { + players.add(new PlayerProfile(player)); + } + + //===================================================================== + //Function: removePlayer + //Input: Player player: The player to remove + //Output: None + //Use: Remove the profile of the specified player + //===================================================================== + public void removePlayer(Player player) + { + players.remove(findProfile(player)); + } + + //===================================================================== + //Function: findProfile + //Input: Player player: The player to find's profile + //Output: PlayerProfile: The profile of the specified player + //Use: Get the profile for the specified player + //===================================================================== + public PlayerProfile findProfile(Player player) + { + for(PlayerProfile ply : players) + { + if(ply.isPlayer(player)) + return ply; + } + return null; + } + + class PlayerProfile + { + protected final Logger log = Logger.getLogger("Minecraft"); + private String playerName, gather, party, myspawn; + private boolean dead; + char defaultColor; + + String location = "mcMMO.users"; + + + //===================================================================== + //Function: PlayerProfile + //Input: Player player: The player to create a profile object for + //Output: none + //Use: Loads settings for the player or creates them if they don't + // exist. + //===================================================================== + public PlayerProfile(Player player) + { + //Declare things + playerName = player.getName(); + party = new String(); + myspawn = new String(); + gather = new String(); + party = null; + dead = false; + + //Try to load the player and if they aren't found, append them + if(!load()) + addPlayer(); + } + + public boolean load() + { + try { + //Open the user file + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + String line = ""; + while((line = in.readLine()) != null) + { + //Find if the line contains the player we want. + String[] character = line.split(":"); + if(!character[0].equals(playerName)){continue;} + + //Get gather + if(character.length > 1) + gather = character[1]; + if(character.length > 2){ + myspawn = character[2]; + } + in.close(); + return true; + } + in.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while reading " + + location + " (Are you sure you formatted it correctly?)", e); + } + return false; + } + + //===================================================================== + // Function: save + // Input: none + // Output: None + // Use: Writes current values of PlayerProfile to disk + // Call this function to save current values + //===================================================================== + public void save() + { + try { + //Open the file + FileReader file = new FileReader(location); + BufferedReader in = new BufferedReader(file); + StringBuilder writer = new StringBuilder(); + String line = ""; + + //While not at the end of the file + while((line = in.readLine()) != null) + { + //Read the line in and copy it to the output it's not the player + //we want to edit + if(!line.split(":")[0].equalsIgnoreCase(playerName)) + { + writer.append(line).append("\r\n"); + + //Otherwise write the new player information + } else { + writer.append(playerName + ":"); + writer.append(gather + ":"); + writer.append(myspawn + ":"); + writer.append("\r\n"); + } + } + in.close(); + //Write the new file + FileWriter out = new FileWriter(location); + out.write(writer.toString()); + out.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); + } + } + public void addPlayer() + { + try { + //Open the file to write the player + FileWriter file = new FileWriter(location, true); + BufferedWriter out = new BufferedWriter(file); + + //Add the player to the end + out.append(playerName + ":"); + out.append(gather + ":"); + out.append(myspawn+":"); + //Add more in the same format as the line above + + out.newLine(); + out.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); + } + } + + //===================================================================== + //Function: isPlayer + //Input: None + //Output: Player: The player this profile belongs to + //Use: Finds if this profile belongs to a specified player + //===================================================================== + public boolean isPlayer(Player player) + { + return player.getName().equals(playerName); + } + + public void addgather(int newgather) + { + int x = 0; + if(isInt(gather)){ + x = Integer.parseInt(gather); + } + x += newgather; + gather = String.valueOf(x); + save(); + } + + public boolean isInt(String string){ + try { + int x = Integer.parseInt(gather); + return true; + } + catch(NumberFormatException nFE) { + return false; + } + } + //Returns player gather + public String getgather() { return gather; } + + //Store the player's party + public void setParty(String newParty) + { + party = newParty; + save(); + } + //Retrieve the player's party + public String getParty() {return party;} + //Remove party + public void removeParty() { + party = null; + save(); + } + //Retrieve whether or not the player is in a party + public boolean inParty() { + if(party != null){ + return true; + } else { + return false; + } + } + //Save a users spawn location + public void setMySpawn(double x, double y, double z){ + myspawn = x+","+y+","+z; + save(); + } + public String getX(){ + String[] split = myspawn.split(","); + String x = split[0]; + return x; + } + public String getY(){ + String[] split = myspawn.split(","); + String y = split[1]; + return y; + } + public String getZ(){ + String[] split = myspawn.split(","); + String z = split[2]; + return z; + } + public void setDead(boolean x){ + dead = x; + save(); + } + public boolean isDead(){ + return dead; + } + public Location getMySpawn(Player player){ + Location loc = player.getLocation(); + loc.setX(Double.parseDouble(mcUsers.getProfile(player).getX())); + loc.setY(Double.parseDouble(mcUsers.getProfile(player).getY())); + loc.setZ(Double.parseDouble(mcUsers.getProfile(player).getZ())); + loc.setYaw(0); + loc.setPitch(0); + return loc; + } + } + +} + + + diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml new file mode 100644 index 000000000..5d41b4229 --- /dev/null +++ b/mcMMO/plugin.yml @@ -0,0 +1,3 @@ +name: mcMMO +main: com.bukkit.nossr50.mcMMO.mcMMO +version: alpha \ No newline at end of file