Skip to content

Commit

Permalink
2.1.4.1 - quick fix for 1.4.2 R2
Browse files Browse the repository at this point in the history
  • Loading branch information
jascotty2 committed Nov 5, 2012
1 parent 8167254 commit 8ed2492
Show file tree
Hide file tree
Showing 27 changed files with 433 additions and 39 deletions.
4 changes: 4 additions & 0 deletions changelog
Expand Up @@ -2,6 +2,10 @@
BetterShop Changelog: (the (?) means plugin didn't report that as the version.. sorry :))
===============================================================================

Version 2.1.4 - 2.1.4.1
quick fix to work with 1.4


Version 2.1.4 - 7/12/12 (actually 5/4/12.. sorry about that)
Fixed misleading error message from spamming console
- was caused from checking if empty-string bank exists in vault
Expand Down
1 change: 0 additions & 1 deletion src/me/jascotty2/bettershop/BSEcon.java
Expand Up @@ -21,7 +21,6 @@
import com.nijikokun.register_1_5.payment.Methods;
import java.util.Map.Entry;
import me.jascotty2.bettershop.enums.EconMethod;
import me.jascotty2.bettershop.utils.BSPermissions;
import me.jascotty2.bettershop.utils.BetterShopLogger;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.economy.Economy;
Expand Down
92 changes: 92 additions & 0 deletions src/me/jascotty2/bettershop/BSPermissions.java
@@ -0,0 +1,92 @@
/**
* Copyright (C) 2011 Jacob Scott <jascottytechie@gmail.com>
* Description: for handling permissions checks
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.jascotty2.bettershop;

import com.nijikokun.bukkit.Permissions.Permissions;
import me.jascotty2.bettershop.enums.BetterShopPermission;
import me.jascotty2.bettershop.utils.BetterShopLogger;
import me.jascotty2.lib.util.Str;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

/**
* @author jacob
*/
public class BSPermissions {

public static Permissions permissionsPlugin = null;
public static Permission vaultPerms = null;

public static boolean hasPermission(CommandSender player, BetterShopPermission node) {
return hasPermission(player, node.toString(), false);
}

public static boolean hasPermission(CommandSender player, BetterShopPermission node, boolean notify) {
return hasPermission(player, node.toString(), notify);
}

public static boolean hasPermission(CommandSender player, String node) {
return hasPermission(player, node, false);
}

public static boolean hasPermission(CommandSender player, String node, boolean notify) {
if (player == null || player.isOp() || !(player instanceof Player)
|| node == null || node.length() == 0) { // ops override permission check (double-check is a Player)
return true;
}
if (has((Player) player, node)) {
return true;
} else if (notify) {
//PermDeny(player, node);
BSutils.sendMessage(player,
BetterShop.getSettings().getString("permdeny").replace("<perm>", node));
}
return false;
}

public static boolean has(Player player, String node) {
try {
if (vaultPerms != null) {
return vaultPerms.has(player, node);
} else if (permissionsPlugin != null) {
return permissionsPlugin.getHandler().has(player, node);
}
// System.out.println("no perm: checking superperm for " + player.getName() + ": " + node);
// System.out.println(player.hasPermission(node));
// for(PermissionAttachmentInfo i : player.getEffectivePermissions()){
// System.out.println(i.getPermission());
// }
if (player.hasPermission(node)) {
return true;
} else if (!node.contains("*") && Str.count(node, '.') >= 2) {
// System.out.println("Checking for " + node.substring(0, node.lastIndexOf('.') + 1) + "* : "
// + player.hasPermission(node.substring(0, node.lastIndexOf('.') + 1) + "*"));
return player.hasPermission(node.substring(0, node.lastIndexOf('.') + 1) + "*");
}
// System.out.println("no permission");
return false;
} catch (Exception e) {
BetterShopLogger.Severe(e, false);
}
return node.length() < 16 // if invalid node, assume true
|| (!node.substring(0, 16).equalsIgnoreCase("BetterShop.admin") // only ops have access to .admin
&& !node.substring(0, 19).equalsIgnoreCase("BetterShop.discount"));
}

} // end class BSPermissions
1 change: 0 additions & 1 deletion src/me/jascotty2/bettershop/BSPluginListener.java
Expand Up @@ -20,7 +20,6 @@
import me.jascotty2.bettershop.commands.HelpCommands;
import me.jascotty2.bettershop.spout.SpoutKeyListener;
import me.jascotty2.bettershop.spout.SpoutPopupListener;
import me.jascotty2.bettershop.utils.BSPermissions;
import me.jascotty2.bettershop.utils.BetterShopErrorTracker;
import me.jascotty2.bettershop.utils.BetterShopLogger;

Expand Down
34 changes: 12 additions & 22 deletions src/me/jascotty2/bettershop/BetterShop.java
Expand Up @@ -48,6 +48,7 @@
import java.util.TimerTask;
import java.util.Collection;

import me.jascotty2.bettershop.enums.ShopMethod;
import me.jascotty2.lib.bukkit.item.JItemDB;
import me.jascotty2.lib.bukkit.item.CreatureItem.EntityListen;
import me.jascotty2.lib.bukkit.commands.CommandException;
Expand All @@ -63,14 +64,15 @@
*/
public class BetterShop extends JavaPlugin {

public final static String lastUpdatedStr = "01/27/12 05:40 -0500"; // "MM/dd/yy HH:mm Z"
public final static String lastUpdatedStr = "07/12/12 08:40 -0500"; // "MM/dd/yy HH:mm Z"
public final static int lastUpdated_gracetime = 20; // how many minutes off before out of date
protected static Plugin bettershopPlugin = null;
protected final static BSConfig config = new BSConfig();
protected final static RegionShopManager shopManager = new RegionShopManager();
protected static BSSignShop signShop = null;
protected static BSChestShop chestShop = null;
protected static BSEcon economy;
protected static TransactionHandler shopHandler;
private BSPluginListener pListener = null;
// for animal/monster purchases
public final EntityListen entityListener = new EntityListen();
Expand All @@ -80,6 +82,7 @@ public class BetterShop extends JavaPlugin {
protected static SpoutKeyListener keyListener = null;
protected static SpoutPopupListener buttonListener = null;

@Override
public void onEnable() {
bettershopPlugin = this;
PluginDescriptionFile pdfFile = this.getDescription();
Expand Down Expand Up @@ -126,7 +129,10 @@ public void onEnable() {
Updater.Check();
}
}

economy = new BSEcon(this);
shopHandler = new TransactionHandler(economy, shopManager);

if (shopManager.load() > 0) {
BetterShopLogger.Severe("Error while enabling Shop");
}
Expand Down Expand Up @@ -162,16 +168,10 @@ public void onEnable() {
BetterShopLogger.Info(pdfFile.getName() + " version "
+ pdfFile.getVersion() + " is enabled!");

// //sendErrorReport("Test Error", new Exception());
// // usage stats tracking :)
// if (config.sendErrorReports) { // setting to allow privacy-minded people some privacy..
// me.jascotty2.lib.bukkit.FTP_PluginTracker.queueSend(this);
// }
// new plugin tracking method that bothers someone else's server ;)
//com.arandomappdev.bukkitstats.CallHome.load(this);
com.randomappdev.pluginstats.Ping.init(this);
}

@Override
public void onDisable() {
// NOTE: All registered events are automatically unregistered when a plugin is disabled
try {
Expand Down Expand Up @@ -383,6 +383,10 @@ public static boolean commandShopEnabled(Location loc) {
public static boolean spoutEnabled(){
return buttonListener != null;
}

public static TransactionHandler.TransactionResult executeTransaction(Player player, PlayerTransation action, ShopMethod method) {
return shopHandler.execute(player, action, method);
}

public static int reload(CommandSender sender) {
int errors = 0;
Expand Down Expand Up @@ -447,18 +451,4 @@ public void run() {
}
}
}

// static class phoneHome implements Runnable {
//
// Plugin plugin;
//
// public phoneHome(Plugin p) {
// plugin = p;
// }
//
// @Override
// public void run() {
// com.arandomappdev.bukkitstats.CallHome.load(plugin);
// }
// }
}
46 changes: 46 additions & 0 deletions src/me/jascotty2/bettershop/PlayerTransation.java
@@ -0,0 +1,46 @@
/**
* Copyright (C) 2012 Jacob Scott <jascottytechie@gmail.com>
* Description: Structure to hold central transaction details
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.jascotty2.bettershop;
import me.jascotty2.lib.bukkit.item.JItem;

public class PlayerTransation {
/**
* player initiating the transaction
*/
public String playername;
/**
* what direction (false == buying the item)
*/
public boolean is_selling;
/**
* how many items trying to buy/sell
*/
public int amount;
/**
* if the item(s) is known
*/
public JItem items[];
/**
* if the item is being looked up, what the search term is
*/
public String itemSearch;
/**
* if this is a custom request, can define the specific buy/sell price
*/
public float customPrice = -1;
}

0 comments on commit 8ed2492

Please sign in to comment.