TimerHolder cancel task NPE check.

This commit is contained in:
MobiusDevelopment
2019-05-28 22:52:44 +00:00
parent e5b9a0b64d
commit b07ed23778
12 changed files with 36 additions and 96 deletions

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }

View File

@@ -103,7 +103,7 @@ public class TimerHolder<T> implements Runnable
} }
/** /**
* @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otherwise
*/ */
public boolean cancelTimer() public boolean cancelTimer()
{ {
@@ -117,7 +117,7 @@ public class TimerHolder<T> implements Runnable
TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this); TimersManager.getInstance().unregisterTimer(_player.getObjectId(), this);
} }
if (_task.isCancelled() || _task.isDone()) if ((_task == null) || _task.isCancelled() || _task.isDone())
{ {
return false; return false;
} }
@@ -132,12 +132,7 @@ public class TimerHolder<T> implements Runnable
*/ */
public long getRemainingTime() public long getRemainingTime()
{ {
if (_task == null) if ((_task == null) || _task.isCancelled() || _task.isDone())
{
return -1;
}
if (_task.isCancelled() || _task.isDone())
{ {
return -1; return -1;
} }