pull/6/head
parent
7c354ccc57
commit
e84cd87d07
4 changed files with 120 additions and 3 deletions
@ -0,0 +1,35 @@ |
||||
package xyz.soukup.ecoCraftCore.commands; |
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; |
||||
import com.mojang.brigadier.context.CommandContext; |
||||
import io.papermc.paper.command.brigadier.CommandSourceStack; |
||||
import io.papermc.paper.command.brigadier.Commands; |
||||
import org.bukkit.Material; |
||||
import org.bukkit.command.CommandSender; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.inventory.ItemStack; |
||||
import xyz.soukup.ecoCraftCore.utilities.PDC; |
||||
|
||||
public class RulerCommand { |
||||
public static LiteralArgumentBuilder<CommandSourceStack> createCommand() { |
||||
return Commands.literal("ruler") |
||||
.executes(RulerCommand::obtainRuler); |
||||
} |
||||
|
||||
private static int obtainRuler(CommandContext<CommandSourceStack> context){ |
||||
|
||||
CommandSender commandSender = context.getSource().getSender(); |
||||
|
||||
if (!(commandSender instanceof Player)){ |
||||
commandSender.sendPlainMessage("Musíš být hráč"); |
||||
return 0; |
||||
} |
||||
|
||||
Player player = (Player) commandSender; |
||||
ItemStack itemStack = PDC.setItemStackBoolean(new ItemStack(Material.BLAZE_ROD), "ruler", true); |
||||
|
||||
player.getInventory().addItem(itemStack); |
||||
|
||||
return 1; |
||||
} |
||||
} |
||||
@ -0,0 +1,4 @@ |
||||
package xyz.soukup.ecoCraftCore.commands; |
||||
|
||||
public class ShopCommand { |
||||
} |
||||
@ -0,0 +1,70 @@ |
||||
package xyz.soukup.ecoCraftCore.events; |
||||
|
||||
import org.bukkit.BlockChangeDelegate; |
||||
import org.bukkit.Location; |
||||
import org.bukkit.block.Block; |
||||
import org.bukkit.block.Chest; |
||||
import org.bukkit.block.Sign; |
||||
import org.bukkit.entity.Player; |
||||
import org.bukkit.event.EventHandler; |
||||
import org.bukkit.event.Listener; |
||||
import org.bukkit.event.player.PlayerInteractEvent; |
||||
import org.bukkit.inventory.ItemStack; |
||||
import xyz.soukup.ecoCraftCore.utilities.PDC; |
||||
|
||||
import java.util.HashMap; |
||||
|
||||
public class RulerMarking implements Listener { |
||||
|
||||
public static HashMap<Player, Location> primary_locations = new HashMap<>(); |
||||
public static HashMap<Player, Location> secondary_locations = new HashMap<>(); |
||||
public static HashMap<Player, Location> sign_locations = new HashMap<>(); |
||||
public static HashMap<Player, Location> storage_locations = new HashMap<>(); |
||||
|
||||
@EventHandler |
||||
public void playerInteract(PlayerInteractEvent event){ |
||||
|
||||
ItemStack itemStack = event.getItem(); |
||||
Block block = event.getClickedBlock(); |
||||
|
||||
|
||||
if (itemStack == null || block == null){ |
||||
return; |
||||
} |
||||
|
||||
Boolean isRuler = PDC.retrieveBooleanFromItemStack(itemStack, "ruler"); |
||||
|
||||
if (isRuler == null || !isRuler) { |
||||
return; |
||||
} |
||||
|
||||
event.setCancelled(true); |
||||
|
||||
if (block.getState() instanceof Chest){ |
||||
storage_locations.put(event.getPlayer(), block.getLocation()); |
||||
event.getPlayer().sendMessage("pozice truhly nastavena"); |
||||
return; |
||||
} |
||||
|
||||
if (block.getState() instanceof Sign){ |
||||
sign_locations.put(event.getPlayer(), block.getLocation()); |
||||
event.getPlayer().sendMessage("pozice cedule nastavena"); |
||||
return; |
||||
} |
||||
|
||||
switch (event.getAction()){ |
||||
case LEFT_CLICK_BLOCK -> { |
||||
primary_locations.put(event.getPlayer(), block.getLocation()); |
||||
event.getPlayer().sendMessage("první pozice nastavena"); |
||||
return; |
||||
} |
||||
case RIGHT_CLICK_BLOCK -> { |
||||
secondary_locations.put(event.getPlayer(), block.getLocation()); |
||||
event.getPlayer().sendMessage("druhá pozice nastavena"); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
event.setCancelled(false); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue