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.FileWriter;
- import java.io.IOException;
- import java.io.Writer;
- import java.util.HashMap;
- public class JailWand extends PluginListener{
- int i = 1;
- File coords = new File("plugins/config/Jail/FileC.txt");
- File names = new File("plugins/config/Jail/Jailnames.txt");
- String directory = "plugins/config/Jail/Jailes/";
- PropertiesFile props = new PropertiesFile("plugins/config/Jail/JailProps.properties");
- HashMap<String,String> alist = new HashMap<String,String>();
- public boolean onCommand(Player player,String[] split){
- if (split[0].equalsIgnoreCase("/jailwand")&&player.canUseCommand("/jailadmin")){
- if (split.length <2|| split.length >2){
- player.sendMessage("§cThe correct usage is '/jailwand <jailname>'");
- return true;
- }else{
- if (isInList(split[1])){
- alist.put(player.getName(), split[1]);
- player.sendMessage("§2You can now select jails by rightklicking with your jailwand.");
- return true;
- }else{
- player.sendMessage("§cThis jail doesnt exist.");
- return true;
- }
- }
- }else{
- if(split[0].equalsIgnoreCase("/stopwand")&&player.canUseCommand("/jailadmin")){
- alist.remove(player.getName());
- player.sendMessage("§2You stopped selecting cells.");
- return true;
- }
- }
- return false;
- }
- Writer writer;
- public boolean onBlockRightClick(Player player,Block block,Item iih){
- if (alist.containsKey(player.getName())){
- if (iih.getItemId() == props.getInt("Jail-Wand-Item")){
- String co = Math.floor(block.getX())+","+Math.floor(block.getY())+","+Math.floor(block.getZ())+","+player.getWorld();
- if (!isInListco(co)){
- try {
- writer = new FileWriter("plugins/config/Jail/FileC.txt", true);
- writer.write(co+"\n");
- writer.close();
- } catch (IOException e) {
- }
- PropertiesFile jail = new PropertiesFile(directory+alist.get(player.getName())+".properties");
- jail.setString(i+"",co);
- player.sendMessage("§2Cell "+i+" has been set.");
- i++;
- return false;
- }else{
- player.sendMessage("§cThese coördinates are already used by another jail or cell.");
- 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; }
- public boolean isInListco(String s) {
- try {
- BufferedReader in = new BufferedReader(new FileReader(coords));
- 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