You are not logged in.

  • Login

[Bukkit-Plugin] Interact Event -- FEHLER

Bitte besucht unser neues Forum unter https://forum.nitrado.net | Please visit our new Forum at https://forum.nitrado.net

Dear visitor, welcome to Nitrado.net Prepaid Gameserver Community-Support - Archiv. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

1

Monday, September 29th 2014, 2:52pm

Interact Event -- FEHLER

Gutentag,
Ich habe folgendes Problem, ich möchte das, wenn man auf ein Item klickt, das sich ein Fenster öffnet, gleichzeitig sollte dieses Item auch gelöscht werden. Das Item wird gelöscht, jedoch das Inventar nicht geöffnet(Das Inventar geht, da man es mit einem Kommando öffnen kan)

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
    public void onPlayerKlick(PlayerInteractEvent i)
    {
        
        Player p i.getPlayer();
        
        if(i.getMaterial().equals(Material.NETHER_STAR))
                {

                p.openInventory(this.inv);
                p.getInventory().remove(Material.NETHER_STAR);
            
                }

Fehelermeldung:

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
[14:55:20 ERROR]: Could not pass event PlayerInteractEvent to KlassenSystem v1.0

org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
va:427) ~[bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
a:62) ~[bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
ava:481) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
ava:466) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
ractEvent(CraftEventFactory.java:191) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnk
s]
        at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
ractEvent(CraftEventFactory.java:161) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnk
s]
        at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
:604) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.a(SourceFile:60)
[bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.handle(SourceFile
:9) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [bukk
it.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
55) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
50) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
45) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
:457) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
17) [bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
Caused byjava.lang.NullPointerException
        at org.bukkit.craftbukkit.v1_7_R1.entity.CraftHumanEntity.openInventory(
CraftHumanEntity.java:185) ~[bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at ape.main.main.onPlayerKlick(main.java:330) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
.7.0_45]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_45]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
va:425) ~[bukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        ... 15 more
>

Schonmal danke im Voraus :)

Abgegrieft

User / Kunde

  • "Abgegrieft" is male

Posts: 674

Location: Waschraum

  • Send private message

2

Monday, September 29th 2014, 2:54pm

Zeig mal die Stelle, wo du this.inv definierst :)
lädt

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

3

Monday, September 29th 2014, 2:57pm

PHP Source code

1
2
 public Inventory inv null;
 

UnitedSeventeen

User / Kunde

  • "UnitedSeventeen" is male

Posts: 641

Location: Localhost

Occupation: Nix

  • Send private message

4

Monday, September 29th 2014, 2:58pm

Da fehlt eine Initialisierung.

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

5

Monday, September 29th 2014, 2:58pm

Die wäre... ??????

This post has been edited 1 times, last edit by "ApeFake" (Sep 29th 2014, 3:04pm)


UnitedSeventeen

User / Kunde

  • "UnitedSeventeen" is male

Posts: 641

Location: Localhost

Occupation: Nix

  • Send private message

6

Monday, September 29th 2014, 3:05pm

Du hast es Deklaration.
Eine Definierung ist das Zuweisen eines Wertes.
Beispiel:

Java source code

1
this.inv = Bukkit.createInventory(null,9,"Mein Inventar");

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

7

Monday, September 29th 2014, 3:07pm

Dies habe ich gemacht:

PHP Source code

1
inv p.getPlayer().getServer().createInventory(null54"§c§lStarter Items");

Abgegrieft

User / Kunde

  • "Abgegrieft" is male

Posts: 674

Location: Waschraum

  • Send private message

8

Monday, September 29th 2014, 3:08pm

Schick doch mal den ganzen Code, dann raten wir nicht weiter rum :)
lädt

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

9

Monday, September 29th 2014, 3:11pm

Also wenn ihr euch fragt, warum dass alles in einer klasse ist. Dies liegt daran das ich es erst lerne :)

Spoiler Spoiler

package ape.main;


import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

