質問編集履歴
1
文の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,2 +1,26 @@
|
|
1
1
|
###質問
|
2
|
-
|
2
|
+
MinecraftのPluginの作成をしていたのですが、`b.getType().equals(Material.EMERALD_BLOCK`のequalsがわかりません。==と何が違うのでしょうか?超初心者なので、極力分かりやすくお願いします。
|
3
|
+
```java
|
4
|
+
public class EventsClass implements Listener{
|
5
|
+
|
6
|
+
@EventHandler
|
7
|
+
public void onInteract(PlayerInteractEvent event) {
|
8
|
+
Action a = event.getAction();
|
9
|
+
Player p = event.getPlayer();
|
10
|
+
Block b = event.getClickedBlock();
|
11
|
+
|
12
|
+
if(a.equals(Action.LEFT_CLICK_BLOCK)) {
|
13
|
+
if(b.getType().equals(Material.EMERALD_BLOCK)) {
|
14
|
+
p.sendMessage(ChatColor.LIGHT_PURPLE + "test");
|
15
|
+
if(p.getHealth() == 20) {
|
16
|
+
|
17
|
+
}
|
18
|
+
}else {
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
```
|