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:
Xiao-MoMi
2022-08-30 04:02:01 +08:00
parent 5592b2a97c
commit 929a8143e7
2 changed files with 50 additions and 22 deletions

View File

@@ -319,7 +319,6 @@ public class FishListener implements Listener {
if (!ConfigReader.Config.vanillaLoot) if (!ConfigReader.Config.vanillaLoot)
AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.noRod); AdventureUtil.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.noRod);
nextLoot.put(player, null); nextLoot.put(player, null);
return;
} }
FishHook hook = event.getHook(); FishHook hook = event.getHook();
@@ -329,17 +328,17 @@ public class FishListener implements Listener {
List<Loot> possibleLoots = getPossibleLootList(new FishingCondition(hook.getLocation(), player)); List<Loot> possibleLoots = getPossibleLootList(new FishingCondition(hook.getLocation(), player));
List<Loot> availableLoots = new ArrayList<>(); List<Loot> availableLoots = new ArrayList<>();
if (possibleLoots.size() == 0){
nextLoot.put(player, null);
return;
}
Modifier modifier = new Modifier(); Modifier modifier = new Modifier();
modifier.setDifficulty(difficultyModifier); modifier.setDifficulty(difficultyModifier);
modifier.setScore(scoreModifier); modifier.setScore(scoreModifier);
modifier.setWillDouble(doubleLoot > Math.random()); modifier.setWillDouble(doubleLoot > Math.random());
modifiers.put(player, modifier); modifiers.put(player, modifier);
if (possibleLoots.size() == 0){
nextLoot.put(player, null);
return;
}
double[] weights = new double[possibleLoots.size()]; double[] weights = new double[possibleLoots.size()];
int index = 0; int index = 0;
for (Loot loot : possibleLoots){ for (Loot loot : possibleLoots){
@@ -402,7 +401,11 @@ public class FishListener implements Listener {
//不是原版战利品 //不是原版战利品
if (ConfigReader.Config.vanillaRatio < Math.random()) { if (ConfigReader.Config.vanillaRatio < Math.random()) {
event.setCancelled(true); event.setCancelled(true);
vanilla.remove(player); if (nextLoot.get(player) != null){
vanilla.remove(player);
}else {
vanilla.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
}
showPlayerBar(player); showPlayerBar(player);
} }
//是原版战利品 //是原版战利品
@@ -468,10 +471,12 @@ public class FishListener implements Listener {
else { else {
dropMyLoot(player, loot, location, droppedItem); dropMyLoot(player, loot, location, droppedItem);
} }
}else if (loot == null && vanillaLoot != null){
dropVanillaLoot(player, vanillaLoot, location);
} }
} }
else { else {
fail(player, loot); fail(player, loot, vanillaLoot != null);
} }
} }
} }
@@ -540,7 +545,7 @@ public class FishListener implements Listener {
} }
//捕鱼失败 //捕鱼失败
else { else {
fail(player, loot); fail(player, loot, false);
} }
} }
else { else {
@@ -597,10 +602,12 @@ public class FishListener implements Listener {
else { else {
dropMyLoot(player, loot, location, droppedItem); dropMyLoot(player, loot, location, droppedItem);
} }
}else if (loot == null && vanillaLoot != null){
dropVanillaLoot(player, vanillaLoot, location);
} }
} }
else if (vanillaLoot == null) { else{
fail(player, loot); fail(player, loot, vanillaLoot != null);
} }
} }
else { else {
@@ -878,11 +885,20 @@ public class FishListener implements Listener {
} }
} }
private void fail(Player player, Loot loot) { private void fail(Player player, Loot loot, boolean isVanilla) {
fishingPlayers.remove(player); fishingPlayers.remove(player);
for (ActionB action : loot.getFailureActions()) if (!isVanilla && loot != null){
action.doOn(player); for (ActionB action : loot.getFailureActions())
AdventureUtil.playerTitle(player, ConfigReader.Title.failure_title.get((int) (ConfigReader.Title.failure_title.size()*Math.random())), ConfigReader.Title.failure_subtitle.get((int) (ConfigReader.Title.failure_subtitle.size()*Math.random())), ConfigReader.Title.failure_in, ConfigReader.Title.failure_stay, ConfigReader.Title.failure_out); action.doOn(player);
}
AdventureUtil.playerTitle(
player,
ConfigReader.Title.failure_title.get((int) (ConfigReader.Title.failure_title.size()*Math.random())),
ConfigReader.Title.failure_subtitle.get((int) (ConfigReader.Title.failure_subtitle.size()*Math.random())),
ConfigReader.Title.failure_in,
ConfigReader.Title.failure_stay,
ConfigReader.Title.failure_out
);
} }
@EventHandler @EventHandler
@@ -977,10 +993,11 @@ public class FishListener implements Listener {
} }
private void showPlayerBar(Player player){ private void showPlayerBar(Player player){
Loot loot = nextLoot.get(player); Loot loot = nextLoot.get(player);
String layout; String layout;
if (loot.getLayout() != null){ if (loot != null && loot.getLayout() != null){
try { try {
layout = loot.getLayout().get((int) (loot.getLayout().size() * Math.random())); layout = loot.getLayout().get((int) (loot.getLayout().size() * Math.random()));
} }
@@ -994,25 +1011,34 @@ public class FishListener implements Listener {
layout = (String) values[new Random().nextInt(values.length)]; layout = (String) values[new Random().nextInt(values.length)];
} }
int difficulty = loot.getDifficulty().getSpeed(); int difficulty = new Random().nextInt(5);
difficulty += Objects.requireNonNullElse(modifiers.get(player).getDifficulty(), 0);; int timer = 1;
int time = 10000;
if (loot != null){
difficulty = loot.getDifficulty().getSpeed();
timer = loot.getDifficulty().getTimer();
time = loot.getTime();
}
difficulty += Objects.requireNonNullElse(modifiers.get(player).getDifficulty(), 0);
if (difficulty < 1){ if (difficulty < 1){
difficulty = 1; difficulty = 1;
} }
Difficulty difficult = new Difficulty(loot.getDifficulty().getTimer(), difficulty); Difficulty difficult = new Difficulty(timer, difficulty);
fishingPlayers.put(player, fishingPlayers.put(player,
new FishingPlayer(System.currentTimeMillis() + loot.getTime(), new FishingPlayer(System.currentTimeMillis() + time,
new Timer(player, difficult, layout) new Timer(player, difficult, layout)
) )
); );
if (vanilla.get(player) == null){ if (vanilla.get(player) == null && loot != null){
for (ActionB action : loot.getHookActions()){ for (ActionB action : loot.getHookActions()){
action.doOn(player); action.doOn(player);
} }
} }
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, loot.getTime()/50,3)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, time/50,3));
} }
} }

View File

@@ -13,6 +13,8 @@ config:
# Papi hook # Papi hook
PlaceholderAPI: true PlaceholderAPI: true
# Skill xp hook # Skill xp hook
# If skill xp is added not as expected
# Check the xp-source file in those skill plugins and set them to 0
mcMMO: false mcMMO: false
MMOCore: false MMOCore: false
AureliumSkills: false AureliumSkills: false