inventory click bug fix
This commit is contained in:
parent
4ee326733c
commit
b5c626cf3e
|
@ -17,6 +17,7 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
@ -51,6 +52,7 @@ public final class CubeTP extends JavaPlugin implements Listener {
|
|||
Block clickedBlock;
|
||||
String curCubeName = "";
|
||||
boolean curCubePrivate = false;
|
||||
boolean inCubeTPInventory = false;
|
||||
double curCubeX = 0;
|
||||
double curCubeY = 0;
|
||||
double curCubeZ = 0;
|
||||
|
@ -102,6 +104,7 @@ 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){
|
||||
|
@ -109,6 +112,7 @@ 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);
|
||||
}
|
||||
|
@ -119,6 +123,7 @@ public final class CubeTP extends JavaPlugin implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onInventoryClick(final InventoryClickEvent e) throws SQLException {
|
||||
if(inCubeTPInventory){
|
||||
e.setCancelled(true);
|
||||
if (!e.isLeftClick()) return;
|
||||
|
||||
|
@ -142,6 +147,7 @@ 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
|
||||
|
@ -153,6 +159,7 @@ 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
|
||||
|
@ -164,14 +171,22 @@ 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
|
||||
public void onBlockBreakWithSignOnIt(BlockBreakEvent event){
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: CubeTP
|
||||
version: '1.2.0'
|
||||
version: '1.2.1'
|
||||
main: ovh.mxg.cubetp.CubeTP
|
||||
api-version: '1.20'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: CubeTP
|
||||
version: '1.2.0'
|
||||
version: '1.2.1'
|
||||
main: ovh.mxg.cubetp.CubeTP
|
||||
api-version: '1.20'
|
||||
|
|
Loading…
Reference in New Issue