Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .run/ShulkerPacks.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ShulkerPacks" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list />
</option>
<option name="pomFileName" />
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
13 changes: 10 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.Darkolythe</groupId>
<artifactId>ShulkerPacks</artifactId>
<version>1.6.4</version>
<version>1.6.6</version>
<packaging>jar</packaging>

<properties>
Expand All @@ -27,10 +27,16 @@
</repositories>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -42,13 +48,14 @@
</dependencies>

<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>C:\Users\ChrisWalker\Desktop\1.18server\plugins</outputDirectory>
<outputDirectory>C:\Users\dinob\Documents\plugins</outputDirectory>
</configuration>
</plugin>
<plugin>
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/me/darkolythe/shulkerpacks/OpenShulker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package me.darkolythe.shulkerpacks;

import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.bukkit.Location;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Data
@RequiredArgsConstructor
public class OpenShulker {
private ShulkerPacks plugin;
private HashMap<Inventory, OpenShulker> openShulkerInventories = new HashMap<>();
private HashMap<UUID, Long> lastOpened = new HashMap<>();

private ItemStack itemStack;
private Location openLocation;
private InventoryType.SlotType slotType;
private int rawSlot;

public OpenShulker(ItemStack itemStack) {
this.itemStack = itemStack;
}
public boolean doesPlayerShulkerOpen(UUID uuid) {
for (Inventory inv : openShulkerInventories.keySet()) {
for (HumanEntity he : inv.getViewers()) {
if (he.getUniqueId().equals(uuid)) {
return true;
}
}
}
return false;
}
}
36 changes: 28 additions & 8 deletions src/main/java/me/darkolythe/shulkerpacks/ShulkerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.Cancellable;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.inventory.*;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
Expand All @@ -22,10 +24,15 @@
import java.util.List;

