9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2024-01-12 19:39:16 +08:00
parent 75aaa02cb5
commit b3cef677ef
7 changed files with 56 additions and 14 deletions

View File

@@ -34,6 +34,7 @@ public class CFLoot implements Loot {
private String nick;
private boolean showInFinder;
private boolean disableGame;
private boolean disableGlobalAction;
private boolean disableStats;
private boolean instanceGame;
private double score;
@@ -129,6 +130,17 @@ public class CFLoot implements Loot {
return this;
}
/**
* Set whether global actions are disabled for this loot.
*
* @param disable True if statistics are disabled, false otherwise.
* @return The builder.
*/
public Builder disableGlobalActions(boolean disable) {
this.loot.disableGlobalAction = disable;
return this;
}
/**
* Set the score for this loot.
*
@@ -303,6 +315,14 @@ public class CFLoot implements Loot {
return this.disableStats;
}
/**
* Check if the loot disables global actions
*/
@Override
public boolean disableGlobalAction() {
return this.disableGlobalAction;
}
/**
* Get the loot group of this loot.
*

View File

@@ -34,6 +34,11 @@ public interface Loot {
*/
boolean instanceGame();
/**
* Check if the loot disables global actions
*/
boolean disableGlobalAction();
/**
* Get the unique ID of this loot.
*

View File

@@ -7,7 +7,7 @@ plugins {
allprojects {
version = "2.0.10.5"
version = "2.0.11"
apply<JavaPlugin>()
apply(plugin = "java")

View File

@@ -60,10 +60,10 @@ dependencies {
implementation(project(":api"))
// adventure
implementation("net.kyori:adventure-api:4.14.0")
implementation("net.kyori:adventure-api:4.15.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.1")
implementation("net.kyori:adventure-text-minimessage:4.14.0")
implementation("net.kyori:adventure-text-serializer-legacy:4.14.0")
implementation("net.kyori:adventure-text-minimessage:4.15.0")
implementation("net.kyori:adventure-text-serializer-legacy:4.15.0")
// nbt
implementation("de.tr7zw:item-nbt-api:2.12.2")

View File

@@ -459,10 +459,14 @@ public class FishingManagerImpl implements Listener, FishingManager {
var fishingPreparation = temp.getPreparation();
fishingPreparation.setLocation(event.getHook().getLocation());
if (!loot.disableGlobalAction())
GlobalSettings.triggerLootActions(ActionTrigger.BITE, fishingPreparation);
loot.triggerActions(ActionTrigger.BITE, fishingPreparation);
fishingPreparation.triggerActions(ActionTrigger.BITE);
if (loot.instanceGame() && !loot.disableGame()) {
if (!loot.disableGlobalAction())
GlobalSettings.triggerLootActions(ActionTrigger.HOOK, fishingPreparation);
loot.triggerActions(ActionTrigger.HOOK, fishingPreparation);
fishingPreparation.triggerActions(ActionTrigger.HOOK);
startFishingGame(player, fishingPreparation, temp.getEffect());
@@ -500,11 +504,14 @@ public class FishingManagerImpl implements Listener, FishingManager {
var temp = getTempFishingState(uuid);
if (temp != null ) {
Loot loot = temp.getLoot();
loot.triggerActions(ActionTrigger.HOOK, temp.getPreparation());
temp.getPreparation().triggerActions(ActionTrigger.HOOK);
var fishingPreparation = temp.getPreparation();
if (!loot.disableGlobalAction())
GlobalSettings.triggerLootActions(ActionTrigger.HOOK, fishingPreparation);
loot.triggerActions(ActionTrigger.HOOK, fishingPreparation);
fishingPreparation.triggerActions(ActionTrigger.HOOK);
if (!loot.disableGame()) {
event.setCancelled(true);
startFishingGame(player, temp.getPreparation(), temp.getEffect());
startFishingGame(player, fishingPreparation, temp.getEffect());
} else {
success(temp, event.getHook());
}
@@ -586,7 +593,8 @@ public class FishingManagerImpl implements Listener, FishingManager {
return;
}
GlobalSettings.triggerLootActions(ActionTrigger.FAILURE, fishingPreparation);
if (!loot.disableGlobalAction())
GlobalSettings.triggerLootActions(ActionTrigger.FAILURE, fishingPreparation);
loot.triggerActions(ActionTrigger.FAILURE, fishingPreparation);
fishingPreparation.triggerActions(ActionTrigger.FAILURE);
@@ -662,11 +670,16 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
}
}
case ENTITY -> plugin.getEntityManager().summonEntity(hook.getLocation(), player.getLocation(), loot);
case BLOCK -> plugin.getBlockManager().summonBlock(player, hook.getLocation(), player.getLocation(), loot);
case ENTITY -> {
plugin.getEntityManager().summonEntity(hook.getLocation(), player.getLocation(), loot);
doSuccessActions(loot, effect, fishingPreparation, player);
}
case BLOCK -> {
plugin.getBlockManager().summonBlock(player, hook.getLocation(), player.getLocation(), loot);
doSuccessActions(loot, effect, fishingPreparation, player);
}
}
doSuccessActions(loot, effect, fishingPreparation, player);
if (player.getGameMode() != GameMode.CREATIVE) {
ItemStack rod = state.getPreparation().getRodItemStack();
ItemUtils.decreaseHookDurability(rod, 1, false);
@@ -720,7 +733,8 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
// events and actions
GlobalSettings.triggerLootActions(ActionTrigger.SUCCESS, fishingPreparation);
if (!loot.disableGlobalAction())
GlobalSettings.triggerLootActions(ActionTrigger.SUCCESS, fishingPreparation);
loot.triggerActions(ActionTrigger.SUCCESS, fishingPreparation);
fishingPreparation.triggerActions(ActionTrigger.SUCCESS);
@@ -738,7 +752,8 @@ public class FishingManagerImpl implements Listener, FishingManager {
String size = fishingPreparation.getArg("{SIZE}");
if (size != null)
if (it.setSizeIfHigher(loot.getStatisticKey().getSizeKey(), Float.parseFloat(size))) {
GlobalSettings.triggerLootActions(ActionTrigger.NEW_SIZE_RECORD, fishingPreparation);
if (!loot.disableGlobalAction())
GlobalSettings.triggerLootActions(ActionTrigger.NEW_SIZE_RECORD, fishingPreparation);
loot.triggerActions(ActionTrigger.NEW_SIZE_RECORD, fishingPreparation);
}
});

View File

@@ -905,7 +905,8 @@ public class ItemManagerImpl implements ItemManager, Listener {
Loot loot = plugin.getLootManager().getLoot(id);
if (loot != null) {
Condition condition = new Condition(event.getPlayer());
GlobalSettings.triggerLootActions(ActionTrigger.CONSUME, condition);
if (!loot.disableGlobalAction())
GlobalSettings.triggerLootActions(ActionTrigger.CONSUME, condition);
loot.triggerActions(ActionTrigger.CONSUME, condition);
}
}

View File

@@ -269,6 +269,7 @@ public class LootManagerImpl implements LootManager {
.disableGames(section.getBoolean("disable-game", CFConfig.globalDisableGame))
.instantGame(section.getBoolean("instant-game", CFConfig.globalInstantGame))
.showInFinder(section.getBoolean("show-in-fishfinder", CFConfig.globalShowInFinder))
.disableGlobalActions(section.getBoolean("disable-global-event", false))
.score(section.getDouble("score"))
.lootGroup(ConfigUtils.stringListArgs(section.get("group")).toArray(new String[0]))
.nick(section.getString("nick", section.getString("display.name", key)))