Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Problem z pluginem na drop


SkredoX

Rekomendowane odpowiedzi

Opublikowano

Witam, mam problem z moim pluginem na drop. Po próbie otworzenia GUI odpowiedzialnego za wyświetlenie dropu ze stone, wyskakują następujące logi:

 

[20:30:03 ERROR]: Could not pass event InventoryClickEvent to sxDrop v1.0
org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[server.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [server.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1630) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:31) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:9) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-db6de12-18fbb24]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_131]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: java.lang.NullPointerException
at pl.skredox.sxDrop.gui.DropGuiItem.<init>(DropGuiItem.java:22) ~[?:?]
at pl.skredox.sxDrop.gui.DropGuiMenu.<init>(DropGuiMenu.java:16) ~[?:?]
at pl.skredox.sxDrop.listeners.InventoryClickListener.onClick(InventoryClickListener.java:34) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-db6de12-18fbb24]
... 15 more


Klasa DropGuiItem

 

	  private final Drop drop;
	  private final DropGuiMenu menu;
	  
	  public DropGuiItem(Drop drop, DropGuiMenu menu)
	  {
	    super(drop.getName(), drop.getItem(), new String[0]);
	    this.drop = drop;
	    this.menu = menu;
	  }
	  
	  public ItemStack getFinalIcon(Player viever)
	  {
	    ItemStack icon = getIcon().clone();
	    ItemMeta meta = icon.getItemMeta();
	    meta.setDisplayName(Util.fixColor(this.drop.getName()));
	    @SuppressWarnings({ "rawtypes", "unchecked" })
		List<String> lores = new ArrayList();
	    for (String lore : Config.GUI_ICON_LORE) {
	      lores.add(MessagesUtil.replace(lore, this.drop, viever));
	    }
	    meta.setLore(Util.fixColor(lores));
	    icon.setItemMeta(meta);
	    return icon;
	  }
	  
	  public void onItemClick(ItemClickEvent event)
	  {
	    this.drop.changeStatus(event.getPlayer().getName());
	    this.menu.update(event.getPlayer());
	    if (Config.GUI_CLOSE$AFTER$CLICK) {
	      event.setWillClose(true);
	    }
	  }


Klasa DropGuiMenu

 

	  public DropGuiMenu()
	  {
	    super(Util.fixColor(Config.GUI_NAME), GuiMenu.Size.fit(Main.getPlugin().getDropManager().getRandomDrops().size()));
	    int pos = 0;
	    for (Drop drop : getDropManager().getRandomDrops())
	    {
	      setItem(pos, new DropGuiItem(drop, this));
	      pos++;
	    }
	  }


Klasa InventoryClickListener

 

	 @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
	 public void onClick(InventoryClickEvent e) {
		 if(Util.fixColor("&8» &cDROP NA SERWERZE").equalsIgnoreCase(e.getInventory().getName())) {
			 e.setCancelled(true);
			 ItemStack item = e.getCurrentItem();
			 if(item != null) {
				 ItemMeta meta = item.getItemMeta();
				 if(meta != null) {
					 Player p = (Player)e.getWhoClicked();
					 Inventory inv = p.getInventory();
					 if(inv != null) {
						 if ((meta.getDisplayName() != null) && (meta.getDisplayName().equals(Util.fixColor("&cDrop ze &7&lSTONE&c!")))) {
							 p.closeInventory();
							 new DropGuiMenu().open(p);
							 e.setCancelled(true);
						 }
						 if ((meta.getDisplayName() != null) && (meta.getDisplayName().equals(Util.fixColor("&cDrop z &7&lPANDORY&c!")))) {
							 p.closeInventory();
							 PandoraDropUtil.pandoradrop(p);
							 e.setCancelled(true);
						 }
						 if ((meta.getDisplayName() != null) && (meta.getDisplayName().equals(Util.fixColor("&cDrop z &7&lSKRZYNKI&c!")))) {
							 p.closeInventory();
							 CaseDropUtil.casedrop(p);
							 e.setCancelled(true);
						 }
					 }
				 }
			 }
		 }
		    if (((e.getWhoClicked() instanceof Player)) && ((e.getInventory().getHolder() instanceof GuiHolder)))
		    {
		      e.setCancelled(true);
		      ((GuiHolder)e.getInventory().getHolder()).getMenu().onInventoryClick(e);
		    }
	 }


Bardzo proszę o pomoc.

Opublikowano

wiec tak, 1. nie twoj plugin, kazdy plugin edytujesz i tutaj wrzucasz problemy z nim..

2.

Caused by: java.lang.NullPointerException
at pl.skredox.sxDrop.gui.DropGuiItem.<init>(DropGuiItem.java:22) ~[?:?]
at pl.skredox.sxDrop.gui.DropGuiMenu.<init>(DropGuiMenu.java:16) ~[?:?]
at pl.skredox.sxDrop.listeners.InventoryClickListener.onClick(InventoryClickListener.java:34) ~[?:?]

 

nie bedziemy zgadywac ktora linijka jest czym.. Wiec prosilibysmy abys podal czym jest linijka 22 w klasie dropguiitem i 16 w klasie dropguimenu

 

Aktualnie interesuję się javą, powoli ogarniam java swing i awt, czasem bawię się HTML.

Opublikowano

Jak ja lubie takich 'koderów' którzy piszą kod i myślą 'a tutaj sobie pier*dolne 2 spacje, tutaj tab'a.. Hmm zostawie tutaj ten cast bo tak było w dekompilatorze a eclipse mi nie podświetla, że jest bezużyteczny'

Opublikowano
1 godzinę temu, ˈyøøniks napisał:

wiec tak, 1. nie twoj plugin, kazdy plugin edytujesz i tutaj wrzucasz problemy z nim..

2.


Caused by: java.lang.NullPointerException
at pl.skredox.sxDrop.gui.DropGuiItem.<init>(DropGuiItem.java:22) ~[?:?]
at pl.skredox.sxDrop.gui.DropGuiMenu.<init>(DropGuiMenu.java:16) ~[?:?]
at pl.skredox.sxDrop.listeners.InventoryClickListener.onClick(InventoryClickListener.java:34) ~[?:?]

 

nie bedziemy zgadywac ktora linijka jest czym.. Wiec prosilibysmy abys podal czym jest linijka 22 w klasie dropguiitem i 16 w klasie dropguimenu

22 linijka w klasie DropGuiItem:
 

super(drop.getName(), drop.getItem(), new String[0]);


16 linijka w klasie DropGuiMenu:
 

setItem(pos, new DropGuiItem(drop, this));

 

1 godzinę temu, __AHA__ napisał:

Jak ja lubie takich 'koderów' którzy piszą kod i myślą 'a tutaj sobie pier*dolne 2 spacje, tutaj tab'a.. Hmm zostawie tutaj ten cast bo tak było w dekompilatorze a eclipse mi nie podświetla, że jest bezużyteczny'


Nie wiem dlaczego zakładasz, że używam dekompilatora, ale ok, nie wnikam.

Opublikowano
8 minut temu, SkredoX napisał:

22 linijka w klasie DropGuiItem:
 


super(drop.getName(), drop.getItem(), new String[0]);


16 linijka w klasie DropGuiMenu:
 


setItem(pos, new DropGuiItem(drop, this));

 


Nie wiem dlaczego zakładasz, że używam dekompilatora, ale ok, nie wnikam.

Cytat

Nie wiem dlaczego zakładasz, że używam dekompilatora, ale ok, nie wnikam.

bo wszędzie jest niepotrzebny cast, troche niepotrzebnego kodu, zle wytabowany kod.

 

co do tematu

super(drop.getName(), drop.getItem(), new String[0]);

tu jest coś nullem, a najlepiej daj nam tu src, bo nie bedziemy tak cały czas po jednej klasie ci mówić..

 

Aktualnie interesuję się javą, powoli ogarniam java swing i awt, czasem bawię się HTML.

Opublikowano
20 minut temu, ˈyøøniks napisał:

bo wszędzie jest niepotrzebny cast, troche niepotrzebnego kodu, zle wytabowany kod.

 

co do tematu


super(drop.getName(), drop.getItem(), new String[0]);

tu jest coś nullem, a najlepiej daj nam tu src, bo nie bedziemy tak cały czas po jednej klasie ci mówić..

 

Wysylam wszystkie importy z klasy DropGuiItem:

Klasa Drop:

 

	  private final String name;
	  private final String permission;
	  private final ItemStack item;
	  private final String message;
	  private final double chance;
	  private final int exp;
	  private final boolean fortune;
	  private final boolean canDisable;
	  private final IntegerCompare height;
	  private final IntegerCompare amount;
	  private final IntegerCompare points;
	  
	  
	  public String getName()
	  {
	    return this.name;
	  }
	  
	  public String getPermission()
	  {
	    return this.permission;
	  }
	  
	  public ItemStack getItem()
	  {
	    return this.item;
	  }
	  
	  public String getMessage()
	  {
	    return this.message;
	  }
	  
	  public double getChance()
	  {
	    return this.chance;
	  }
	  
	  public int getExp()
	  {
	    return this.exp;
	  }
	  
	  public boolean isFortune()
	  {
	    return this.fortune;
	  }
	  
	  public boolean isCanDisable()
	  {
	    return this.canDisable;
	  }
	  
	  public IntegerCompare getHeight()
	  {
	    return this.height;
	  }
	  
	  public IntegerCompare getAmount()
	  {
	    return this.amount;
	  }
	  
	  public IntegerCompare getPoints()
	  {
	    return this.points;
	  }
	  
	  public List<Material> getTools()
	  {
	    return this.tools;
	  }
	  
	  public boolean canDrop(Player viewer)
	  {
	    return (this.permission == null) || (viewer.hasPermission(this.permission));
	  }
	  
	  @SuppressWarnings({ "rawtypes", "unchecked" })
	private final List<Material> tools = new ArrayList();
	  
	  public Set<String> getDisabled()
	  {
	    return this.disabled;
	  }
	  
	  @SuppressWarnings({ "rawtypes", "unchecked" })
	private final Set<String> disabled = new HashSet();
	  
	  public Drop(String name, String permission, ItemStack item, String message, double chance, int exp, boolean fortune, boolean canDisable, IntegerCompare height, IntegerCompare amount, IntegerCompare points, List<Material> tools)
	  {
	    this.name = name;
	    this.permission = permission;
	    this.item = item;
	    this.message = message;
	    this.chance = chance;
	    this.exp = exp;
	    this.fortune = fortune;
	    this.canDisable = canDisable;
	    this.height = height;
	    this.amount = amount;
	    this.points = points;
	    this.tools.addAll(tools);
	  }
	  
	  @SuppressWarnings({ "unchecked", "rawtypes" })
	public static Drop deserialize(Map<String, Object> map)
	  {
	    String name = null;
	    String permission = null;
	    ItemStack item = null;
	    String message = null;
	    double chance = 0.0D;
	    int exp = 0;
	    boolean fortune = false;
	    boolean canDisable = true;
	    IntegerCompare height = null;
	    IntegerCompare amount = null;
	    IntegerCompare points = null;
	    @SuppressWarnings({ })
		List<Material> tools = new ArrayList();
	    if (map.containsKey("name"))
	    {
	      name = (String)map.get("name");
	      if (name == null) {
	        throw new IllegalArgumentException("Name can not be null!");
	      }
	    }
	    if (map.containsKey("permission")) {
	      permission = (String)map.get("permission");
	    }
	    if (map.containsKey("item"))
	    {
	      item = ItemUtil.itemStackFromString((String)map.get("item"));
	      if (item == null) {
	        throw new IllegalArgumentException("Item can not be null!");
	      }
	    }
	    if (map.containsKey("message")) {
	      message = (String)map.get("message");
	    }
	    if (map.containsKey("chance")) {
	      chance = ((Double)map.get("chance")).doubleValue();
	    }
	    if (map.containsKey("exp")) {
	      exp = ((Integer)map.get("exp")).intValue();
	    }
	    if (map.containsKey("fortune")) {
	      fortune = ((Boolean)map.get("fortune")).booleanValue();
	    }
	    if (map.containsKey("can-disable")) {
	      canDisable = ((Boolean)map.get("can-disable")).booleanValue();
	    }
	    if (map.containsKey("height")) {
	      height = Compare.parseString((String)map.get("height"));
	    }
	    if (map.containsKey("amount")) {
	      amount = Compare.parseString((String)map.get("amount"));
	    }
	    if (map.containsKey("points")) {
	      points = Compare.parseString((String)map.get("points"));
	    }
	    if (map.containsKey("tools")) {
	      tools.addAll(ItemUtil.materialsFromStrings((List)map.get("tools")));
	    }
	    return new Drop(name, permission, item, message, chance, exp, fortune, canDisable, height, amount, points, tools);
	  }
	  
	  public double getChance(Player viewer)
	  {
	    double chance = getChance();
	    if ((Config.VIP$DROP_ENABLED & viewer.hasPermission(Config.VIP$DROP_PERMISSION))) {
	      chance += chance * Config.VIP$DROP_MULTIPLIER;
	    }
	    return chance;
	  }
	  
	  
	  public double getChanceBonus(String string)
	  {
	    if (!Config.BONUS$DROP_ENABLED) {
	      return 0.0D;
	    }
	    if (!this.canDisable) {
	      return 0.0D;
	    }
	    if (isDisabled(string)) {
	      return 0.0D;
	    }
	    List<Drop> drops = Main.getPlugin().getDropManager().getRandomDrops();
	    int disabledDrops = 0;
	    int dropsSize = drops.size();
	    double dropsChance = 0.0D;
	    double disabledDropsChance = 0.0D;
	    for (Drop drop : drops)
	    {
	      if (drop.isDisabled(string))
	      {
	        disabledDrops++;
	        disabledDropsChance += drop.getChance();
	      }
	      dropsChance += drop.getChance();
	    }
	    if (disabledDrops == 0) {
	      return 0.0D;
	    }
	    int deltaDrops = dropsSize - disabledDrops;
	    @SuppressWarnings("unused")
		double deltaChance = dropsChance - disabledDropsChance;
	    
	    return getChance() / deltaDrops * Config.BONUS$DROP_MULTIPLIER;
	  }
	  
	  public boolean isDisabled(String string)
	  {
	    if (!this.canDisable) {
	      return false;
	    }
	    return this.disabled.contains(string);
	  }
	  
	  public void changeStatus(String string)
	  {
	    if (!this.canDisable) {
	      return;
	    }
	    if (isDisabled(string)) {
	      this.disabled.remove(string);
	    } else {
	      this.disabled.add(string);
	    }
	  }
	  
	  public boolean enoughHeight(int height)
	  {
	    if (this.height == null) {
	      return true;
	    }
	    return this.height.isInRange(Integer.valueOf(height));
	  }
	  
	  public boolean enoughPickaxe(ItemStack item)
	  {
	    if (!ItemUtil.isPickaxe(item)) {
	      return false;
	    }
	    if (this.tools.size() < 1) {
	      return true;
	    }
	    return this.tools.contains(item.getType());
	  }
	  
	  public int getRandomAmount()
	  {
	    if (this.amount == null) {
	      return 1;
	    }
	    return Compare.getRandomValue(this.amount);
	  }
	  
	  public int getRandomPoints()
	  {
	    if (this.points == null) {
	      return 0;
	    }
	    return Compare.getRandomValue(this.points);
	  }
	  
	  public Map<String, Object> serialize()
	  {
	    System.out.println(this.permission + " :D");
	    @SuppressWarnings({ "rawtypes", "unchecked" })
		Map<String, Object> map = new LinkedHashMap();
	    map.put("name", this.name);
	    if (this.permission != null) {
	      map.put("permission", this.permission);
	    }
	    map.put("item", ItemUtil.itemStackToString(this.item));
	    if ((this.message != null) && (this.message.length() > 0)) {
	      map.put("message", this.message);
	    }
	    map.put("chance", Double.valueOf(this.chance));
	    if (this.exp > 0) {
	      map.put("exp", Integer.valueOf(this.exp));
	    }
	    map.put("fortune", Boolean.valueOf(this.fortune));
	    map.put("can-disable", Boolean.valueOf(this.canDisable));
	    if (this.height != null) {
	      map.put("height", this.height.getParse());
	    }
	    if (this.amount != null) {
	      map.put("amount", this.amount.getParse());
	    }
	    if (this.points != null) {
	      map.put("points", this.points.getParse());
	    }
	    map.put("tools", ItemUtil.materialsToStrings(this.tools));
	    return map;
	  }


