UUID changes

This commit is contained in:
Andrzej Pomirski 2014-04-12 14:22:34 +02:00
parent 4107b10f4b
commit b37ae0fbc4
6 changed files with 24 additions and 20 deletions

View File

@ -1,6 +1,7 @@
package com.Acrobot.ChestShop.Events.Protection;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -11,14 +12,14 @@ import org.bukkit.event.HandlerList;
public class ProtectBlockEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Player player;
private Block block;
private String name;
boolean isProtected = false;
public ProtectBlockEvent(Block block, String name) {
public ProtectBlockEvent(Block block, Player player) {
this.block = block;
this.name = name;
this.player = player;
}
public boolean isProtected() {
@ -33,8 +34,8 @@ public class ProtectBlockEvent extends Event {
return block;
}
public String getName() {
return name;
public Player getPlayer() {
return player;
}
public HandlerList getHandlers() {

View File

@ -6,6 +6,7 @@ import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.DB.Queue;
import com.Acrobot.ChestShop.DB.Transaction;
import com.Acrobot.ChestShop.Events.TransactionEvent;
import com.Acrobot.ChestShop.UUIDs.NameManager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -63,8 +64,8 @@ public class TransactionLogger implements Listener {
transaction.setPrice((float) pricePerStack);
transaction.setShopOwner(event.getOwner().getName());
transaction.setShopUser(event.getClient().getName());
transaction.setShopOwner(NameManager.getUsername(event.getOwner().getUniqueId()));
transaction.setShopUser(NameManager.getUsername(event.getClient().getUniqueId()));
transaction.setSec(System.currentTimeMillis() / 1000);
transaction.setBuy(event.getTransactionType() == BUY);

View File

@ -15,6 +15,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
/**
* @author Acrobot
*/
@ -30,7 +32,7 @@ public class TransactionMessageSender implements Listener {
protected static void sendBuyMessage(TransactionEvent event) {
String itemName = parseItemInformation(event.getStock());
String owner = event.getOwner().getName();
String owner = NameManager.getUsername(event.getOwner().getUniqueId());
Player player = event.getClient();
@ -53,7 +55,7 @@ public class TransactionMessageSender implements Listener {
protected static void sendSellMessage(TransactionEvent event) {
String itemName = parseItemInformation(event.getStock());
String owner = event.getOwner().getName();
String owner = NameManager.getUsername(event.getOwner().getUniqueId());
Player player = event.getClient();
@ -88,10 +90,9 @@ public class TransactionMessageSender implements Listener {
}
private static void sendMessageToOwner(String message, TransactionEvent event) {
String owner = event.getOwner().getName();
owner = NameManager.getFullUsername(owner);
UUID owner = event.getOwner().getUniqueId();
Player player = Bukkit.getPlayerExact(owner);
Player player = Bukkit.getPlayer(owner);
if (player != null) {
player.sendMessage(message);

View File

@ -7,6 +7,7 @@ import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
import com.Acrobot.ChestShop.Events.ShopDestroyedEvent;
import com.Acrobot.ChestShop.Security;
import com.Acrobot.ChestShop.UUIDs.NameManager;
import com.griefcraft.lwc.LWC;
import com.griefcraft.model.Protection;
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
@ -36,12 +37,12 @@ public class LightweightChestProtection implements Listener {
Chest connectedChest = event.getChest();
if (Properties.PROTECT_SIGN_WITH_LWC) {
if (!Security.protect(player.getName(), sign.getBlock())) {
if (!Security.protect(player, sign.getBlock())) {
player.sendMessage(Messages.prefix(Messages.NOT_ENOUGH_PROTECTIONS));
}
}
if (Properties.PROTECT_CHEST_WITH_LWC && connectedChest != null && Security.protect(player.getName(), connectedChest.getBlock())) {
if (Properties.PROTECT_CHEST_WITH_LWC && connectedChest != null && Security.protect(player, connectedChest.getBlock())) {
player.sendMessage(Messages.prefix(Messages.PROTECTED_SHOP));
}
}
@ -73,7 +74,7 @@ public class LightweightChestProtection implements Listener {
}
Block block = event.getBlock();
Player player = Bukkit.getPlayerExact(event.getName());
Player player = event.getPlayer();
if (player == null) {
return;
@ -99,7 +100,7 @@ public class LightweightChestProtection implements Listener {
return;
}
Protection protection = lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), Protection.Type.PRIVATE, worldName, event.getName(), "", x, y, z);
Protection protection = lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), Protection.Type.PRIVATE, worldName, player.getName(), "", x, y, z);
if (protection != null) {
event.setProtected(true);

View File

@ -20,8 +20,8 @@ public class Security {
private static final BlockFace[] SIGN_CONNECTION_FACES = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
private static final BlockFace[] BLOCKS_AROUND = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
public static boolean protect(String playerName, Block block) {
ProtectBlockEvent event = new ProtectBlockEvent(block, playerName);
public static boolean protect(Player player, Block block) {
ProtectBlockEvent event = new ProtectBlockEvent(block, player);
ChestShop.callEvent(event);
return event.isProtected();

View File

@ -54,7 +54,7 @@ public class NameManager {
}
if (account == null) {
return null;
return "";
}
return account.getName();
@ -118,7 +118,7 @@ public class NameManager {
connection = new JdbcConnectionSource(uri);
accounts = DaoManager.createDao(connection, Account.class);
TableUtils.createTable(connection, Account.class);
TableUtils.createTableIfNotExists(connection, Account.class);
} catch (SQLException e) {
e.printStackTrace();
}