Skip to content

Commit

Permalink
1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ChickenStyle committed Apr 4, 2021
1 parent 37d61af commit 26cbc29
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
3 changes: 3 additions & 0 deletions LuckyCubes/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ messages:
giveMessage: "&6{player} &agave you &6{amount} &ax&6{luckycube}"
getReward: "&7You got &6{amount} &ax&6{item}"
cooldown: "&cYou have to wait &6{seconds} &cto open another luckycube!"
disableCommandUse: "&cYou cannot use commands while opening a luckycube!"


spinningAnimation:
Expand All @@ -14,6 +15,8 @@ spinningAnimation:

sendMessageOnReward: true

disableCommandsOnOpen: true

# allows player to exit the gui animation!
allowExitInGUI: false

Expand Down
2 changes: 1 addition & 1 deletion LuckyCubes/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
main: me.chickenstyle.luckyblocks.Main
name: LuckyCubes
version: 1.0.5
version: 1.0.6
description: implements cool luckyblocks to the game
api-version: 1.13
commands:
Expand Down
9 changes: 7 additions & 2 deletions LuckyCubes/src/me/chickenstyle/luckyblocks/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.chickenstyle.luckyblocks;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -58,8 +59,12 @@ public void onEnable() {
creatingLuckyCube = new HashMap<UUID,LuckyCube>();
stands = new HashSet<ArmorStand>();

this.getConfig().options().copyDefaults();
saveDefaultConfig();
File config = new File(getDataFolder(),"config.yml");

if (!config.exists()) {
this.getConfig().options().copyDefaults();
saveDefaultConfig();
}
new CustomLuckyBlocks(this);

//Loads proper data :)
Expand Down
3 changes: 2 additions & 1 deletion LuckyCubes/src/me/chickenstyle/luckyblocks/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public enum Message {
GIVE_MESSAGE(color(getString("messages.giveMessage"))),
GET_REWARD(color(getString("messages.getReward"))),
COOLDOWN(color(getString("messages.cooldown"))),
PLACE_ON_GROUND(color(getString("messages.placeOnGround")));
PLACE_ON_GROUND(color(getString("messages.placeOnGround"))),
DISABLE_COMMAND(color(getString("messages.disableCommandUse")));
private String error;

Message(String error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.UUID;

import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.inventory.ItemStack;

import me.chickenstyle.luckyblocks.LuckyCube;
Expand All @@ -23,12 +27,41 @@

public class PlaceBlockEvent implements Listener{

@EventHandler
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
if (Main.getInstance().getConfig().getBoolean("disableCommandsOnOpen")) {
if (Main.opening.contains(e.getPlayer().getUniqueId())) {
e.setCancelled(true);
e.getPlayer().sendMessage(Message.DISABLE_COMMAND.getMSG());
}
}
}

@EventHandler
public void onChunkUnload(ChunkUnloadEvent e) {
List<Entity> ents = new ArrayList<>();
for (Entity ent:e.getChunk().getEntities()) {
if (Main.stands.contains(ent)) {
ent.remove();
ents.add(ent);
}
}

ents.forEach(ent -> {
Main.stands.remove(ent);
});

}


HashMap<UUID,Long> cooldown = new HashMap<>();

@SuppressWarnings("deprecation")
@EventHandler
public void onBlockPlace(PlayerInteractEvent e) {
Player player = e.getPlayer();

if (e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (player.getItemInHand() != null && !player.getItemInHand().getType().equals(Material.AIR)) {
if (Main.getVersionHandler().isLuckyBlock(player.getItemInHand())) {
e.setCancelled(true);
Expand Down

0 comments on commit 26cbc29

Please sign in to comment.