public class main extends JavaPlugin implements Listener{


public Inventory inv = null;


public void onEnable()
{

System.out.println("[KlassenSystem] Das Plugin wurde gestartet");
Bukkit.getPluginManager().registerEvents(this, this);
}



public void onDisable()
{

System.out.println("[KlassenSystem] Das Plugin wurde gestopt");

}


public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){

Player p = (Player) sender;

if(cmd.getName().equalsIgnoreCase("Klassen"))
{

inv = p.getPlayer().getServer().createInventory(null, 54, "§c§lStarter Items");


//----------------------------------------------------------------------------//
// Rüstung 1
//----------------------------------------------------------------------------//
ItemStack istack = new ItemStack(Material.LEATHER_HELMET);
ItemMeta istackMeta = istack.getItemMeta();
istackMeta.setDisplayName("§l§6Helm");
istack.setItemMeta(istackMeta);
istackMeta = istack.getItemMeta();

ItemStack istack2 = new ItemStack(Material.LEATHER_CHESTPLATE);
ItemMeta istackMeta2 = istack2.getItemMeta();
istackMeta2.setDisplayName("§l§6Brustplatte");
istack2.setItemMeta(istackMeta2);
istackMeta2 = istack2.getItemMeta();

ItemStack istack3 = new ItemStack(Material.LEATHER_LEGGINGS);
ItemMeta istackMeta3 = istack3.getItemMeta();
istackMeta3.setDisplayName("§l§6Hose");
istack3.setItemMeta(istackMeta3);
istackMeta3 = istack3.getItemMeta();

ItemStack istack4 = new ItemStack(Material.LEATHER_BOOTS);
ItemMeta istackMeta4 = istack4.getItemMeta();
istackMeta4.setDisplayName("§l§6Schuhe");
istack4.setItemMeta(istackMeta4);
istackMeta4 = istack4.getItemMeta();

//----------------------------------------------------------------------------//
// Rüstung 2
//----------------------------------------------------------------------------//
ItemStack istack5 = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta istackMeta5 = (LeatherArmorMeta) istack5.getItemMeta();
istackMeta5.setColor(Color.GREEN);
istackMeta5.setDisplayName("§l§2Helm");
istack5.setItemMeta(istackMeta5);
istackMeta5 = (LeatherArmorMeta) istack5.getItemMeta();

ItemStack istack6 = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta istackMeta6 = (LeatherArmorMeta) istack6.getItemMeta();
istackMeta6.setColor(Color.GREEN);
istackMeta6.setDisplayName("§l§2Brustplatte");
istack6.setItemMeta(istackMeta6);
istackMeta6 = (LeatherArmorMeta) istack6.getItemMeta();

ItemStack istack7 = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta istackMeta7 = (LeatherArmorMeta) istack7.getItemMeta();
istackMeta7.setColor(Color.GREEN);
istackMeta7.setDisplayName("§l§2Hose");
istack7.setItemMeta(istackMeta7);
istackMeta7 = (LeatherArmorMeta) istack7.getItemMeta();

ItemStack istack8 = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta istackMeta8 = (LeatherArmorMeta) istack8.getItemMeta();
istackMeta8.setColor(Color.GREEN);
istackMeta8.setDisplayName("§l§2Schuhe");
istack8.setItemMeta(istackMeta8);
istackMeta8 = (LeatherArmorMeta) istack8.getItemMeta();

//----------------------------------------------------------------------------//
// Rüstung 3
//----------------------------------------------------------------------------//
ItemStack istack9 = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta istackMeta9 = (LeatherArmorMeta) istack9.getItemMeta();
istackMeta9.setColor(Color.BLUE);
istackMeta9.setDisplayName("§l§1Helm");
istack9.setItemMeta(istackMeta9);
istackMeta = istack9.getItemMeta();

ItemStack istack10 = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta istackMeta10 = (LeatherArmorMeta) istack10.getItemMeta();
istackMeta10.setColor(Color.BLUE);
istackMeta10.setDisplayName("§l§1Brustplatte");
istack10.setItemMeta(istackMeta10);
istackMeta10 = (LeatherArmorMeta) istack10.getItemMeta();

ItemStack istack11 = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta istackMeta11 = (LeatherArmorMeta) istack11.getItemMeta();
istackMeta11.setColor(Color.BLUE);
istackMeta11.setDisplayName("§l§1Hose");
istack11.setItemMeta(istackMeta11);
istackMeta11 = (LeatherArmorMeta) istack11.getItemMeta();

ItemStack istack12 = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta istackMeta12 = (LeatherArmorMeta) istack12.getItemMeta();
istackMeta12.setColor(Color.BLUE);
istackMeta12.setDisplayName("§l§1Schuhe");
istack12.setItemMeta(istackMeta12);
istackMeta12 = (LeatherArmorMeta) istack12.getItemMeta();


//----------------------------------------------------------------------------//
// Rüstung 4
//----------------------------------------------------------------------------//

ItemStack istack13 = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta istackMeta13 = (LeatherArmorMeta) istack13.getItemMeta();
istackMeta13.setColor(Color.RED);
istackMeta13.setDisplayName("§l§4Helm");
istack13.setItemMeta(istackMeta13);
istackMeta13 = (LeatherArmorMeta) istack13.getItemMeta();

ItemStack istack14 = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta istackMeta14 = (LeatherArmorMeta) istack14.getItemMeta();
istackMeta14.setColor(Color.RED);
istackMeta14.setDisplayName("§l§4Brustplatte");
istack14.setItemMeta(istackMeta14);
istackMeta14 = (LeatherArmorMeta) istack14.getItemMeta();

ItemStack istack15 = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta istackMeta15 = (LeatherArmorMeta) istack15.getItemMeta();
istackMeta15.setColor(Color.RED);
istackMeta15.setDisplayName("§l§4Hose");
istack15.setItemMeta(istackMeta15);
istackMeta15 = (LeatherArmorMeta) istack15.getItemMeta();

ItemStack istack16 = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta istackMeta16 = (LeatherArmorMeta) istack16.getItemMeta();
istackMeta16.setColor(Color.RED);
istackMeta16.setDisplayName("§l§4Schuhe");
istack16.setItemMeta(istackMeta16);
istackMeta16 = (LeatherArmorMeta) istack16.getItemMeta();


//----------------------------------------------------------------------------//
// Waffen
//----------------------------------------------------------------------------//

ItemStack istack21 = new ItemStack(Material.STICK, 1);
istack21.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
ItemMeta istackMeta21 = istack21.getItemMeta();
istackMeta21.setDisplayName("§6§lKnüppel");
istack21.setItemMeta(istackMeta21);
istackMeta21 = istack21.getItemMeta();

ItemStack istack22 = new ItemStack(Material.WOOD_SWORD);
ItemMeta istackMeta22 = istack22.getItemMeta();
istackMeta22.setDisplayName("§6§lSchwert");
istack22.setItemMeta(istackMeta22);
istackMeta22 = istack22.getItemMeta();

ItemStack istack23 = new ItemStack(Material.STONE_AXE);
ItemMeta istackMeta23 = istack23.getItemMeta();
istackMeta23.setDisplayName("§6§lAxt");
istack23.setItemMeta(istackMeta23);
istackMeta23 = istack23.getItemMeta();

ItemStack istack24 = new ItemStack(Material.STICK, 1);
istack24.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
ItemMeta istackMeta24 = istack24.getItemMeta();
istackMeta24.setDisplayName("§6§lKnüppel");
istack24.setItemMeta(istackMeta6);
istackMeta24 = istack24.getItemMeta();

//----------------------------------------------------------------------------//
// Essen
//----------------------------------------------------------------------------//

ItemStack istack25 = new ItemStack(Material.COOKED_BEEF, 64);
ItemMeta istackMeta25 = istack25.getItemMeta();
istackMeta25.setDisplayName("§6§lSteak");
istack25.setItemMeta(istackMeta25);
istackMeta25 = istack25.getItemMeta();

ItemStack istack26 = new ItemStack(Material.PUMPKIN_PIE, 64);
ItemMeta istackMeta26 = istack26.getItemMeta();
istackMeta26.setDisplayName("§46§lKürbiskuchen");
istack26.setItemMeta(istackMeta26);
istackMeta26 = istack26.getItemMeta();

//----------------------------------------------------------------------------//
// Glass
//----------------------------------------------------------------------------//

ItemStack istack27 = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.GRAY.getData());
ItemMeta istackMeta27 = istack27.getItemMeta();
istackMeta27.setDisplayName("");
istack27.setItemMeta(istackMeta27);
istackMeta27 = istack27.getItemMeta();

//----------------------------------------------------------------------------//
// Potion
//----------------------------------------------------------------------------//

// ItemStack istack28 = new ItemStack(Material.POTION, 1, (short) 8197);
// ItemMeta istackMeta28 = istack28.getItemMeta();
// istackMeta28.setDisplayName("");
// istack28.setItemMeta(istackMeta28);
// istackMeta28 = (LeatherArmorMeta) istack28.getItemMeta();



//Rüstung1
inv.setItem(10, istack);
inv.setItem(19, istack2);
inv.setItem(28, istack3);
inv.setItem(37, istack4);
//Rüstung2
inv.setItem(11, istack5);
inv.setItem(20, istack6);
inv.setItem(29, istack7);
inv.setItem(38, istack8);
//Rüstung3
inv.setItem(12, istack9);
inv.setItem(21, istack10);
inv.setItem(30, istack11);
inv.setItem(39, istack12);
//Rüstung4
inv.setItem(13, istack13);
inv.setItem(22, istack14);
inv.setItem(31, istack15);
inv.setItem(40, istack16);

//Waffen
inv.setItem(15, istack21);
inv.setItem(24, istack22);
inv.setItem(33, istack23);
inv.setItem(42, istack24);
//Essen
inv.setItem(25, istack25);
inv.setItem(34, istack26);
//Glass
inv.setItem(0, istack27);
inv.setItem(1, istack27);
inv.setItem(2, istack27);
inv.setItem(3, istack27);
inv.setItem(4, istack27);
inv.setItem(5, istack27);
inv.setItem(6, istack27);
inv.setItem(7, istack27);
inv.setItem(8, istack27);
inv.setItem(9, istack27);
inv.setItem(14, istack27);
inv.setItem(17, istack27);
inv.setItem(18, istack27);
inv.setItem(23, istack27);
inv.setItem(26, istack27);
inv.setItem(27, istack27);
inv.setItem(32, istack27);
inv.setItem(35, istack27);
inv.setItem(36, istack27);
inv.setItem(41, istack27);
inv.setItem(44, istack27);
inv.setItem(45, istack27);
inv.setItem(46, istack27);
inv.setItem(47, istack27);
inv.setItem(48, istack27);
inv.setItem(49, istack27);
inv.setItem(50, istack27);
inv.setItem(51, istack27);
inv.setItem(52, istack27);
inv.setItem(53, istack27);


p.getPlayer().openInventory(inv);

return true;

}

