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