-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
363 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
...plementations/energys/EXPLevelEnergy.java → ...plementations/energys/BukkitExpLevel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/me/xpyex/plugin/flywithfood/bukkit/implementations/energys/BukkitExpPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package me.xpyex.plugin.flywithfood.bukkit.implementations.energys; | ||
|
||
import me.xpyex.plugin.flywithfood.bukkit.FlyWithFood; | ||
import me.xpyex.plugin.flywithfood.common.implementations.FWFUser; | ||
import me.xpyex.plugin.flywithfood.common.implementations.flyenergy.EnergyManager; | ||
import me.xpyex.plugin.flywithfood.common.implementations.flyenergy.energys.ExpPointEnergy; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class BukkitExpPoint implements ExpPointEnergy { | ||
@Override | ||
public @NotNull String getName() { | ||
return "ExpPoint"; | ||
} | ||
|
||
@Override | ||
public void cost(@NotNull FWFUser user, @NotNull Number value) { | ||
Player target = (Player) user.getPlayer(); | ||
if (value.floatValue() < -1f || value.floatValue() > 1f) { | ||
throw new IllegalArgumentException("在" + getName() + "模式中,Cost项∈[-1.0, 1.0].小数位可精确到6位.当前为" + value.floatValue() + ", 您也可尝试" + new BukkitExpLevel().getName() + "模式"); | ||
} | ||
if (target.getExp() - value.floatValue() < 0f) { | ||
Bukkit.getScheduler().runTask(FlyWithFood.INSTANCE, () -> { | ||
target.setLevel(target.getLevel() - 1); | ||
target.setExp(1f + target.getExp() - value.floatValue()); | ||
}); | ||
} else if (target.getExp() - value.floatValue() > 1f) { | ||
Bukkit.getScheduler().runTask(FlyWithFood.INSTANCE, () -> { | ||
target.setLevel(target.getLevel() + 1); | ||
target.setExp(target.getExp() - value.floatValue() - 1f); | ||
}); | ||
} else { | ||
Bukkit.getScheduler().runTask(FlyWithFood.INSTANCE, () -> | ||
target.setExp(target.getExp() - value.floatValue()) | ||
); | ||
} | ||
} | ||
|
||
@Override | ||
public @NotNull Float getNow(FWFUser user) { | ||
Player target = (Player) user.getPlayer(); | ||
return target.getExp(); | ||
} | ||
|
||
@Override | ||
public void register() { | ||
EnergyManager.registerEnergy(getName(), this); | ||
} | ||
} |
13 changes: 9 additions & 4 deletions
13
...t/implementations/energys/FoodEnergy.java → ...t/implementations/energys/BukkitFood.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
package me.xpyex.plugin.flywithfood.bukkit.implementations.energys; | ||
|
||
import me.xpyex.plugin.flywithfood.bukkit.FlyWithFood; | ||
|
||
import me.xpyex.plugin.flywithfood.common.implementations.FWFUser; | ||
import me.xpyex.plugin.flywithfood.common.implementations.flyenergy.EnergyManager; | ||
import me.xpyex.plugin.flywithfood.common.implementations.flyenergy.energys.FoodEnergy; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class FoodEnergy implements FlyEnergy { | ||
public class BukkitFood implements FoodEnergy { | ||
@Override | ||
public @NotNull String getName() { | ||
return "Food"; | ||
} | ||
|
||
@Override | ||
public void cost(@NotNull Player target, @NotNull Number value) { | ||
public void cost(@NotNull FWFUser user, @NotNull Number value) { | ||
Player target = (Player) user.getPlayer(); | ||
Bukkit.getScheduler().runTask(FlyWithFood.INSTANCE, () -> | ||
target.setFoodLevel(Math.max(target.getFoodLevel() - value.intValue(), 0)) | ||
); | ||
} | ||
|
||
@Override | ||
public @NotNull Integer getNow(Player target) { | ||
public @NotNull Integer getNow(FWFUser user) { | ||
Player target = (Player) user.getPlayer(); | ||
return target.getFoodLevel(); | ||
} | ||
|
||
@Override | ||
public void register() { | ||
EnergyManager.registerEnergy(getName(), this); | ||
// | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/me/xpyex/plugin/flywithfood/bukkit/implementations/energys/BukkitMoney.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package me.xpyex.plugin.flywithfood.bukkit.implementations.energys; | ||
|
||
import me.xpyex.plugin.flywithfood.bukkit.FlyWithFood; | ||
import me.xpyex.plugin.flywithfood.common.implementations.FWFUser; | ||
import me.xpyex.plugin.flywithfood.common.implementations.flyenergy.EnergyManager; | ||
import me.xpyex.plugin.flywithfood.common.implementations.flyenergy.energys.MoneyEnergy; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class BukkitMoney implements MoneyEnergy { | ||
@Override | ||
public @NotNull String getName() { | ||
return "Money"; | ||
} | ||
|
||
@Override | ||
public void cost(@NotNull FWFUser user, @NotNull Number value) { | ||
Player target = (Player) user.getPlayer(); | ||
if (FlyWithFood.econ != null) { | ||
FlyWithFood.econ.depositPlayer(target, getNow(user) - value.doubleValue()); | ||
} | ||
} | ||
|
||
@Override | ||
public @NotNull Double getNow(FWFUser user) { | ||
Player target = (Player) user.getPlayer(); | ||
return FlyWithFood.econ.getBalance(target); | ||
} | ||
|
||
@Override | ||
public void register() { | ||
EnergyManager.registerEnergy(getName(), this); | ||
} | ||
} |
Oops, something went wrong.