inventory click bug fix attempt #2

This commit is contained in:
mikx 2023-11-27 21:52:32 -05:00
parent b5c626cf3e
commit b6ab82c8e1
3 changed files with 8 additions and 12 deletions

View File

@ -64,7 +64,9 @@ public final class CubeTP extends JavaPlugin implements Listener {
File f = new File("plugins/CubeTP/config.yml");
if(!f.exists())
{
getLogger().info("Generating config...");
saveDefaultConfig();
reloadConfig();
}
getLogger().info("Loading config...");
@ -96,7 +98,7 @@ public final class CubeTP extends JavaPlugin implements Listener {
Sign sign = (Sign) state;
SignSide sside = sign.getSide(Side.FRONT);
curCubeName = sside.getLine(0);
if(!sside.getLine(1).isEmpty()){
if(sside.getLine(1).equals("pri")){
curCubePrivate = true;
} else {
curCubePrivate = false;
@ -104,7 +106,6 @@ public final class CubeTP extends JavaPlugin implements Listener {
curCubeX = clickedBlock.getLocation().getBlockX();
curCubeY = clickedBlock.getLocation().getBlockY();
curCubeZ = clickedBlock.getLocation().getBlockZ();
inCubeTPInventory = true;
ShowUI(player);
}
if(action == Action.RIGHT_CLICK_BLOCK){
@ -112,7 +113,6 @@ public final class CubeTP extends JavaPlugin implements Listener {
if(mhi.getItemMeta() != null){
String mainhand = mhi.getItemMeta().getDisplayName();
if(mainhand.equals("Tome de portail")){
inCubeTPInventory = true;
ShowUIPortal(player);
mhi.setAmount(0);
}
@ -123,7 +123,7 @@ public final class CubeTP extends JavaPlugin implements Listener {
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) throws SQLException {
if(inCubeTPInventory){
if(e.getInventory().equals(inv)){
e.setCancelled(true);
if (!e.isLeftClick()) return;
@ -147,7 +147,6 @@ public final class CubeTP extends JavaPlugin implements Listener {
p.sendMessage(MessageFormat.format("§bLe cube {0} a été ajouté.", curCubeName));
ShowUI(p);
}
inCubeTPInventory = false;
}
// create a tome of portal from a book
@ -159,7 +158,6 @@ public final class CubeTP extends JavaPlugin implements Listener {
} else {
p.sendMessage("§bVous devez posséder un livre pour créer cet objet.");
}
inCubeTPInventory = false;
}
// unregister a cube
@ -171,21 +169,18 @@ public final class CubeTP extends JavaPlugin implements Listener {
} else {
p.sendMessage(MessageFormat.format("§bLe cube {0} n'existe pas.", curCubeName));
}
inCubeTPInventory = false;
}
// tp to a remote cube
if (e.getRawSlot() >= 9){
String name = e.getCurrentItem().getItemMeta().getDisplayName();
CubeTP(p,name);
inCubeTPInventory = false;
}
}
}
@EventHandler
public void InventoryCloseEvent(final InventoryCloseEvent e) throws SQLException {
inCubeTPInventory = false;
}
@EventHandler
@ -348,6 +343,7 @@ public final class CubeTP extends JavaPlugin implements Listener {
@Override
public void onDisable() {
//Disable message
getLogger().info("Disabled!");
}
}

View File

@ -1,4 +1,4 @@
name: CubeTP
version: '1.2.1'
version: '1.2.2'
main: ovh.mxg.cubetp.CubeTP
api-version: '1.20'

View File

@ -1,4 +1,4 @@
name: CubeTP
version: '1.2.1'
version: '1.2.2'
main: ovh.mxg.cubetp.CubeTP
api-version: '1.20'