spenk

MineAnnounceListener

Mar 13th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.51 KB | None | 0 0
  1. import java.io.File;
  2. import java.util.ArrayList;
  3.  
  4.  
  5. public class MineAnnounceListener extends PluginListener{
  6.         File file = new File("plugins/config");
  7.         File file2 = new File ("plugins/config/MineAnnounce");
  8.     PropertiesFile props1 = new PropertiesFile("plugins/config/MineAnnounce/configuration.properties");
  9.     PropertiesFile props2 = new PropertiesFile("plugins/config/MineAnnounce/announcements.properties");
  10.     PropertiesFile props3 = new PropertiesFile("plugins/config/MineAnnounce/Radiusses.properties");
  11.     PropertiesFile props4 = new PropertiesFile("plugins/config/MineAnnounce/timer.properties");
  12.     boolean coal;
  13.     boolean iron;
  14.     boolean gold;
  15.     boolean diamond;
  16.     boolean lapis;
  17.     boolean redstone;
  18.     boolean spawner;
  19.     boolean mossycobble;
  20.  
  21.     String coals;
  22.     String irons;
  23.     String golds;
  24.     String diamonds;
  25.     String lapiss;
  26.     String redstones;
  27.     String spawners;
  28.     String mossycobbles;
  29.  
  30.     int coalr;
  31.     int ironr;
  32.     int goldr;
  33.     int diamondr;
  34.     int lapisr;
  35.     int redstoner;
  36.     int spawnerr;
  37.     int mossycobbler;
  38.    
  39.     int coalt;
  40.     int iront;
  41.     int goldt;
  42.     int diamondt;
  43.     int lapist;
  44.     int redstonet;
  45.     int spawnert;
  46.     int mossycobblet;
  47.  
  48.     public void load1(){
  49.     coal = props1.getBoolean("Announce-Coal",true);
  50.     iron = props1.getBoolean("Announce-Iron",true);
  51.     gold = props1.getBoolean("Announce-Gold",true);
  52.     diamond = props1.getBoolean("Announce-Diamond",true);
  53.     lapis = props1.getBoolean("Announce-Lapis",true);
  54.     redstone = props1.getBoolean("Announce-Redstone",true);
  55.     spawner = props1.getBoolean("Announce-Spawner",true);
  56.     mossycobble = props1.getBoolean("Announce-MossyCobble",true);
  57.     }
  58.     public void load2(){
  59.         coals = props2.getString("Coal-Text","&1/p &2found &3/a &4coal!");
  60.         irons = props2.getString("Iron-Text","&1/p &2found &3/a &4Iron!");
  61.         golds = props2.getString("Gold-Text","&1/p &2found &3/a &4Gold!");
  62.         diamonds = props2.getString("Diamond-Text","&1/p &2found &3/a &4Diamond!");
  63.         lapiss = props2.getString("Lapis-Text","&1/p &2found &3/a &4Lapis!");
  64.         redstones = props2.getString("Redstone-Text","&1/p &2found &3/a &4Redstone!");
  65.         spawners = props2.getString("Spawner-Text","&1/p &2found &3/a &4Spawner!");
  66.         mossycobbles = props2.getString("MossyCobble-Text","&1/p &2found &3/a &4MossyCobbleStone!");
  67.        
  68.     }
  69.     public void load3(){
  70.         coalr = props3.getInt("Coal-Radius",4);
  71.         ironr = props3.getInt("Iron-Radius",3);
  72.         goldr = props3.getInt("Gold-Radius",3);
  73.         diamondr = props3.getInt("Diamond-Radius",3);
  74.         lapisr = props3.getInt("Lapis-Radius",4);
  75.         redstoner = props3.getInt("Redstone-Radius",4);
  76.         spawnerr= props3.getInt("Spawner-Radius",0);
  77.         mossycobbler = props3.getInt("MossyCobble-Radius",10);
  78.     }
  79.     public void load4(){
  80.         coalt = props4.getInt("Coal-Timer", 30);
  81.         ironr = props4.getInt("Iron-Timer", 30);
  82.         goldt = props4.getInt("Gold-Timer",30);
  83.         diamondt = props4.getInt("Diamond-Timer",30);
  84.         lapist = props4.getInt("Lapis-Timer",30);
  85.         redstonet = props4.getInt("Redstone-Timer",30);
  86.         spawnert= props4.getInt("Spawner-Timer",30);
  87.         mossycobblet = props4.getInt("MossyCobble-Timer",30);
  88.     }
  89.     ArrayList<String> listc = new ArrayList<String>();
  90.     ArrayList<String> listi = new ArrayList<String>();
  91.     ArrayList<String> listg = new ArrayList<String>();
  92.     ArrayList<String> listd = new ArrayList<String>();
  93.     ArrayList<String> listl = new ArrayList<String>();
  94.     ArrayList<String> listr = new ArrayList<String>();
  95.     ArrayList<String> lists = new ArrayList<String>();
  96.     ArrayList<String> listm = new ArrayList<String>();
  97.    
  98.     int cam =1;
  99.     public boolean onBlockBreak(Player player,Block block){
  100.         if (block.getType() == 16){
  101.             if (coal == true){
  102.                 if (!listc.contains(player.getName())){
  103.                 amount(player.getName(), coals, block, coalr);
  104.                 listc.add(player.getName()); timer(listc,coalt*1000, player.getName());
  105.                 return false;
  106.             }
  107.             }
  108.             }else if (block.getType() == 15){
  109.             if (iron == true){
  110.                 if (!listi.contains(player.getName())){
  111.                     amount(player.getName(), irons, block, ironr);
  112.                     listi.add(player.getName());timer(listi,coalt*1000, player.getName());
  113.                     return false;
  114.                 }
  115.                 }
  116.             }else if (block.getType() == 14){
  117.                     if (gold == true){
  118.                         if (!listg.contains(player.getName())){
  119.                             amount(player.getName(), golds, block, goldr);
  120.                             listg.add(player.getName());timer(listg,goldt*1000, player.getName());
  121.                             return false;
  122.                         }
  123.                     }
  124.                 }else if (block.getType() == 56){
  125.                         if (diamond == true){
  126.                             if (!listd.contains(player.getName())){
  127.                                 amount(player.getName(), diamonds, block, diamondr);
  128.                                 listd.add(player.getName());timer(listd,diamondt*1000, player.getName());
  129.                                 return false;
  130.                         }
  131.                     }
  132.                 }else if (block.getType() == 21){
  133.                         if (lapis == true){
  134.                             if (!listl.contains(player.getName())){
  135.                                 amount(player.getName(), lapiss, block, lapisr);
  136.                                 listl.add(player.getName());timer(listl,lapist*1000, player.getName());
  137.                                 return false;
  138.                         }
  139.                         }
  140.                 }else if (block.getType() == 52){
  141.                     if (spawner == true){
  142.                         if (!lists.contains(player.getName())){
  143.                             amount(player.getName(), spawners, block, spawnerr);
  144.                             lists.add(player.getName());timer(lists,spawnert*1000, player.getName());
  145.                             return false;
  146.                         }
  147.                     }
  148.                 }else if (block.getType() == 48){
  149.                     if (mossycobble == true){
  150.                         if (!listm.contains(player.getName())){
  151.                             amount(player.getName(), mossycobbles, block, mossycobbler);
  152.                             listm.add(player.getName());timer(listm,mossycobblet*1000, player.getName());
  153.                             return false;
  154.                     }
  155.                 }
  156.                 }else if (block.getType() == 74 || block.getType() == 73){
  157.                     if(redstone == true){
  158.                     if (!listr.contains(player.getName())){
  159.                         redstone(player.getName(), redstones, block, redstoner);
  160.                         listr.add(player.getName());timer(listr,redstonet*1000, player.getName());
  161.                         return false;
  162.                     }
  163.                     }
  164.                 }
  165.         return false;
  166.                 }
  167.    
  168.     public void redstone(String p, String s, Block b, int radius){
  169.             int xmin = (int)b.getX()-radius;
  170.             int xmax = (int)b.getX()+radius;
  171.             int ymin = (int)b.getY()-radius;
  172.             int ymax = (int)b.getY()+radius;
  173.             int zmin = (int)b.getZ()-radius;
  174.             int zmax = (int)b.getZ()+radius;
  175.            
  176.             for (int x = xmin; x <= xmax; x++) {
  177.                 for (int y = ymin; y <= ymax; y++) {
  178.                     for (int z = zmin; z <= zmax; z++) {
  179.                        
  180.                         if (b.getWorld().getBlockAt(x, y, z).getType() == 74 ||b.getWorld().getBlockAt(x, y, z).getType() == 73){cam++;}
  181.                     }
  182.                 }
  183.             }
  184.             s = s.replaceAll("&", "§");
  185.             s = s.replaceAll("/p", p);
  186.             s = s.replaceAll("/a", cam+"");
  187.             etc.getServer().messageAll("§3[MA]§f "+s);
  188.             cam = 0;
  189.     }
  190.     public void amount(String p, String s, Block b, int radius){
  191.         int xmin = (int)b.getX()-radius;
  192.         int xmax = (int)b.getX()+radius;
  193.         int ymin = (int)b.getY()-radius;
  194.         int ymax = (int)b.getY()+radius;
  195.         int zmin = (int)b.getZ()-radius;
  196.         int zmax = (int)b.getZ()+radius;
  197.        
  198.         for (int x = xmin; x <= xmax; x++) {
  199.             for (int y = ymin; y <= ymax; y++) {
  200.                 for (int z = zmin; z <= zmax; z++) {
  201.                    
  202.                     if (b.getWorld().getBlockAt(x, y, z).getType() == b.getType()){cam++;}
  203.                 }
  204.             }
  205.         }
  206.         s = s.replaceAll("&", "§");
  207.         s = s.replaceAll("/p", p);
  208.         s = s.replaceAll("/a", cam+"");
  209.         etc.getServer().messageAll("§3[MA]§f "+s);
  210.         cam = 0;
  211.       }
  212.      
  213.       public void timer(final ArrayList<String> list, final int t, final String s){
  214.              new Thread() {
  215.                  public void run() {
  216.                       try{
  217.                             Thread.sleep(t);
  218.                             list.remove(s);
  219.                       }catch(InterruptedException e) {e.printStackTrace();}
  220.                  }
  221.             }.start();
  222.       }
  223. }
Advertisement
Add Comment
Please, Sign In to add comment