Skip to content

Commit

Permalink
1.0 work & bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jascotty2 committed Nov 27, 2011
1 parent da46228 commit 99d4318
Show file tree
Hide file tree
Showing 23 changed files with 540 additions and 145 deletions.
15 changes: 15 additions & 0 deletions changelog
Expand Up @@ -2,6 +2,21 @@
BetterShop Changelog: (the (?) means plugin didn't report that as the version.. sorry :))
===============================================================================

Version 2.1.0 - ?
items & entities updated for 1.0 (bukkit ####)
fixed a bug with added items sometimes registering -1 max
added discount selling options, but recommend leaving at default
changed permissions error handling.. shouldn't spam more than one error for a nested command
- (and none for a usage lookup)
added option to replace econ with exp or total exp (which is used in enchantments)
TODO - or (if not enabled) allow exp buy/sell
removed ftp stats tracking snippet (added in 1.6.7)
- changed to another i found with a web interface
- http://pluginstats.randomappdev.com/plugin.aspx?pid=27
- still waiting on bukkit for their implementation...



Version 2.0.5 - 10/13/11
added fancy gradient to itempages :)
fixed itemstack null logic error
Expand Down
123 changes: 123 additions & 0 deletions src/com/arandomappdev/bukkitstats/CallHome.java
@@ -0,0 +1,123 @@
/*
* Modified 2011 jblaske
* ---------------------------------------------------------------------------------------
* Copyright (c) 2011. SwearWord
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* No modifications may be made to the Software. User must use the code as is.
*
* Users of any software implementing this Software must be made aware of this Software's
* implementation. This Software may not be executed on uninformed clients.
*
* The above copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.arandomappdev.bukkitstats;

import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;

import java.io.File;
import java.net.URL;
import java.net.URLEncoder;
import java.util.UUID;

public class CallHome {

private static final File file = new File("plugins/stats/config.yml");
private static final YamlConfiguration config = YamlConfiguration.loadConfiguration(file);

public static void load(Plugin plugin) {
if (!verifyConfig()) {
return;
}

if (config.getBoolean("opt-out")) {
return;
}

plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new CallTask(plugin, config.getString("hash")), 10L, 20L * 60L * 60);
System.out.println("[" + plugin.getDescription().getName() + "] Stats are being kept for this plugin. To opt-out for any reason, check plugins/stats.");
}

private static Boolean verifyConfig() {
config.addDefault("opt-out", false);
config.addDefault("hash", UUID.randomUUID().toString());

if (!file.exists() || config.get("hash", null) == null) {
System.out.println("BukkitStats is initializing for the first time. To opt-out check plugins/stats");
try {
config.options().copyDefaults(true);
config.save(file);
} catch (Exception ex) {
// // i don't like the printStackTrace, but licence says no changes :(
// System.out.println("BukkitStats failed to save. (" + ex.getMessage() + ")");
// //ex.printStackTrace();
System.out.println("BukkitStats failed to save.");
ex.printStackTrace();
}
return false;
}
return true;
}
}

class CallTask implements Runnable {

private Plugin plugin;
private String hash;

public CallTask(Plugin plugin, String hash) {
this.plugin = plugin;
this.hash = hash;
}

public void run() {
try {
postUrl();
} catch (Exception ignored) {
// System.out.println("Could not call home. (" + ignored.getMessage() + ")");
// //ignored.printStackTrace();
System.out.println("Could not call home.");
ignored.printStackTrace();
}
}

private void postUrl() throws Exception {

String authors = "";

for (String auth : plugin.getDescription().getAuthors()) {
authors = authors + " " + auth;
}
authors = authors.trim();

String url = String.format("http://bukkitstats.randomappdev.com/ping.aspx?snam=%s&sprt=%s&shsh=%s&sver=%s&spcnt=%s&pnam=%s&pmcla=%s&paut=%s&pweb=%s&pver=%s",
URLEncoder.encode(plugin.getServer().getName(), "UTF-8"),
plugin.getServer().getPort(),
hash,
URLEncoder.encode(Bukkit.getVersion(), "UTF-8"),
plugin.getServer().getOnlinePlayers().length,
URLEncoder.encode(plugin.getDescription().getName(), "UTF-8"),
URLEncoder.encode(plugin.getDescription().getMain(), "UTF-8"),
URLEncoder.encode(authors, "UTF-8"),
URLEncoder.encode(plugin.getDescription().getWebsite(), "UTF-8"),
URLEncoder.encode(plugin.getDescription().getVersion(), "UTF-8"));

new URL(url).openConnection().getInputStream();

}
}
17 changes: 17 additions & 0 deletions src/config.yml
Expand Up @@ -104,6 +104,15 @@ shop:
# this can make it possible to sell to a full chest
chestSellBar: false

# method for the discount groups when selling
# options:
# Lower: buy & sell prices lowered by the same % (default)
# None: sell prices are not affected
# Higher: sell prices INCREASED by percentage (not recommended)
# when using None or Higher: beware of instances where buy could be lower than sell
# - if this happens, a user could exploit the loophole & gain free money
sellDiscountMethod: Lower

# command-based shop mode
# modes: GLOBAL, REGIONS, BOTH, NONE (default: global)
# GLOBAL: regions are areas where command-based shop access is disabled
Expand Down Expand Up @@ -133,6 +142,14 @@ shop:
# default currency name (not yet used, but might be if no economy plugin found)
currencyName: "Coin"

# what should be used for economy
# auto: uses whatever econ plugin is found (iConomy 4,5,6, BOSEcon 6,7, MultiCurrency, EssentialsEco)
# exp: use experience as currency (does not change when enchanting)
# total: total experience (what is used when enchanting)
# ----------------- note: EXP and TOTAL are integer values: cannot have decimals in prices
economy: auto


spout:
# if you have spout, whether to use the spout gui
enabled: true
Expand Down
17 changes: 16 additions & 1 deletion src/itemsdb.yml
Expand Up @@ -917,6 +917,20 @@ entities:
entity17:
name: Silverfish
aliases: sliverfish, stonefish
entity18:
name: Ender Dragon
aliases:
entity19:
name: Villager
aliases:
entity20:
name: Blaze
aliases:
entity21:
name: Mushroom Cow
aliases: mooshroom



# accepted are item names (and id:data), names (but names must be updated if changed), and aliases
categories:
Expand All @@ -928,7 +942,8 @@ categories:
wool: "35, 35:12, 35:10, 35:2, 35:11, 35:3, 35:9, 35:13, 35:5, 35:4, 35:1, 35:14, 35:6, 35:8, 35:7, 35:15"
dye: "351:15, 351:3, 351:5, 351:13, 351:4, 351:12, 351:6, 351:2, 351:11, 351:14, 351:1, 351:9, 351:7, 351:8, 351"
#dye: "351, 351:1, 351:2, 351:3, 351:4, 351:5, 351:6, 351:7, 351:8, 351:9, 351:10, 351:11, 351:12, 351:13, 351:14, 351:15"
entities: 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014
entities: 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021
animals: 4000, 4001, 4006, 4008, 4014, 4021
kits: 5000, 5001, 5002

#kits can be added here (must be numbered, starting at 1, starts at 5000 in pricelist database)
Expand Down
57 changes: 47 additions & 10 deletions src/me/jascotty2/bettershop/BSConfig.java
@@ -1,6 +1,6 @@
/**
* Copyright (C) 2011 Jacob Scott <jascottytechie@gmail.com>
* Description: plugin configuration settings
* Description: BetterShop plugin configuration settings
*
* 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
Expand Down Expand Up @@ -31,6 +31,8 @@
import java.util.logging.Level;
import me.jascotty2.bettershop.enums.CommandShopMode;
import me.jascotty2.bettershop.enums.DBType;
import me.jascotty2.bettershop.enums.DiscountMethod;
import me.jascotty2.bettershop.enums.EconMethod;
import me.jascotty2.bettershop.enums.SpoutCategoryMethod;
import me.jascotty2.bettershop.shop.ShopConfig;
import me.jascotty2.bettershop.utils.BetterShopLogger;
Expand Down Expand Up @@ -66,6 +68,8 @@ public class BSConfig {
public String defColor = "white",
BOSBank = "";
protected String customErrorMessage = "";
public final ShopConfig mainShopConfig = new ShopConfig();
public EconMethod econ = EconMethod.AUTO;
///// item buying behavior
public boolean allowbuyillegal = true, //if someone without BetterShop.admin.illegal can buy illegal items
usemaxstack = true, //whether maxstack should be honored
Expand Down Expand Up @@ -124,11 +128,12 @@ public class BSConfig {
private String spoutKey = "B";
public boolean largeSpoutMenu = true,
spoutUsePages = false,
spoutCatCustomSort = true;
spoutCatCustomSort = true,
spoutUseScroll = false;
public SpoutCategoryMethod spoutCategories = SpoutCategoryMethod.NONE;
// discount permissions groups
HashMap<String, Double> groups = new HashMap<String, Double>();
public final ShopConfig mainShopConfig = new ShopConfig();
public DiscountMethod discountSellingMethod = DiscountMethod.LOWER;
// </editor-fold>

public BSConfig() {
Expand Down Expand Up @@ -201,18 +206,19 @@ public final boolean load() {
"signDestroyProtection",
"weSignDestroyProtection",
"tntSignDestroyProtection",
"chestShops", "chestSellBar",
"chestShops",
"chestDestroyProtection",
"tntChestDestroyProtection",
"chestText",
"chestEditText",
"chestText", "chestEditText", "chestSellBar",
"sellDiscountMethod",
"commandShop",
"customsort",
"defaultItemColor",
"tablename",
"hideHelp",
"BOSBank",
"currencyName"});
"currencyName",
"economy"});
allKeys.put("errors", new String[]{
"CheckForUpdates",
"AutoUpdate",
Expand Down Expand Up @@ -259,7 +265,7 @@ public final boolean load() {
"restock"});
allKeys.put("strings", stringMap.keySet().toArray(new String[0]));
String allowNull[] = new String[]{
"shop.customsort", "shop.BOSBank", "shop.currencyName",
"shop.customsort", "shop.BOSBank", "shop.currencyName", "shop.sellDiscountMethod",
"strings.listtail", "strings.logformat"};

String missing = "", unused = "";
Expand Down Expand Up @@ -304,7 +310,7 @@ public final boolean load() {
BetterShopLogger.Log("Notice: Unused Configuration Nodes: \n" + unused);
}
if (missing.length() > 0) {
BetterShopLogger.Log(Level.WARNING, "Missing Configuration Nodes: \n" + missing);
BetterShopLogger.Log("Missing Configuration Nodes: \n" + missing);
}
} catch (Exception ex) {
// this shouldn't be happening: send error report
Expand Down Expand Up @@ -444,6 +450,20 @@ public final boolean load() {
signItemColor = n.getBoolean("signItemColor", signItemColor);
signItemColorBWswap = n.getBoolean("signItemColorBWswap", signItemColorBWswap);

String sd = n.getString("sellDiscountMethod");
if(sd != null) {
if(sd.equalsIgnoreCase("None")) {
discountSellingMethod = DiscountMethod.NONE;
} else if(sd.equalsIgnoreCase("Higher")) {
discountSellingMethod = DiscountMethod.HIGHER;
} else {
if(!sd.equalsIgnoreCase("Lower")) {
BetterShopLogger.Warning("Invalid setting in shop.sellDiscountMethod" + sd);
}
discountSellingMethod = DiscountMethod.LOWER;
}
}

String cShopMode = n.getString("commandShop");
if (cShopMode != null) {
if (cShopMode.equalsIgnoreCase("disabled")
Expand Down Expand Up @@ -485,7 +505,24 @@ public final boolean load() {
}
}
hideHelp = n.getBoolean("hideHelp", hideHelp);


String t = n.getString("economy");
if(t != null) {
if(t.equalsIgnoreCase("exp")) {
econ = EconMethod.EXP;
} else if(t.equalsIgnoreCase("total")) {
econ = EconMethod.TOTAL;
}
// else if(t.equalsIgnoreCase("bultin")) {
// econ = EconMethod.BULTIN;
// }
else {
econ = EconMethod.AUTO;
if(!t.equalsIgnoreCase("auto")) {
BetterShopLogger.Log("shop.economy has an invalid value: " + t + " (defaulting to auto)");
}
}
}
}
if (activeSignColor.equalsIgnoreCase("blue")) {
// "blue" looks like light purple on a sign
Expand Down

0 comments on commit 99d4318

Please sign in to comment.