public class ShulkerListener implements Listener {
private OpenShulker os;
private ShulkerPacks plugin;

public ShulkerPacks main;

public ShulkerListener(ShulkerPacks plugin) {

this.main = plugin; //set it equal to an instance of main
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

/*
Expand Down Expand Up @@ -68,10 +75,10 @@ public void onInventoryMoveItem(InventoryMoveItemEvent event) {
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}

Player player = (Player) event.getWhoClicked();

if (ShulkerPacks.openshulkers.containsKey(player)) {
Expand Down Expand Up @@ -118,7 +125,7 @@ public void onInventoryClick(InventoryClickEvent event) {
// prevent the player from opening it in the inventory if they have no permission
if ((player.getInventory() == event.getClickedInventory())) {
if (!main.canopenininventory || !player.hasPermission("shulkerpacks.open_in_inventory")) {
return;
return;
}
}

Expand All @@ -128,7 +135,7 @@ public void onInventoryClick(InventoryClickEvent event) {
}

if(event.getClickedInventory() != null && event.getClickedInventory().getHolder() != null && event.getClickedInventory().getHolder().getClass().toString().endsWith(".CraftBarrel") && !main.canopeninbarrels) {
return;
return;
}

if (!main.canopeninenderchest && type == InventoryType.ENDER_CHEST) {
Expand Down Expand Up @@ -224,9 +231,11 @@ public void onClickAir(PlayerInteractEvent event) {
}

@EventHandler
public void onShulkerPlace(BlockPlaceEvent event) {
public void onShulkerPlace(BlockPlaceEvent event, Player player) {
onPlayerPlackets(event.getPlayer(), event);
if (event.getBlockPlaced().getType().toString().contains("SHULKER_BOX")) {
if (!main.canplaceshulker) {
player.sendMessage(main.prefix + main.noplaceshulker);
event.setCancelled(true);
}
}
Expand Down Expand Up @@ -298,7 +307,7 @@ public boolean openInventoryIfShulker(ItemStack item, Player player) {
if (item.getAmount() == 1 && item.getType().toString().contains("SHULKER")) {

if (main.getPvpTimer(player)) {
player.sendMessage(main.prefix + ChatColor.RED + "You cannot open shulkerboxes in combat!");
player.sendMessage(main.prefix + main.notinpvp);
return false;
}

Expand Down Expand Up @@ -355,4 +364,15 @@ public void run() {
}
}, 1L, 1L);
}
public void onPlayerPlackets(Player p, Cancellable c) {
if (p.getOpenInventory().getType() != InventoryType.SHULKER_BOX) return;
if(p.getOpenInventory().getTopInventory().getLocation() != null) return;
if(!os.doesPlayerShulkerOpen(p.getUniqueId())) return;
c.setCancelled(true);
}
@EventHandler
public void onItemFrameInteract(PlayerInteractEntityEvent e){
onPlayerPlackets(e.getPlayer(), e);
}
}

7 changes: 6 additions & 1 deletion src/main/java/me/darkolythe/shulkerpacks/ShulkerPacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ public final class ShulkerPacks extends JavaPlugin {
String prefix = ChatColor.WHITE.toString() + ChatColor.BOLD.toString() + "[" + ChatColor.BLUE.toString() + "ShulkerPacks" + ChatColor.WHITE.toString() + ChatColor.BOLD.toString() + "] ";

static Map<Player, ItemStack> openshulkers = new HashMap<>();
Map<Player, Boolean> fromhand = new HashMap<>();
Map<Player, Boolean> fromhand = new HashMap<>();;
private HashMap<Inventory, OpenShulker> openShulkerInventories = new HashMap<>();
private HashMap<UUID, Long> lastOpened = new HashMap<>();

Map<Player, Inventory> openinventories = new HashMap<>();
Map<Player, Inventory> opencontainer = new HashMap<>();
private Map<Player, Long> pvp_timer = new HashMap<>();
boolean canopeninchests = true;
boolean openpreviousinv = false;
List<String> blacklist = new ArrayList<>();
String defaultname = ChatColor.BLUE + "Shulker Pack";
String notinpvp = ChatColor.RED +"You cannot open shulkerboxes in combat!";
String noplaceshulker = ChatColor.RED + "you cannot place the shulker.";
boolean pvp_timer_enabled = false;
boolean shiftclicktoopen = false;
boolean canopeninenderchest, canopeninbarrels, canplaceshulker, canopenininventory, canopeninair;
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ canplaceshulker: true #false will prevent users from placing shulkerboxe
#true will prevent users from opening shulkerboxes within 7 seconds of being hit by a player
disable-in-combat: false

defaultname: "&9Shulker Pack"
defaultname: '&9Shulker Pack'
shiftclicktoopen: false
shulkervolume: 1 #0.1 is quiet, 1 is loud
#shift click to open applies to both ingame and in inventory

open-previous-inventory: false

#lang
notinpvp: '&4You cannot open shulkerboxes in combat!'
noplaceshulker: '&4you cannot place the shulker!'
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ShulkerPacks
version: 1.6.4
version: 1.6.6
main: me.darkolythe.shulkerpacks.ShulkerPacks
api-version: 1.13
api-version: 1.19

commands:
shulkerpacks:
Expand Down
27 changes: 27 additions & 0 deletions target/classes/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# BLACKLIST AUCTION INVENTORIES HERE
# blacklist works as follows:
# if you include the word "a" in the blacklist, every inventory with the letter "a" will be blocked.
# because of this, try to be as precise as possible.
# If your inventory contains extra characters, such as "Auction Page 8", simply blacklisting "Auction Page" will block every page
blacklistedinventories: ["&4&lMineXChange", "test inventory"]

canopeninair: true #false will prevent users from opening shulkerboxes by clicking the air
canopenininventory: true #false will prevent users from opening shulkerboxes in their inventory
canopeninchests: true #false will prevent users from opening shulkerboxes in chests
canopeninenderchest: true #false will prevent users from opening shulkerboxes in enderchests
canopeninbarrels: true #false will prevent users from opening shulkerboxes in barrels
canplaceshulker: true #false will prevent users from placing shulkerboxes by accident

#true will prevent users from opening shulkerboxes within 7 seconds of being hit by a player
disable-in-combat: false

defaultname: '&9Shulker Pack'
shiftclicktoopen: false
shulkervolume: 1 #0.1 is quiet, 1 is loud
#shift click to open applies to both ingame and in inventory

open-previous-inventory: false

#lang
notinpvp: '&4You cannot open shulkerboxes in combat!'
noplaceshulker: '&4you cannot place the shulker!'
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions target/classes/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ShulkerPacks
version: 1.6.6
main: me.darkolythe.shulkerpacks.ShulkerPacks
api-version: 1.19

commands:
shulkerpacks:
usage: /<command> reload
description: reloads the shulkerpacks config
permission: op

permissions:
shulkerpacks.use:
description: gives player permission to open shulker boxes in their inventory
default: op
shulkerpacks.open_in_air:
description: allows the player to open the shulkerbox in the air (if config enables it) if the player has "shulkerpacks.use"
default: true
shulkerpacks.open_in_inventory:
description: allows the player to open the shulkerbox in their inventory (if config enables it) if the player has "shulkerpacks.use"
default: true
shulkerpacks.open_in_chests:
description: allows the player to open the shulkerbox in a chest (if config enables it) if the player has "shulkerpacks.use"
default: true
5 changes: 5 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Generated by Maven
#Mon Apr 24 18:29:21 UYT 2023
artifactId=ShulkerPacks
groupId=me.Darkolythe
version=1.6.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
me\darkolythe\shulkerpacks\OpenShulker.class
me\darkolythe\shulkerpacks\ShulkerHolder.class
me\darkolythe\shulkerpacks\ShulkerPacks.class
me\darkolythe\shulkerpacks\ConfigHandler.class
me\darkolythe\shulkerpacks\ShulkerListener$1.class
me\darkolythe\shulkerpacks\CommandReload.class
me\darkolythe\shulkerpacks\ShulkerListener$5.class
me\darkolythe\shulkerpacks\ShulkerListener$3.class
me\darkolythe\shulkerpacks\ShulkerListener$2.class
me\darkolythe\shulkerpacks\ShulkerListener$4.class
me\darkolythe\shulkerpacks\ShulkerListener.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
C:\Users\dinob\IdeaProjects\ShulkerPacks\src\main\java\me\darkolythe\shulkerpacks\CommandReload.java
C:\Users\dinob\IdeaProjects\ShulkerPacks\src\main\java\me\darkolythe\shulkerpacks\ShulkerListener.java
C:\Users\dinob\IdeaProjects\ShulkerPacks\src\main\java\me\darkolythe\shulkerpacks\ShulkerHolder.java
C:\Users\dinob\IdeaProjects\ShulkerPacks\src\main\java\me\darkolythe\shulkerpacks\ShulkerPacks.java
C:\Users\dinob\IdeaProjects\ShulkerPacks\src\main\java\me\darkolythe\shulkerpacks\ConfigHandler.java
Binary file added target/original-ShulkerPacks-1.6.5.jar
Binary file not shown.