Klasa Util:

 

	 public static String fixColor(String message)
	  {
	    return ChatColor.translateAlternateColorCodes('&', message);
	  }
	  
	  public static String[] fixColor(String[] s)
	  {
	    for (int i = 0; i < s.length; i++) {
	      s[i] = fixColor(s[i]);
	    }
	    return s;
	  }
	  
	  public static List<String> fixColor(List<String> s)
	  {
	    for (int i = 0; i < s.size(); i++)
	    {
	      String string = (String)s.get(i);
	      s.set(i, fixColor(string));
	    }
	    return s;
	  }
	  
	  public static boolean sendMsg(CommandSender sender, String message)
	  {
	    sender.sendMessage(fixColor(message));
	    return true;
	  }
	  
	  public static boolean sendMsg(Collection<? extends CommandSender> col, String message)
	  {
	    CommandSender cs;
	    for (@SuppressWarnings("rawtypes")
		Iterator i$ = col.iterator(); i$.hasNext(); sendMsg(cs, message)) {
	      cs = (CommandSender)i$.next();
	    }
	    return true;
	  }
	  
	  public static boolean sendMsg(CommandSender sender, Collection<String> messages)
	  {
	    String s;
	    for (@SuppressWarnings("rawtypes")
		Iterator i$ = messages.iterator(); i$.hasNext(); sendMsg(sender, s)) {
	      s = (String)i$.next();
	    }
	    return true;
	  }
	  
	  public static boolean sendMsg(Collection<? extends CommandSender> col, Collection<String> messages)
	  {
	    String s;
	    for (@SuppressWarnings("rawtypes")
		Iterator i$ = messages.iterator(); i$.hasNext(); sendMsg(col, s)) {
	      s = (String)i$.next();
	    }
	    return true;
	  }
	  
	  public static boolean sendMsg(CommandSender sender, String message, String permission)
	  {
	    if (!sender.hasPermission(permission)) {
	      return false;
	    }
	    return sendMsg(sender, message);
	  }
	  
	  public static boolean sendMsg(Collection<? extends CommandSender> col, String message, String permission)
	  {
	    for (CommandSender cs : col) {
	      if (cs.hasPermission(permission)) {
	        sendMsg(cs, message);
	      }
	    }
	    return true;
	  }
	  
	  public static boolean sendMsg(Collection<? extends CommandSender> col, Collection<String> messages, String permission)
	  {
	    for (CommandSender cs : col) {
	      if (cs.hasPermission(permission)) {
	        sendMsg(cs, messages);
	      }
	    }
	    return true;
	  }