return false;
}

@EventHandler

public void onPlayerKlick(PlayerInteractEvent i)
{

Player p = i.getPlayer();

if(i.getMaterial().equals(Material.NETHER_STAR))
{

p.openInventory(inv);
p.getInventory().remove(Material.NETHER_STAR);

}


}

@EventHandler

public void onPlayerClick(InventoryClickEvent e)
{

if(e.getInventory().getName().equals("§c§lStarter Items"))
{

if(e.getCurrentItem().getType() == Material.STAINED_GLASS_PANE)
{

e.setCancelled(true);

}
}


}
}

UnitedSeventeen

User / Kunde

  • "UnitedSeventeen" is male

Posts: 641

Location: Localhost

Occupation: Nix

  • Send private message

10

Monday, September 29th 2014, 3:16pm

Kann es sein, dass du das Inventory nur in dem Command definierst?
Verschieb das definieren in den OnEnable Teil.

Weiterhin überprüft man enums mit ==, stat mit .equals()

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

11

Monday, September 29th 2014, 3:18pm

Noch mal ne kleine Frage:

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    @EventHandler
            
        public void onPlayerTod(PlayerDeathEvent d)
        {
            
            Player p d.getEntity().getPlayer();
            
            ItemStack stack = new ItemStack(Material.NETHER_STAR);
            ItemMeta stackMeta stack.getItemMeta();
            stackMeta.setDisplayName("§1§l**§c§lKLICK§1§l** §6§lGratis Items §1§l**§c§lKLICK§1§l**");
            stack.setItemMeta(stackMeta);
            stackMeta stack.getItemMeta();
            
            p.getInventory().setItem(4stack);
            
        }
        

    
}

