|
|
|
@@ -7,10 +7,13 @@ import org.bukkit.block.Sign;
|
|
|
|
import org.bukkit.block.sign.Side;
|
|
|
|
import org.bukkit.block.sign.Side;
|
|
|
|
import org.bukkit.block.sign.SignSide;
|
|
|
|
import org.bukkit.block.sign.SignSide;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Item;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.block.Action;
|
|
|
|
import org.bukkit.event.block.Action;
|
|
|
|
|
|
|
|
import org.bukkit.event.block.BlockBreakEvent;
|
|
|
|
|
|
|
|
import org.bukkit.event.block.SignChangeEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
|
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
|
|
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
|
|
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
|
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
|
|
@@ -41,6 +44,8 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
public static String database;
|
|
|
|
public static String database;
|
|
|
|
public static String username;
|
|
|
|
public static String username;
|
|
|
|
public static String password;
|
|
|
|
public static String password;
|
|
|
|
|
|
|
|
public static Material cubeTP;
|
|
|
|
|
|
|
|
public static Material tomePortalReagent;
|
|
|
|
Inventory inv = null;
|
|
|
|
Inventory inv = null;
|
|
|
|
Location clickedCubeLoc;
|
|
|
|
Location clickedCubeLoc;
|
|
|
|
Block clickedBlock;
|
|
|
|
Block clickedBlock;
|
|
|
|
@@ -65,6 +70,8 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
database = getConfig().getString("MxCraftTP.sqlDB");
|
|
|
|
database = getConfig().getString("MxCraftTP.sqlDB");
|
|
|
|
username = getConfig().getString("MxCraftTP.sqlUser");
|
|
|
|
username = getConfig().getString("MxCraftTP.sqlUser");
|
|
|
|
password = getConfig().getString("MxCraftTP.sqlPass");
|
|
|
|
password = getConfig().getString("MxCraftTP.sqlPass");
|
|
|
|
|
|
|
|
cubeTP = Material.valueOf(getConfig().getString("MxCraftTP.cubeMaterial"));
|
|
|
|
|
|
|
|
tomePortalReagent = Material.valueOf(getConfig().getString("MxCraftTP.tomePortalReagent"));
|
|
|
|
|
|
|
|
|
|
|
|
getLogger().info("Enabled!");
|
|
|
|
getLogger().info("Enabled!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -78,7 +85,7 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
if (clickedBlock == null) return;
|
|
|
|
if (clickedBlock == null) return;
|
|
|
|
World world = getServer().getWorld("world");
|
|
|
|
World world = getServer().getWorld("world");
|
|
|
|
Block block = world.getBlockAt(clickedBlock.getLocation().getBlockX(), clickedBlock.getLocation().getBlockY()+1, clickedBlock.getLocation().getBlockZ());
|
|
|
|
Block block = world.getBlockAt(clickedBlock.getLocation().getBlockX(), clickedBlock.getLocation().getBlockY()+1, clickedBlock.getLocation().getBlockZ());
|
|
|
|
if(action == Action.RIGHT_CLICK_BLOCK && clickedBlock.getType() == Material.GOLD_BLOCK && block.getState() instanceof Sign){
|
|
|
|
if(action == Action.RIGHT_CLICK_BLOCK && clickedBlock.getType() == cubeTP && block.getState() instanceof Sign){
|
|
|
|
clickedCubeLoc = clickedBlock.getLocation();
|
|
|
|
clickedCubeLoc = clickedBlock.getLocation();
|
|
|
|
world = getServer().getWorld("world");
|
|
|
|
world = getServer().getWorld("world");
|
|
|
|
block = world.getBlockAt(clickedBlock.getLocation().getBlockX(), clickedBlock.getLocation().getBlockY()+1, clickedBlock.getLocation().getBlockZ());
|
|
|
|
block = world.getBlockAt(clickedBlock.getLocation().getBlockX(), clickedBlock.getLocation().getBlockY()+1, clickedBlock.getLocation().getBlockZ());
|
|
|
|
@@ -91,6 +98,16 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
curCubeZ = clickedBlock.getLocation().getBlockZ();
|
|
|
|
curCubeZ = clickedBlock.getLocation().getBlockZ();
|
|
|
|
ShowUI(player);
|
|
|
|
ShowUI(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(action == Action.RIGHT_CLICK_BLOCK){
|
|
|
|
|
|
|
|
ItemStack mhi = player.getInventory().getItemInMainHand();
|
|
|
|
|
|
|
|
if(mhi.getItemMeta() != null){
|
|
|
|
|
|
|
|
String mainhand = mhi.getItemMeta().getDisplayName();
|
|
|
|
|
|
|
|
if(mainhand.equals("Tome de portail")){
|
|
|
|
|
|
|
|
ShowUIPortal(player);
|
|
|
|
|
|
|
|
mhi.setAmount(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -107,6 +124,7 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
|
|
|
|
|
|
|
|
final Player p = (Player) e.getWhoClicked();
|
|
|
|
final Player p = (Player) e.getWhoClicked();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// register the cube
|
|
|
|
if (e.getRawSlot() == 3){
|
|
|
|
if (e.getRawSlot() == 3){
|
|
|
|
if(SQL.CheckCubeNameExists(curCubeName)){
|
|
|
|
if(SQL.CheckCubeNameExists(curCubeName)){
|
|
|
|
p.sendMessage(MessageFormat.format("§bLe cube {0} existe déjà. Changez le nom.", curCubeName));
|
|
|
|
p.sendMessage(MessageFormat.format("§bLe cube {0} existe déjà. Changez le nom.", curCubeName));
|
|
|
|
@@ -117,6 +135,18 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create a tome of portal from a book
|
|
|
|
|
|
|
|
if (e.getRawSlot() == 4){
|
|
|
|
|
|
|
|
Inventory pinv = p.getInventory();
|
|
|
|
|
|
|
|
if(HaveBook(p)){
|
|
|
|
|
|
|
|
TakeBook(p);
|
|
|
|
|
|
|
|
pinv.addItem(createGuiItem(Material.ENCHANTED_BOOK, "Tome de portail", "Permets d'aller vers un cube, pas de revenir."));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
p.sendMessage("§bVous devez posséder un livre pour créer cet objet.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// unregister a cube
|
|
|
|
if (e.getRawSlot() == 5){
|
|
|
|
if (e.getRawSlot() == 5){
|
|
|
|
if(SQL.CheckCubeNameExists(curCubeName)){
|
|
|
|
if(SQL.CheckCubeNameExists(curCubeName)){
|
|
|
|
SQL.DeleteCubeByName(curCubeName);
|
|
|
|
SQL.DeleteCubeByName(curCubeName);
|
|
|
|
@@ -127,17 +157,86 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tp to a remote cube
|
|
|
|
if (e.getRawSlot() >= 9){
|
|
|
|
if (e.getRawSlot() >= 9){
|
|
|
|
String name = e.getCurrentItem().getItemMeta().getDisplayName();
|
|
|
|
String name = e.getCurrentItem().getItemMeta().getDisplayName();
|
|
|
|
CubeTP(p,name);
|
|
|
|
CubeTP(p,name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
|
|
|
public void onBlockBreakWithSignOnIt(BlockBreakEvent event){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
|
|
|
public void onBlockBreak(BlockBreakEvent event) throws SQLException {
|
|
|
|
|
|
|
|
final Player p = (Player) event.getPlayer();
|
|
|
|
|
|
|
|
Block block = event.getBlock();
|
|
|
|
|
|
|
|
if(block.getState() instanceof Sign){
|
|
|
|
|
|
|
|
BlockState state = block.getState();
|
|
|
|
|
|
|
|
Sign sign = (Sign) state;
|
|
|
|
|
|
|
|
SignSide sside = sign.getSide(Side.FRONT);
|
|
|
|
|
|
|
|
double x = block.getX();
|
|
|
|
|
|
|
|
double y = block.getY()-1;
|
|
|
|
|
|
|
|
double z = block.getZ();
|
|
|
|
|
|
|
|
if(SQL.CheckCubeByLocation(x, y, z)){
|
|
|
|
|
|
|
|
String st = sside.getLine(0);
|
|
|
|
|
|
|
|
SQL.DeleteCubeByName(st);
|
|
|
|
|
|
|
|
Block cb = p.getWorld().getBlockAt(block.getX(),block.getY()-1, block.getZ());
|
|
|
|
|
|
|
|
cb.setType(Material.AIR);
|
|
|
|
|
|
|
|
ItemStack item = new ItemStack(cubeTP, 1);
|
|
|
|
|
|
|
|
p.getWorld().dropItem(p.getLocation(), item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(block.getType() == Material.GOLD_BLOCK){
|
|
|
|
|
|
|
|
double x = block.getX();
|
|
|
|
|
|
|
|
double y = block.getY();
|
|
|
|
|
|
|
|
double z = block.getZ();
|
|
|
|
|
|
|
|
if(SQL.CheckCubeByLocation(x, y, z)){
|
|
|
|
|
|
|
|
Block sb = p.getWorld().getBlockAt(block.getX(),block.getY()+1, block.getZ());
|
|
|
|
|
|
|
|
BlockState state = sb.getState();
|
|
|
|
|
|
|
|
Sign sign = (Sign) state;
|
|
|
|
|
|
|
|
SignSide sside = sign.getSide(Side.FRONT);
|
|
|
|
|
|
|
|
String st = sside.getLine(0);
|
|
|
|
|
|
|
|
SQL.DeleteCubeByName(st);
|
|
|
|
|
|
|
|
sb.setType(Material.AIR);
|
|
|
|
|
|
|
|
ItemStack item = new ItemStack(Material.OAK_SIGN, 1);
|
|
|
|
|
|
|
|
p.getWorld().dropItem(p.getLocation(), item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
@EventHandler
|
|
|
|
public void onPlayerChat(AsyncPlayerChatEvent event){
|
|
|
|
public void onPlayerChat(AsyncPlayerChatEvent event){
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean HaveBook(Player player){
|
|
|
|
|
|
|
|
boolean hb = false;
|
|
|
|
|
|
|
|
Inventory pinv = player.getInventory();
|
|
|
|
|
|
|
|
for(ItemStack i: pinv){
|
|
|
|
|
|
|
|
if(i != null){
|
|
|
|
|
|
|
|
if(i.getType() == tomePortalReagent){
|
|
|
|
|
|
|
|
hb = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return hb;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void TakeBook(Player player){
|
|
|
|
|
|
|
|
int ba = 0;
|
|
|
|
|
|
|
|
Inventory pinv = player.getInventory();
|
|
|
|
|
|
|
|
for(ItemStack i: pinv){
|
|
|
|
|
|
|
|
if(i != null){
|
|
|
|
|
|
|
|
if(i.getType() == tomePortalReagent){
|
|
|
|
|
|
|
|
ba = i.getAmount();
|
|
|
|
|
|
|
|
i.setAmount(ba-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowUI(Player player) throws SQLException {
|
|
|
|
public void ShowUI(Player player) throws SQLException {
|
|
|
|
inv = Bukkit.createInventory(null, 45, "MxCraftTP");
|
|
|
|
inv = Bukkit.createInventory(null, 45, "MxCraftTP");
|
|
|
|
World world = getServer().getWorld("world");
|
|
|
|
World world = getServer().getWorld("world");
|
|
|
|
@@ -151,12 +250,26 @@ public final class MxCraftTP extends JavaPlugin implements Listener {
|
|
|
|
inv.setItem(1,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(1,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(2,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(2,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(3,createGuiItem(Material.BOOK, "§bEnregistrer", lore01, lore02));
|
|
|
|
inv.setItem(3,createGuiItem(Material.BOOK, "§bEnregistrer", lore01, lore02));
|
|
|
|
inv.setItem(4,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(4,createGuiItem(Material.ENCHANTED_BOOK, "Tome de portail"));
|
|
|
|
inv.setItem(5,createGuiItem(Material.TNT, "§bRetirer", "§aRetirer de la liste de TP."));
|
|
|
|
inv.setItem(5,createGuiItem(Material.TNT, "§bRetirer", "§aRetirer de la liste de TP."));
|
|
|
|
inv.setItem(6,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(6,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(7,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(7,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(8,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(8,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
inv.setItem(9,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
AddAllCubes(player);
|
|
|
|
|
|
|
|
player.openInventory(inv);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowUIPortal(Player player) throws SQLException {
|
|
|
|
|
|
|
|
inv = Bukkit.createInventory(null, 45, "MxCraftTP");
|
|
|
|
|
|
|
|
inv.setItem(0,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(1,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(2,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(3,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(4,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(5,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(6,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(7,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
|
|
|
|
inv.setItem(8,createGuiItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
|
|
|
AddAllCubes(player);
|
|
|
|
AddAllCubes(player);
|
|
|
|
player.openInventory(inv);
|
|
|
|
player.openInventory(inv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|