Klasa MessagesUtil:

 

	 public static String replace(String source, Drop drop)
	  {
	    source = source.replace("{NAME}", drop.getName());
	    source = source.replace("{ITEM}", ItemUtil.itemStackToString(drop.getItem()));
	    source = source.replace("{MESSAGE}", (drop.getMessage() != null) && (drop.getMessage().length() > 0) ? drop.getMessage() : "");
	    source = source.replace("{CHANCE}", Double.toString(drop.getChance()));
	    source = source.replace("{EXP}", Integer.toString(drop.getExp()));
	    source = source.replace("{FORTUNE}", drop.isFortune() ? "tak" : "nie");
	    source = source.replace("{CAN_DISABLE}", drop.isCanDisable() ? "tak" : "nie");
	    source = source.replace("{HEIGHT}", drop.getHeight() != null ? drop.getHeight().getParse() : "wszedzie");
	    source = source.replace("{AMOUNT}", drop.getAmount() != null ? drop.getAmount().getParse() : "1");
	    source = source.replace("{POINTS}", drop.getPoints() != null ? drop.getPoints().getParse() : "0");
	    source = source.replace("{TOOLS}", drop.getTools().size() == 0 ? "wszystkim" : StringUtils.join(drop.getTools(), ", "));
	    return Util.fixColor(source);
	  }
	  
	  public static String replace(String source, Drop drop, Player player)
	  {
	    source = source.replace("{ACTIVE}", drop.isDisabled(player.getName()) ? "nie" : "tak");
	    source = source.replace("{CHANCE}", String.format("%1$.3f", new Object[] { Double.valueOf(drop.getChance(player)) }));
	    source = source.replace("{CAN_DROP}", drop.canDrop(player) ? "tak" : "nie");
	    source = replace(source, drop);
	    return source;
	  }


