Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Zaros.LogGift;
- //--------------------------------------//
- // Code by Zaros104 //
- // Free to edit, make sure to credit! //
- //--------------------------------------//
- import org.bukkit.entity.Player;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerLoginEvent;
- import org.bukkit.inventory.ItemStack;
- public class loginListener implements Listener {
- public void onPlayerLogin(PlayerLoginEvent e){
- Player player = e.getPlayer();
- //randomized variables for the itemStack
- int quantity = (int) Math.random() * 64;
- int item = (int) Math.random() * 383;
- //Array Sizes
- int sizeBlock = 38;
- int sizeItem = 2;
- //Arrays containing (usually) banned items
- int[] exceptionBlock = {0, 7, 8, 9, 10, 11, 14, 15, 16, 21, 34, 36, 51, 52, 55,
- 56, 59, 60, 62, 63, 64, 68, 71, 75, 76, 90, 93, 94, 95,
- 97, 99, 100, 104, 105, 115, 117, 118, 119, 120};
- int[] exceptionItem = { 326, 327, 383 };
- //Check for non-allowed blocks
- for(int i = 0; i < sizeBlock; i++){
- if (exceptionBlock[i] == item){
- item = (int) Math.random() * 383;
- }
- }
- for(int i = 0; i < sizeItem; i++){
- if (exceptionItem[i] == item){
- quantity = (int) Math.random() * 64;
- }
- }
- //Do the dirty work
- ItemStack newItem = new ItemStack(item, quantity);
- player.getInventory().addItem(newItem);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement