Skip to content
This repository
Browse code

Bugfixes.

  • Loading branch information...
commit 52b574a7b93ee46091385fb33e20ab8f048ec136 1 parent 2e40de7
ibhh authored
4 src/config.yml
@@ -11,10 +11,10 @@ command:
11 11 de: Du kannst maximal %1$d Geld in %2$d XP umwandeln.
12 12 en: You can change maximal %1$d money into %2$d XP.
13 13 notenoughmoney:
14   - de: Du hast nicht gengend Geld!
  14 + de: Du hast nicht genuegend Geld!
15 15 en: Not enough money!
16 16 notenoughxp:
17   - de: Du hast nicht gengend XP!
  17 + de: Du hast nicht genuegend XP!
18 18 en: Not enough XP!
19 19 else:
20 20 de: Unbekannter Error!
119 src/me/ibhh/xpShop/xpShop.java
@@ -6,7 +6,6 @@
6 6 import java.io.InputStreamReader;
7 7 import java.net.URL;
8 8 import java.net.URLConnection;
9   -import java.util.List;
10 9
11 10 //import net.milkbowl.vault.Vault;
12 11 //import net.milkbowl.vault.economy.Economy;
@@ -14,6 +13,7 @@
14 13
15 14 import org.bukkit.Bukkit;
16 15 import org.bukkit.ChatColor;
  16 +import org.bukkit.OfflinePlayer;
17 17 import org.bukkit.command.Command;
18 18 import org.bukkit.command.CommandSender;
19 19 import org.bukkit.entity.Player;
@@ -29,7 +29,6 @@
29 29
30 30 import com.iConomy.iConomy;
31 31 import com.iConomy.system.Account;
32   -import com.iConomy.system.Holdings;
33 32
34 33 import com.nijikokun.register.payment.Methods;
35 34
@@ -38,7 +37,7 @@
38 37
39 38
40 39 private String ActionxpShop;
41   - private Holdings balance5;
  40 + private com.iConomy.system.Holdings balance5;
42 41 private Double balance;
43 42 private int buy;
44 43 private int sell;
@@ -442,13 +441,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
442 441 }
443 442
444 443
445   - // }
446   - // else
447   - // {
448   - // System.out.println("JRE Error!");
449   - // }
450   - // }
451   - }
  444 + // }
  445 + // else
  446 + // {
  447 + // System.out.println("JRE Error!");
  448 + // }
  449 + // }
  450 + }
452 451 } //if (cmd.getName().equalsIgnoreCase("xpShop"))
453 452 } //if (sender instanceof Player)
454 453 else
@@ -473,13 +472,8 @@ protected static boolean isConsole(CommandSender sender) {
473 472 protected static Player getPlayer(CommandSender sender, String[] args, int index)
474 473 {
475 474 if (args.length > index) {
476   - List<Player> players = sender.getServer().matchPlayer(args[index]);
477   -
478   - if (players.isEmpty()) {
479   - sender.sendMessage("Could not find player with the name: " + args[index]);
480   - return null;
481   - }
482   - return (Player)players.get(0);
  475 + OfflinePlayer players = sender.getServer().getOfflinePlayer(args[index]);
  476 + return (Player)players.getPlayer();
483 477 }
484 478
485 479 if (isConsole(sender)) {
@@ -488,29 +482,39 @@ protected static Player getPlayer(CommandSender sender, String[] args, int index
488 482 return (Player)sender;
489 483 }
490 484
  485 + // protected static Player getPlayer(CommandSender sender, String[] args, int index)
  486 + // {
  487 + // if (args.length > index) {
  488 + // List<Player> players = sender.getServer().matchPlayer(args[index]);
  489 + //
  490 + // if (players.isEmpty()) {
  491 + // sender.sendMessage("Could not find player with the name: " + args[index]);
  492 + // return null;
  493 + // }
  494 + // return (Player)players.get(0);
  495 + // }
  496 + //
  497 + // if (isConsole(sender)) {
  498 + // return null;
  499 + // }
  500 + // return (Player)sender;
  501 + // }
  502 +
491 503 public void sendxp(CommandSender sender, int giveamount, String empfaenger, String[] args)
492 504 {
493 505 Player player = (Player) sender;
494 506 try{
495   - if(getPlayer(sender, args, 1).hasPlayedBefore())
  507 + Player empfaenger1 = (Player) getPlayer(sender, args, 1);
  508 + sell(sender, giveamount, false, "sendxp"); //Trys to substract amount, else stop.
  509 + buy(empfaenger1, SubstractedXP, false, "sentxp"); //Gives other player XP wich were substracted.
  510 + try
496 511 {
497   - Player empfaenger1 = (Player) getPlayer(sender, args, 1);
498   - sell(sender, giveamount, false, "sentxp"); //Trys to substract amount, else stop.
499   - buy(empfaenger1, SubstractedXP, false, "sentxp"); //Gives other player XP wich were substracted.
500   - try
501   - {
502   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("command.success." + "sentxp" + "." + getConfig().getString("language")), SubstractedXP, args[1] ));
503   - empfaenger1.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("command.success." + "recievedxp" + "." + getConfig().getString("language")), SubstractedXP, args[1]));
504   - }
505   - catch (NullPointerException e)
506   - {
507   - player.sendMessage("Error!");
508   - }
  512 + player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("command.success." + "sentxp" + "." + getConfig().getString("language")), SubstractedXP, args[1] ));
  513 + empfaenger1.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("command.success." + "recievedxp" + "." + getConfig().getString("language")), SubstractedXP, sender.getName()));