Klasa Config:

 

	  @SuppressWarnings("unused")
	private static final String pathPrefix = "config.";
	  public static String GUI_NAME = "&8» &cDROP Z &7KAMIENIA";
	  public static List<String> GUI_ICON_LORE = Arrays.asList(new String[] { "&8» &cSzansa&8: &7{CHANCE}", "&8» &cFortune&8: &7{FORTUNE}", "&8» &cAktywny&8: &7{ACTIVE}" });
	  public static boolean GUI_CLOSE$AFTER$CLICK = false;
	  public static boolean GAMEMODE_DROP = false;
	  public static String MESSAGES_CANCELDROP = "&8» &cDrop z tego bloku jest wylaczony!";
	  public static boolean BONUS$DROP_ENABLED = true;
	  public static double BONUS$DROP_MULTIPLIER = 0.5D;
	  public static boolean VIP$DROP_ENABLED = true;
	  public static String VIP$DROP_PERMISSION = "karolekdrop.vip";
	  public static double VIP$DROP_MULTIPLIER = 0.5D;
	  public static int STONE$EXP = 10;
	  public static double FORTUNE_1_PERCENT = 30.0D;
	  public static String FORTUNE_1_AMOUNT = "1-2";
	  public static double FORTUNE_2_PERCENT = 20.0D;
	  public static String FORTUNE_2_AMOUNT = "1-3";
	  public static double FORTUNE_3_PERCENT = 10.0D;
	  public static String FORTUNE_3_AMOUNT = "1-4";
	  public static double FORTUNE_HIGH$LEVELS_PERCENT = 5.0D;
	  public static String FORTUNE_HIGH$LEVELS_AMOUNT = "1-10";
	  
	  public static void loadConfig()
	  {
	    try
	    {
	      Main.getPlugin().saveDefaultConfig();
	      FileConfiguration f = Main.getPlugin().getConfig();
	      for (Field field : Config.class.getFields()) {
	        if ((Modifier.isStatic(field.getModifiers())) && (Modifier.isPublic(field.getModifiers())))
	        {
	          String path = "config." + field.getName().toLowerCase().replace("$", "-").replace("_", ".");
	          if (f.isSet(path)) {
	            field.set(null, f.get(path));
	          }
	        }
	      }
	    }
	    catch (Exception e)
	    {
	      Main.getPlugin().getLogger().log(Level.WARNING, "Nastapil blad podczas ladowania configu!", e);
	    }
	  }
	  
	  public static void saveConfig()
	  {
	    try
	    {
	      Main.getPlugin().saveDefaultConfig();
	      FileConfiguration f = Main.getPlugin().getConfig();
	      for (Field field : Config.class.getFields()) {
	        if ((Modifier.isStatic(field.getModifiers())) && (Modifier.isPublic(field.getModifiers())))
	        {
	          String path = "config." + field.getName().toLowerCase().replace("$", "-").replace("_", ".");
	          f.set(path, field.get(null));
	        }
	      }
	      Main.getPlugin().saveConfig();
	    }
	    catch (Exception e)
	    {
	      Main.getPlugin().getLogger().log(Level.WARNING, "Nastapil blad przy zapisywaniu configu!", e);
	    }
	  }
	  
	  public static void reloadConfig()
	  {
	    Main.getPlugin().reloadConfig();
	    loadConfig();
	    saveConfig();
	  }

 

Opublikowano

duble, plagiat i proszę zacznij korzystać ze spojlerów

ogólnie to polecam napisać plugin od początku

ew. skrypty ( skrypty czasem są jedynym słusznym wyborem )

opencraft.pl << { na takim jeszcze nie grałeś }

TDepLbR.gif

Opublikowano
21 minut temu, macjoker007 napisał:

duble, plagiat i proszę zacznij korzystać ze spojlerów

ogólnie to polecam napisać plugin od początku

ew. skrypty ( skrypty czasem są jedynym słusznym wyborem )

Nie ukrywam, ze nie chce mi sie po prostu pisac tego od poczatku, wole naprawic to, bo na pewno jest jakis sposob.
Skrypty obciazaja serwer.

