質問編集履歴

6

ソースコード変更

2023/04/28 09:29

投稿

hotal_mami1021
hotal_mami1021

スコア1

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 = Arrays.asList(Material.LEATHER_HELMET, Material.CHAINMAIL_HELMET, Material.IRON_HELMET, Material.GOLDEN_HELMET, Material.DIAMOND_HELMET);
48
- private final List<Material> chestplateMaterials = Arrays.asList(Material.LEATHER_CHESTPLATE, Material.CHAINMAIL_CHESTPLATE, Material.IRON_CHESTPLATE, Material.GOLDEN_CHESTPLATE, Material.DIAMOND_CHESTPLATE);
49
- private final List<Material> leggingsMaterials = Arrays.asList(Material.LEATHER_LEGGINGS, Material.CHAINMAIL_LEGGINGS, Material.IRON_LEGGINGS, Material.GOLDEN_LEGGINGS, Material.DIAMOND_LEGGINGS);
50
- private final List<Material> bootsMaterials = Arrays.asList(Material.LEATHER_BOOTS, Material.CHAINMAIL_BOOTS, Material.IRON_BOOTS, Material.GOLDEN_BOOTS, Material.DIAMOND_BOOTS);
51
- private final List<Material> weaponMaterials = Arrays.asList(Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD);
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

前提文変更

2023/04/27 22:15

投稿

hotal_mami1021
hotal_mami1021

スコア1

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抜け修正

2023/04/27 08:37

投稿

hotal_mami1021
hotal_mami1021

スコア1

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

ソースコード変更

2023/04/27 08:35

投稿

hotal_mami1021
hotal_mami1021

スコア1

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
- private final Random random = new Random();
43
+ private final Random random = new Random();
46
44
 
47
- private final List<Material> helmetMaterials = Arrays.asList(Material.LEATHER_HELMET, Material.CHAINMAIL_HELMET, Material.IRON_HELMET, Material.GOLDEN_HELMET, Material.DIAMOND_HELMET);
48
- private final List<Material> chestplateMaterials = Arrays.asList(Material.LEATHER_CHESTPLATE, Material.CHAINMAIL_CHESTPLATE, Material.IRON_CHESTPLATE, Material.GOLDEN_CHESTPLATE, Material.DIAMOND_CHESTPLATE);
49
- private final List<Material> leggingsMaterials = Arrays.asList(Material.LEATHER_LEGGINGS, Material.CHAINMAIL_LEGGINGS, Material.IRON_LEGGINGS, Material.GOLDEN_LEGGINGS, Material.DIAMOND_LEGGINGS);
50
- private final List<Material> bootsMaterials = Arrays.asList(Material.LEATHER_BOOTS, Material.CHAINMAIL_BOOTS, Material.IRON_BOOTS, Material.GOLDEN_BOOTS, Material.DIAMOND_BOOTS);
51
- private final List<Material> weaponMaterials = Arrays.asList(Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD);
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
- if (event.getEntityType() == EntityType.ZOMBIE) {
53
+ if (EntityType.ZOMBIE == event.getEntityType()) {
150
- ItemStack helmet = new ItemStack(helmetMaterials.get(random.nextInt(helmetMaterials.size())));
54
+ ItemStack helmet = new ItemStack(helmetMaterials.get(random.nextInt(helmetMaterials.size())));
151
- helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
55
+ helmet.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
152
- ItemMeta helmetMeta = helmet.getItemMeta();
56
+ ItemMeta helmetMeta = helmet.getItemMeta();
153
- helmetMeta.setDisplayName("Zombie's Helmet");
57
+ helmetMeta.setDisplayName("Zombie's Helmet");
154
- helmet.setItemMeta(helmetMeta);
58
+ helmet.setItemMeta(helmetMeta);
155
59
 
156
- ItemStack chestplate = new ItemStack(chestplateMaterials.get(random.nextInt(chestplateMaterials.size())));
60
+ ItemStack chestplate = new ItemStack(chestplateMaterials.get(random.nextInt(chestplateMaterials.size())));
157
- chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
61
+ chestplate.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
158
- ItemMeta chestplateMeta = chestplate.getItemMeta();
62
+ ItemMeta chestplateMeta = chestplate.getItemMeta();
159
- chestplateMeta.setDisplayName("Zombie's Chestplate");
63
+ chestplateMeta.setDisplayName("Zombie's Chestplate");
160
- chestplate.setItemMeta(chestplateMeta);
64
+ chestplate.setItemMeta(chestplateMeta);
161
65
 
162
- ItemStack leggings = new ItemStack(leggingsMaterials.get(random.nextInt(leggingsMaterials.size())));
66
+ ItemStack leggings = new ItemStack(leggingsMaterials.get(random.nextInt(leggingsMaterials.size())));
163
- leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
67
+ leggings.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
164
- ItemMeta leggingsMeta = leggings.getItemMeta();
68
+ ItemMeta leggingsMeta = leggings.getItemMeta();
165
- leggingsMeta.setDisplayName("Zombie's Leggings");
69
+ leggingsMeta.setDisplayName("Zombie's Leggings");
166
- leggings.setItemMeta(leggingsMeta);
70
+ leggings.setItemMeta(leggingsMeta);
167
71
 
168
- ItemStack boots = new ItemStack(bootsMaterials.get(random.nextInt(bootsMaterials.size())));
72
+ ItemStack boots = new ItemStack(bootsMaterials.get(random.nextInt(bootsMaterials.size())));
169
- boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
73
+ boots.addEnchantment(PROTECTION_ENVIRONMENTAL, 1);
170
- ItemMeta bootsMeta = boots.getItemMeta();
74
+ ItemMeta bootsMeta = boots.getItemMeta();
171
- bootsMeta.setDisplayName("Zombie's Boots");
75
+ bootsMeta.setDisplayName("Zombie's Boots");
172
- boots.setItemMeta(bootsMeta);
76
+ boots.setItemMeta(bootsMeta);
173
77
 
174
- ItemStack weapon = new ItemStack(weaponMaterials.get(random.nextInt(weaponMaterials.size())));
78
+ ItemStack weapon = new ItemStack(weaponMaterials.get(random.nextInt(weaponMaterials.size())));
175
- weapon.addEnchantment(Enchantment.DAMAGE_ALL, 1);
79
+ weapon.addEnchantment(Enchantment.DAMAGE_ALL, 1);
176
- ItemMeta weaponMeta = weapon.getItemMeta();
80
+ ItemMeta weaponMeta = weapon.getItemMeta();
177
- weaponMeta.setDisplayName("Zombie's Weapon");
178
- weapon.setItemMeta(weaponMeta);
81
+ weaponMeta.getDisplayName
179
82
 
83
+
84
+ @Override;
180
- event.getEntity().getEquipment().setHelmet(helmet);
85
+ public void onEnable() {
181
- event.getEntity().getEquipment().setChestplate(chestplate);
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

タグ未記入

2023/04/26 11:34

投稿

hotal_mami1021
hotal_mami1021

スコア1

test CHANGED
File without changes
test CHANGED
File without changes

1

実現したいことの脱字

2023/04/26 06:30

投稿

hotal_mami1021
hotal_mami1021

スコア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