parent
9bb87ca1ca
commit
339371125f
7 changed files with 230 additions and 18 deletions
@ -0,0 +1,61 @@ |
||||
package xyz.mineconomia.mineconomiacore.commands; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.Sound; |
||||
import org.bukkit.command.Command; |
||||
import org.bukkit.command.CommandExecutor; |
||||
import org.bukkit.command.CommandSender; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.inventory.Inventory; |
||||
import org.bukkit.inventory.ItemStack; |
||||
import org.bukkit.plugin.Plugin; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import xyz.mineconomia.mineconomiacore.MineconomiaCore; |
||||
import xyz.mineconomia.mineconomiacore.events.shopInteract; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
public class gamble implements CommandExecutor { |
||||
@Override |
||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { |
||||
Inventory gambleGui = Bukkit.createInventory(null, 27, "GAMBLE GAMBLE GAMBLE"); |
||||
for (int i = 0; i<9; i++){ |
||||
gambleGui.setItem( i,shopInteract.newItemStack(" ", Material.BLACK_STAINED_GLASS_PANE)); |
||||
gambleGui.setItem( i + 18,shopInteract.newItemStack(" ", Material.BLACK_STAINED_GLASS_PANE)); |
||||
} |
||||
gambleGui.setItem(4, shopInteract.newItemStack(" ", Material.LIME_STAINED_GLASS_PANE)); |
||||
gambleGui.setItem(22, shopInteract.newItemStack(" ", Material.LIME_STAINED_GLASS_PANE)); |
||||
Player p = (Player) commandSender; |
||||
|
||||
List<ItemStack> itemStackList = new ArrayList<>(); |
||||
for (Material m : Material.values()){ |
||||
gambleGui.setItem(15, new ItemStack(m)); |
||||
if (gambleGui.getItem(15) != null){ |
||||
itemStackList.add(new ItemStack(m)); |
||||
} |
||||
} |
||||
p.openInventory(gambleGui); |
||||
Collections.shuffle(itemStackList); |
||||
for(int i = 0; i < 100; i++){ |
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(MineconomiaCore.getPlugin(MineconomiaCore.class), new Runnable() { |
||||
public void run() { |
||||
ItemStack itemStackToEnd = itemStackList.get(0); |
||||
itemStackList.remove(0); |
||||
itemStackList.add(itemStackToEnd); |
||||
for (int i = 0; i<9; i++){ |
||||
gambleGui.setItem(i+9, itemStackList.get(i)); |
||||
if (gambleGui.getItem(i+9) == null){ |
||||
gambleGui.setItem(i+9, new ItemStack(Material.STICK)); |
||||
} |
||||
} |
||||
p.playSound(p, Sound.BLOCK_NOTE_BLOCK_BANJO, 100, 1); |
||||
} |
||||
}, Long.parseLong(String.valueOf(i+1))); |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
@ -0,0 +1,21 @@ |
||||
package xyz.mineconomia.mineconomiacore.commands; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.command.Command; |
||||
import org.bukkit.command.CommandExecutor; |
||||
import org.bukkit.command.CommandSender; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.persistence.PersistentDataType; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import xyz.mineconomia.mineconomiacore.PDC; |
||||
|
||||
public class sell implements CommandExecutor { |
||||
@Override |
||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { |
||||
Player p = (Player) commandSender; |
||||
PDC.WritePlayerPDC(p, "sellGUIOpen", PersistentDataType.INTEGER, 1); |
||||
p.openInventory(Bukkit.createInventory(null, 36, ChatColor.GREEN + "" + ChatColor.BOLD + "Vlož itemy, které chceš prodat")); |
||||
return false; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue