質問編集履歴
6
ソースコード変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,11 +12,9 @@
|
|
12
12
|
|
13
13
|
```
|
14
14
|
問題
|
15
|
-
式の開始が不正です
|
15
|
+
式の開始が不正です:62
|
16
|
-
|
16
|
+
";"がありません:62
|
17
|
-
|
17
|
+
式の開始が不正です:63
|
18
|
-
(がありません
|
19
|
-
型の開始が不正です
|
20
18
|
```
|
21
19
|
|
22
20
|
### 該当のソースコード
|
@@ -33,65 +31,65 @@
|
|
33
31
|
import org.bukkit.inventory.ItemStack;
|
34
32
|
import org.bukkit.inventory.meta.ItemMeta;
|
35
33
|
import org.bukkit.plugin.java.JavaPlugin;
|
36
|
-
import java.util.Arrays;
|
37
34
|
import java.util.List;
|
38
35
|
import java.util.Random;
|
39
36
|
|
37
|
+
import static java.util.List.*;
|
40
38
|
import static org.bukkit.enchantments.Enchantment.PROTECTION_ENVIRONMENTAL;
|
41
39
|
|
42
40
|
@SuppressWarnings("deprecation")
|
43
41
|
public class ChangeZombieMaterials extends JavaPlugin implements Listener {
|
44
42
|
|
45
|
-
private final Random random = new Random();
|
43
|
+
private final Random random = new Random();
|
46
44
|
|
47
|
-
private final List<Material> helmetMaterials =
|
48
|
-
private final List<Material> chestplateMaterials =
|
49
|
-
private final List<Material> leggingsMaterials =
|
50
|
-
private final List<Material> bootsMaterials =
|
51
|
-
private final List<Material> weaponMaterials =
|
45
|
+
private final List<Material> helmetMaterials = of(Material.DIAMOND_HELMET);
|
46
|
+
private final List<Material> chestplateMaterials = of(Material.DIAMOND_CHESTPLATE);
|
47
|
+
private final List<Material> leggingsMaterials = of(Material.DIAMOND_LEGGINGS);
|
48
|
+
private final List<Material> bootsMaterials = of(Material.DIAMOND_BOOTS);
|
49
|
+
private final List<Material> weaponMaterials = of(Material.DIAMOND_SWORD);
|
52
50
|
|
53
|
-
@EventHandler
|
51
|
+
@EventHandler
|
54
|
-
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
52
|
+
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
55
|
-
if (EntityType.ZOMBIE == event.getEntityType()) {
|
53
|
+
if (EntityType.ZOMBIE == event.getEntityType()) {
|
56
|
-
ItemStack helmet = new ItemStack(helmetMaterials.get(random.nextInt(helmetMaterials.size())));
|
54
|
+
ItemStack helmet = new ItemStack(helmetMaterials.get(random.nextInt(helmetMaterials.size())));
|
57
|
-
helmet.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
55
|
+
helmet.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
58
|
-
ItemMeta helmetMeta = helmet.getItemMeta();
|
56
|
+
ItemMeta helmetMeta = helmet.getItemMeta();
|
59
|
-
helmetMeta.setDisplayName("Zombie's Helmet");
|
57
|
+
helmetMeta.setDisplayName("Zombie's Helmet");
|
60
|
-
helmet.setItemMeta(helmetMeta);
|
58
|
+
helmet.setItemMeta(helmetMeta);
|
61
59
|
|
62
|
-
ItemStack chestplate = new ItemStack(chestplateMaterials.get(random.nextInt(chestplateMaterials.size())));
|
60
|
+
ItemStack chestplate = new ItemStack(chestplateMaterials.get(random.nextInt(chestplateMaterials.size())));
|
63
|
-
chestplate.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
61
|
+
chestplate.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
64
|
-
ItemMeta chestplateMeta = chestplate.getItemMeta();
|
62
|
+
ItemMeta chestplateMeta = chestplate.getItemMeta();
|
65
|
-
chestplateMeta.setDisplayName("Zombie's Chestplate");
|
63
|
+
chestplateMeta.setDisplayName("Zombie's Chestplate");
|
66
|
-
chestplate.setItemMeta(chestplateMeta);
|
64
|
+
chestplate.setItemMeta(chestplateMeta);
|
67
65
|
|
68
|
-
ItemStack leggings = new ItemStack(leggingsMaterials.get(random.nextInt(leggingsMaterials.size())));
|
66
|
+
ItemStack leggings = new ItemStack(leggingsMaterials.get(random.nextInt(leggingsMaterials.size())));
|
69
|
-
leggings.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
67
|
+
leggings.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
70
|
-
ItemMeta leggingsMeta = leggings.getItemMeta();
|
68
|
+
ItemMeta leggingsMeta = leggings.getItemMeta();
|
71
|
-
leggingsMeta.setDisplayName("Zombie's Leggings");
|
69
|
+
leggingsMeta.setDisplayName("Zombie's Leggings");
|
72
|
-
leggings.setItemMeta(leggingsMeta);
|
70
|
+
leggings.setItemMeta(leggingsMeta);
|
73
71
|
|
74
|
-
ItemStack boots = new ItemStack(bootsMaterials.get(random.nextInt(bootsMaterials.size())));
|
72
|
+
ItemStack boots = new ItemStack(bootsMaterials.get(random.nextInt(bootsMaterials.size())));
|
75
|
-
boots.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
73
|
+
boots.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
76
|
-
ItemMeta bootsMeta = boots.getItemMeta();
|
74
|
+
ItemMeta bootsMeta = boots.getItemMeta();
|
77
|
-
bootsMeta.setDisplayName("Zombie's Boots");
|
75
|
+
bootsMeta.setDisplayName("Zombie's Boots");
|
78
|
-
boots.setItemMeta(bootsMeta);
|
76
|
+
boots.setItemMeta(bootsMeta);
|
79
77
|
|
80
|
-
ItemStack weapon = new ItemStack(weaponMaterials.get(random.nextInt(weaponMaterials.size())));
|
78
|
+
ItemStack weapon = new ItemStack(weaponMaterials.get(random.nextInt(weaponMaterials.size())));
|
81
|
-
weapon.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
79
|
+
weapon.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
82
|
-
ItemMeta weaponMeta = weapon.getItemMeta();
|
80
|
+
ItemMeta weaponMeta = weapon.getItemMeta();
|
83
|
-
weaponMeta.getDisplayName
|
81
|
+
weaponMeta.getDisplayName
|
84
82
|
|
85
83
|
|
86
|
-
@Override
|
84
|
+
@Override
|
87
|
-
public void onEnable() {
|
85
|
+
public void onEnable() {
|
88
|
-
getServer().getPluginManager().registerEvents(this, this);
|
86
|
+
getServer().getPluginManager().registerEvents(this, this);
|
89
|
-
}
|
87
|
+
}
|
90
88
|
|
91
|
-
@Override
|
89
|
+
@Override
|
92
|
-
public void onDisable() {
|
90
|
+
public void onDisable() {
|
93
|
-
// Plugin shutdown logic
|
91
|
+
// Plugin shutdown logic
|
94
|
-
}
|
92
|
+
}
|
95
93
|
}
|
96
94
|
```
|
97
95
|
有識者の方よろしくお願いします。
|
5
前提文変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
InteliJでMinecraftのPluginを作っています。
|
9
9
|
|
10
|
-
short動画用のプラグインを作っており、それで動画を撮影するために開発しています。(今回のプラグインはその為)
|
10
|
+
short動画用のプラグインを作っており、それで動画を撮影するために開発しています。(今回のプラグインはその為です)
|
11
11
|
### 発生している問題・エラーメッセージ
|
12
12
|
|
13
13
|
```
|
4
package抜け修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,6 +22,8 @@
|
|
22
22
|
### 該当のソースコード
|
23
23
|
|
24
24
|
```Java
|
25
|
+
package org.hotal.changezombiematerials;
|
26
|
+
|
25
27
|
import org.bukkit.Material;
|
26
28
|
import org.bukkit.enchantments.Enchantment;
|
27
29
|
import org.bukkit.entity.EntityType;
|
3
ソースコード変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,8 +22,6 @@
|
|
22
22
|
### 該当のソースコード
|
23
23
|
|
24
24
|
```Java
|
25
|
-
package org.hotal.changezombiematerials;
|
26
|
-
|
27
25
|
import org.bukkit.Material;
|
28
26
|
import org.bukkit.enchantments.Enchantment;
|
29
27
|
import org.bukkit.entity.EntityType;
|
@@ -40,150 +38,58 @@
|
|
40
38
|
import static org.bukkit.enchantments.Enchantment.PROTECTION_ENVIRONMENTAL;
|
41
39
|
|
42
40
|
@SuppressWarnings("deprecation")
|
43
|
-
public class ChangeZombieMaterials extends JavaPlugin implements Listener {
|
41
|
+
public class ChangeZombieMaterials extends JavaPlugin implements Listener {
|
44
42
|
|
45
|
-
|
43
|
+
private final Random random = new Random();
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
@EventHandler
|
54
|
-
public void handleCreatureSpawn(CreatureSpawnEvent event) {;
|
55
|
-
if (EntityType.ZOMBIE == event.getEntityType()) {;
|
56
|
-
ItemStack helmet = new ItemStack(helmetMaterials.get(random.nextInt(helmetMaterials.size())));
|
57
|
-
helmet.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
58
|
-
ItemMeta helmetMeta = helmet.getItemMeta();
|
59
|
-
helmetMeta.setDisplayName("Zombie's Helmet");
|
60
|
-
helmet.setItemMeta(helmetMeta);
|
61
|
-
|
62
|
-
ItemStack chestplate = new ItemStack(chestplateMaterials.get(random.nextInt(chestplateMaterials.size())));
|
63
|
-
chestplate.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
64
|
-
ItemMeta chestplateMeta = chestplate.getItemMeta();
|
65
|
-
chestplateMeta.setDisplayName("Zombie's Chestplate");
|
66
|
-
chestplate.setItemMeta(chestplateMeta);
|
67
|
-
|
68
|
-
ItemStack leggings = new ItemStack(leggingsMaterials.get(random.nextInt(leggingsMaterials.size())));
|
69
|
-
leggings.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
70
|
-
ItemMeta leggingsMeta = leggings.getItemMeta();
|
71
|
-
leggingsMeta.setDisplayName("Zombie's Leggings");
|
72
|
-
leggings.setItemMeta(leggingsMeta);
|
73
|
-
|
74
|
-
ItemStack boots = new ItemStack(bootsMaterials.get(random.nextInt(bootsMaterials.size())));
|
75
|
-
boots.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
76
|
-
ItemMeta bootsMeta = boots.getItemMeta();
|
77
|
-
bootsMeta.setDisplayName("Zombie's Boots");
|
78
|
-
boots.setItemMeta(bootsMeta);
|
79
|
-
|
80
|
-
ItemStack weapon = new ItemStack(weaponMaterials.get(random.nextInt(weaponMaterials.size())));
|
81
|
-
weapon.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
82
|
-
ItemMeta weaponMeta = weapon.getItemMeta();
|
83
|
-
weaponMeta.setDisplayName("Zombie's Weapon");
|
84
|
-
weapon.setItemMeta(weaponMeta);
|
85
|
-
|
86
|
-
event.getEntity().getEquipment().setHelmet(helmet);
|
87
|
-
event.getEntity().getEquipment().setChestplate(chestplate);
|
88
|
-
event.getEntity().getEquipment().setLeggings(leggings);
|
89
|
-
event.getEntity().getEquipment().setBoots(boots);
|
90
|
-
|
91
|
-
|
92
|
-
public void onEnable;() {;
|
93
|
-
// Plugin startup logic
|
94
|
-
getServer().getPluginManager().registerEvents(this, this);
|
95
|
-
}
|
96
|
-
|
97
|
-
public void onDisable;() {
|
98
|
-
// Plugin shutdown logic
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
|
103
|
-
```
|
104
|
-
|
105
|
-
### 試したこと
|
106
|
-
|
107
|
-
コード修正
|
108
|
-
ChatGPTによる修正
|
109
|
-
|
110
|
-
### 補足情報(FW/ツールのバージョンなど)
|
111
|
-
InteliJ Community
|
112
|
-
Minecraft 1.19.4
|
113
|
-
Paper 1.19.4 latest
|
114
|
-
|
115
|
-
ここにより詳細な情報を記載してください。
|
116
|
-
元のコードはこちらです
|
117
|
-
```Java
|
118
|
-
import org.bukkit.Material;
|
119
|
-
import org.bukkit.enchantments.Enchantment;
|
120
|
-
import org.bukkit.entity.EntityType;
|
121
|
-
import org.bukkit.event.EventHandler;
|
122
|
-
import org.bukkit.event.Listener;
|
123
|
-
import org.bukkit.event.entity.CreatureSpawnEvent;
|
124
|
-
import org.bukkit.inventory.ItemStack;
|
125
|
-
import org.bukkit.inventory.meta.ItemMeta;
|
126
|
-
import org.bukkit.plugin.java.JavaPlugin;
|
127
|
-
|
128
|
-
import java.util.Arrays;
|
129
|
-
import java.util.List;
|
130
|
-
import java.util.Random;
|
131
|
-
|
132
|
-
public class ZombieEquipmentPlugin extends JavaPlugin implements Listener {
|
133
|
-
|
134
|
-
private final Random random = new Random();
|
135
|
-
|
136
|
-
private final List<Material> helmetMaterials = Arrays.asList(Material.LEATHER_HELMET, Material.CHAINMAIL_HELMET, Material.IRON_HELMET, Material.GOLDEN_HELMET, Material.DIAMOND_HELMET);
|
137
|
-
private final List<Material> chestplateMaterials = Arrays.asList(Material.LEATHER_CHESTPLATE, Material.CHAINMAIL_CHESTPLATE, Material.IRON_CHESTPLATE, Material.GOLDEN_CHESTPLATE, Material.DIAMOND_CHESTPLATE);
|
138
|
-
private final List<Material> leggingsMaterials = Arrays.asList(Material.LEATHER_LEGGINGS, Material.CHAINMAIL_LEGGINGS, Material.IRON_LEGGINGS, Material.GOLDEN_LEGGINGS, Material.DIAMOND_LEGGINGS);
|
139
|
-
private final List<Material> bootsMaterials = Arrays.asList(Material.LEATHER_BOOTS, Material.CHAINMAIL_BOOTS, Material.IRON_BOOTS, Material.GOLDEN_BOOTS, Material.DIAMOND_BOOTS);
|
140
|
-
private final List<Material> weaponMaterials = Arrays.asList(Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD);
|
141
|
-
|
142
|
-
@Override
|
143
|
-
public void onEnable() {
|
144
|
-
getServer().getPluginManager().registerEvents(this, this);
|
145
|
-
}
|
45
|
+
private final List<Material> helmetMaterials = Arrays.asList(Material.LEATHER_HELMET, Material.CHAINMAIL_HELMET, Material.IRON_HELMET, Material.GOLDEN_HELMET, Material.DIAMOND_HELMET);
|
46
|
+
private final List<Material> chestplateMaterials = Arrays.asList(Material.LEATHER_CHESTPLATE, Material.CHAINMAIL_CHESTPLATE, Material.IRON_CHESTPLATE, Material.GOLDEN_CHESTPLATE, Material.DIAMOND_CHESTPLATE);
|
47
|
+
private final List<Material> leggingsMaterials = Arrays.asList(Material.LEATHER_LEGGINGS, Material.CHAINMAIL_LEGGINGS, Material.IRON_LEGGINGS, Material.GOLDEN_LEGGINGS, Material.DIAMOND_LEGGINGS);
|
48
|
+
private final List<Material> bootsMaterials = Arrays.asList(Material.LEATHER_BOOTS, Material.CHAINMAIL_BOOTS, Material.IRON_BOOTS, Material.GOLDEN_BOOTS, Material.DIAMOND_BOOTS);
|
49
|
+
private final List<Material> weaponMaterials = Arrays.asList(Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD);
|
146
50
|
|
147
51
|
@EventHandler
|
148
52
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
149
|
-
|
53
|
+
if (EntityType.ZOMBIE == event.getEntityType()) {
|
150
|
-
|
54
|
+
ItemStack helmet = new ItemStack(helmetMaterials.get(random.nextInt(helmetMaterials.size())));
|
151
|
-
|
55
|
+
helmet.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
152
|
-
|
56
|
+
ItemMeta helmetMeta = helmet.getItemMeta();
|
153
|
-
|
57
|
+
helmetMeta.setDisplayName("Zombie's Helmet");
|
154
|
-
|
58
|
+
helmet.setItemMeta(helmetMeta);
|
155
59
|
|
156
|
-
|
60
|
+
ItemStack chestplate = new ItemStack(chestplateMaterials.get(random.nextInt(chestplateMaterials.size())));
|
157
|
-
|
61
|
+
chestplate.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
158
|
-
|
62
|
+
ItemMeta chestplateMeta = chestplate.getItemMeta();
|
159
|
-
|
63
|
+
chestplateMeta.setDisplayName("Zombie's Chestplate");
|
160
|
-
|
64
|
+
chestplate.setItemMeta(chestplateMeta);
|
161
65
|
|
162
|
-
|
66
|
+
ItemStack leggings = new ItemStack(leggingsMaterials.get(random.nextInt(leggingsMaterials.size())));
|
163
|
-
|
67
|
+
leggings.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
164
|
-
|
68
|
+
ItemMeta leggingsMeta = leggings.getItemMeta();
|
165
|
-
|
69
|
+
leggingsMeta.setDisplayName("Zombie's Leggings");
|
166
|
-
|
70
|
+
leggings.setItemMeta(leggingsMeta);
|
167
71
|
|
168
|
-
|
72
|
+
ItemStack boots = new ItemStack(bootsMaterials.get(random.nextInt(bootsMaterials.size())));
|
169
|
-
|
73
|
+
boots.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
|
170
|
-
|
74
|
+
ItemMeta bootsMeta = boots.getItemMeta();
|
171
|
-
|
75
|
+
bootsMeta.setDisplayName("Zombie's Boots");
|
172
|
-
|
76
|
+
boots.setItemMeta(bootsMeta);
|
173
77
|
|
174
|
-
|
78
|
+
ItemStack weapon = new ItemStack(weaponMaterials.get(random.nextInt(weaponMaterials.size())));
|
175
|
-
|
79
|
+
weapon.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
176
|
-
|
80
|
+
ItemMeta weaponMeta = weapon.getItemMeta();
|
177
|
-
weaponMeta.setDisplayName("Zombie's Weapon");
|
178
|
-
|
81
|
+
weaponMeta.getDisplayName
|
179
82
|
|
83
|
+
|
84
|
+
@Override;
|
180
|
-
|
85
|
+
public void onEnable() {
|
181
|
-
|
86
|
+
getServer().getPluginManager().registerEvents(this, this);
|
182
|
-
event.getEntity().getEquipment().setLeggings(leggings);
|
183
|
-
event.getEntity().getEquipment().setBoots(boots);
|
184
|
-
event.getEntity().getEquipment().setItemInMainHand(weapon);
|
185
|
-
|
87
|
+
}
|
88
|
+
|
89
|
+
@Override;
|
90
|
+
public void onDisable() {
|
91
|
+
// Plugin shutdown logic
|
186
|
-
|
92
|
+
}
|
187
93
|
}
|
188
94
|
```
|
189
95
|
有識者の方よろしくお願いします。
|
2
タグ未記入
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
実現したいことの脱字
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Minecraftのshort用のプラグインのコード
|
1
|
+
Minecraftのshort用のプラグインのコードを書いてますがエラーで困ってます
|
test
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
### 実現したいこと
|
2
2
|
|
3
|
-
ここに実現したいことを箇条書きで書いてください。
|
4
|
-
|
3
|
+
プラグインが動作、起動でき、サーバーで動作するようになる
|
5
|
-
|
4
|
+
環境:1.19.4
|
6
5
|
### 前提
|
7
6
|
|
8
7
|
|