mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-22 15:22:47 +01:00
[trunk] moved the worth-id: cost out to their own file "worth.yml" some default values will be created. If you have values in config.yml already then they need to be copied to this new file. Added a setworth command that can change / add worth values.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1203 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
3a18f9bf33
commit
2372be6a57
@ -43,6 +43,7 @@ public class Essentials extends JavaPlugin
|
||||
public Spawn spawn;
|
||||
private Jail jail;
|
||||
private Warps warps;
|
||||
private Worth worth;
|
||||
private List<IConf> confList;
|
||||
public ArrayList bans = new ArrayList();
|
||||
public ArrayList bannedIps = new ArrayList();
|
||||
@ -106,6 +107,8 @@ public class Essentials extends JavaPlugin
|
||||
confList.add(spawn);
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
reload();
|
||||
this.backup = new Backup();
|
||||
|
||||
@ -667,4 +670,9 @@ public class Essentials extends JavaPlugin
|
||||
{
|
||||
return getStatic().warps;
|
||||
}
|
||||
|
||||
public static Worth getWorth()
|
||||
{
|
||||
return getStatic().worth;
|
||||
}
|
||||
}
|
||||
|
36
Essentials/src/com/earth2me/essentials/Worth.java
Normal file
36
Essentials/src/com/earth2me/essentials/Worth.java
Normal file
@ -0,0 +1,36 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class Worth implements IConf
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
public EssentialsConf config;
|
||||
|
||||
public Worth(File dataFolder)
|
||||
{
|
||||
config = new EssentialsConf(new File(dataFolder, "worth.yml"));
|
||||
config.setTemplateName("/worth.yml");
|
||||
config.load();
|
||||
}
|
||||
|
||||
public int getPrice(String id)
|
||||
{
|
||||
return config.getInt("worth-" + id, 0);
|
||||
}
|
||||
|
||||
public void setPrice(String id, int price)
|
||||
{
|
||||
config.setProperty("worth-" + id, price);
|
||||
config.save();
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -25,7 +24,7 @@ public class Commandsell extends EssentialsCommand
|
||||
int id = is.getTypeId();
|
||||
int amount = 0;
|
||||
if (args.length > 0) amount = Integer.parseInt(args[0].replaceAll("[^0-9]", ""));
|
||||
int worth = parent.getConfiguration().getInt("worth-" + id, 0);
|
||||
int worth = Essentials.getWorth().config.getInt("worth-" + id, 0);
|
||||
boolean stack = args.length > 0 && args[0].endsWith("s");
|
||||
boolean requireStack = parent.getConfiguration().getBoolean("trade-in-stacks-" + id, false);
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandsetworth extends EssentialsCommand
|
||||
{
|
||||
public Commandsetworth()
|
||||
{
|
||||
super("setworth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if(args.length < 2)
|
||||
{
|
||||
user.sendMessage("§cUsage: /" + commandLabel + " [itemname|id] [price]");
|
||||
}
|
||||
ItemStack stack = ItemDb.get(args[0]);
|
||||
Essentials.getWorth().setPrice(Integer.toString(stack.getTypeId()), Integer.parseInt(args[1]));
|
||||
user.charge(this);
|
||||
user.sendMessage("§7Worth value set");
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
|
||||
|
||||
public class Commandspawner extends EssentialsCommand
|
||||
{
|
||||
public Commandspawner()
|
||||
@ -31,11 +32,11 @@ public class Commandspawner extends EssentialsCommand
|
||||
|
||||
try
|
||||
{
|
||||
user.charge(this);
|
||||
((CreatureSpawner)target).setCreatureType(CreatureType.fromName(args[0]));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class Commandworth extends EssentialsCommand
|
||||
amount = 64;
|
||||
}
|
||||
|
||||
int worth = parent.getConfiguration().getInt("worth-" + id, 0);
|
||||
int worth = Essentials.getWorth().config.getInt("worth-" + id, 0);
|
||||
|
||||
user.charge(this);
|
||||
user.sendMessage("§7Stack of " + id + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)");
|
||||
|
@ -196,9 +196,7 @@ spawn-if-no-home: false
|
||||
starting-balance: 0
|
||||
|
||||
# worth-# defines the value of an item when it is sold to the server via /sell.
|
||||
# For a premade list which you may copy and paste in: http://pastie.org/1707782
|
||||
#worth-1: 1
|
||||
#worth-278: 1000
|
||||
# These are now defined in worth.yml
|
||||
|
||||
# Defines the cost to use the given commands PER USE
|
||||
command-costs:
|
||||
|
@ -188,6 +188,9 @@ commands:
|
||||
description: Creates a new warp.
|
||||
usage: /<command> [warp]
|
||||
aliases: [createwarp]
|
||||
setworth:
|
||||
description: Set the value of an item for sale, will add item if doesn't exist
|
||||
usage: /<command> [itemname|id] [price]
|
||||
spawnmob:
|
||||
description: Spawns a mob.
|
||||
usage: /<command> [mob]<:data><,mount<:data>> <amount>
|
||||
|
166
Essentials/src/worth.yml
Normal file
166
Essentials/src/worth.yml
Normal file
@ -0,0 +1,166 @@
|
||||
worth-1: 2
|
||||
worth-2: 1
|
||||
worth-3: 1
|
||||
worth-4: 1
|
||||
worth-5: 1
|
||||
worth-6: 2
|
||||
worth-7: 1000
|
||||
worth-8: 1
|
||||
worth-9: 1
|
||||
worth-10: 1
|
||||
worth-11: 1
|
||||
worth-12: 1
|
||||
worth-13: 1
|
||||
worth-14: 45
|
||||
worth-15: 18
|
||||
worth-16: 15
|
||||
worth-17: 2
|
||||
worth-18: 0
|
||||
worth-19: 80
|
||||
worth-20: 10
|
||||
worth-21: 100
|
||||
worth-22: 500
|
||||
worth-23: 9
|
||||
worth-24: 5
|
||||
worth-25: 40
|
||||
worth-35: 8
|
||||
worth-37: 2
|
||||
worth-38: 2
|
||||
worth-39: 2
|
||||
worth-40: 2
|
||||
worth-41: 400
|
||||
worth-42: 160
|
||||
worth-43: 3
|
||||
worth-44: 3
|
||||
worth-45: 40
|
||||
worth-46: 10000
|
||||
worth-47: 20
|
||||
worth-48: 90
|
||||
worth-49: 130
|
||||
worth-50: 1
|
||||
worth-53: 8
|
||||
worth-54: 15
|
||||
worth-55: 7
|
||||
worth-56: 200
|
||||
worth-57: 1500
|
||||
worth-58: 20
|
||||
worth-60: 3
|
||||
worth-61: 10
|
||||
worth-65: 10
|
||||
worth-66: 40
|
||||
worth-67: 22
|
||||
worth-68: 1
|
||||
worth-69: 7
|
||||
worth-70: 10
|
||||
worth-71: 15
|
||||
worth-72: 10
|
||||
worth-73: 30
|
||||
worth-74: 30
|
||||
worth-76: 10
|
||||
worth-77: 7
|
||||
worth-81: 10
|
||||
worth-82: 3
|
||||
worth-83: 15
|
||||
worth-85: 10
|
||||
worth-86: 50
|
||||
worth-91: 60
|
||||
worth-256: 40
|
||||
worth-257: 80
|
||||
worth-258: 60
|
||||
worth-260: 10
|
||||
worth-261: 75
|
||||
worth-262: 10
|
||||
worth-263: 3
|
||||
worth-264: 230
|
||||
worth-265: 20
|
||||
worth-266: 50
|
||||
worth-267: 60
|
||||
worth-268: 10
|
||||
worth-269: 10
|
||||
worth-270: 10
|
||||
worth-271: 10
|
||||
worth-272: 40
|
||||
worth-273: 40
|
||||
worth-274: 40
|
||||
worth-275: 40
|
||||
worth-276: 700
|
||||
worth-277: 350
|
||||
worth-278: 1000
|
||||
worth-279: 1000
|
||||
worth-280: 1
|
||||
worth-281: 6
|
||||
worth-282: 30
|
||||
worth-283: 200
|
||||
worth-284: 220
|
||||
worth-285: 300
|
||||
worth-286: 300
|
||||
worth-287: 5
|
||||
worth-288: 3
|
||||
worth-289: 19
|
||||
worth-290: 10
|
||||
worth-291: 40
|
||||
worth-292: 60
|
||||
worth-293: 600
|
||||
worth-294: 200
|
||||
worth-295: 5
|
||||
worth-296: 9
|
||||
worth-297: 20
|
||||
worth-298: 20
|
||||
worth-299: 40
|
||||
worth-300: 20
|
||||
worth-301: 17
|
||||
worth-302: 40
|
||||
worth-303: 40
|
||||
worth-304: 50
|
||||
worth-305: 30
|
||||
worth-306: 120
|
||||
worth-307: 300
|
||||
worth-308: 250
|
||||
worth-309: 50
|
||||
worth-310: 1500
|
||||
worth-311: 3000
|
||||
worth-312: 2200
|
||||
worth-313: 1500
|
||||
worth-314: 300
|
||||
worth-315: 600
|
||||
worth-316: 400
|
||||
worth-317: 250
|
||||
worth-320: 6
|
||||
worth-321: 50
|
||||
worth-322: 500
|
||||
worth-323: 10
|
||||
worth-324: 30
|
||||
worth-325: 10
|
||||
worth-326: 10
|
||||
worth-327: 30
|
||||
worth-328: 20
|
||||
worth-329: 100
|
||||
worth-330: 35
|
||||
worth-331: 1
|
||||
worth-332: 1
|
||||
worth-333: 5
|
||||
worth-334: 10
|
||||
worth-335: 15
|
||||
worth-336: 10
|
||||
worth-337: 8
|
||||
worth-338: 10
|
||||
worth-339: 30
|
||||
worth-340: 35
|
||||
worth-341: 50
|
||||
worth-342: 35
|
||||
worth-343: 30
|
||||
worth-344: 1
|
||||
worth-345: 50
|
||||
worth-346: 25
|
||||
worth-347: 100
|
||||
worth-348: 11
|
||||
worth-349: 5
|
||||
worth-350: 20
|
||||
worth-351: 10
|
||||
worth-352: 10
|
||||
worth-353: 5
|
||||
worth-354: 100
|
||||
worth-355: 25
|
||||
worth-356: 10
|
||||
worth-2256: 950
|
||||
worth-2257: 1000
|
Loading…
Reference in New Issue
Block a user