Skip to content
This repository has been archived by the owner on Sep 19, 2018. It is now read-only.

Commit

Permalink
2.75
Browse files Browse the repository at this point in the history
  • Loading branch information
Acrobot committed Jun 5, 2011
1 parent 7da9232 commit e25be8f
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 207 deletions.
6 changes: 4 additions & 2 deletions com/Acrobot/iConomyChestShop/DBqueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public static void saveQueue(){
}

public static void saveQueueOnExit(){
iConomyChestShop.getPlugin().getDatabase().save(queue);
queue.clear();
try{
iConomyChestShop.getPlugin().getDatabase().save(queue);
queue.clear();
}catch (Exception ignored){}
}

public void run(){
Expand Down
8 changes: 6 additions & 2 deletions com/Acrobot/iConomyChestShop/Shop.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.Acrobot.iConomyChestShop.Chests.ChestObject;
import com.Acrobot.iConomyChestShop.Chests.MinecraftChest;

import org.bukkit.Location;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -71,12 +73,14 @@ public boolean buy(Player player){
EconomyManager.add(owner, getBuyPrice());
}else{
String account = ConfigManager.getString("serverAccountName");
if(!account.equals("") && EconomyManager.hasAccount(account)){
if(account != null && EconomyManager.hasAccount(account)){
EconomyManager.add(account, getSellPrice());
}
}
stock.setAmount(stockAmount);
Basic.addItemToInventory(player.getInventory(), stock, stockAmount);

//player.getInventory().addItem(stock);
player.updateInventory();

//////////////PAYMENT////////////////
Expand Down Expand Up @@ -109,7 +113,7 @@ public boolean sell(Player player){
EconomyManager.substract(owner, getSellPrice());
}else{
String account = ConfigManager.getString("serverAccountName");
if(!account.equals("") && EconomyManager.hasAccount(account)){
if(account != null && EconomyManager.hasAccount(account)){
EconomyManager.substract(account, getSellPrice());
}
}
Expand Down
32 changes: 20 additions & 12 deletions com/Acrobot/iConomyChestShop/SignManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public void onSignChange(SignChangeEvent event) {
p.sendMessage(ConfigManager.getLanguage("Negative_price"));
return;
}
if(!priceIsOK(text[2]) && !isAdmin){
p.sendMessage(ConfigManager.getLanguage("Incorrect_price"));
Basic.cancelEventAndDropSign(event);
return;
}
if (Integer.parseInt(text[1]) < 1) {
Basic.cancelEventAndDropSign(event);
p.sendMessage(ConfigManager.getLanguage("Incorrect_item_amount"));
Expand Down Expand Up @@ -172,12 +177,14 @@ public void onSignChange(SignChangeEvent event) {
}
}

private boolean priceIsOK(String signLine, Material item) {
Double maxPrice = ConfigManager.getDouble(item.getId() + ".maxPrice");
Double minPrice = ConfigManager.getDouble(item.getId() + ".minPrice");
private boolean priceIsOK(String signLine) {
Double maxPrice = ConfigManager.getDouble("maxPrice");
Double minPrice = ConfigManager.getDouble("minPrice");
Float buyPrice = buyPrice(signLine);
Float sellPrice = sellPrice(signLine);
return !(maxPrice != -1 && (buyPrice > maxPrice || sellPrice > maxPrice)) && !(minPrice != -1 && (buyPrice < maxPrice || sellPrice < maxPrice));

System.out.println(maxPrice + " " + minPrice + " " + buyPrice + " " + sellPrice);
return !(maxPrice != -1 && (buyPrice > maxPrice || sellPrice > maxPrice)) && !(minPrice != -1 && (buyPrice < minPrice || sellPrice < minPrice));
}


Expand All @@ -197,13 +204,13 @@ public static boolean mySign(String text[]) {
public static float buyPrice(String text) {
text = text.replace(" ", "");
text = text.toLowerCase();
if (!text.contains("b")) {
return 0;
}
//text = text.replaceAll("(?!free)[A-Z,a-z]", "");
text = text.replace("b", "");
String bs[] = text.split(":");
if (bs.length == 1) {
if (!text.contains("b")) {
return 0;
}
text = text.replace("b", "");
//text = text.replace("B", "");
if (text.equals("free")) {
return -1;
Expand Down Expand Up @@ -232,12 +239,12 @@ public static float buyPrice(Sign sign) {
public static float sellPrice(String text) {
text = text.replace(" ", "");
text = text.toLowerCase();
if (!text.contains("s")) {
return 0;
}
text = text.replace("s", "");
String bs[] = text.split(":");
if (bs.length == 1) {
if (!text.contains("s")) {
return 0;
}
text = text.replace("s", "");
if (text.equals("free")) {
return -1;
}
Expand All @@ -246,6 +253,7 @@ public static float sellPrice(String text) {
}
} else if (bs.length == 2) {
text = bs[1];
text = text.replace("s", "");
if (text.equals("free")) {
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions com/Acrobot/iConomyChestShop/iConomyChestShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ public static iConomyChestShop getPlugin(){
}

public void onDisable() {
DBqueue.saveQueueOnExit();
this.getServer().getScheduler().cancelAllTasks();
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println("[" + pdfFile.getName() + "]" + " version " + pdfFile.getVersion() + " distabled!");

DBqueue.saveQueueOnExit();
}
}

14 changes: 14 additions & 0 deletions com/nijikokun/register/payment/Method.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package com.nijikokun.register.payment;

import org.bukkit.plugin.Plugin;

/**
* Method.java
* Interface for all sub-methods for payment.
*
* @author: Nijikokun<[email protected]> (@nijikokun)
* @copyright: Copyright (C) 2011
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
*/
public interface Method {
public Object getPlugin();
public String getName();
Expand All @@ -11,9 +21,12 @@ public interface Method {
public boolean hasBankAccount(String bank, String name);
public MethodAccount getAccount(String name);
public MethodBankAccount getBankAccount(String bank, String name);
public boolean isCompatible(Plugin plugin);
public void setPlugin(Plugin plugin);

public interface MethodAccount {
public double balance();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
Expand All @@ -32,6 +45,7 @@ public interface MethodBankAccount {
public double balance();
public String getBankName();
public int getBankId();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
Expand Down
106 changes: 0 additions & 106 deletions com/nijikokun/register/payment/MethodEEco.java

This file was deleted.

Loading

0 comments on commit e25be8f

Please sign in to comment.