Ejemplo n.º 1
0
  @EventHandler
  public void onPlayerRespawn(PlayerRespawnEvent event) {
    Player player = event.getPlayer();
    if (!plugin.playerIsJailed(player)) return;
    event.setRespawnLocation(plugin.getJailLocation());

    World w = plugin.getJailLocation().getWorld();
    Wolf wolf = (Wolf) w.spawnCreature(plugin.getJailLocation(), EntityType.WOLF);
    wolf.setAdult();
    wolf.setTarget(player);
    wolf.setAngry(true);
    wolf.damage(0, player);

    plugin.setPotionEffects(player);
  }
Ejemplo n.º 2
0
  @EventHandler
  public void onPlayerJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    if ((!plugin.playerIsJailed(player)) && (!plugin.playerIsTempJailed(player))) {
      return;
    }

    if (plugin.playerIsTempJailed(player)) {
      int minutes =
          (int) Math.round((plugin.getTimeSentenced(player) - plugin.getTimeServed(player)) / 60.0);
      // int minutes = (int)((plugin.getTempJailTime(player) -
      // System.currentTimeMillis()) / 60000.0D);
      player.sendMessage(
          ChatColor.RED
              + "[JailLikeHell] You are jailed for "
              + plugin.prettifyMinutes(minutes)
              + ".");
    } else {
      player.sendMessage(ChatColor.RED + "[JailLikeHell] You are permanently jailed!");
      plugin
          .getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              plugin,
              new Runnable() {
                @Override
                public void run() {
                  player.teleport(JL.plugin.getJailLocation());

                  World w = JL.plugin.getJailLocation().getWorld();
                  Wolf wolf = (Wolf) w.spawnCreature(JL.plugin.getJailLocation(), EntityType.WOLF);
                  wolf.setAdult();
                  wolf.setTarget(player);
                  wolf.setAngry(true);
                  wolf.damage(0, player);
                }
              },
              60L);
    }
  }