Warum bekommt man nach dem tod, nich das Item in das Inventar ?

UnitedSeventeen

User / Kunde

  • "UnitedSeventeen" is male

Posts: 641

Location: Localhost

Occupation: Nix

  • Send private message

12

Monday, September 29th 2014, 3:38pm

Benutz das PlayerRespawnEvent.

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

13

Monday, September 29th 2014, 3:41pm

Ein Problem besetht noch, wenn ich neu auf den Server joine dann auf den Netherstar klicke, dann öffnet sich ein Leeres Inventar, sobald ich jedoch einmal den Befehl eingegeben habe geht es wieder mit dem netherstar... wo liegt das problem?

UnitedSeventeen

User / Kunde

  • "UnitedSeventeen" is male

Posts: 641

Location: Localhost

Occupation: Nix

  • Send private message

14

Monday, September 29th 2014, 3:45pm

Die Items werden auch im Command erst geaddet.
Verschieb auch das in den onEnable.

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

15

Monday, September 29th 2014, 3:47pm

kann ich das nicht mit einer Privat methode machen ?
und wenn ja wie ?
(Eben erst am lernen Programmieren)

Achelos

User / Kunde

Posts: 54

  • Send private message

16

Monday, September 29th 2014, 3:57pm

Wenn ich das richtig verstehen willst du eine Methode haben um in das Inventory die Items zu setzten oder?
Wenn ja dann geht das natürlich auch mit

