Oheers / EvenMoreFish

An advanced fishing plugin based on MoreFish, created 2 years after its last update.
MIT License
91 stars 56 forks source link

Improve Reward System #297

Closed FireML closed 3 months ago

FireML commented 3 months ago

All reward types work just like they used to as we can see in the console log below:

  1:
    - "COMMAND:give {player} diamond 5"
    - "MESSAGE:&aCongratulations for coming 1st!"
    # Can't contain decimals.
    - "MONEY:5000"
    - "EFFECT:SPEED,2,5"
    - "ITEM:DIAMOND,2"
    - "HEALTH:-5"
    - "HUNGER:-5"
    - "PERMISSION:test.123"
    - "PLAYER_POINTS:100"
[06:52:41 INFO]: [EvenMoreFish] [STDOUT] give FireML diamond 5
[06:52:41 INFO]: Giving 5 of Diamond () to FireML
[06:52:41 INFO]: [EvenMoreFish] [STDOUT] &aCongratulations for coming 1st!
[06:52:41 INFO]: 5000
[06:52:41 INFO]: PotionEffect{amplifier=2, duration=100, type=CraftPotionEffectType[minecraft:speed], ambient=true, particles=true, icon=true, hiddenEffect=null}
[06:52:41 INFO]: ItemStack{DIAMOND x 2}
[06:52:41 INFO]: -5
[06:52:41 INFO]: -5
[06:52:41 INFO]: [EvenMoreFish] [STDOUT] test.123
[06:52:41 INFO]: 100
FireML commented 3 months ago

Also, an example of how a third party plugin would register one:

public class WarpRewardType implements RewardType {

    @Override
    public void doReward(@NotNull Player player, @NotNull String key, @NotNull String value, Location hookLocation) {
        Warp warp = Data.getInstance().getWarp(value);
        if (warp != null) {
            warp.tryVisit(player, true);
        }
    }

    @Override
    public @NotNull String getIdentifier() {
        return "WARP";
    }

    @Override
    public @NotNull String getAuthor() {
        return "FireML";
    }

    @Override
    public @NotNull JavaPlugin getPlugin() {
        return Plugin.getInstance();
    }

}

new WarpRewardType().register();

FireML commented 3 months ago

Alright, I'll give that a go

FireML commented 3 months ago

I've moved RewardManager, RewardType, Reward, and EMFRewardEvent to the API module.

I've added the following:

Rewards still work correctly:

[10:44:29 INFO]: FireML issued server command: /emf admin competition start 5
[10:44:34 INFO]: Giving 5 of Diamond () to FireML