9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-04 15:41:35 +00:00

left click

This commit is contained in:
XiaoMoMi
2023-11-08 02:15:02 +08:00
parent b82c74ca08
commit 92aae9f901
10 changed files with 108 additions and 40 deletions

View File

@@ -67,6 +67,11 @@ public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
return true;
}
@Override
public boolean onLeftClick() {
return false;
}
@Override
public boolean onChat(String message) {
return false;
@@ -94,8 +99,15 @@ public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
@Override
public void run() {
timeOutCheck();
if (timeOutCheck()) {
return;
}
switchItemCheck();
onTick();
}
public void onTick() {
}
protected void endGame() {
@@ -106,18 +118,21 @@ public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
this.success = success;
}
protected void timeOutCheck() {
protected boolean timeOutCheck() {
if (System.currentTimeMillis() > deadline) {
isTimeOut = true;
cancel();
endGame();
return true;
}
return false;
}
protected void switchItemCheck() {
PlayerInventory playerInventory = player.getInventory();
if (playerInventory.getItemInMainHand().getType() != Material.FISHING_ROD
&& playerInventory.getItemInOffHand().getType() != Material.FISHING_ROD) {
&& playerInventory.getItemInOffHand().getType() != Material.FISHING_ROD
) {
cancel();
endGame();
}

View File

@@ -40,6 +40,8 @@ public interface GamingPlayer {
*/
boolean onSwapHand();
boolean onLeftClick();
/**
* @return whether to cancel the event
*/