SHOW:
|
|
- or go back to the newest paste.
1 | package party.events; | |
2 | ||
3 | import java.io.File; | |
4 | ||
5 | import org.bukkit.Bukkit; | |
6 | import org.bukkit.GameMode; | |
7 | import org.bukkit.Location; | |
8 | import org.bukkit.Material; | |
9 | import org.bukkit.Sound; | |
10 | import org.bukkit.configuration.file.FileConfiguration; | |
11 | import org.bukkit.configuration.file.YamlConfiguration; | |
12 | import org.bukkit.entity.Player; | |
13 | import org.bukkit.event.EventHandler; | |
14 | import org.bukkit.event.Listener; | |
15 | import org.bukkit.event.player.PlayerJoinEvent; | |
16 | import org.bukkit.inventory.ItemStack; | |
17 | ||
18 | import party.main.PartyPvP; | |
19 | ||
20 | public class Join implements Listener { | |
21 | ||
22 | private PartyPvP plugin; | |
23 | int Start = 6; | |
24 | int Countdown; | |
25 | ||
26 | public Join(PartyPvP partyPvP) { | |
27 | this.plugin = partyPvP; | |
28 | plugin.getServer().getPluginManager().registerEvents(this, this.plugin); | |
29 | } | |
30 | ||
31 | public boolean isStarted = false; | |
32 | ||
33 | @EventHandler | |
34 | public void onJoin(PlayerJoinEvent e) { | |
35 | final Player p = e.getPlayer(); | |
36 | ||
37 | e.setJoinMessage(plugin.Prefix + "§5" + p.getName() + "§7 hat den PartyPvP Server betreten."); | |
38 | ||
39 | ||
40 | if(plugin.blue.size() == 0) { | |
41 | plugin.blue.add(p); | |
42 | p.sendMessage(plugin.Prefix + "Du wurdest in das Team §9Blau §7verschoben!"); | |
43 | p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind."); | |
44 | p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3); | |
45 | ||
46 | ||
47 | } else if(plugin.red.size() == 0) { | |
48 | plugin.red.add(p); | |
49 | p.sendMessage(plugin.Prefix + "Du wurdest in das Team §cRot §7verschoben!"); | |
50 | p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind."); | |
51 | p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3); | |
52 | ||
53 | ||
54 | } else if(plugin.green.size() == 0) { | |
55 | plugin.green.add(p); | |
56 | p.sendMessage(plugin.Prefix + "Du wurdest in das Team §aGrün §7verschoben!"); | |
57 | p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind."); | |
58 | p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3); | |
59 | ||
60 | ||
61 | } else if(plugin.yellow.size() == 0) { | |
62 | plugin.yellow.add(p); | |
63 | p.sendMessage(plugin.Prefix + "Du wurdest in das Team §eGelb §7verschoben!"); | |
64 | p.sendMessage(plugin.Prefix + "§cDas Spiel startet wenn, 4 Spieler online sind."); | |
65 | p.playSound(p.getLocation(), Sound.LEVEL_UP, 2, 3); | |
66 | ||
67 | ||
68 | } | |
69 | ||
70 | ||
71 | startCountdown(); | |
72 | ||
73 | } | |
74 | ||
75 | ||
76 | ||
77 | ||
78 | ||
79 | ||
80 | private void Items(Player p) { | |
81 | p.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); | |
82 | p.getInventory().addItem(new ItemStack(Material.FISHING_ROD)); | |
83 | p.getInventory().addItem(new ItemStack(Material.BOW)); | |
84 | p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 1)); | |
85 | p.getInventory().addItem(new ItemStack(Material.BREAD, 5)); | |
86 | p.getInventory().addItem(new ItemStack(Material.ARROW, 5)); | |
87 | ||
88 | p.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET)); | |
89 | p.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); | |
90 | p.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); | |
91 | p.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS)); | |
92 | ||
93 | ||
94 | ||
95 | } | |
96 | ||
97 | public void startCountdown() { | |
98 | - | if(isStarted) { |
98 | + | if(isStarted || Bukkit.getOnlinePlayers().length != 4) { |
99 | return; | |
100 | } | |
101 | if(Bukkit.getOnlinePlayers().length == 4) { | |
102 | for(final Player players : Bukkit.getOnlinePlayers()) { | |
103 | Countdown = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { | |
104 | ||
105 | @Override | |
106 | public void run() { | |
107 | if(isStarted) { | |
108 | return; | |
109 | } | |
110 | isStarted = true; | |
111 | Start--; | |
112 | if(Start == 5) { | |
113 | Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §55 §7Sekunden!"); | |
114 | ||
115 | } else if(Start == 4) { | |
116 | Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §54 §7Sekunden!"); | |
117 | ||
118 | } else if(Start == 3) { | |
119 | Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §53 §7Sekunden!"); | |
120 | ||
121 | } else if(Start == 2) { | |
122 | Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §52 §7Sekunden!"); | |
123 | ||
124 | } else if(Start == 1) { | |
125 | Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel startet in §51 §7Sekunde!"); | |
126 | ||
127 | } else if(Start == 0) { | |
128 | Bukkit.getScheduler().cancelTask(Countdown); | |
129 | Bukkit.broadcastMessage(plugin.Prefix + "Das Spiel hat gestartet! §5Viel Glück!"); | |
130 | ||
131 | ||
132 | for(Player red : plugin.red) { | |
133 | File file = new File("plugins/PartyPvP/", "Red-Point.yml"); | |
134 | FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); | |
135 | String world = cfg.getString("red.World"); | |
136 | double x = cfg.getDouble("red.X"); | |
137 | double y = cfg.getDouble("red.Y"); | |
138 | double z = cfg.getDouble("red.Z"); | |
139 | double yaw = cfg.getDouble("red.Yaw"); | |
140 | double pitch = cfg.getDouble("red.Pitch"); | |
141 | ||
142 | Location loc = new Location(Bukkit.getWorld(world), x, y, z); | |
143 | loc.setPitch((float)pitch); | |
144 | loc.setYaw((float)yaw); | |
145 | ||
146 | red.teleport(loc); | |
147 | Items(red); | |
148 | red.setGameMode(GameMode.ADVENTURE); | |
149 | ||
150 | ||
151 | } | |
152 | ||
153 | for(Player blue : plugin.blue) { | |
154 | File file = new File("plugins/PartyPvP/", "Blue-Point.yml"); | |
155 | FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); | |
156 | String world = cfg.getString("blue.World"); | |
157 | double x = cfg.getDouble("blue.X"); | |
158 | double y = cfg.getDouble("blue.Y"); | |
159 | double z = cfg.getDouble("blue.Z"); | |
160 | double yaw = cfg.getDouble("blue.Yaw"); | |
161 | double pitch = cfg.getDouble("blue.Pitch"); | |
162 | ||
163 | Location loc = new Location(Bukkit.getWorld(world), x, y, z); | |
164 | loc.setPitch((float)pitch); | |
165 | loc.setYaw((float)yaw); | |
166 | ||
167 | blue.teleport(loc); | |
168 | Items(blue); | |
169 | blue.setGameMode(GameMode.ADVENTURE); | |
170 | ||
171 | ||
172 | } | |
173 | ||
174 | for(Player green : plugin.green) { | |
175 | File file = new File("plugins/PartyPvP/", "Green-Point.yml"); | |
176 | FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); | |
177 | String world = cfg.getString("green.World"); | |
178 | double x = cfg.getDouble("green.X"); | |
179 | double y = cfg.getDouble("green.Y"); | |
180 | double z = cfg.getDouble("green.Z"); | |
181 | double yaw = cfg.getDouble("green.Yaw"); | |
182 | double pitch = cfg.getDouble("green.Pitch"); | |
183 | ||
184 | Location loc = new Location(Bukkit.getWorld(world), x, y, z); | |
185 | loc.setPitch((float)pitch); | |
186 | loc.setYaw((float)yaw); | |
187 | ||
188 | green.teleport(loc); | |
189 | Items(green); | |
190 | green.setGameMode(GameMode.ADVENTURE); | |
191 | ||
192 | ||
193 | } | |
194 | ||
195 | for(Player yellow : plugin.yellow) { | |
196 | File file = new File("plugins/PartyPvP/", "Yellow-Point.yml"); | |
197 | FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); | |
198 | String world = cfg.getString("yellow.World"); | |
199 | double x = cfg.getDouble("yellow.X"); | |
200 | double y = cfg.getDouble("yellow.Y"); | |
201 | double z = cfg.getDouble("yellow.Z"); | |
202 | double yaw = cfg.getDouble("yellow.Yaw"); | |
203 | double pitch = cfg.getDouble("yellow.Pitch"); | |
204 | ||
205 | Location loc = new Location(Bukkit.getWorld(world), x, y, z); | |
206 | loc.setPitch((float)pitch); | |
207 | loc.setYaw((float)yaw); | |
208 | ||
209 | yellow.teleport(loc); | |
210 | Items(yellow); | |
211 | yellow.setGameMode(GameMode.ADVENTURE); | |
212 | ||
213 | } | |
214 | ||
215 | ||
216 | ||
217 | } | |
218 | ||
219 | ||
220 | ||
221 | - | }, 20, 20); |
221 | + | |
222 | } | |
223 | ||
224 | }, 0, 20); | |
225 | } | |
226 | ||
227 | ||
228 | } | |
229 | } | |
230 | ||
231 | } |