1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

格式化代码 修复商店创建BUG(7老板)...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2016-01-15 00:05:44 +08:00
parent 062534af1f
commit b00e35dc17
51 changed files with 4943 additions and 4936 deletions

View File

@ -44,7 +44,8 @@ public class DatabaseHelper {
*/ */
public static void createShopsTable(Database db) throws SQLException { public static void createShopsTable(Database db) throws SQLException {
Statement st = db.getConnection().createStatement(); Statement st = db.getConnection().createStatement();
String createTable = "CREATE TABLE shops (" + "owner TEXT(32) NOT NULL, " + "price double(32, 2) NOT NULL, " + "itemConfig TEXT CHARSET utf8 NOT NULL, " + "x INTEGER(32) NOT NULL, " + "y INTEGER(32) NOT NULL, " + "z INTEGER(32) NOT NULL, " + "world VARCHAR(32) NOT NULL, " + "unlimited boolean, " + "type boolean, " + "PRIMARY KEY (x, y, z, world) " + ");"; String createTable = "CREATE TABLE shops (" + "owner TEXT(32) NOT NULL, " + "price double(32, 2) NOT NULL, " + "itemConfig TEXT CHARSET utf8 NOT NULL, " + "x INTEGER(32) NOT NULL, "
+ "y INTEGER(32) NOT NULL, " + "z INTEGER(32) NOT NULL, " + "world VARCHAR(32) NOT NULL, " + "unlimited boolean, " + "type boolean, " + "PRIMARY KEY (x, y, z, world) " + ");";
st.execute(createTable); st.execute(createTable);
} }

View File

@ -23,7 +23,7 @@ import org.maxgamer.QuickShop.Util.MsgUtil;
import org.maxgamer.QuickShop.Util.Util; import org.maxgamer.QuickShop.Util.Util;
public class ContainerShop implements Shop { public class ContainerShop implements Shop {
private DisplayItem displayName; private DisplayItem displayItem;
private final ItemStack item; private final ItemStack item;
private final Location loc; private final Location loc;
private String owner; private String owner;
@ -54,16 +54,16 @@ public class ContainerShop implements Shop {
this.item.setAmount(1); this.item.setAmount(1);
if (plugin.getConfigManager().isDisplay()) { if (plugin.getConfigManager().isDisplay()) {
if (plugin.getConfigManager().isFakeItem()) { if (plugin.getConfigManager().isFakeItem()) {
this.displayName = new FakeItem(this, this.getItem()); this.displayItem = new FakeItem(this, this.getItem());
} else { } else {
this.displayName = new NormalItem(this, this.getItem()); this.displayItem = new NormalItem(this, this.getItem());
} }
} }
this.shopType = ShopType.SELLING; this.shopType = ShopType.SELLING;
} }
private ContainerShop(final ContainerShop s) { private ContainerShop(final ContainerShop s) {
this.displayName = s.displayName; this.displayItem = s.displayItem;
this.shopType = s.shopType; this.shopType = s.shopType;
this.item = s.item; this.item = s.item;
this.loc = s.loc; this.loc = s.loc;
@ -247,7 +247,7 @@ public class ContainerShop implements Shop {
* @return The display item associated with this shop. * @return The display item associated with this shop.
*/ */
public DisplayItem getDisplayItem() { public DisplayItem getDisplayItem() {
return this.displayName; return this.displayItem;
} }
/** /**
@ -473,7 +473,7 @@ public class ContainerShop implements Shop {
public void onUnload() { public void onUnload() {
if (this.getDisplayItem() != null) { if (this.getDisplayItem() != null) {
this.getDisplayItem().remove(); this.getDisplayItem().remove();
this.displayName = null; this.displayItem = null;
} }
} }
@ -682,17 +682,17 @@ public class ContainerShop implements Shop {
final boolean trans = Util.isTransparent(getLocation().clone().add(0.5, 1.2, 0.5).getBlock().getType()); final boolean trans = Util.isTransparent(getLocation().clone().add(0.5, 1.2, 0.5).getBlock().getType());
if (trans && this.getDisplayItem() == null) { if (trans && this.getDisplayItem() == null) {
if (plugin.getConfigManager().isFakeItem()) { if (plugin.getConfigManager().isFakeItem()) {
this.displayName = new FakeItem(this, this.getItem()); this.displayItem = new FakeItem(this, this.getItem());
} else { } else {
this.displayName = new NormalItem(this, this.getItem()); this.displayItem = new NormalItem(this, this.getItem());
} }
this.getDisplayItem().spawn(); this.getDisplayItem().spawn();
return; return;
} }
if (this.getDisplayItem() != null) { if (this.getDisplayItem() != null && displayItem instanceof NormalItem) {
if (!trans) { // We have a display item in a block... delete it if (!trans) { // We have a display item in a block... delete it
this.getDisplayItem().remove(); this.getDisplayItem().remove();
this.displayName = null; this.displayItem = null;
return; return;
} }
final DisplayItem disItem = this.getDisplayItem(); final DisplayItem disItem = this.getDisplayItem();

View File

@ -122,7 +122,7 @@ public class FakeItem implements DisplayItem {
public FakeItem(final ContainerShop containerShop, final ItemStack item) { public FakeItem(final ContainerShop containerShop, final ItemStack item) {
this.itemStack = item; this.itemStack = item;
this.location = containerShop.getLocation().add(0.5, 1, 0.5); this.location = containerShop.getLocation().clone().add(0.5, 1, 0.5);
this.eid = getFakeEntityId(); this.eid = getFakeEntityId();
} }
@ -154,8 +154,10 @@ public class FakeItem implements DisplayItem {
@Override @Override
public void respawn() { public void respawn() {
destory(); ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDestoryPacket());
create(); ProtocolLibrary.getProtocolManager().broadcastServerPacket(getSpawnPacket());
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getVelocityPacket());
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getMetadataPacket());
} }
@Override @Override

View File

@ -1,5 +1,7 @@
package org.maxgamer.QuickShop.Shop; package org.maxgamer.QuickShop.Shop;
public enum ShopAction { public enum ShopAction {
BUY(), CREATE(), CANCELLED(); BUY(),
CREATE(),
CANCELLED();
} }

View File

@ -1,8 +1,10 @@
package org.maxgamer.QuickShop.Shop; package org.maxgamer.QuickShop.Shop;
public enum ShopType { public enum ShopType {
SELLING(0), BUYING(1); SELLING(0),
BUYING(1);
private int id; private int id;
private ShopType(int id) { private ShopType(int id) {
this.id = id; this.id = id;
} }