Spoiler Spoiler

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
private void setItems() {
//----------------------------------------------------------------------------//
// Rüstung 1
//----------------------------------------------------------------------------//
ItemStack istack = new ItemStack(Material.LEATHER_HELMET);
ItemMeta istackMeta = istack.getItemMeta();
istackMeta.setDisplayName("§l§6Helm");
istack.setItemMeta(istackMeta);
istackMeta = istack.getItemMeta();

ItemStack istack2 = new ItemStack(Material.LEATHER_CHESTPLATE);
ItemMeta istackMeta2 = istack2.getItemMeta();
istackMeta2.setDisplayName("§l§6Brustplatte");
istack2.setItemMeta(istackMeta2);
istackMeta2 = istack2.getItemMeta();

ItemStack istack3 = new ItemStack(Material.LEATHER_LEGGINGS);
ItemMeta istackMeta3 = istack3.getItemMeta();
istackMeta3.setDisplayName("§l§6Hose");
istack3.setItemMeta(istackMeta3);
istackMeta3 = istack3.getItemMeta();

ItemStack istack4 = new ItemStack(Material.LEATHER_BOOTS);
ItemMeta istackMeta4 = istack4.getItemMeta();
istackMeta4.setDisplayName("§l§6Schuhe");
istack4.setItemMeta(istackMeta4);
istackMeta4 = istack4.getItemMeta();

//----------------------------------------------------------------------------//
// Rüstung 2
//----------------------------------------------------------------------------//	
ItemStack istack5 = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta istackMeta5 = (LeatherArmorMeta) istack5.getItemMeta();
istackMeta5.setColor(Color.GREEN);
istackMeta5.setDisplayName("§l§2Helm");
istack5.setItemMeta(istackMeta5);
istackMeta5 = (LeatherArmorMeta) istack5.getItemMeta();

ItemStack istack6 = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta istackMeta6 = (LeatherArmorMeta) istack6.getItemMeta();
istackMeta6.setColor(Color.GREEN);
istackMeta6.setDisplayName("§l§2Brustplatte");
istack6.setItemMeta(istackMeta6);
istackMeta6 = (LeatherArmorMeta) istack6.getItemMeta();

ItemStack istack7 = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta istackMeta7 = (LeatherArmorMeta) istack7.getItemMeta();
istackMeta7.setColor(Color.GREEN);
istackMeta7.setDisplayName("§l§2Hose");
istack7.setItemMeta(istackMeta7);
istackMeta7 = (LeatherArmorMeta) istack7.getItemMeta();

ItemStack istack8 = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta istackMeta8 = (LeatherArmorMeta) istack8.getItemMeta();
istackMeta8.setColor(Color.GREEN);
istackMeta8.setDisplayName("§l§2Schuhe");
istack8.setItemMeta(istackMeta8);
istackMeta8 = (LeatherArmorMeta) istack8.getItemMeta();

//----------------------------------------------------------------------------//
// Rüstung 3
//----------------------------------------------------------------------------//	
ItemStack istack9 = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta istackMeta9 = (LeatherArmorMeta) istack9.getItemMeta();
istackMeta9.setColor(Color.BLUE);
istackMeta9.setDisplayName("§l§1Helm");
istack9.setItemMeta(istackMeta9);
istackMeta = istack9.getItemMeta();

ItemStack istack10 = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta istackMeta10 = (LeatherArmorMeta) istack10.getItemMeta();
istackMeta10.setColor(Color.BLUE);
istackMeta10.setDisplayName("§l§1Brustplatte");
istack10.setItemMeta(istackMeta10);
istackMeta10 = (LeatherArmorMeta) istack10.getItemMeta();

ItemStack istack11 = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta istackMeta11 = (LeatherArmorMeta) istack11.getItemMeta();
istackMeta11.setColor(Color.BLUE);
istackMeta11.setDisplayName("§l§1Hose");
istack11.setItemMeta(istackMeta11);
istackMeta11 = (LeatherArmorMeta) istack11.getItemMeta();

ItemStack istack12 = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta istackMeta12 = (LeatherArmorMeta) istack12.getItemMeta();
istackMeta12.setColor(Color.BLUE);
istackMeta12.setDisplayName("§l§1Schuhe");
istack12.setItemMeta(istackMeta12);
istackMeta12 = (LeatherArmorMeta) istack12.getItemMeta();


//----------------------------------------------------------------------------//
// Rüstung 4
//----------------------------------------------------------------------------//	

ItemStack istack13 = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta istackMeta13 = (LeatherArmorMeta) istack13.getItemMeta();
istackMeta13.setColor(Color.RED);
istackMeta13.setDisplayName("§l§4Helm");
istack13.setItemMeta(istackMeta13);
istackMeta13 = (LeatherArmorMeta) istack13.getItemMeta();

ItemStack istack14 = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta istackMeta14 = (LeatherArmorMeta) istack14.getItemMeta();
istackMeta14.setColor(Color.RED);
istackMeta14.setDisplayName("§l§4Brustplatte");
istack14.setItemMeta(istackMeta14);
istackMeta14 = (LeatherArmorMeta) istack14.getItemMeta();

ItemStack istack15 = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta istackMeta15 = (LeatherArmorMeta) istack15.getItemMeta();
istackMeta15.setColor(Color.RED);
istackMeta15.setDisplayName("§l§4Hose");
istack15.setItemMeta(istackMeta15);
istackMeta15 = (LeatherArmorMeta) istack15.getItemMeta();

ItemStack istack16 = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta istackMeta16 = (LeatherArmorMeta) istack16.getItemMeta();
istackMeta16.setColor(Color.RED);
istackMeta16.setDisplayName("§l§4Schuhe");
istack16.setItemMeta(istackMeta16);
istackMeta16 = (LeatherArmorMeta) istack16.getItemMeta();


//----------------------------------------------------------------------------//
// Waffen
//----------------------------------------------------------------------------//

ItemStack istack21 = new ItemStack(Material.STICK, 1);
istack21.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
ItemMeta istackMeta21 = istack21.getItemMeta();
istackMeta21.setDisplayName("§6§lKnüppel");
istack21.setItemMeta(istackMeta21);
istackMeta21 = istack21.getItemMeta();

ItemStack istack22 = new ItemStack(Material.WOOD_SWORD);
ItemMeta istackMeta22 = istack22.getItemMeta();
istackMeta22.setDisplayName("§6§lSchwert");
istack22.setItemMeta(istackMeta22);
istackMeta22 = istack22.getItemMeta();

ItemStack istack23 = new ItemStack(Material.STONE_AXE);
ItemMeta istackMeta23 = istack23.getItemMeta();
istackMeta23.setDisplayName("§6§lAxt");
istack23.setItemMeta(istackMeta23);
istackMeta23 = istack23.getItemMeta();

ItemStack istack24 = new ItemStack(Material.STICK, 1);
istack24.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
ItemMeta istackMeta24 = istack24.getItemMeta();
istackMeta24.setDisplayName("§6§lKnüppel");
istack24.setItemMeta(istackMeta6);
istackMeta24 = istack24.getItemMeta();

//----------------------------------------------------------------------------//
// Essen
//----------------------------------------------------------------------------//

ItemStack istack25 = new ItemStack(Material.COOKED_BEEF, 64);
ItemMeta istackMeta25 = istack25.getItemMeta();
istackMeta25.setDisplayName("§6§lSteak");
istack25.setItemMeta(istackMeta25);
istackMeta25 = istack25.getItemMeta();

ItemStack istack26 = new ItemStack(Material.PUMPKIN_PIE, 64);
ItemMeta istackMeta26 = istack26.getItemMeta();
istackMeta26.setDisplayName("§46§lKürbiskuchen");
istack26.setItemMeta(istackMeta26);
istackMeta26 = istack26.getItemMeta();

//----------------------------------------------------------------------------//
// Glass
//----------------------------------------------------------------------------//

ItemStack istack27 = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.GRAY.getData());
ItemMeta istackMeta27 = istack27.getItemMeta();
istackMeta27.setDisplayName("");
istack27.setItemMeta(istackMeta27);
istackMeta27 = istack27.getItemMeta();

