marcinkoxx 3 Opublikowano 10 czerwca 2019 Udostępnij Opublikowano 10 czerwca 2019 (edytowane) Witam, mam o to taki kod i chciałbym żeby ktoś pomogl mi go dokonczyc, żeby np. na 13 bloku sprzedawania było 'Sprzedaj Wszystko' nie wiem jak to zrobić. (TO JEST POD CORE) POMOZCIE PLS Tutaj macie kod: Spoiler import me.fernikq.core.Commands.PlayerCommand; import me.fernikq.core.Data.Gui; import me.fernikq.core.Data.Lang; import me.fernikq.core.Data.Sklep; import me.fernikq.core.Data.User; import me.fernikq.core.Item; import me.fernikq.core.Manager.SklepManager; import me.fernikq.core.Utils.Utils; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; public class SklepCommand extends PlayerCommand implements Listener { public SklepCommand() { super("sklep", "Sklep serwerowy", "/sklep", "core.cmd.sklep", new String[0]); } public boolean onCommand(Player p, String[] args) { return Gui.SklepMenu(p); } @EventHandler public void onSklep(InventoryClickEvent e) { Player p = (Player)e.getWhoClicked(); User u = User.get(p); if (Utils.FixColor("&8[ &6MENU SKLEPU &8]").equals(e.getInventory().getName())) { e.setCancelled(true); if (e.getSlot() == 2 && e.getCurrentItem().getType() == Material.CHEST) { Gui.SklepBuy(p); } if (e.getSlot() == 6 && e.getCurrentItem().getType() == Material.CHEST) { Gui.SklepSell(p); } } if (Utils.FixColor("&8[ &6KUPOWANIE &8]").equals(e.getInventory().getName())) { e.setCancelled(true); if (e.getSlot() < SklepManager.getBuy().size() && e.getSlot() >= 0) { Sklep s = (Sklep)SklepManager.getBuy().get(e.getSlot()); Item it = new Item(s.getItem().clone()); if (u.getCoins() < s.getCena()) { Utils.send(p, Lang.BLAD("Nie posiadasz wystarczajacej ilosci monet! &8[&4" + s.getCena() + "&8]")); return; } u.setCoins(u.getCoins() - s.getCena()); u.save(); it.setAmount(s.getIlosc()); Utils.giveItems(p, it.toIs()); Utils.send(p, "&8{.} &7Kupiles &a" + s.getNazwa() + " &7za&8: &a" + s.getCena() + "&l$"); u.updateSidebar(); Gui.SklepBuy(p); return; } if (e.getSlot() == 35 && e.getCurrentItem().getType() == Material.FENCE_GATE) { Gui.SklepMenu(p); } } if (Utils.FixColor("&8[ &6SPRZEDAWANIE &8]").equals(e.getInventory().getName())) { e.setCancelled(true); if (e.getSlot() < SklepManager.getSell().size() && e.getSlot() >= 0) { Sklep s = (Sklep)SklepManager.getSell().get(e.getSlot()); Item it = new Item(s.getItem().clone()); if (!p.getInventory().containsAtLeast(it.toIs(), s.getIlosc())) { Utils.send(p, Lang.BLAD("Nie posiadasz wystarczajecej iloscu przedmiotu! &8[&4" + s.getNazwa() + "&8]")); return; } it.setAmount(s.getIlosc()); p.getInventory().removeItem(new ItemStack[] { it.toIs() }); u.addCoins(s.getCena()); u.updateSidebar(); u.save(); Utils.send(p, "&8{.} &7Sprzedales &a" + s.getNazwa() + " &7za&8: &a" + s.getCena() + "&l$"); Gui.SklepSell(p); return; } if (e.getSlot() == 35 && e.getCurrentItem().getType() == Material.FENCE_GATE) Gui.SklepMenu(p); } } } Config: Spoiler 1: item: diamond data: 0 ilosc: 32 cena: 2 name: 'Diament' enchant: 'null' lore: 'null' 2: item: emerald data: 0 ilosc: 16 cena: 2 name: 'Emerald' enchant: 'null' lore: 'null' 3: item: 4 data: 0 ilosc: 64 cena: 1 name: 'Bruk' enchant: 'null' lore: 'null' 4: item: dirt data: 0 ilosc: 64 cena: 1 name: 'Ziemia' enchant: 'null' lore: 'null' 5: item: gold_ingot data: 0 ilosc: 32 cena: 3 name: 'Zloto' enchant: 'null' lore: 'null' 6: item: iron_ingot data: 0 ilosc: 32 cena: 1 name: 'Zelazo' enchant: 'null' lore: 'null' 7: item: redstone data: 0 ilosc: 32 cena: 1 name: 'Czerwony proszek' enchant: 'null' lore: 'null' 7: item: redstone data: 0 ilosc: 32 cena: 2 name: 'Czerwony proszek' enchant: 'null' lore: 'null' 8: item: apple data: 0 ilosc: 32 cena: 3 name: 'Jablko' enchant: 'null' lore: 'null' 9: item: coal data: 0 ilosc: 64 cena: 1 name: 'Wegiel' enchant: 'null' lore: 'null' 10: item: book data: 0 ilosc: 16 cena: 2 name: 'Ksiazka' enchant: 'null' lore: 'null' 11: item: bookshelf data: 0 ilosc: 32 cena: 5 name: 'Biblioteczka' enchant: 'null' lore: 'null' 12: item: tnt data: 0 ilosc: 32 cena: 5 name: 'TNT' enchant: 'null' lore: 'null' Edytowane 12 czerwca 2019 przez knugi Dodałem spojler do kodów. Notatka dodana przez knugi Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 PakerP1337 3 Opublikowano 10 czerwca 2019 Udostępnij Opublikowano 10 czerwca 2019 Jeśli nie dasz skryptu to ci nie pomoże nikt, nikt nie wie jak to dziala, jak ma wygladac itp... Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 kerpson 534 Opublikowano 10 czerwca 2019 Udostępnij Opublikowano 10 czerwca 2019 To łaskawie daj kod ze skryptu. Jeżeli to twój "core", to bez problemu znajdziesz kod na sklep i go dasz tu Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 xAxee 1951 Opublikowano 11 czerwca 2019 Udostępnij Opublikowano 11 czerwca 2019 bez twojego kodu nic nie zrobimy jedynie moge ci wysłać skrypt który posiada /sellall Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 marcinkoxx 3 Opublikowano 11 czerwca 2019 Autor Udostępnij Opublikowano 11 czerwca 2019 W dniu 10.06.2019 o 19:47, PakerP1337 napisał: Jeśli nie dasz skryptu to ci nie pomoże nikt, nikt nie wie jak to dziala, jak ma wygladac itp... już U GORY JEST. W dniu 11.06.2019 o 16:47, xAxee napisał: bez twojego kodu nic nie zrobimy jedynie moge ci wysłać skrypt który posiada /sellall WYZEJ W dniu 10.06.2019 o 22:12, HotAngel2K17 napisał: To łaskawie daj kod ze skryptu. Jeżeli to twój "core", to bez problemu znajdziesz kod na sklep i go dasz tu MASZ U GORY. Łączę. Notatka dodana przez knugi Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 Szifter 134 Opublikowano 11 czerwca 2019 Udostępnij Opublikowano 11 czerwca 2019 To nie skript a java, jak już. Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 Szifter 134 Opublikowano 11 czerwca 2019 Udostępnij Opublikowano 11 czerwca 2019 Ten temat został przeniesiony. Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 yooniks 347 Opublikowano 12 czerwca 2019 Udostępnij Opublikowano 12 czerwca 2019 Obawiam się, że większość tego kodu nie jest twoja =( Tam gdzie masz tworzenie ekwipunków (od sklepu itp), w tym ekwipunku którym chcesz dodaj na 13 slocie ten item, tak jak poprzednie. A w listenerze dorób kolejnego ifa, if (e.getSlot() == 13) { //lub 12, nie wiem jak chcesz, 1 slot w gui to tak naprawdę 0, w pluginie jest liczone od 0, nie od 1! czyli ostatni slot w pierwszym rzędzie to 8, a nie 9 //no i tutaj wlasnie nie wiem za bardzo o co ci chodzi, "SPRZEDAJ WSZYSTKO", ale co wszystko? //mozesz zrobic petle ze wsyzstkimi itemami ze sklepu ktore mozna sprzedac i sprawdzic czy gracz moze je sprzedac (czy ma wystarczajaca ilosc itd) final List<Item> items = ItemManager.getAllSellableItems(); //zamien to na swoja metode z pobieraniem itemamow ktore mozna sprzedac items.stream() .filter(item -> this.canSell(player, item)) .forEach(item -> this.sell(player, item)); //lub jakas inna petla, bo za kazdym razem musisz w sumie usuwac itemy za zakupiony przedmiot i dopiero wtedy sprawdzac czy gracza stac na nastepny, ja daje tylko przyklad } private boolean canSell(Player player, Item item) { //sprawdz czy ma wystarczajaco itemow w ekwipunku itd, zwroc poprawna wartosc - true/false return true; } private void sell (Player player, Item item) { //add coins etc } to tylko przyklad, sam musisz pokombinowac, to w koncu podobno twoj kod Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 kerpson 534 Opublikowano 12 czerwca 2019 Udostępnij Opublikowano 12 czerwca 2019 5 godzin temu, yooniks napisał: Obawiam się, że większość tego kodu nie jest twoja =( Tam gdzie masz tworzenie ekwipunków (od sklepu itp), w tym ekwipunku którym chcesz dodaj na 13 slocie ten item, tak jak poprzednie. A w listenerze dorób kolejnego ifa, if (e.getSlot() == 13) { //lub 12, nie wiem jak chcesz, 1 slot w gui to tak naprawdę 0, w pluginie jest liczone od 0, nie od 1! czyli ostatni slot w pierwszym rzędzie to 8, a nie 9 //no i tutaj wlasnie nie wiem za bardzo o co ci chodzi, "SPRZEDAJ WSZYSTKO", ale co wszystko? //mozesz zrobic petle ze wsyzstkimi itemami ze sklepu ktore mozna sprzedac i sprawdzic czy gracz moze je sprzedac (czy ma wystarczajaca ilosc itd) final List<Item> items = ItemManager.getAllSellableItems(); //zamien to na swoja metode z pobieraniem itemamow ktore mozna sprzedac items.stream() .filter(item -> this.canSell(player, item)) .forEach(item -> this.sell(player, item)); //lub jakas inna petla, bo za kazdym razem musisz w sumie usuwac itemy za zakupiony przedmiot i dopiero wtedy sprawdzac czy gracza stac na nastepny, ja daje tylko przyklad } private boolean canSell(Player player, Item item) { //sprawdz czy ma wystarczajaco itemow w ekwipunku itd, zwroc poprawna wartosc - true/false return true; } private void sell (Player player, Item item) { //add coins etc } to tylko przyklad, sam musisz pokombinowac, to w koncu podobno twoj kod Ten kod nie jest jego, jest to kod z wycieku fernikq. Jest tam też src na yt Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 marcinkoxx 3 Opublikowano 13 czerwca 2019 Autor Udostępnij Opublikowano 13 czerwca 2019 przerobisz mi to? Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
0 yooniks 347 Opublikowano 14 czerwca 2019 Udostępnij Opublikowano 14 czerwca 2019 15 godzin temu, marcinkoxx napisał: przerobisz mi to? pomagamy z kodem, a nie piszemy go za ciebie, tymbardziej że to nie twoj plugin Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Pytanie
marcinkoxx 3
Witam, mam o to taki kod i chciałbym żeby ktoś pomogl mi go dokonczyc, żeby np. na 13 bloku sprzedawania było 'Sprzedaj Wszystko'
nie wiem jak to zrobić. (TO JEST POD CORE) POMOZCIE PLS
Tutaj macie kod:
import me.fernikq.core.Commands.PlayerCommand; import me.fernikq.core.Data.Gui; import me.fernikq.core.Data.Lang; import me.fernikq.core.Data.Sklep; import me.fernikq.core.Data.User; import me.fernikq.core.Item; import me.fernikq.core.Manager.SklepManager; import me.fernikq.core.Utils.Utils; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; public class SklepCommand extends PlayerCommand implements Listener { public SklepCommand() { super("sklep", "Sklep serwerowy", "/sklep", "core.cmd.sklep", new String[0]); } public boolean onCommand(Player p, String[] args) { return Gui.SklepMenu(p); } @EventHandler public void onSklep(InventoryClickEvent e) { Player p = (Player)e.getWhoClicked(); User u = User.get(p); if (Utils.FixColor("&8[ &6MENU SKLEPU &8]").equals(e.getInventory().getName())) { e.setCancelled(true); if (e.getSlot() == 2 && e.getCurrentItem().getType() == Material.CHEST) { Gui.SklepBuy(p); } if (e.getSlot() == 6 && e.getCurrentItem().getType() == Material.CHEST) { Gui.SklepSell(p); } } if (Utils.FixColor("&8[ &6KUPOWANIE &8]").equals(e.getInventory().getName())) { e.setCancelled(true); if (e.getSlot() < SklepManager.getBuy().size() && e.getSlot() >= 0) { Sklep s = (Sklep)SklepManager.getBuy().get(e.getSlot()); Item it = new Item(s.getItem().clone()); if (u.getCoins() < s.getCena()) { Utils.send(p, Lang.BLAD("Nie posiadasz wystarczajacej ilosci monet! &8[&4" + s.getCena() + "&8]")); return; } u.setCoins(u.getCoins() - s.getCena()); u.save(); it.setAmount(s.getIlosc()); Utils.giveItems(p, it.toIs()); Utils.send(p, "&8{.} &7Kupiles &a" + s.getNazwa() + " &7za&8: &a" + s.getCena() + "&l$"); u.updateSidebar(); Gui.SklepBuy(p); return; } if (e.getSlot() == 35 && e.getCurrentItem().getType() == Material.FENCE_GATE) { Gui.SklepMenu(p); } } if (Utils.FixColor("&8[ &6SPRZEDAWANIE &8]").equals(e.getInventory().getName())) { e.setCancelled(true); if (e.getSlot() < SklepManager.getSell().size() && e.getSlot() >= 0) { Sklep s = (Sklep)SklepManager.getSell().get(e.getSlot()); Item it = new Item(s.getItem().clone()); if (!p.getInventory().containsAtLeast(it.toIs(), s.getIlosc())) { Utils.send(p, Lang.BLAD("Nie posiadasz wystarczajecej iloscu przedmiotu! &8[&4" + s.getNazwa() + "&8]")); return; } it.setAmount(s.getIlosc()); p.getInventory().removeItem(new ItemStack[] { it.toIs() }); u.addCoins(s.getCena()); u.updateSidebar(); u.save(); Utils.send(p, "&8{.} &7Sprzedales &a" + s.getNazwa() + " &7za&8: &a" + s.getCena() + "&l$"); Gui.SklepSell(p); return; } if (e.getSlot() == 35 && e.getCurrentItem().getType() == Material.FENCE_GATE) Gui.SklepMenu(p); } } }
Config:
1: item: diamond data: 0 ilosc: 32 cena: 2 name: 'Diament' enchant: 'null' lore: 'null' 2: item: emerald data: 0 ilosc: 16 cena: 2 name: 'Emerald' enchant: 'null' lore: 'null' 3: item: 4 data: 0 ilosc: 64 cena: 1 name: 'Bruk' enchant: 'null' lore: 'null' 4: item: dirt data: 0 ilosc: 64 cena: 1 name: 'Ziemia' enchant: 'null' lore: 'null' 5: item: gold_ingot data: 0 ilosc: 32 cena: 3 name: 'Zloto' enchant: 'null' lore: 'null' 6: item: iron_ingot data: 0 ilosc: 32 cena: 1 name: 'Zelazo' enchant: 'null' lore: 'null' 7: item: redstone data: 0 ilosc: 32 cena: 1 name: 'Czerwony proszek' enchant: 'null' lore: 'null' 7: item: redstone data: 0 ilosc: 32 cena: 2 name: 'Czerwony proszek' enchant: 'null' lore: 'null' 8: item: apple data: 0 ilosc: 32 cena: 3 name: 'Jablko' enchant: 'null' lore: 'null' 9: item: coal data: 0 ilosc: 64 cena: 1 name: 'Wegiel' enchant: 'null' lore: 'null' 10: item: book data: 0 ilosc: 16 cena: 2 name: 'Ksiazka' enchant: 'null' lore: 'null' 11: item: bookshelf data: 0 ilosc: 32 cena: 5 name: 'Biblioteczka' enchant: 'null' lore: 'null' 12: item: tnt data: 0 ilosc: 32 cena: 5 name: 'TNT' enchant: 'null' lore: 'null'
Dodałem spojler do kodów.
Notatka dodana przez knugi
Odnośnik do komentarza
Udostępnij na innych stronach
10 odpowiedzi na to pytanie
Rekomendowane odpowiedzi