Opublikowano
1 godzinę temu, SkredoX napisał:

Nie ukrywam, ze nie chce mi sie po prostu pisac tego od poczatku, wole naprawic to, bo na pewno jest jakis sposob.
Skrypty obciazaja serwer.

jak już chcesz coś naprawiać, to nie zmieniaj paczek i nie podpisuj się pod czyjąś pracą, poza tym - plugin nie ma otwartego źródła, że musisz dekompilować?

 

 

 

 

fKJeAI4.jpg

 

 

 

Opublikowano
8 minut temu, Nocny napisał:

jak już chcesz coś naprawiać, to nie zmieniaj paczek i nie podpisuj się pod czyjąś pracą, poza tym - plugin nie ma otwartego źródła, że musisz dekompilować?

Byłbym bardzo wdzięczny, jakby ktoś w końcu pomógł zamiast pisać "to nie twoje" c:
Kod nie jest w 100% mój lecz w 80%, to czego nie wiem to wzoruję się na innych :)

Opublikowano
Przed chwilą, SkredoX napisał:

Byłbym bardzo wdzięczny, jakby ktoś w końcu pomógł zamiast pisać "to nie twoje" c:
Kod nie jest w 100% mój lecz w 80%, to czego nie wiem to wzoruję się na innych :)

no ale co tutaj można Ci pomóc, jak ten kod nie ma numerowania, a bez tego analizowanie nie ma sensu.

 

 

 

 

fKJeAI4.jpg

 

 

 

Opublikowano

Nie ma to jak castować stringa do stringa.

 

To, że przepisałeś kod z dekompilatora a zapewne nawet wkleiłeś to nie oznacza, że kod jest Twój.

Opublikowano
56 minut temu, SkredoX napisał:

Jak mam wyslac ten kod ponumerowany? Serio ten plugin jest mi potrzebny ._.

Kolego, jak byś napisał ten kod, to byś wiedział jak naprawić zwykłego null'a.

Wystarczy zrobić debugi tego co tam wpierdzielasz i zobaczysz co dokładnie wali nulla.

		 if(Util.fixColor("&8» &cDROP NA SERWERZE").equalsIgnoreCase(e.getInventory().getName())) {

if(item != null) {
				 ItemMeta meta = item.getItemMeta();
				 if(meta != null) {
					 Player p = (Player)e.getWhoClicked();
					 Inventory inv = p.getInventory();
					 if(inv != null) {

 

Po co sprawdzasz czy inv nie jest nullem ??? jak event od klikania w inventory??

i dlaczego tak sprawdzasz czy meta i item nie jest nullem?

nie lepiej tak?

if(item == null || meta == null) return; 

Na inne klasy nawet nie chce mi sie patrzec.

Opublikowano
5 godzin temu, TheMajster napisał:

Kolego, jak byś napisał ten kod, to byś wiedział jak naprawić zwykłego null'a.

Wystarczy zrobić debugi tego co tam wpierdzielasz i zobaczysz co dokładnie wali nulla.


		 if(Util.fixColor("&8» &cDROP NA SERWERZE").equalsIgnoreCase(e.getInventory().getName())) {

if(item != null) {
				 ItemMeta meta = item.getItemMeta();
				 if(meta != null) {
					 Player p = (Player)e.getWhoClicked();
					 Inventory inv = p.getInventory();
					 if(inv != null) {

 

Po co sprawdzasz czy inv nie jest nullem ??? jak event od klikania w inventory??

i dlaczego tak sprawdzasz czy meta i item nie jest nullem?

nie lepiej tak?


if(item == null || meta == null) return; 

Na inne klasy nawet nie chce mi sie patrzec.

sprawdza czy inventory nie jest nullem, bo gdy gracz kliknie poza okno ekwipunku, to inventory bedzie nullem i będzie sypać exceptionami, gdybyś debugował to byś wiedział :P

 

 

 

 

fKJeAI4.jpg

 

 

 

Opublikowano
Dnia 3.08.2017 o 13:31, MIXSER1337 napisał:

	  public static String VIP$DROP_PERMISSION = "karolekdrop.vip"; oho

karolekdrop nie jest opensource?

https://github.com/KarolekFM/karolekDrop

 

 

 

 

 

fKJeAI4.jpg

 

 

 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...