Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.HashMap;
- public class JailListener extends PluginListener{
- JailDelay jd = new JailDelay();
- HashMap<String , String> a = new HashMap<String , String>();
- int i = 1;
- double x1;
- double y1;
- double z1;
- String directory = "plugins/config/Jail/Jailes/";
- File names = new File("plugins/config/Jail/Jailnames.txt");
- PropertiesFile mainj = new PropertiesFile(directory+"Mainjail.properties");
- public boolean onCommand(Player player, String[] split){
- if (split[0].equalsIgnoreCase("/jail")&&player.canUseCommand("/jailadmin")){
- if (split.length == 1){
- player.sendMessage("§cthe correct usage is '/jail player'");
- return true;
- }else
- if (split.length == 2){
- Player player2 = etc.getServer().matchPlayer(split[1]);
- if (player2 == null){
- player.sendMessage("§cThis player does not exist or is currently not logged in.");
- return true;
- }else{
- String[] split2 = a.get(player2.getName()).split(",");
- if(!split2[0].equals(i)){
- if (mainj.containsKey(i+"")){
- if(!a.containsKey(player2.getName())){
- String[] split1 = mainj.getString(i+"").split(",");
- x1 = Double.parseDouble(split1[0]); y1 = Double.parseDouble(split1[1]); z1 = Double.parseDouble(split1[2]);
- a.put(player2.getName(),i+","+"Mainjail");
- player2.teleportTo(x1,y1+1,z1,0,0);
- player.sendMessage("§2Player jailed at cell "+i);
- player2.sendMessage("§4"+player.getName()+" Jailed you!");
- return true;
- }else{player.sendMessage("§cThis Player is already jailed"); return true;}
- }else{
- player.sendMessage("§cThere are no available cells in the Mainjail anymore");
- return true;
- }
- }
- i++;
- }
- }
- }
- if (split.length == 3){
- Player player2 = etc.getServer().matchPlayer(split[1]);
- if (player2 == null){
- player.sendMessage("§cThis player does not exist or is currently not logged in.");
- return true;
- }else{
- if (isInList(split[2])){
- PropertiesFile jail = new PropertiesFile(directory+split[2]+".properties");
- if (!a.containsKey(player2.getName())){
- if (jail.containsKey(i+"")){
- String[] split2 = a.get(player2.getName()).split(",");
- if (!split2[0].equals(i)){
- String[] split1 = jail.getString(i+"").split(",");
- x1 = Double.parseDouble(split1[0]); y1 = Double.parseDouble(split1[1]); z1 = Double.parseDouble(split1[2]);
- a.put(player2.getName(),i+","+"Mainjail");
- player2.teleportTo(x1,y1+1,z1,0,0);
- player.sendMessage("§2Player jailed at cell "+i);
- player2.sendMessage("§4"+player.getName()+" Jailed you!");
- return true;
- }
- }
- }else{
- player.sendMessage("§cThis player is already jailed.");
- return true;
- }
- }else{
- player.sendMessage("§cThis jail doesnt exist.");
- return true;
- }
- }
- }
- return false;
- }
- public boolean isInList(String s) {
- try {
- BufferedReader in = new BufferedReader(new FileReader(names));
- String line = in.readLine();
- while (line != null) {
- if (line.equalsIgnoreCase(s)) {
- in.close();
- return true;
- }
- line = in.readLine();
- }
- in.close();
- } catch (IOException localIOException) {
- }
- return false; }
- }
Advertisement
Add Comment
Please, Sign In to add comment