9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-29 03:49:07 +00:00

2.0-backup-4

This commit is contained in:
XiaoMoMi
2023-09-03 23:22:51 +08:00
parent b73dd6cf51
commit 3f79d9c621
17 changed files with 390 additions and 183 deletions

View File

@@ -8,20 +8,6 @@ import org.bukkit.entity.Player;
import java.util.UUID;
public interface OnlineUser {
public interface OnlineUser extends OfflineUser {
Player getPlayer();
String getName();
UUID getUUID();
FishingBagHolder getHolder();
EarningData getEarningData();
Statistics getStatistics();
boolean isOnline();
PlayerData getPlayerData();
}

View File

@@ -1,8 +1,13 @@
package net.momirealms.customfishing.api.manager;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
public interface MarketManager {
void openMarketGUI(Player player);
int getDate();
double getItemPrice(ItemStack itemStack);

View File

@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
public class Condition {
@@ -14,7 +15,7 @@ public class Condition {
@Nullable
protected final Player player;
@NotNull
protected final HashMap<String, String> args;
protected final Map<String, String> args;
public Condition() {
this(null, null, new HashMap<>());
@@ -28,21 +29,21 @@ public class Condition {
this(player.getLocation(), player, new HashMap<>());
}
public Condition(Player player, HashMap<String, String> args) {
public Condition(Player player, Map<String, String> args) {
this(player.getLocation(), player, args);
}
public Condition(@Nullable Location location, @Nullable Player player, @NotNull HashMap<String, String> args) {
public Condition(@Nullable Location location, @Nullable Player player, @NotNull Map<String, String> args) {
this.location = location;
this.player = player;
this.args = args;
if (player != null)
this.args.put("player", player.getName());
this.args.put("{player}", player.getName());
if (location != null) {
this.args.put("x", String.valueOf(location.getX()));
this.args.put("y", String.valueOf(location.getY()));
this.args.put("z", String.valueOf(location.getZ()));
this.args.put("world", location.getWorld().getName());
this.args.put("{x}", String.valueOf(location.getX()));
this.args.put("{y}", String.valueOf(location.getY()));
this.args.put("{z}", String.valueOf(location.getZ()));
this.args.put("{world}", location.getWorld().getName());
}
}
@@ -57,7 +58,7 @@ public class Condition {
}
@NotNull
public HashMap<String, String> getArgs() {
public Map<String, String> getArgs() {
return args;
}

View File

@@ -5,6 +5,7 @@ import net.momirealms.customfishing.api.manager.FishingManager;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import org.bukkit.Material;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffectType;
@@ -13,23 +14,26 @@ import java.util.concurrent.TimeUnit;
public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
protected boolean succeeded;
private final FishingManager manager;
private final long deadline;
protected boolean success;
protected CancellableTask task;
protected Player player;
protected GameSettings settings;
protected FishingManager manager;
private final long deadline;
protected FishHook fishHook;
public AbstractGamingPlayer(Player player, GameSettings settings, FishingManager manager) {
public AbstractGamingPlayer(Player player, FishHook hook, GameSettings settings) {
this.player = player;
this.fishHook = hook;
this.settings = settings;
this.manager = manager;
this.manager = CustomFishingPlugin.get().getFishingManager();
this.deadline = System.currentTimeMillis() + settings.getTime() * 1000L;
this.arrangeTask();
}
public void arrangeTask() {
this.task = CustomFishingPlugin.get().getScheduler().runTaskAsyncTimer(this, 50, 50, TimeUnit.MILLISECONDS);
this.task = CustomFishingPlugin.get().getScheduler().runTaskSyncTimer(this, fishHook.getLocation(), 1, 1);
}
@Override
@@ -39,13 +43,13 @@ public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
}
@Override
public boolean isSucceeded() {
return succeeded;
public boolean isSuccessful() {
return success;
}
@Override
public boolean onRightClick() {
manager.processGameResult(this);
endGame();
return true;
}
@@ -85,10 +89,18 @@ public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
switchItemCheck();
}
protected void endGame() {
this.manager.processGameResult(this);
}
protected void setGameResult(boolean success) {
this.success = success;
}
protected void timeOutCheck() {
if (System.currentTimeMillis() > deadline) {
cancel();
manager.processGameResult(this);
endGame();
}
}
@@ -97,8 +109,7 @@ public abstract class AbstractGamingPlayer implements GamingPlayer, Runnable {
if (playerInventory.getItemInMainHand().getType() != Material.FISHING_ROD
&& playerInventory.getItemInOffHand().getType() != Material.FISHING_ROD) {
cancel();
manager.processGameResult(this);
player.removePotionEffect(PotionEffectType.SLOW);
endGame();
}
}
}

View File

@@ -1,9 +1,9 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.momirealms.customfishing.api.manager.FishingManager;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
public interface Game {
GamingPlayer start(Player player, GameSettings settings, FishingManager manager);
GamingPlayer start(Player player, FishHook hook, GameSettings settings);
}

View File

@@ -1,6 +1,5 @@
package net.momirealms.customfishing.api.mechanic.game;
import net.kyori.adventure.text.Component;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import org.bukkit.entity.Player;
@@ -8,7 +7,7 @@ public interface GamingPlayer {
void cancel();
boolean isSucceeded();
boolean isSuccessful();
boolean onRightClick();

View File

@@ -11,7 +11,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface ItemBuilder {
public interface ItemBuilder extends BuildableItem {
ItemBuilder customModelData(int value);