mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-01-09 09:48:15 +01:00
Added support for money rewards - untested!
This commit is contained in:
parent
b9746d4526
commit
9bdab01b10
@ -54,6 +54,7 @@ public class DPlayer {
|
||||
public String[] linesCopy;
|
||||
|
||||
public Inventory treasureInv = P.p.getServer().createInventory(player, 45, "Belohnungen");
|
||||
public double treasureMoney = 0;
|
||||
|
||||
public int initialLives = -1;
|
||||
|
||||
@ -131,6 +132,7 @@ public class DPlayer {
|
||||
if (!this.isinTestMode) {// Nur wenn man nicht am Testen ist
|
||||
if (isFinished) {
|
||||
this.addTreasure();
|
||||
p.economy.depositPlayer(this.player, treasureMoney);
|
||||
|
||||
// Set Time
|
||||
File file = new File(p.getDataFolder() + "/dungeons/" + gworld.dungeonname, "players.yml");
|
||||
@ -157,7 +159,6 @@ public class DPlayer {
|
||||
if (gworld.isTutorial) {
|
||||
p.permission.playerAddGroup(this.player, p.mainConfig.tutorialEndGroup);
|
||||
p.permission.playerRemoveGroup(this.player, p.mainConfig.tutorialStartGroup);
|
||||
p.getServer().dispatchCommand(p.getServer().getConsoleSender(), "pex user "+player.getName()+" group set "+p.mainConfig.tutorialEndGroup);//TODO: Use Vault for this!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
@ -88,6 +89,9 @@ public class P extends JavaPlugin {
|
||||
|
||||
// Setup Permissions
|
||||
this.setupPermissions();
|
||||
|
||||
// Setup Economy
|
||||
this.setupEconomy();
|
||||
|
||||
// Listener
|
||||
entityListener = new EntityListener();
|
||||
@ -219,6 +223,17 @@ public class P extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Economy
|
||||
public Economy economy = null;
|
||||
|
||||
private Boolean setupEconomy() {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
return (economy != null);
|
||||
}
|
||||
|
||||
// Save and Load
|
||||
public void saveData() {
|
||||
File file = new File(this.getDataFolder(), "data.yml");
|
||||
|
@ -20,12 +20,15 @@ public class GameChest {
|
||||
public boolean isUsed = false;
|
||||
public Chest chest;
|
||||
public GameWorld gworld;
|
||||
public double moneyReward;
|
||||
|
||||
public GameChest(Block chest, GameWorld gworld) {
|
||||
public GameChest(Block chest, GameWorld gworld, double moneyReward) {
|
||||
if (chest.getState() instanceof Chest) {
|
||||
this.chest = (Chest) chest.getState();
|
||||
|
||||
this.gworld = gworld;
|
||||
|
||||
this.moneyReward = moneyReward;
|
||||
|
||||
gworld.gchests.add(this);
|
||||
}
|
||||
@ -36,6 +39,7 @@ public class GameChest {
|
||||
for (Player player : dgroup.getPlayers()) {
|
||||
DPlayer dplayer = DPlayer.get(player);
|
||||
if (dplayer != null) {
|
||||
dplayer.treasureMoney = dplayer.treasureMoney + moneyReward;
|
||||
String msg = "";
|
||||
for (ItemStack istack : this.chest.getInventory().getContents()) {
|
||||
if (istack != null) {
|
||||
|
@ -12,28 +12,37 @@ public class SIGNChest extends DSign {
|
||||
public String buildPermissions = "dxl.sign.chest";
|
||||
public boolean onDungeonInit = false;
|
||||
|
||||
// Variables
|
||||
private double moneyReward;
|
||||
|
||||
public SIGNChest(Sign sign, GameWorld gworld) {
|
||||
super(sign, gworld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
String lines[] = sign.getLines();
|
||||
if (lines[1].equals("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
String lines[] = sign.getLines();
|
||||
if (!lines[1].equals("")) {
|
||||
moneyReward = Double.parseDouble(lines[1]);
|
||||
}
|
||||
for (int i = -1; i <= 1; i++) {
|
||||
if (sign.getBlock().getRelative(i, 0, 0).getType() == Material.CHEST) {
|
||||
new GameChest(sign.getBlock().getRelative(i, 0, 0), gworld);
|
||||
new GameChest(sign.getBlock().getRelative(i, 0, 0), gworld, moneyReward);
|
||||
}
|
||||
if (sign.getBlock().getRelative(0, 0, i).getType() == Material.CHEST) {
|
||||
new GameChest(sign.getBlock().getRelative(0, 0, i), gworld);
|
||||
new GameChest(sign.getBlock().getRelative(0, 0, i), gworld, moneyReward);
|
||||
}
|
||||
if (sign.getBlock().getRelative(0, i, 0).getType() == Material.CHEST) {
|
||||
new GameChest(sign.getBlock().getRelative(0, i, 0), gworld);
|
||||
new GameChest(sign.getBlock().getRelative(0, i, 0), gworld, moneyReward);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.dre.dungeonsxl.P;
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class SIGNMythicMobs extends DSign {
|
||||
|
Loading…
Reference in New Issue
Block a user