509 514 }
510   - else
  515 + catch (NullPointerException e)
511 516 {
512   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + "Player doesnt exist!");
513   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + "Player may should leave and join the game.");
  517 + player.sendMessage("Error!");
514 518 }
515 519 }
516 520 catch (Exception e) {
@@ -572,17 +576,8 @@ public void infolevel(CommandSender sender, String[] args)
572 576 else if(args.length == 2)
573 577 {
574 578 try{
575   - if(getPlayer(sender, args, 1).hasPlayedBefore())
576   - {
577   - Player empfaenger1 = (Player) getPlayer(sender, args, 1);
578   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("info.otherLevel." + getConfig().getString("language")), empfaenger1.getName(), empfaenger1.getLevel()));
579   -
580   - }
581   - else
582   - {
583   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + "Player doesnt exist!");
584   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + "Player may should leave and join the game.");
585   - }
  579 + Player empfaenger1 = (Player) getPlayer(sender, args, 1);
  580 + player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("info.otherLevel." + getConfig().getString("language")), empfaenger1.getName(), empfaenger1.getLevel()));
586 581 }
587 582 catch(Exception e)
588 583 {
@@ -602,17 +597,8 @@ else if(args.length == 2)
602 597 {
603 598 try
604 599 {
605   - if(getPlayer(sender, args, 1).hasPlayedBefore())
606   - {
607   - Player empfaenger1 = (Player) getPlayer(sender, args, 1);
608   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("info.otherXP." + getConfig().getString("language")), empfaenger1.getName(), (int) getTOTALXP(empfaenger1)));
609   -
610   - }
611   - else
612   - {
613   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + "Player doesnt exist!");
614   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + "Player may should leave and join the game.");
615   - }
  600 + Player empfaenger1 = (Player) getPlayer(sender, args, 1);
  601 + player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + String.format(getConfig().getString("info.otherXP." + getConfig().getString("language")), empfaenger1.getName(), (int) getTOTALXP(empfaenger1)));
616 602 }
617 603 catch (Exception e)
618 604 {
@@ -640,7 +626,24 @@ public boolean buy(CommandSender sender, int buyamount, boolean moneyactive, Str
640 626 }
641 627 return false;
642 628 }
643   - if(getBalance156(player) >= TOTALXPDOUBLE)
  629 + boolean valid;
  630 + valid = false;
  631 + if(moneyactive)
  632 + {
  633 + if(getBalance156(player) >= TOTALXPDOUBLE)
  634 + {
  635 + valid = true;
  636 + }
  637 + else
  638 + {
  639 + player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + (getConfig().getString("command.error.notenoughmoney." + getConfig().getString("language"))));
  640 + }
  641 + }
  642 + else if(von.equals("sendxp"))
  643 + {
  644 + valid = true;
  645 + }
  646 + if(valid)
644 647 {
645 648 if(buyamount > 0)
646 649 {
@@ -669,10 +672,6 @@ else if (ActionxpShop.equalsIgnoreCase("info") && von.equals("buylevel") == fals
669 672 }
670 673 player.saveData();
671 674 return true;
672   - } //if (Balance >= money)
673   - else
674   - {
675   - player.sendMessage(ChatColor.GRAY + "[xpShop] " + ChatColor.RED + (getConfig().getString("command.error.notenoughmoney." + getConfig().getString("language"))));
676 675 }
677 676 return false;
678 677 }
2  src/plugin.yml
... ... @@ -1,5 +1,5 @@
1 1 name: xpShop
2   -version: 2.2
  2 +version: 2.6
3 3 description: Player can buy xp
4 4 author: ibhh
5 5 website: http://www.ibhh.de

0 comments on commit 52b574a

Please sign in to comment.
Something went wrong with that request. Please try again.