mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Minor cleanup.
This commit is contained in:
parent
f2be996e3d
commit
6887ddd570
@ -26,36 +26,34 @@ public class mcBleedTimer implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Update bleedList with bleedRemoveList and bleedAddList
|
|
||||||
updateBleedList();
|
updateBleedList();
|
||||||
|
|
||||||
// Player bleed simulation
|
// Player bleed simulation
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers())
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
{
|
if (player == null) {
|
||||||
if (player == null) continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
if (PP == null) continue;
|
if (PP == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PP.getBleedTicks() >= 1) {
|
||||||
|
|
||||||
if (PP.getBleedTicks() >= 1)
|
|
||||||
{
|
|
||||||
//Never kill with Bleeding
|
//Never kill with Bleeding
|
||||||
if (player.getHealth() - 2 < 0)
|
if (player.getHealth() - 2 < 0) {
|
||||||
{
|
if (player.getHealth() - 1 > 0) {
|
||||||
if (player.getHealth() - 1 > 0)
|
|
||||||
{
|
|
||||||
Combat.dealDamage(player, 1);
|
Combat.dealDamage(player, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Combat.dealDamage(player, 2);
|
Combat.dealDamage(player, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
PP.decreaseBleedTicks();
|
PP.decreaseBleedTicks();
|
||||||
|
|
||||||
if (PP.getBleedTicks() == 0)
|
if (PP.getBleedTicks() == 0) {
|
||||||
{
|
|
||||||
player.sendMessage(mcLocale.getString("Swords.StoppedBleeding"));
|
player.sendMessage(mcLocale.getString("Swords.StoppedBleeding"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,19 +64,15 @@ public class mcBleedTimer implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bleedSimulate() {
|
private void bleedSimulate() {
|
||||||
// Lock list for looping
|
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
// Bleed monsters/animals
|
// Bleed monsters/animals
|
||||||
for (LivingEntity entity : bleedList)
|
for (LivingEntity entity : bleedList) {
|
||||||
{
|
if ((entity == null || entity.isDead())) {
|
||||||
if ((entity == null || entity.isDead()))
|
|
||||||
{
|
|
||||||
remove(entity);
|
remove(entity);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Combat.dealDamage(entity, 2);
|
Combat.dealDamage(entity, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,17 +82,13 @@ public class mcBleedTimer implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateBleedList() {
|
private void updateBleedList() {
|
||||||
if (lock)
|
if (lock) {
|
||||||
{
|
|
||||||
// We can't do anything when locked.
|
|
||||||
plugin.getLogger().warning("mcBleedTimer attempted to update the bleedList but the list was locked!");
|
plugin.getLogger().warning("mcBleedTimer attempted to update the bleedList but the list was locked!");
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// Remove
|
|
||||||
bleedList.removeAll(bleedRemoveList);
|
bleedList.removeAll(bleedRemoveList);
|
||||||
bleedRemoveList.clear();
|
bleedRemoveList.clear();
|
||||||
// Add
|
|
||||||
bleedList.addAll(bleedAddList);
|
bleedList.addAll(bleedAddList);
|
||||||
bleedAddList.clear();
|
bleedAddList.clear();
|
||||||
}
|
}
|
||||||
@ -110,43 +100,31 @@ public class mcBleedTimer implements Runnable {
|
|||||||
* @param entity LivingEntity to remove
|
* @param entity LivingEntity to remove
|
||||||
*/
|
*/
|
||||||
public static void remove(LivingEntity entity) {
|
public static void remove(LivingEntity entity) {
|
||||||
if (lock)
|
if (lock) {
|
||||||
{
|
if (!bleedRemoveList.contains(entity)) {
|
||||||
// Cannot remove when locked, put into bleedRemoveList
|
|
||||||
if (!bleedRemoveList.contains(entity))
|
|
||||||
{
|
|
||||||
bleedRemoveList.add(entity);
|
bleedRemoveList.add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (bleedList.contains(entity)) {
|
||||||
// Remove as normal
|
|
||||||
if (bleedList.contains(entity))
|
|
||||||
{
|
|
||||||
bleedList.remove(entity);
|
bleedList.remove(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a LivingEntity to the bleedList if it is not in it
|
* Add a LivingEntity to the bleedList if it is not in it.
|
||||||
*
|
*
|
||||||
* @param entity LivingEntity to add
|
* @param entity LivingEntity to add
|
||||||
*/
|
*/
|
||||||
public static void add(LivingEntity entity) {
|
public static void add(LivingEntity entity) {
|
||||||
if (lock)
|
if (lock) {
|
||||||
{
|
if (!bleedAddList.contains(entity)) {
|
||||||
// Cannot add when locked, put into bleedAddList
|
|
||||||
if (!bleedAddList.contains(entity))
|
|
||||||
{
|
|
||||||
bleedAddList.add(entity);
|
bleedAddList.add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (!bleedList.contains(entity)){
|
||||||
// Add as normal
|
|
||||||
if (!bleedList.contains(entity))
|
|
||||||
{
|
|
||||||
bleedList.add(entity);
|
bleedList.add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.spout;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
import org.getspout.spoutapi.sound.SoundEffect;
|
import org.getspout.spoutapi.sound.SoundEffect;
|
||||||
|
Loading…
Reference in New Issue
Block a user