Skip to content

Commit 4335122

Browse files
committed
コマンドから弓のダメージを変更できるように
1 parent 9e93865 commit 4335122

File tree

6 files changed

+35
-12
lines changed

6 files changed

+35
-12
lines changed

src/main/java/com/github/elic0de/thejpspit/spigot/TheJpsPit.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.github.elic0de.thejpspit.spigot.hook.Hook;
1515
import com.github.elic0de.thejpspit.spigot.hook.VaultEconomyHook;
1616
import com.github.elic0de.thejpspit.spigot.item.ItemManager;
17+
import com.github.elic0de.thejpspit.spigot.leveler.Levels;
1718
import com.github.elic0de.thejpspit.spigot.listener.BlockPlaceListener;
1819
import com.github.elic0de.thejpspit.spigot.listener.CombatTagger;
1920
import com.github.elic0de.thejpspit.spigot.listener.EventListener;
@@ -81,6 +82,7 @@ private void loadConfig() throws RuntimeException {
8182

8283
public void reload() {
8384
loadConfig();
85+
Levels.initialize();
8486
}
8587

8688
@Override

src/main/java/com/github/elic0de/thejpspit/spigot/command/PitCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ public void onKillCoin(Player player, int amount) {
6363
player.sendMessage("変更しました");
6464
}
6565

66+
@Subcommand("set arrowDamage")
67+
@CommandPermission("tjp.arrow")
68+
public void onArrowDamage(Player player, double amount) {
69+
pit.getPitPreferences().ifPresent(pitPreferences -> pitPreferences.setDamageAmount(amount));
70+
pit.getPitPreferences().ifPresent(preferences -> pit.getDatabase().updatePitPreferences(preferences));
71+
player.sendMessage("変更しました");
72+
}
73+
6674
@Subcommand("shop")
6775
@CommandPermission("tjp.shop")
6876
public void onCreateShop(Player player) {

src/main/java/com/github/elic0de/thejpspit/spigot/config/PitPreferences.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public class PitPreferences {
2121
@SerializedName("amount_reward")
2222
private int amountReward;
2323

24+
@Expose
25+
@SerializedName("damage_amount")
26+
private double damageAmount;
27+
2428
public static PitPreferences getDefaults() {
2529
final Location location = Bukkit.getWorlds().stream().findAny().get().getSpawnLocation();
2630
return new PitPreferences(LocationData.at(location.getX(), location.getY(), location.getZ(), location.getWorld()));
@@ -30,6 +34,7 @@ private PitPreferences(LocationData spawn) {
3034
this.spawn = spawn;
3135
this.amountRegenHealth = 1;
3236
this.amountReward = 10;
37+
this.damageAmount = .5;
3338
}
3439

3540
public Optional<LocationData> getSpawn() {
@@ -55,4 +60,12 @@ public int getAmountReward() {
5560
public void setAmountReward(int amountReward) {
5661
this.amountReward = amountReward;
5762
}
63+
64+
public double getDamageAmount() {
65+
return damageAmount;
66+
}
67+
68+
public void setDamageAmount(double damageAmount) {
69+
this.damageAmount = damageAmount;
70+
}
5871
}

src/main/java/com/github/elic0de/thejpspit/spigot/config/Settings.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public class Settings {
3535
@YamlKey("level")
3636
private List<String> level = Arrays.asList(
3737
"1,15,15," + ChatColor.GRAY.name(),
38-
"10,30,300," + ChatColor.BLUE.name(),
39-
"20,50,1000," + ChatColor.DARK_AQUA.name(),
40-
"30,75,2250," + ChatColor.DARK_GREEN.name(),
41-
"40,125,5000," + ChatColor.GREEN.name(),
42-
"50,250,12500," + ChatColor.YELLOW.name(),
43-
"60,600,36000," + ChatColor.GOLD.name(),
44-
"70,800,56000," + ChatColor.RED.name(),
45-
"80,900,72000," + ChatColor.DARK_RED.name(),
46-
"90,1000,90000," + ChatColor.AQUA.name()
38+
"10,30,10," + ChatColor.BLUE.name(),
39+
"20,50,20," + ChatColor.DARK_AQUA.name(),
40+
"30,75,30," + ChatColor.DARK_GREEN.name(),
41+
"40,125,40," + ChatColor.GREEN.name(),
42+
"50,250,50," + ChatColor.YELLOW.name(),
43+
"60,600,60," + ChatColor.GOLD.name(),
44+
"70,800,36000," + ChatColor.RED.name(),
45+
"80,900,56000," + ChatColor.DARK_RED.name(),
46+
"90,1000,72000," + ChatColor.AQUA.name()
4747
);
4848

4949
public String getGithubToken() {

src/main/java/com/github/elic0de/thejpspit/spigot/leveler/Levels.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Levels {
1515
initialize();
1616
}
1717

18-
private static void initialize() {
18+
public static void initialize() {
1919
Arrays.stream(TheJpsPit.getInstance().getSettings().getLevel().toArray(new String[0]))
2020
.map(text -> text.split(","))
2121
.map(data -> new Level(Integer.parseInt(data[0]), Integer.parseInt(data[1]),Integer.parseInt(data[2]), ChatColor.valueOf(data[3])))
@@ -30,7 +30,7 @@ private static void initialize() {
3030
int totalXp = level.getNeededXP();
3131
for (int i = 1; i < 10; i++){
3232
final int nextLevel = l + i;
33-
if (LEVELS.containsKey(nextLevel)) continue;
33+
//if (LEVELS.containsKey(nextLevel)) continue;
3434
totalXp += neededXp;
3535
addedLevels.put(nextLevel, new Level(nextLevel, neededXp, neededXp * nextLevel, color));
3636
}

src/main/java/com/github/elic0de/thejpspit/spigot/listener/EventListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void onDamage(EntityDamageByEntityEvent event) {
160160
event.setCancelled(true);
161161
return;
162162
}
163-
case PROJECTILE -> event.setDamage(event.getDamage() - (event.getDamage() * .8));
163+
case PROJECTILE -> plugin.getPitPreferences().ifPresent(pitPreferences -> event.setDamage(pitPreferences.getDamageAmount()));
164164
}
165165

166166
pitPlayer.showHealth(victimPitPlayer);

0 commit comments

Comments
 (0)