Ejemplo n.º 1
0
	public boolean CrapsSign(Player player, Sign sign){
		String line2string = null;
		double line2 = 0;
		if(sign.getText(3).equalsIgnoreCase("GLOBAL")){
			if(player.canUseCommand("/scplaceglobal") || player.canUseCommand("/scadmin")){
				sign.setText(3, "GLOBAL");
			}
			else{
				if(!SC.SCD.canPlaceSign(2, player.getName())){
					player.sendMessage("[�ign��s�no] You have too many '�RAPS' signs");
					NoPlaceSign(sign);
					return false;
				}
				if(player.getName().length() > 15){
					SC.SCD.setNameFix(player.getName().substring(0, 15), player.getName());
					sign.setText(3, player.getName().substring(0, 15));
				}
				else{
					sign.setText(3, player.getName());
				}
			}
		}
		else{
			if(!SC.SCD.canPlaceSign(2, player.getName())){
				player.sendMessage("[�ign��s�no] You have too many '�RAPS' signs");
				NoPlaceSign(sign);
				return false;
			}
			if(player.getName().length() > 15){
				SC.SCD.setNameFix(player.getName().substring(0, 15), player.getName());
				sign.setText(3, player.getName().substring(0, 15));
			}
			else{
				sign.setText(3, player.getName());
			}
		}
		sign.setText(0, "�CRAPS]");
		if (!sign.getText(1).equals("")) {
			try {
				line2string = sign.getText(1);
				line2 = Double.parseDouble(line2string);
			}catch (NumberFormatException NFE) {
				if(SCD.dCo){
					player.sendMessage("[�ign��s�no]�Invalid '�ET�. Auto-setting 'BET' to '�+SCD.priceForm(SCD.AB)+"�");
					sign.setText(1, "�+SCD.priceForm(SCD.AB));
				}
				else{
					player.sendMessage("[�ign��s�no]�Invalid '�ET�. Auto-setting 'BET' to '�+((int)SCD.AB)+"�");
					sign.setText(1, "�+((int)SCD.AB));
				}
			}
  public boolean onSignChange(Player player, Sign sign) {
    int max_length = 10;

    String[] line0split = sign.getText(0).split(" ");
    if (line0split.length >= 1
        && line0split.length <= 3
        && line0split[0].equalsIgnoreCase("[SENSOR]")) {
      // interpret sign
      try {
        // read params
        int length = max_length;
        if (line0split.length >= 2) {
          int l = new Integer(line0split[1]);
          if (l < max_length && l > 0) {
            length = l;
          }
        }

        int duration = 0;
        if (line0split.length >= 3) {
          int d = new Integer(line0split[2]);
          if (d >= -2) duration = d;
        }

        SensorBlock.SignOrientation o = SensorBlock.SignOrientation.SOUTH;
        int data = sign.getBlock().getData();
        if (data == 0x2) o = SensorBlock.SignOrientation.EAST;
        else if (data == 0x3) o = SensorBlock.SignOrientation.WEST;
        else if (data == 0x4) o = SensorBlock.SignOrientation.NORTH;
        else if (data == 0x5) o = SensorBlock.SignOrientation.SOUTH;
        else {
          Logger.getLogger("Minecraft").severe("Invalid sign data: " + data);
          throw new RuntimeException("Invalid sign data.");
        }
        String extra = sign.getText(1) + sign.getText(2) + sign.getText(3);
        SensorBlock s =
            new SensorBlock(
                new Location(sign.getX(), sign.getY(), sign.getZ()), o, length, duration, extra);
        mSensorList.add(s);

        player.sendMessage(mMessagePrefix + "You created a sensor.");
        if (etc.getServer().getBlockAt(sign.getX(), sign.getY() - 1, sign.getZ()).blockType
            != Block.Type.Lever) {
          player.sendMessage(
              mMessagePrefix
                  + "Now place a §fLever "
                  + mMessageColor
                  + "underneath the sign post.");
        }
        sign.setText(0, "[SENSOR] " + length + " " + duration);
        if (s.IsTriggeringAny()) sign.setText(1, "*");
        sign.update();
        Save();
      } catch (NumberFormatException e) {
        player.sendMessage(
            mMessagePrefix
                + "Invalid sign format. See §f/towndefense help sensor "
                + mMessageColor
                + " for help.");
      }
    }
    return false;
  }