mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 09:06:46 +01:00
Moved Party API functions to their own file.
This commit is contained in:
parent
fd6bf931fc
commit
2e4aeca0df
@ -18,16 +18,13 @@ import com.gmail.nossr50.locale.mcLocale;
|
|||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -207,94 +204,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if two players are in the same party.
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
|
||||||
* @param playera The first player to check
|
|
||||||
* @param playerb The second player to check
|
|
||||||
* @return true if the two players are in the same party, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean inSameParty(Player playera, Player playerb) {
|
|
||||||
if (Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()) {
|
|
||||||
if (Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all current party names.
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
|
||||||
* @return the list of parties.
|
|
||||||
*/
|
|
||||||
public static ArrayList<String> getParties() {
|
|
||||||
String location = "plugins/mcMMO/mcmmo.users";
|
|
||||||
ArrayList<String> parties = new ArrayList<String>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
//Open the users file
|
|
||||||
FileReader file = new FileReader(location);
|
|
||||||
BufferedReader in = new BufferedReader(file);
|
|
||||||
String line = "";
|
|
||||||
|
|
||||||
while((line = in.readLine()) != null) {
|
|
||||||
String[] character = line.split(":");
|
|
||||||
String theparty = null;
|
|
||||||
|
|
||||||
//Party
|
|
||||||
if (character.length > 3) {
|
|
||||||
theparty = character[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parties.contains(theparty)) {
|
|
||||||
parties.add(theparty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
|
||||||
}
|
|
||||||
return parties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of the party a player is in.
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
|
||||||
* @param player The player to check the party name of
|
|
||||||
* @return the name of the player's party
|
|
||||||
*/
|
|
||||||
public static String getPartyName(Player player) {
|
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
|
||||||
return PP.getParty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a player is in a party.
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
|
||||||
* @param player The player to check
|
|
||||||
* @return true if the player is in a party, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean inParty(Player player) {
|
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
|
||||||
return PP.inParty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Things to be run when the plugin is disabled.
|
* Things to be run when the plugin is disabled.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user