//----------------------------------------------------------------------------//
// Potion
//----------------------------------------------------------------------------//

//	 ItemStack istack28 = new ItemStack(Material.POTION, 1, (short) 8197);
//	 ItemMeta istackMeta28 = istack28.getItemMeta();
//	 istackMeta28.setDisplayName("");
//	 istack28.setItemMeta(istackMeta28);
//	 istackMeta28 = (LeatherArmorMeta) istack28.getItemMeta();



//Rüstung1
inv.setItem(10, istack);
inv.setItem(19, istack2);
inv.setItem(28, istack3);
inv.setItem(37, istack4);
//Rüstung2
inv.setItem(11, istack5);
inv.setItem(20, istack6);
inv.setItem(29, istack7);
inv.setItem(38, istack8);
//Rüstung3
inv.setItem(12, istack9);
inv.setItem(21, istack10);
inv.setItem(30, istack11);
inv.setItem(39, istack12);
//Rüstung4
inv.setItem(13, istack13);
inv.setItem(22, istack14);
inv.setItem(31, istack15);
inv.setItem(40, istack16);

//Waffen
inv.setItem(15, istack21);
inv.setItem(24, istack22);
inv.setItem(33, istack23);
inv.setItem(42, istack24);
//Essen
inv.setItem(25, istack25);
inv.setItem(34, istack26);
//Glass
inv.setItem(0, istack27);
inv.setItem(1, istack27);
inv.setItem(2, istack27);
inv.setItem(3, istack27);
inv.setItem(4, istack27);
inv.setItem(5, istack27);
inv.setItem(6, istack27);
inv.setItem(7, istack27);
inv.setItem(8, istack27);
inv.setItem(9, istack27);
inv.setItem(14, istack27);
inv.setItem(17, istack27);
inv.setItem(18, istack27);
inv.setItem(23, istack27);
inv.setItem(26, istack27);
inv.setItem(27, istack27);
inv.setItem(32, istack27);
inv.setItem(35, istack27);
inv.setItem(36, istack27);
inv.setItem(41, istack27);
inv.setItem(44, istack27);
inv.setItem(45, istack27);
inv.setItem(46, istack27);
inv.setItem(47, istack27);
inv.setItem(48, istack27);
inv.setItem(49, istack27);
inv.setItem(50, istack27);
inv.setItem(51, istack27);
inv.setItem(52, istack27);
inv.setItem(53, istack27);
}

LG Achelos

ApeFake

User / Kunde

  • "ApeFake" started this thread

Posts: 13

  • Send private message

17

Monday, September 29th 2014, 4:01pm

Danke

Abgegrieft

User / Kunde

  • "Abgegrieft" is male

Posts: 674

Location: Waschraum

  • Send private message

18

Monday, September 29th 2014, 4:12pm

Ein Array + Schleife würde den Code erheblich übersichtlicher machen..
lädt

UnitedSeventeen

User / Kunde

  • "UnitedSeventeen" is male

Posts: 641

Location: Localhost

Occupation: Nix

  • Send private message

19

Monday, September 29th 2014, 4:31pm

Ne Methode zum verändern/erstellen von ItemStacks ebenfalls.

Bitte besucht unser neues Forum unter https://forum.nitrado.net| Please visit our new Forum at https://forum.nitrado.net

Similar threads