mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-12-31 18:17:49 +01:00
Bugfixes
More shulkerboxes related stuff is blocked now
This commit is contained in:
parent
9ae1909200
commit
d82bea094f
@ -4,7 +4,7 @@ website: ${website}
|
||||
main: ${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}
|
||||
description: ${project.description}
|
||||
version: ${project.version}
|
||||
depend: [PCGF_MC_Plugin_Lib]
|
||||
depend: [PCGF_PluginLib]
|
||||
commands:
|
||||
backpack:
|
||||
description: Main command
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 GeorgH93
|
||||
* Copyright (C) 2016-2017 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -309,7 +309,6 @@ public void run()
|
||||
{
|
||||
if(id <= 0)
|
||||
{
|
||||
final int newID;
|
||||
try(PreparedStatement ps = connection.prepareStatement(queryGetPlayerID))
|
||||
{
|
||||
ps.setString(1, nameOrUUID);
|
||||
@ -317,8 +316,8 @@ public void run()
|
||||
{
|
||||
if(rs.next())
|
||||
{
|
||||
newID = rs.getInt(1);
|
||||
DBTools.runStatement(connection, queryInsertBp, data, usedSerializer, id);
|
||||
final int newID = rs.getInt(1);
|
||||
DBTools.runStatement(connection, queryInsertBp, newID, data, usedSerializer);
|
||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 GeorgH93
|
||||
* Copyright (C) 2016-2017 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -86,11 +86,11 @@ protected void updateQuerysForDialect()
|
||||
{
|
||||
queryInsertBp = queryInsertBp.replaceAll("\\) VALUES \\(\\?,\\?,\\?", "{FieldBPLastUpdate}) VALUES (?,?,?,DATE('now')");
|
||||
}
|
||||
queryDeleteOldBackpacks = "DELETE FROM `{TableBackpacks}` WHERE `{FieldBPLastUpdate}` < DATE('now', '-{VarMaxAge} days')";
|
||||
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')";
|
||||
queryUpdateBp = queryUpdateBp.replaceAll("\\{NOW\\}", "DATE('now')");
|
||||
if(useUUIDs)
|
||||
{
|
||||
queryUpdatePlayerAdd = "INSERT OR IGNORE INTO `{TablePlayers}` (`{FieldName}`,`{FieldUUID}`) VALUES (?,?);";
|
||||
queryUpdatePlayerAdd = "INSERT OR IGNORE INTO {TablePlayers} ({FieldName},{FieldUUID}) VALUES (?,?);";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 GeorgH93
|
||||
* Copyright (C) 2016-2017 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -19,15 +19,22 @@
|
||||
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class DisableShulkerboxes extends ShulkerboxesListener implements Listener
|
||||
{
|
||||
//TODO remove shulkerboxes
|
||||
public DisableShulkerboxes(final Minepacks plugin)
|
||||
{
|
||||
super(plugin);
|
||||
@ -63,7 +70,7 @@ public void onInventoryOpen(InventoryOpenEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onItemMove(InventoryMoveItemEvent event)
|
||||
{
|
||||
if(SHULKER_BOX_MATERIALS.contains(event.getItem().getType()))
|
||||
if(event.getItem() != null && SHULKER_BOX_MATERIALS.contains(event.getItem().getType()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -72,7 +79,11 @@ public void onItemMove(InventoryMoveItemEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onItemMove(InventoryDragEvent event)
|
||||
{
|
||||
if(SHULKER_BOX_MATERIALS.contains(event.getCursor().getType()))
|
||||
if(event.getCursor() != null && SHULKER_BOX_MATERIALS.contains(event.getCursor().getType()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if(event.getOldCursor() != null && SHULKER_BOX_MATERIALS.contains(event.getOldCursor().getType()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -149,4 +160,40 @@ public void onBlockBreak(BlockMultiPlaceEvent event)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPrepareItemCraftEvent(PrepareItemCraftEvent event)
|
||||
{
|
||||
Material itemType = event.getRecipe().getResult().getType();
|
||||
if(itemType == Material.SHULKER_SHELL || SHULKER_BOX_MATERIALS.contains(itemType))
|
||||
{
|
||||
event.getInventory().setResult(new ItemStack(Material.AIR));
|
||||
//TODO message
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDrop(PlayerDropItemEvent event)
|
||||
{
|
||||
//TODO null checks
|
||||
Material itemType = event.getItemDrop().getItemStack().getType();
|
||||
if(itemType == Material.SHULKER_SHELL || SHULKER_BOX_MATERIALS.contains(itemType))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDrop(EntityDeathEvent event)
|
||||
{
|
||||
Iterator<ItemStack> it = event.getDrops().iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
Material itemType = it.next().getType();
|
||||
if(itemType == Material.SHULKER_SHELL || SHULKER_BOX_MATERIALS.contains(itemType))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 GeorgH93
|
||||
* Copyright (C) 2016-2017 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -39,8 +39,8 @@ public class EventListener implements Listener
|
||||
public EventListener(Minepacks mp)
|
||||
{
|
||||
plugin = mp;
|
||||
messageOwnBackpackClose = plugin.lang.getMessage("Ingame.OwnBackPackClose");
|
||||
messageOtherBackpackClose = plugin.lang.getMessage("Ingame.PlayerBackPackClose").replaceAll("\\{OwnerName\\}", "%1\\$s").replaceAll("\\{OwnerDisplayName\\}", "%2\\$s");
|
||||
messageOwnBackpackClose = plugin.lang.getMessage("Ingame.OwnBackpackClose");
|
||||
messageOtherBackpackClose = plugin.lang.getMessage("Ingame.PlayerBackpackClose").replaceAll("\\{OwnerName\\}", "%1\\$s").replaceAll("\\{OwnerDisplayName\\}", "%2\\$s");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 GeorgH93
|
||||
* Copyright (C) 2016-2017 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -21,9 +21,11 @@
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
|
||||
@ -42,7 +44,20 @@ public void onItemMove(InventoryMoveItemEvent event)
|
||||
{
|
||||
if(event.getDestination().getHolder() instanceof Backpack && SHULKER_BOX_MATERIALS.contains(event.getItem().getType()))
|
||||
{
|
||||
//TODO get player and send him a message
|
||||
if(event.getSource().getHolder() instanceof Player)
|
||||
{
|
||||
messageNotAllowedInBackpack.send((Player) event.getSource().getHolder());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onItemMove(InventoryClickEvent event)
|
||||
{
|
||||
if(event.getInventory().getHolder() instanceof Backpack && event.getCurrentItem() != null && SHULKER_BOX_MATERIALS.contains(event.getCurrentItem().getType()))
|
||||
{
|
||||
messageNotAllowedInBackpack.send(event.getView().getPlayer());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -50,9 +65,9 @@ public void onItemMove(InventoryMoveItemEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onItemMove(InventoryDragEvent event)
|
||||
{
|
||||
if(event.getInventory().getHolder() instanceof Backpack && SHULKER_BOX_MATERIALS.contains(event.getCursor().getType()))
|
||||
if(event.getInventory().getHolder() instanceof Backpack && event.getOldCursor() != null && SHULKER_BOX_MATERIALS.contains(event.getOldCursor().getType()))
|
||||
{
|
||||
//TODO get player and send him a message
|
||||
messageNotAllowedInBackpack.send(event.getView().getPlayer());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 GeorgH93
|
||||
* Copyright (C) 2016-2017 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -24,7 +24,7 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
class ShulkerboxesListener
|
||||
abstract class ShulkerboxesListener
|
||||
{
|
||||
protected static final Set<Material> SHULKER_BOX_MATERIALS = new HashSet<>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user