Skip to content

Commit 51e4605

Browse files
committed
化粧品諸々
1 parent abc61f7 commit 51e4605

File tree

12 files changed

+127
-13
lines changed

12 files changed

+127
-13
lines changed

src/main/java/com/github/elic0de/thejpspit/cosmetics/AbstractCosmetic.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.github.elic0de.thejpspit.cosmetics;
22

3+
import org.bukkit.Material;
4+
35
public interface AbstractCosmetic {
46

57
// todo: slot charの追加, material
@@ -9,5 +11,9 @@ public interface AbstractCosmetic {
911

1012
String getDescription();
1113

14+
Character getSlot();
15+
16+
Material getMaterial();
17+
1218
double getCoin();
1319
}

src/main/java/com/github/elic0de/thejpspit/cosmetics/Cosmetic.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import com.github.elic0de.thejpspit.player.PitPlayer;
44
import java.util.concurrent.atomic.AtomicBoolean;
5+
import org.bukkit.Material;
56

67
public class Cosmetic implements AbstractCosmetic {
78

8-
99
private String cosmeticId;
1010
private String cosmeticName;
11-
1211
private String cosmeticDescription;
13-
12+
private Character slot;
13+
private Material material;
1414
private double coin;
1515

1616
public Cosmetic() {
@@ -21,6 +21,8 @@ public Cosmetic() {
2121
this.cosmeticId = cosmeticData.id();
2222
this.cosmeticName = cosmeticData.name();
2323
this.cosmeticDescription = cosmeticData.description();
24+
this.slot = cosmeticData.slot();
25+
this.material = cosmeticData.icon();
2426
this.coin = cosmeticData.coin();
2527
}
2628
}
@@ -44,6 +46,14 @@ public String getDescription() {
4446
return cosmeticDescription;
4547
}
4648

49+
public Character getSlot() {
50+
return slot;
51+
}
52+
53+
public Material getMaterial() {
54+
return material;
55+
}
56+
4757
public double getCoin() {
4858
return coin;
4959
}

src/main/java/com/github/elic0de/thejpspit/cosmetics/CosmeticData.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
import java.lang.annotation.Retention;
55
import java.lang.annotation.RetentionPolicy;
66
import java.lang.annotation.Target;
7+
import org.bukkit.Material;
78

89
@Retention(RetentionPolicy.RUNTIME)
910
@Target(ElementType.TYPE)
1011
public @interface CosmeticData {
1112
String id() default "";
12-
1313
String name() default "UNKNOWN";
1414

1515
String description() default "No description provided";
1616

17+
char slot() default 'z';
18+
19+
Material icon() default Material.BARRIER;
20+
1721
double coin() default 0;
1822
}
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.github.elic0de.thejpspit.cosmetics;
22

3+
import com.github.elic0de.thejpspit.cosmetics.impl.death.CatCosmetic;
34
import com.github.elic0de.thejpspit.cosmetics.impl.kill.FireCosmetic;
5+
import com.github.elic0de.thejpspit.cosmetics.type.DeathCosmetic;
46
import com.github.elic0de.thejpspit.cosmetics.type.KillCosmetic;
57
import com.github.elic0de.thejpspit.player.PitPlayer;
68
import com.google.common.collect.ClassToInstanceMap;
@@ -9,20 +11,46 @@
911
public class CosmeticManager {
1012

1113
ClassToInstanceMap<KillCosmetic> killCosmetics;
14+
ClassToInstanceMap<DeathCosmetic> deathCosmetics;
15+
16+
public ClassToInstanceMap<AbstractCosmetic> allCosmetics;
1217

1318
public CosmeticManager() {
1419
killCosmetics = new ImmutableClassToInstanceMap.Builder<KillCosmetic>()
1520
.put(FireCosmetic.class, new FireCosmetic())
1621
.build();
22+
23+
deathCosmetics = new ImmutableClassToInstanceMap.Builder<DeathCosmetic>()
24+
.put(CatCosmetic.class, new CatCosmetic())
25+
.build();
26+
27+
allCosmetics = new ImmutableClassToInstanceMap.Builder<AbstractCosmetic>()
28+
.putAll(killCosmetics)
29+
.putAll(deathCosmetics)
30+
.build();
1731
}
1832

19-
public void onProcess(PitPlayer player) {
33+
public void onKill(PitPlayer player) {
2034
for (KillCosmetic cosmetic : killCosmetics.values()) {
2135
cosmetic.onKill(player);
2236
}
2337
}
2438

39+
public void onDeath(PitPlayer player) {
40+
for (DeathCosmetic cosmetic : deathCosmetics.values()) {
41+
cosmetic.onDeath(player);
42+
}
43+
}
44+
2545
public ClassToInstanceMap<KillCosmetic> getKillCosmetics() {
2646
return killCosmetics;
2747
}
48+
49+
public ClassToInstanceMap<DeathCosmetic> getDeathCosmetics() {
50+
return deathCosmetics;
51+
}
52+
53+
public ClassToInstanceMap<AbstractCosmetic> getAllCosmetics() {
54+
return allCosmetics;
55+
}
2856
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.github.elic0de.thejpspit.cosmetics.impl.death;
2+
3+
import com.github.elic0de.thejpspit.cosmetics.Cosmetic;
4+
import com.github.elic0de.thejpspit.cosmetics.CosmeticData;
5+
import com.github.elic0de.thejpspit.cosmetics.type.DeathCosmetic;
6+
import com.github.elic0de.thejpspit.player.PitPlayer;
7+
import org.bukkit.Material;
8+
import org.bukkit.Sound;
9+
10+
@CosmeticData(id = "cat", name = "ねこねこ", description = "あいうえお", slot = 'x', icon = Material.CAT_SPAWN_EGG, coin = 50)
11+
public class CatCosmetic extends Cosmetic implements DeathCosmetic {
12+
13+
@Override
14+
public void onDeath(PitPlayer player) {
15+
if (canExecute(player)) {
16+
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_CAT_DEATH, 1F,1F);
17+
}
18+
}
19+
}
20+

src/main/java/com/github/elic0de/thejpspit/cosmetics/impl/kill/FireCosmetic.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
import com.github.elic0de.thejpspit.cosmetics.CosmeticData;
55
import com.github.elic0de.thejpspit.cosmetics.type.KillCosmetic;
66
import com.github.elic0de.thejpspit.player.PitPlayer;
7+
import org.bukkit.Material;
78
import xyz.xenondevs.particle.ParticleBuilder;
89
import xyz.xenondevs.particle.ParticleEffect;
910

10-
@CosmeticData(id = "Fire", name = "ファイやー", description = "足元が焦げて..", coin = 50)
11+
@CosmeticData(id = "Fire", name = "ファイやー", description = "足元が焦げて..", slot = 'F', icon = Material.BLACK_BANNER, coin = 50)
1112
public class FireCosmetic extends Cosmetic implements KillCosmetic {
1213

1314
@Override
1415
public void onKill(PitPlayer player) {
1516
if (canExecute(player)) {
1617
new ParticleBuilder(ParticleEffect.FLAME, player.getPlayer().getLocation())
18+
.setAmount(5)
1719
.setOffsetY(1f)
1820
.setSpeed(0.1f)
1921
.display();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.github.elic0de.thejpspit.cosmetics.type;
2+
3+
import com.github.elic0de.thejpspit.cosmetics.AbstractCosmetic;
4+
import com.github.elic0de.thejpspit.player.PitPlayer;
5+
6+
public interface AuraCosmetic extends AbstractCosmetic {
7+
8+
default void onAura(PitPlayer player) {
9+
}
10+
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.github.elic0de.thejpspit.cosmetics.type;
2+
3+
import com.github.elic0de.thejpspit.cosmetics.AbstractCosmetic;
4+
import com.github.elic0de.thejpspit.player.PitPlayer;
5+
6+
public interface DeathCosmetic extends AbstractCosmetic {
7+
8+
default void onDeath(PitPlayer player) {
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.github.elic0de.thejpspit.cosmetics.type;
2+
3+
import com.github.elic0de.thejpspit.cosmetics.AbstractCosmetic;
4+
import com.github.elic0de.thejpspit.player.PitPlayer;
5+
6+
public interface StreakCosmetic extends AbstractCosmetic {
7+
8+
default void onStreak(PitPlayer player) {
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.github.elic0de.thejpspit.cosmetics.type;
2+
3+
import com.github.elic0de.thejpspit.cosmetics.AbstractCosmetic;
4+
import com.github.elic0de.thejpspit.player.PitPlayer;
5+
6+
public interface TrailCosmetic extends AbstractCosmetic {
7+
8+
default void onTrail(PitPlayer player) {
9+
}
10+
}

0 commit comments

Comments
 (0)