mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 11:59:11 +00:00
bug fixs
This commit is contained in:
@@ -55,6 +55,7 @@ import net.momirealms.customfishing.version.VersionManagerImpl;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -120,29 +121,29 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
((AdventureManagerImpl) this.adventure).close();
|
||||
((BagManagerImpl) this.bagManager).disable();
|
||||
((BlockManagerImpl) this.blockManager).disable();
|
||||
((EffectManagerImpl) this.effectManager).disable();
|
||||
((FishingManagerImpl) this.fishingManager).disable();
|
||||
((GameManagerImpl) this.gameManager).disable();
|
||||
((ItemManagerImpl) this.itemManager).disable();
|
||||
((LootManagerImpl) this.lootManager).disable();
|
||||
((MarketManagerImpl) this.marketManager).disable();
|
||||
((EntityManagerImpl) this.entityManager).disable();
|
||||
((RequirementManagerImpl) this.requirementManager).disable();
|
||||
((SchedulerImpl) this.scheduler).shutdown();
|
||||
((IntegrationManagerImpl) this.integrationManager).disable();
|
||||
((CompetitionManagerImpl) this.competitionManager).disable();
|
||||
((StorageManagerImpl) this.storageManager).disable();
|
||||
((PlaceholderManagerImpl) this.placeholderManager).disable();
|
||||
((StatisticsManagerImpl) this.statisticsManager).disable();
|
||||
((ActionManagerImpl) this.actionManager).disable();
|
||||
((TotemManagerImpl) this.totemManager).disable();
|
||||
((HookManagerImpl) this.hookManager).disable();
|
||||
this.coolDownManager.disable();
|
||||
this.chatCatcherManager.disable();
|
||||
this.commandManager.unload();
|
||||
if (this.adventure != null) ((AdventureManagerImpl) this.adventure).close();
|
||||
if (this.bagManager != null) ((BagManagerImpl) this.bagManager).disable();
|
||||
if (this.blockManager != null) ((BlockManagerImpl) this.blockManager).disable();
|
||||
if (this.effectManager != null) ((EffectManagerImpl) this.effectManager).disable();
|
||||
if (this.fishingManager != null) ((FishingManagerImpl) this.fishingManager).disable();
|
||||
if (this.gameManager != null) ((GameManagerImpl) this.gameManager).disable();
|
||||
if (this.itemManager != null) ((ItemManagerImpl) this.itemManager).disable();
|
||||
if (this.lootManager != null) ((LootManagerImpl) this.lootManager).disable();
|
||||
if (this.marketManager != null) ((MarketManagerImpl) this.marketManager).disable();
|
||||
if (this.entityManager != null) ((EntityManagerImpl) this.entityManager).disable();
|
||||
if (this.requirementManager != null) ((RequirementManagerImpl) this.requirementManager).disable();
|
||||
if (this.scheduler != null) ((SchedulerImpl) this.scheduler).shutdown();
|
||||
if (this.integrationManager != null) ((IntegrationManagerImpl) this.integrationManager).disable();
|
||||
if (this.competitionManager != null) ((CompetitionManagerImpl) this.competitionManager).disable();
|
||||
if (this.storageManager != null) ((StorageManagerImpl) this.storageManager).disable();
|
||||
if (this.placeholderManager != null) ((PlaceholderManagerImpl) this.placeholderManager).disable();
|
||||
if (this.statisticsManager != null) ((StatisticsManagerImpl) this.statisticsManager).disable();
|
||||
if (this.actionManager != null) ((ActionManagerImpl) this.actionManager).disable();
|
||||
if (this.totemManager != null) ((TotemManagerImpl) this.totemManager).disable();
|
||||
if (this.hookManager != null) ((HookManagerImpl) this.hookManager).disable();
|
||||
if (this.coolDownManager != null) this.coolDownManager.disable();
|
||||
if (this.chatCatcherManager != null) this.chatCatcherManager.disable();
|
||||
if (this.commandManager != null) this.commandManager.unload();
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class Competition implements FishingCompetition {
|
||||
|
||||
Action[] actions = config.getStartActions();
|
||||
if (actions != null) {
|
||||
Condition condition = new Condition(null, null, new HashMap<>());
|
||||
Condition condition = new Condition(null, null, this.publicPlaceholders);
|
||||
for (Action action : actions) {
|
||||
action.trigger(condition);
|
||||
}
|
||||
@@ -186,14 +186,14 @@ public class Competition implements FishingCompetition {
|
||||
Player player = Bukkit.getPlayer(competitionPlayer.left());
|
||||
if (player != null)
|
||||
for (Action action : rewardsMap.get(String.valueOf(i)))
|
||||
action.trigger(new Condition(player));
|
||||
action.trigger(new Condition(player, this.publicPlaceholders));
|
||||
} else {
|
||||
Action[] actions = rewardsMap.get("participation");
|
||||
if (actions != null) {
|
||||
Player player = Bukkit.getPlayer(competitionPlayer.left()); {
|
||||
if (player != null)
|
||||
for (Action action : actions)
|
||||
action.trigger(new Condition(player));
|
||||
action.trigger(new Condition(player, this.publicPlaceholders));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -199,6 +201,7 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
this.registerCompetitionRequirement();
|
||||
this.registerListRequirement();
|
||||
this.registerEnvironmentRequirement();
|
||||
this.registerPotionEffectRequirement();
|
||||
}
|
||||
|
||||
public HashMap<String, Double> getLootWithWeight(Condition condition) {
|
||||
@@ -1139,11 +1142,59 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
};
|
||||
} else {
|
||||
LogUtils.warn("Wrong value format found at plugin-level requirement.");
|
||||
return null;
|
||||
return EmptyRequirement.instance;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void registerPotionEffectRequirement() {
|
||||
registerRequirement("potion-effect", (args, actions, advanced) -> {
|
||||
String potions = (String) args;
|
||||
String[] split = potions.split("(<=|>=|<|>|==)", 2);
|
||||
PotionEffectType type = PotionEffectType.getByName(split[0]);
|
||||
if (type == null) {
|
||||
LogUtils.warn("Potion effect doesn't exist: " + split[0]);
|
||||
return EmptyRequirement.instance;
|
||||
}
|
||||
int required = Integer.parseInt(split[1]);
|
||||
String operator = potions.substring(split[0].length(), potions.length() - split[1].length());
|
||||
return condition -> {
|
||||
int level = -1;
|
||||
PotionEffect potionEffect = condition.getPlayer().getPotionEffect(type);
|
||||
if (potionEffect != null) {
|
||||
level = potionEffect.getAmplifier();
|
||||
}
|
||||
boolean result = false;
|
||||
switch (operator) {
|
||||
case ">=" -> {
|
||||
if (level >= required) result = true;
|
||||
}
|
||||
case ">" -> {
|
||||
if (level > required) result = true;
|
||||
}
|
||||
case "==" -> {
|
||||
if (level == required) result = true;
|
||||
}
|
||||
case "!=" -> {
|
||||
if (level != required) result = true;
|
||||
}
|
||||
case "<=" -> {
|
||||
if (level <= required) result = true;
|
||||
}
|
||||
case "<" -> {
|
||||
if (level < required) result = true;
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
return true;
|
||||
}
|
||||
if (advanced) triggerActions(actions, condition);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a list of actions with the given condition.
|
||||
* If the list of actions is not null, each action in the list is triggered.
|
||||
|
||||
Reference in New Issue
Block a user