Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.79 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Effect;
  7. import org.bukkit.Material;
  8. import org.bukkit.Sound;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandSender;
  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.entity.EntityDamageEvent;
  16. import org.bukkit.event.player.PlayerMoveEvent;
  17. import org.bukkit.plugin.Plugin;
  18. import org.bukkit.plugin.java.JavaPlugin;
  19. import org.bukkit.util.Vector;
  20.  
  21. public class JumpPads extends JavaPlugin implements Listener {
  22. static String prefix = "";
  23.  
  24. static int on = 0;
  25.  
  26. static int a = 0;
  27.  
  28. static int b = 1;
  29.  
  30. static int JumpPads = 0;
  31.  
  32. static int c = 3;
  33.  
  34. static int JumpPadsweite = 0;
  35.  
  36. static int JumpPadsh = 0;
  37.  
  38. static int d = 0;
  39.  
  40. static String e = "true";
  41.  
  42. static int JumpPadplate = 0;
  43.  
  44. static int JumpPadNoFallDamage = 0;
  45.  
  46. public void onEnable() {
  47. getJumpPads(null);
  48. if (JumpPads == 0)
  49. on = 0;
  50. if (JumpPads == 1)
  51. on = 1;
  52. getServer().getPluginManager().registerEvents(this, (Plugin)this);
  53. System.out.println("[JumpPads] Plugin erfolgreich aktiviert!");
  54. }
  55.  
  56. public void onDisable() {
  57. System.out.println("[JumpPads] Plugin erfolgreich deaktiviert!");
  58. }
  59.  
  60. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  61. Player p = (Player)sender;
  62. if (sender instanceof org.bukkit.command.ConsoleCommandSender) {
  63. sender.sendMessage("kannst du nur als Spieler");
  64. return true;
  65. }
  66. if (cmd.getName().equalsIgnoreCase("JumpPads")) {
  67. if (args.length == 0 &&
  68. p.hasPermission("JumpPads.configuration")) {
  69. p.sendMessage(String.valueOf(prefix) + "on die JumpPads an.");
  70. p.sendMessage(String.valueOf(prefix) + "off die JumpPads aus.");
  71. p.sendMessage(String.valueOf(prefix) + "Configuration eine Configurations Config.");
  72. }
  73. if (args.length == 1) {
  74. if (p.hasPermission("JumpPads.configuration") &&
  75. args[0].equalsIgnoreCase("Configuration")) {
  76. p.sendMessage(String.valueOf(prefix) + "Du hast Erfolgreich die Configurations-Config Ergestellt. Du kannst sie nun im Plugins Ordner bearbeiten.");
  77. setJumpPadsPlate(p);
  78. setJumpPadsLarge(p);
  79. setNoFallDamage(p);
  80. }
  81. if (p.hasPermission("JumpPads.configuration")) {
  82. if (args[0].equalsIgnoreCase("on"))
  83. if (on == 1) {
  84. p.sendMessage(String.valueOf(prefix) + "Du hast Erfolgreich die JumpPads );
  85. on = 0;
  86. setJumpPads(p);
  87. } else {
  88. p.sendMessage(String.valueOf(prefix) + "JumpPads sind schon );
  89. }
  90. if (args[0].equalsIgnoreCase("off"))
  91. if (on == 0) {
  92. p.sendMessage(String.valueOf(prefix) + "Du hast Erfolgreich die JumpPads );
  93. on = 1;
  94. setJumpPads(p);
  95. } else {
  96. p.sendMessage(String.valueOf(prefix) + "JumpPads sind schon );
  97. }
  98. }
  99. }
  100. }
  101. return false;
  102. }
  103.  
  104. @EventHandler
  105. public void onFallDamageEvent(EntityDamageEvent e) {
  106. getNoFallDamage(null);
  107. if (JumpPadNoFallDamage == 0)
  108. e.setCancelled(true);
  109. }
  110.  
  111. @EventHandler
  112. public void onMove(PlayerMoveEvent e) {
  113. Player p = e.getPlayer();
  114. getJumpPadsPlate(p);
  115. getJumpPadsLarge(p);
  116. if (JumpPadsweite > 5)
  117. Bukkit.broadcastMessage(String.valueOf(prefix) + "JumpPadsweite darf h5 betragen.");
  118. if (JumpPadsh > 5)
  119. Bukkit.broadcastMessage(String.valueOf(prefix) + "JumpPadshdarf h5 betragen.");
  120. if (JumpPadplate > 1)
  121. Bukkit.broadcastMessage(String.valueOf(prefix) + "in der Config eine Druckplatte von 0-1 W0 = Golddruckplatte 1 = Eisendruckplatte.");
  122. if (JumpPadplate == 1 &&
  123. p.getLocation().getBlock().getType() == Material.STONE_PLATE) {
  124. getJumpPads(p);
  125. getJumpPadsLarge(p);
  126. if (on == 0) {
  127. if (JumpPadsweite == 1 || JumpPadsh == 1) {
  128. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(1.0D);
  129. p.setVelocity(v);
  130. }
  131. if (JumpPadsweite == 1 || JumpPadsh == 2) {
  132. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(2.0D);
  133. p.setVelocity(v);
  134. }
  135. if (JumpPadsweite == 1 || JumpPadsh == 3) {
  136. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(3.0D);
  137. p.setVelocity(v);
  138. }
  139. if (JumpPadsweite == 1 || JumpPadsh == 4) {
  140. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(4.0D);
  141. p.setVelocity(v);
  142. }
  143. if (JumpPadsweite == 1 || JumpPadsh == 5) {
  144. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(5.0D);
  145. p.setVelocity(v);
  146. }
  147. if (JumpPadsweite == 2 || JumpPadsh == 1) {
  148. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(1.0D);
  149. p.setVelocity(v);
  150. }
  151. if (JumpPadsweite == 2 || JumpPadsh == 2) {
  152. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(2.0D);
  153. p.setVelocity(v);
  154. }
  155. if (JumpPadsweite == 2 || JumpPadsh == 3) {
  156. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(3.0D);
  157. p.setVelocity(v);
  158. }
  159. if (JumpPadsweite == 2 || JumpPadsh == 4) {
  160. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(4.0D);
  161. p.setVelocity(v);
  162. }
  163. if (JumpPadsweite == 2 || JumpPadsh == 5) {
  164. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(5.0D);
  165. p.setVelocity(v);
  166. }
  167. if (JumpPadsweite == 3 || JumpPadsh == 1) {
  168. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(1.0D);
  169. p.setVelocity(v);
  170. }
  171. if (JumpPadsweite == 3 || JumpPadsh == 2) {
  172. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(2.0D);
  173. p.setVelocity(v);
  174. }
  175. if (JumpPadsweite == 3 || JumpPadsh == 3) {
  176. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(3.0D);
  177. p.setVelocity(v);
  178. }
  179. if (JumpPadsweite == 3 || JumpPadsh == 4) {
  180. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(4.0D);
  181. p.setVelocity(v);
  182. }
  183. if (JumpPadsweite == 3 || JumpPadsh == 5) {
  184. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(5.0D);
  185. p.setVelocity(v);
  186. }
  187. if (JumpPadsweite == 4 || JumpPadsh == 1) {
  188. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(1.0D);
  189. p.setVelocity(v);
  190. }
  191. if (JumpPadsweite == 4 || JumpPadsh == 2) {
  192. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(2.0D);
  193. p.setVelocity(v);
  194. }
  195. if (JumpPadsweite == 4 || JumpPadsh == 3) {
  196. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(3.0D);
  197. p.setVelocity(v);
  198. }
  199. if (JumpPadsweite == 4 || JumpPadsh == 4) {
  200. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(4.0D);
  201. p.setVelocity(v);
  202. }
  203. if (JumpPadsweite == 4 || JumpPadsh == 5) {
  204. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(5.0D);
  205. p.setVelocity(v);
  206. }
  207. if (JumpPadsweite == 5 || JumpPadsh == 1) {
  208. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(1.0D);
  209. p.setVelocity(v);
  210. }
  211. if (JumpPadsweite == 5 || JumpPadsh == 2) {
  212. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(2.0D);
  213. p.setVelocity(v);
  214. }
  215. if (JumpPadsweite == 5 || JumpPadsh == 3) {
  216. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(3.0D);
  217. p.setVelocity(v);
  218. }
  219. if (JumpPadsweite == 5 || JumpPadsh == 4) {
  220. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(4.0D);
  221. p.setVelocity(v);
  222. }
  223. if (JumpPadsweite == 5 || JumpPadsh == 5) {
  224. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(5.0D);
  225. p.setVelocity(v);
  226. }
  227. p.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 3);
  228. p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 3.0F, 2.0F);
  229. } else {
  230. p.sendMessage(String.valueOf(prefix) + "Die JumpPads sind );
  231. }
  232. }
  233. getJumpPadsPlate(p);
  234. if (JumpPadplate == 0 &&
  235. p.getLocation().getBlock().getType() == Material.GOLD_PLATE) {
  236. getJumpPads(p);
  237. if (on == 0) {
  238. getJumpPadsLarge(p);
  239. if (JumpPadsweite == 1 || JumpPadsh == 1) {
  240. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(1.0D);
  241. p.setVelocity(v);
  242. }
  243. if (JumpPadsweite == 1 || JumpPadsh == 2) {
  244. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(2.0D);
  245. p.setVelocity(v);
  246. }
  247. if (JumpPadsweite == 1 || JumpPadsh == 3) {
  248. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(3.0D);
  249. p.setVelocity(v);
  250. }
  251. if (JumpPadsweite == 1 || JumpPadsh == 4) {
  252. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(4.0D);
  253. p.setVelocity(v);
  254. }
  255. if (JumpPadsweite == 1 || JumpPadsh == 5) {
  256. Vector v = p.getLocation().getDirection().multiply(1.0D).setY(5.0D);
  257. p.setVelocity(v);
  258. }
  259. if (JumpPadsweite == 2 || JumpPadsh == 1) {
  260. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(1.0D);
  261. p.setVelocity(v);
  262. }
  263. if (JumpPadsweite == 2 || JumpPadsh == 2) {
  264. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(2.0D);
  265. p.setVelocity(v);
  266. }
  267. if (JumpPadsweite == 2 || JumpPadsh == 3) {
  268. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(3.0D);
  269. p.setVelocity(v);
  270. }
  271. if (JumpPadsweite == 2 || JumpPadsh == 4) {
  272. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(4.0D);
  273. p.setVelocity(v);
  274. }
  275. if (JumpPadsweite == 2 || JumpPadsh == 5) {
  276. Vector v = p.getLocation().getDirection().multiply(2.0D).setY(5.0D);
  277. p.setVelocity(v);
  278. }
  279. if (JumpPadsweite == 3 || JumpPadsh == 1) {
  280. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(1.0D);
  281. p.setVelocity(v);
  282. }
  283. if (JumpPadsweite == 3 || JumpPadsh == 2) {
  284. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(2.0D);
  285. p.setVelocity(v);
  286. }
  287. if (JumpPadsweite == 3 || JumpPadsh == 3) {
  288. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(3.0D);
  289. p.setVelocity(v);
  290. }
  291. if (JumpPadsweite == 3 || JumpPadsh == 4) {
  292. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(4.0D);
  293. p.setVelocity(v);
  294. }
  295. if (JumpPadsweite == 3 || JumpPadsh == 5) {
  296. Vector v = p.getLocation().getDirection().multiply(3.0D).setY(5.0D);
  297. p.setVelocity(v);
  298. }
  299. if (JumpPadsweite == 4 || JumpPadsh == 1) {
  300. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(1.0D);
  301. p.setVelocity(v);
  302. }
  303. if (JumpPadsweite == 4 || JumpPadsh == 2) {
  304. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(2.0D);
  305. p.setVelocity(v);
  306. }
  307. if (JumpPadsweite == 4 || JumpPadsh == 3) {
  308. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(3.0D);
  309. p.setVelocity(v);
  310. }
  311. if (JumpPadsweite == 4 || JumpPadsh == 4) {
  312. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(4.0D);
  313. p.setVelocity(v);
  314. }
  315. if (JumpPadsweite == 4 || JumpPadsh == 5) {
  316. Vector v = p.getLocation().getDirection().multiply(4.0D).setY(5.0D);
  317. p.setVelocity(v);
  318. }
  319. if (JumpPadsweite == 5 || JumpPadsh == 1) {
  320. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(1.0D);
  321. p.setVelocity(v);
  322. }
  323. if (JumpPadsweite == 5 || JumpPadsh == 2) {
  324. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(2.0D);
  325. p.setVelocity(v);
  326. }
  327. if (JumpPadsweite == 5 || JumpPadsh == 3) {
  328. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(3.0D);
  329. p.setVelocity(v);
  330. }
  331. if (JumpPadsweite == 5 || JumpPadsh == 4) {
  332. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(4.0D);
  333. p.setVelocity(v);
  334. }
  335. if (JumpPadsweite == 5 || JumpPadsh == 5) {
  336. Vector v = p.getLocation().getDirection().multiply(5.0D).setY(5.0D);
  337. p.setVelocity(v);
  338. }
  339. p.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 3);
  340. p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 3.0F, 2.0F);
  341. } else {
  342. p.sendMessage(String.valueOf(prefix) + "Die JumpPads sind );
  343. }
  344. }
  345. }
  346.  
  347. public static void setJumpPads(Player p) {
  348. File ordner = new File("plugins//JumpPads");
  349. File file = new File("plugins//JumpPads//JumpPads.yml");
  350. if (!ordner.exists())
  351. ordner.mkdir();
  352. if (!file.exists())
  353. try {
  354. file.createNewFile();
  355. } catch (IOException e) {
  356. p.sendMessage(String.valueOf(prefix) + "Datei konnte auf dem Pfad nicht erstellt werden");
  357. }
  358. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  359. if (on == 0)
  360. cfg.set("JumpPads", Integer.valueOf(a));
  361. if (on == 1)
  362. cfg.set("JumpPads", Integer.valueOf(b));
  363. try {
  364. cfg.save(file);
  365. } catch (IOException e) {
  366. p.sendMessage(String.valueOf(prefix) + "konnte der angegebene Pfad nicht gefunden werde.");
  367. }
  368. }
  369.  
  370. public static void getJumpPads(Player p) {
  371. File file = new File("plugins//JumpPads//JumpPads.yml");
  372. if (!file.exists())
  373. return;
  374. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  375. double a = cfg.getDouble("JumpPads");
  376. JumpPads = (int)a;
  377. }
  378.  
  379. public static void setJumpPadsLarge(Player p) {
  380. File ordner = new File("plugins//JumpPads");
  381. File file = new File("plugins//JumpPads//Configuration.yml");
  382. if (!ordner.exists())
  383. ordner.mkdir();
  384. if (!file.exists())
  385. try {
  386. file.createNewFile();
  387. } catch (IOException e) {
  388. p.sendMessage(String.valueOf(prefix) + "Datei konnte auf dem Pfad nicht erstellt werden");
  389. }
  390. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  391. cfg.set("Weite", Integer.valueOf(c));
  392. cfg.set("Hoehe", Integer.valueOf(c));
  393. try {
  394. cfg.save(file);
  395. } catch (IOException e) {
  396. p.sendMessage(String.valueOf(prefix) + "konnte der angegebene Pfad nicht gefunden werde.");
  397. }
  398. }
  399.  
  400. public static void getJumpPadsLarge(Player p) {
  401. File file = new File("plugins//JumpPads//Configuration.yml");
  402. if (!file.exists())
  403. return;
  404. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  405. double Coins1 = cfg.getDouble("Weite");
  406. double Coins2 = cfg.getDouble("Hoehe");
  407. JumpPadsweite = (int)Coins1;
  408. JumpPadsh = (int)Coins2;
  409. }
  410.  
  411. public static void setJumpPadsPlate(Player p) {
  412. File ordner = new File("plugins//JumpPads");
  413. File file = new File("plugins//JumpPads//Druckplatte.yml");
  414. if (!ordner.exists())
  415. ordner.mkdir();
  416. if (!file.exists())
  417. try {
  418. file.createNewFile();
  419. } catch (IOException e) {
  420. p.sendMessage(String.valueOf(prefix) + "Datei konnte auf dem Pfad nicht erstellt werden");
  421. }
  422. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  423. cfg.set("Druckplatte", "GOLD_PLATE");
  424. try {
  425. cfg.save(file);
  426. } catch (IOException e) {
  427. p.sendMessage(String.valueOf(prefix) + "konnte der angegebene Pfad nicht gefunden werde.");
  428. }
  429. }
  430.  
  431. public static void getJumpPadsPlate(Player p) {
  432. File file = new File("plugins//JumpPads//Druckplatte.yml");
  433. if (!file.exists())
  434. return;
  435. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  436. String Druckplatte = cfg.getString("Druckplatte");
  437. if (Druckplatte == "GOLD_PLATE")
  438. JumpPadplate = 0;
  439. if (Druckplatte == "STONE_PLATE")
  440. JumpPadplate = 1;
  441. }
  442.  
  443. public static void setNoFallDamage(Player p) {
  444. File ordner = new File("plugins//JumpPads");
  445. File file = new File("plugins//JumpPads//NoFallDamage.yml");
  446. if (!ordner.exists())
  447. ordner.mkdir();
  448. if (!file.exists())
  449. try {
  450. file.createNewFile();
  451. } catch (IOException e) {
  452. p.sendMessage(String.valueOf(prefix) + "Datei konnte auf dem Pfad nicht erstellt werden");
  453. }
  454. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  455. cfg.set("NoFallDamage", "true");
  456. try {
  457. cfg.save(file);
  458. } catch (IOException e) {
  459. p.sendMessage(String.valueOf(prefix) + "konnte der angegebene Pfad nicht gefunden werde.");
  460. }
  461. }
  462.  
  463. public static void getNoFallDamage(Player p) {
  464. File file = new File("plugins//JumpPads//NoFallDamage.yml");
  465. if (!file.exists())
  466. return;
  467. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  468. String b = cfg.getString("NoFallDamage");
  469. if (b == "true")
  470. JumpPadNoFallDamage = 0;
  471. if (b == "false")
  472. JumpPadNoFallDamage = 1;
  473. }
  474. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement