mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-01-09 09:48:15 +01:00
Merge pull request #2 from DRE2N/0.9.6
==v0.9.6== =Money as a reward= Add one line to your [chest] sign that contains a number. =Money fees= All you need to do: Put "fee: [amount]" to your dungeon config. =Optimization for 1.8.8= Nothing noticable. =Command to play dungeons without portal= /dxl play =Split keepInventory to keepInventoryOnEnter, OnEscape, OnFinish and OnDeath= keepInventoryOnEscape means whether or not you keep your inventory if you leave the dungeon without an end sign, e.g. with /dxl leave. The old "keepInventory" still works, it contains Enter, Escape and Finish. =Added MythicMobs support to mob trigger= Just use the same name that you put into your MM config file. =Bugfixes= No motivation to list them :p
This commit is contained in:
commit
f23665bc8b
@ -23,6 +23,10 @@ public class DConfig {
|
||||
private File file;
|
||||
|
||||
private boolean keepInventory = false;
|
||||
private boolean keepInventoryOnEnter = false;
|
||||
private boolean keepInventoryOnEscape = false;
|
||||
private boolean keepInventoryOnFinish = false;
|
||||
private boolean keepInventoryOnDeath = true;
|
||||
|
||||
private CopyOnWriteArrayList<DClass> dClasses = new CopyOnWriteArrayList<DClass>();
|
||||
private Map<Integer, String> msgs = new HashMap<Integer, String>();
|
||||
@ -38,6 +42,8 @@ public class DConfig {
|
||||
|
||||
private int timeUntilKickOfflinePlayer = -1;
|
||||
|
||||
private double fee = 0;
|
||||
|
||||
private List<String> finishedOne;
|
||||
private List<String> finishedAll;
|
||||
private int timeLastPlayed = 0;
|
||||
@ -147,14 +153,50 @@ public class DConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/* keep Inventory */
|
||||
/* Keep Inventory */
|
||||
if (configFile.contains("keepInventory")) {
|
||||
keepInventory = configFile.getBoolean("keepInventory");
|
||||
if (!configFile.contains("keepInventoryOnEnter")) {
|
||||
keepInventoryOnEnter = configFile.getBoolean("keepInventory");
|
||||
}
|
||||
if (!configFile.contains("keepInventoryOnEscape")) {
|
||||
keepInventoryOnEscape = configFile.getBoolean("keepInventory");
|
||||
}
|
||||
if (!configFile.contains("keepInventoryOnFinish")) {
|
||||
keepInventoryOnFinish = configFile.getBoolean("keepInventory");
|
||||
}
|
||||
} else {
|
||||
keepInventory = mainConfig.keepInventory;
|
||||
if (mainConfig.keepInventory) {
|
||||
keepInventoryOnEnter = mainConfig.keepInventory;
|
||||
keepInventoryOnEscape = mainConfig.keepInventory;
|
||||
keepInventoryOnFinish = mainConfig.keepInventory;
|
||||
}
|
||||
}
|
||||
|
||||
/* keep Inventory */
|
||||
if (configFile.contains("keepInventoryOnEnter")) {
|
||||
keepInventoryOnEnter = configFile.getBoolean("keepInventoryOnEnter");
|
||||
} else {
|
||||
keepInventoryOnEnter = mainConfig.keepInventoryOnEnter;
|
||||
}
|
||||
|
||||
if (configFile.contains("keepInventoryOnEscape")) {
|
||||
keepInventoryOnEscape = configFile.getBoolean("keepInventoryOnEscape");
|
||||
} else {
|
||||
keepInventoryOnEscape = mainConfig.keepInventoryOnEscape;
|
||||
}
|
||||
|
||||
if (configFile.contains("keepInventoryOnFinish")) {
|
||||
keepInventoryOnFinish = configFile.getBoolean("keepInventoryOnFinish");
|
||||
} else {
|
||||
keepInventoryOnFinish = mainConfig.keepInventoryOnFinish;
|
||||
}
|
||||
|
||||
if (configFile.contains("keepInventoryOnDeath")) {
|
||||
keepInventoryOnDeath = configFile.getBoolean("keepInventoryOnDeath");
|
||||
} else {
|
||||
keepInventoryOnDeath = mainConfig.keepInventoryOnDeath;
|
||||
}
|
||||
|
||||
/* Lives */
|
||||
if (configFile.contains("initialLives")) {
|
||||
initialLives = configFile.getInt("initialLives");
|
||||
} else {
|
||||
@ -188,6 +230,12 @@ public class DConfig {
|
||||
}
|
||||
|
||||
/* Dungeon Requirements */
|
||||
if (configFile.contains("fee")) {
|
||||
fee = configFile.getDouble("fee");
|
||||
} else {
|
||||
fee = mainConfig.fee;
|
||||
}
|
||||
|
||||
if (configFile.contains("mustFinishOne")) {
|
||||
finishedOne = configFile.getStringList("mustFinishOne");
|
||||
} else {
|
||||
@ -304,8 +352,20 @@ public class DConfig {
|
||||
return tmpSecureObjects;
|
||||
}
|
||||
|
||||
public boolean getKeepInventory() {
|
||||
return keepInventory;
|
||||
public boolean getKeepInventoryOnEnter() {
|
||||
return keepInventoryOnEnter;
|
||||
}
|
||||
|
||||
public boolean getKeepInventoryOnEscape() {
|
||||
return keepInventoryOnEscape;
|
||||
}
|
||||
|
||||
public boolean getKeepInventoryOnFinish() {
|
||||
return keepInventoryOnFinish;
|
||||
}
|
||||
|
||||
public boolean getKeepInventoryOnDeath() {
|
||||
return keepInventoryOnDeath;
|
||||
}
|
||||
|
||||
public int getInitialLives() {
|
||||
@ -332,6 +392,10 @@ public class DConfig {
|
||||
return timeLastPlayed;
|
||||
}
|
||||
|
||||
public double getFee() {
|
||||
return fee;
|
||||
}
|
||||
|
||||
public List<String> getFinishedAll() {
|
||||
return finishedAll;
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.dre.dungeonsxl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class DGroup {
|
||||
@ -61,6 +63,15 @@ public class DGroup {
|
||||
for (Player player : getPlayers()) {
|
||||
DPlayer dplayer = DPlayer.get(player);
|
||||
dplayer.respawn();
|
||||
if (P.p.mainConfig.enableEconomy) {
|
||||
File file = new File(P.p.getDataFolder() + "/dungeons/" + dungeonname + "/config.yml");
|
||||
if (file != null) {
|
||||
DConfig confReader = new DConfig(file);
|
||||
if (confReader != null) {
|
||||
P.p.economy.withdrawPlayer(player, confReader.getFee());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DGSign.updatePerGroup(this);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
@ -75,17 +76,18 @@ public class DPlayer {
|
||||
this.clearPlayerData();
|
||||
} else {
|
||||
this.player.setGameMode(GameMode.SURVIVAL);
|
||||
if (!(GameWorld.get(world).config.getKeepInventory())) {
|
||||
DConfig dConfig = GameWorld.get(world).config;
|
||||
if (!(dConfig.getKeepInventoryOnEnter())) {
|
||||
this.clearPlayerData();
|
||||
}
|
||||
if (GameWorld.get(world).config.isLobbyDisabled()) {
|
||||
if (dConfig.isLobbyDisabled()) {
|
||||
this.ready();
|
||||
}
|
||||
initialLives = GameWorld.get(world).config.getInitialLives();
|
||||
}
|
||||
|
||||
// Lives
|
||||
P.lives.put(this.player, initialLives);
|
||||
p.lives.put(this.player, initialLives);
|
||||
|
||||
DUtility.secureTeleport(this.player, teleport);
|
||||
}
|
||||
@ -104,16 +106,28 @@ public class DPlayer {
|
||||
|
||||
public void escape() {
|
||||
remove(this);
|
||||
this.savePlayer.reset();
|
||||
this.savePlayer.reset(false);
|
||||
}
|
||||
|
||||
public void leave() {
|
||||
remove(this);
|
||||
|
||||
// Lives
|
||||
P.lives.remove(player);
|
||||
if (p.lives.containsKey(player)) {
|
||||
p.lives.remove(player);
|
||||
}
|
||||
|
||||
this.savePlayer.reset();
|
||||
if (!this.isEditing) {
|
||||
DConfig dConfig = GameWorld.get(world).config;
|
||||
if (this.isFinished) {
|
||||
this.savePlayer.reset(dConfig.getKeepInventoryOnFinish());
|
||||
}
|
||||
else {
|
||||
this.savePlayer.reset(dConfig.getKeepInventoryOnEscape());
|
||||
}
|
||||
} else {
|
||||
this.savePlayer.reset(false);
|
||||
}
|
||||
|
||||
if (this.isEditing) {
|
||||
EditWorld eworld = EditWorld.get(this.world);
|
||||
@ -131,6 +145,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 +172,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!
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,7 +231,7 @@ public class DPlayer {
|
||||
}
|
||||
|
||||
// Respawn Items
|
||||
if (!(GameWorld.get(world).config.getKeepInventory())) {
|
||||
if (GameWorld.get(world).config.getKeepInventoryOnDeath()) {
|
||||
if (this.respawnInventory != null || this.respawnArmor != null) {
|
||||
this.player.getInventory().setContents(this.respawnInventory);
|
||||
this.player.getInventory().setArmorContents(this.respawnArmor);
|
||||
|
@ -59,30 +59,31 @@ public class DSavePlayer {
|
||||
save();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
public void reset(boolean keepInventory) {
|
||||
Player onlinePlayer = p.getServer().getPlayer(this.playerName);
|
||||
|
||||
try{
|
||||
if (onlinePlayer != null) {
|
||||
/* Player is online */
|
||||
onlinePlayer.getInventory().setContents(this.oldInventory);
|
||||
onlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
||||
onlinePlayer.setTotalExperience(this.oldExp);
|
||||
onlinePlayer.setLevel(this.oldLvl);
|
||||
onlinePlayer.setHealth(this.oldHealth);
|
||||
onlinePlayer.setFoodLevel(this.oldFoodLevel);
|
||||
onlinePlayer.setGameMode(this.oldGamemode);
|
||||
onlinePlayer.setFireTicks(this.oldFireTicks);
|
||||
for (PotionEffect effect : onlinePlayer.getActivePotionEffects()) {
|
||||
onlinePlayer.removePotionEffect(effect.getType());
|
||||
if (!keepInventory) {
|
||||
onlinePlayer.getInventory().setContents(this.oldInventory);
|
||||
onlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
||||
onlinePlayer.setTotalExperience(this.oldExp);
|
||||
onlinePlayer.setLevel(this.oldLvl);
|
||||
onlinePlayer.setHealth(this.oldHealth);
|
||||
onlinePlayer.setFoodLevel(this.oldFoodLevel);
|
||||
onlinePlayer.setGameMode(this.oldGamemode);
|
||||
onlinePlayer.setFireTicks(this.oldFireTicks);
|
||||
for (PotionEffect effect : onlinePlayer.getActivePotionEffects()) {
|
||||
onlinePlayer.removePotionEffect(effect.getType());
|
||||
}
|
||||
onlinePlayer.addPotionEffects(this.oldPotionEffects);
|
||||
}
|
||||
onlinePlayer.addPotionEffects(this.oldPotionEffects);
|
||||
|
||||
DUtility.secureTeleport(onlinePlayer, this.oldLocation);
|
||||
} else {
|
||||
/* Player is offline */
|
||||
Player offlinePlayer = p.getOfflinePlayer(this.playerName, UUID.fromString(uuid), this.oldLocation);
|
||||
if (offlinePlayer != null) {
|
||||
if (offlinePlayer != null && !keepInventory) {
|
||||
offlinePlayer.getInventory().setContents(this.oldInventory);
|
||||
offlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
||||
offlinePlayer.setTotalExperience(this.oldExp);
|
||||
@ -174,7 +175,7 @@ public class DSavePlayer {
|
||||
|
||||
// Create Player
|
||||
DSavePlayer savePlayer = new DSavePlayer(playerName, uuid, oldLocation, oldInventory, oldArmor, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGamemode, oldPotionEffects);
|
||||
savePlayer.reset();
|
||||
savePlayer.reset(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,10 +122,10 @@ public class LanguageReader {
|
||||
defaults.put("Help_Cmd_DeletePortal", "/dxl deleteportal - Deletes the portal you are looking at");
|
||||
defaults.put("Help_Cmd_Reload", "/dxl reload - Reloads the plugin");
|
||||
defaults.put("Help_Cmd_Save", "/dxl save - Saves the current dungeon");
|
||||
defaults.put("Help_Cmd_Play", "/dxl play [dungeon]");
|
||||
defaults.put("Help_Cmd_Test", "/dxl test [dungeon] - Tests a dungeon");
|
||||
defaults.put("Help_Cmd_Lives", "/dxl lives <player> - Shows the lives a player has left");
|
||||
defaults.put("Help_Cmd_Uninvite", "/dxl uninvite <player> <dungeon> - Uninvite a player to edit a dungeon");
|
||||
defaults.put("Help_Cmd_Lives", "/dxl lives <player> - show the lives a player has left");
|
||||
|
||||
}
|
||||
|
||||
private void check() {
|
||||
|
@ -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;
|
||||
@ -31,18 +32,18 @@ import com.dre.dungeonsxl.commands.DCommandRoot;
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
import com.dre.dungeonsxl.listener.BlockListener;
|
||||
import com.dre.dungeonsxl.listener.CommandListener;
|
||||
import com.dre.dungeonsxl.listener.DeathListener;
|
||||
import com.dre.dungeonsxl.listener.EntityListener;
|
||||
import com.dre.dungeonsxl.listener.HangingListener;
|
||||
import com.dre.dungeonsxl.listener.PlayerListener;
|
||||
import com.dre.dungeonsxl.listener.WorldListener;
|
||||
import com.dre.dungeonsxl.listener.player.PlayerDeathListener;
|
||||
import com.dre.dungeonsxl.multiversionhandler.MultiVersionHandler;
|
||||
|
||||
public class P extends JavaPlugin {
|
||||
public static P p;
|
||||
|
||||
// Lives
|
||||
public static HashMap<Player, Integer> lives;
|
||||
public HashMap<Player, Integer> lives;
|
||||
|
||||
// Listener
|
||||
private static Listener entityListener;
|
||||
@ -50,7 +51,7 @@ public class P extends JavaPlugin {
|
||||
private static Listener blockListener;
|
||||
private static Listener worldListener;
|
||||
private static Listener hangingListener;
|
||||
private static Listener deathListener;
|
||||
private static Listener playerDeathListener;
|
||||
|
||||
// Main Config Reader
|
||||
public MainConfig mainConfig;
|
||||
@ -88,6 +89,9 @@ public class P extends JavaPlugin {
|
||||
|
||||
// Setup Permissions
|
||||
this.setupPermissions();
|
||||
|
||||
// Setup Economy
|
||||
this.setupEconomy();
|
||||
|
||||
// Listener
|
||||
entityListener = new EntityListener();
|
||||
@ -95,14 +99,14 @@ public class P extends JavaPlugin {
|
||||
blockListener = new BlockListener();
|
||||
worldListener = new WorldListener();
|
||||
hangingListener = new HangingListener();
|
||||
deathListener = new DeathListener();
|
||||
playerDeathListener = new PlayerDeathListener();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(entityListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(playerListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(blockListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(worldListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(hangingListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(deathListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(playerDeathListener, this);
|
||||
|
||||
// Load All
|
||||
this.loadAll();
|
||||
@ -219,6 +223,21 @@ public class P extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Economy
|
||||
public Economy economy = null;
|
||||
|
||||
private Boolean setupEconomy() {
|
||||
if (mainConfig.enableEconomy) {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
return (economy != null);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Save and Load
|
||||
public void saveData() {
|
||||
File file = new File(this.getDataFolder(), "data.yml");
|
||||
|
@ -18,8 +18,8 @@ public class CMDLives extends DCommand {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
String lives = "";
|
||||
if (P.lives.containsKey(player)) {
|
||||
lives = String.valueOf(P.lives.get(player));
|
||||
if (P.p.lives.containsKey(player)) {
|
||||
lives = String.valueOf(P.p.lives.get(player));
|
||||
p.msg(player, p.language.get("Cmd_Lives").replaceAll("v1", player.getName()).replaceAll("v2", lives));
|
||||
} else {
|
||||
p.msg(player, p.language.get("Error_NotInDungeon"));
|
||||
|
77
src/com/dre/dungeonsxl/commands/CMDPlay.java
Normal file
77
src/com/dre/dungeonsxl/commands/CMDPlay.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.dre.dungeonsxl.commands;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.dre.dungeonsxl.DConfig;
|
||||
import com.dre.dungeonsxl.DGroup;
|
||||
import com.dre.dungeonsxl.DPlayer;
|
||||
import com.dre.dungeonsxl.EditWorld;
|
||||
import com.dre.dungeonsxl.P;
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class CMDPlay extends DCommand {
|
||||
|
||||
public CMDPlay() {
|
||||
this.command = "play";
|
||||
this.args = -1;
|
||||
this.help = p.language.get("Help_Cmd_Play");
|
||||
this.permissions = "dxl.play";
|
||||
this.isPlayerCommand = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
DPlayer dplayer = DPlayer.get(player);
|
||||
String dungeonname;
|
||||
|
||||
if (dplayer == null) {
|
||||
if (args.length > 1) {
|
||||
dungeonname = args[1];
|
||||
|
||||
if (EditWorld.exist(dungeonname)) {
|
||||
if (GameWorld.canPlayDungeon(dungeonname, player)) {
|
||||
if (GameWorld.checkRequirements(dungeonname, player)) {
|
||||
if (DGroup.get(player) == null) {
|
||||
DGroup dgroup = new DGroup(player, dungeonname);
|
||||
if (dgroup != null) {
|
||||
if (dgroup.getGworld() == null) {
|
||||
dgroup.setGworld(GameWorld.load(DGroup.get(player).getDungeonname()));
|
||||
}
|
||||
if (dgroup.getGworld().locLobby == null) {
|
||||
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().world.getSpawnLocation(), false);
|
||||
} else {
|
||||
new DPlayer(player, dgroup.getGworld().world, dgroup.getGworld().locLobby, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.msg(player, p.language.get("Error_LeaveGroup"));
|
||||
}
|
||||
} else {
|
||||
P.p.msg(player, P.p.language.get("Error_Requirements"));
|
||||
}
|
||||
} else {
|
||||
File file = new File(p.getDataFolder() + "/dungeons/" + dungeonname + "/config.yml");
|
||||
if (file != null) {
|
||||
DConfig confReader = new DConfig(file);
|
||||
if (confReader != null) {
|
||||
P.p.msg(player, P.p.language.get("Error_Cooldown", "" + confReader.getTimeToNextPlay()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.msg(player, p.language.get("Error_DungeonNotExist", dungeonname));
|
||||
}
|
||||
} else {
|
||||
this.displayHelp(player);
|
||||
}
|
||||
} else {
|
||||
p.msg(player, p.language.get("Error_LeaveDungeon"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -18,14 +18,15 @@ public class DCommandRoot {
|
||||
public CMDDeletePortal cmdDeletePortal = new CMDDeletePortal();
|
||||
public CMDChat cmdChat = new CMDChat();
|
||||
public CMDChatSpy cmdChatSpy = new CMDChatSpy();
|
||||
public CMDLives cmdLives = new CMDLives();
|
||||
public CMDList cmdList = new CMDList();
|
||||
public CMDUninvite cmdUninvite = new CMDUninvite();
|
||||
public CMDInvite cmdInvite = new CMDInvite();
|
||||
public CMDMsg cmdMsg = new CMDMsg();
|
||||
public CMDPlay cmdPlay = new CMDPlay();
|
||||
public CMDTest cmdTest = new CMDTest();
|
||||
public CMDHelp cmdHelp = new CMDHelp();
|
||||
public CMDReload cmdReload = new CMDReload();
|
||||
public CMDLives cmdLives = new CMDLives();
|
||||
|
||||
// Methods
|
||||
public DCommandRoot() {
|
||||
@ -41,13 +42,14 @@ public class DCommandRoot {
|
||||
this.commands.add(cmdDeletePortal);
|
||||
this.commands.add(cmdChat);
|
||||
this.commands.add(cmdChatSpy);
|
||||
this.commands.add(cmdLives);
|
||||
this.commands.add(cmdList);
|
||||
this.commands.add(cmdUninvite);
|
||||
this.commands.add(cmdInvite);
|
||||
this.commands.add(cmdMsg);
|
||||
this.commands.add(cmdPlay);
|
||||
this.commands.add(cmdTest);
|
||||
this.commands.add(cmdHelp);
|
||||
this.commands.add(cmdReload);
|
||||
this.commands.add(cmdLives);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ public class DMob {
|
||||
public LivingEntity entity;
|
||||
public DMobType type;
|
||||
|
||||
public String trigger;
|
||||
|
||||
public DMob(LivingEntity entity, GameWorld gworld, DMobType type) {
|
||||
gworld.dmobs.add(this);
|
||||
|
||||
@ -29,6 +31,21 @@ public class DMob {
|
||||
this.entity.getEquipment().setItemInHandDropChance(0);
|
||||
}
|
||||
|
||||
public DMob(LivingEntity entity, GameWorld gworld, DMobType type, String trigger) {
|
||||
gworld.dmobs.add(this);
|
||||
|
||||
this.entity = entity;
|
||||
this.type = type;
|
||||
this.trigger = trigger;
|
||||
|
||||
/* Remove DropChance of equipment */
|
||||
this.entity.getEquipment().setHelmetDropChance(0);
|
||||
this.entity.getEquipment().setChestplateDropChance(0);
|
||||
this.entity.getEquipment().setLeggingsDropChance(0);
|
||||
this.entity.getEquipment().setBootsDropChance(0);
|
||||
this.entity.getEquipment().setItemInHandDropChance(0);
|
||||
}
|
||||
|
||||
// Statics
|
||||
public static void onDeath(EntityDeathEvent event) {
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
||||
@ -49,6 +66,8 @@ public class DMob {
|
||||
}
|
||||
}
|
||||
name = dmob.type.getName();
|
||||
} else if (dmob.type == null && dmob.trigger != null) {// <=MythicMobs mob
|
||||
name = dmob.trigger;
|
||||
} else {
|
||||
name = victim.getType().getName();
|
||||
}
|
||||
|
@ -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) {
|
||||
@ -57,6 +61,9 @@ public class GameChest {
|
||||
msg = msg.substring(0, msg.length() - 1);
|
||||
|
||||
P.p.msg(player, P.p.language.get("Player_LootAdded", msg));
|
||||
if (moneyReward != 0) {
|
||||
P.p.msg(player, P.p.language.get("Player_LootAdded", String.valueOf(moneyReward)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,7 +88,7 @@ public class GameChest {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
P.p.msg(P.p.getServer().getPlayer(event.getPlayer().getName()), ChatColor.RED + "Diese Kiste wurde schon geöffnet!");
|
||||
P.p.msg(P.p.getServer().getPlayer(event.getPlayer().getUniqueId()), ChatColor.RED + "Diese Kiste wurde schon geöffnet!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,13 @@ public class GameWorld {
|
||||
}
|
||||
|
||||
DConfig config = new DConfig(new File(p.getDataFolder() + "/dungeons/" + dungeon, "config.yml"));
|
||||
|
||||
if (p.mainConfig.enableEconomy) {
|
||||
if (!(P.p.economy.getBalance(player) >= config.getFee())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getFinished() != null && config.getFinishedAll() != null) {
|
||||
if (!config.getFinished().isEmpty()) {
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
package com.dre.dungeonsxl.listener;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import com.dre.dungeonsxl.P;
|
||||
|
||||
public class DeathListener implements Listener {
|
||||
|
||||
P p = P.p;
|
||||
int lives = -1;
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
if (P.lives.containsKey(player)) {
|
||||
lives = P.lives.get(player) - 1;
|
||||
P.lives.put(player, lives);
|
||||
}
|
||||
if (lives == 0) {
|
||||
Bukkit.broadcastMessage(p.language.get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a76"));
|
||||
player.performCommand("dxl leave");
|
||||
} else if (!(lives == -1)) {
|
||||
p.msg(player, p.language.get("Player_Death").replaceAll("v1", String.valueOf(lives)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
@ -378,19 +377,6 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
DPlayer dplayer = DPlayer.get(event.getEntity());
|
||||
if (dplayer != null) {
|
||||
dplayer.respawnInventory = event.getEntity().getInventory().getContents();
|
||||
dplayer.respawnArmor = event.getEntity().getInventory().getArmorContents();
|
||||
// Delete all drops
|
||||
for (ItemStack istack : event.getDrops()) {
|
||||
istack.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Deny Player Cmds
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.dre.dungeonsxl.listener.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.dre.dungeonsxl.DConfig;
|
||||
import com.dre.dungeonsxl.DPlayer;
|
||||
import com.dre.dungeonsxl.P;
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class PlayerDeathListener implements Listener {
|
||||
|
||||
P p = P.p;
|
||||
int lives = -1;
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
DPlayer dPlayer = DPlayer.get(player);
|
||||
|
||||
DConfig dConfig = GameWorld.get(player.getLocation().getWorld()).config;
|
||||
|
||||
if (dConfig.getKeepInventoryOnDeath()) {
|
||||
if (dPlayer != null) {
|
||||
dPlayer.respawnInventory = event.getEntity().getInventory().getContents();
|
||||
dPlayer.respawnArmor = event.getEntity().getInventory().getArmorContents();
|
||||
// Delete all drops
|
||||
for (ItemStack istack : event.getDrops()) {
|
||||
istack.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p.lives.containsKey(player)) {
|
||||
lives = p.lives.get(player) - 1;
|
||||
p.lives.put(player, lives);
|
||||
}
|
||||
|
||||
if (lives == 0 && dPlayer.isReady) {
|
||||
Bukkit.broadcastMessage(p.language.get("Player_DeathKick").replaceAll("v1", player.getName()).replaceAll("&", "\u00a7"));
|
||||
player.performCommand("dxl leave");
|
||||
} else if (!(lives == -1)) {
|
||||
p.msg(player, p.language.get("Player_Death").replaceAll("v1", String.valueOf(lives)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,16 @@
|
||||
package com.dre.dungeonsxl.signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.dre.dungeonsxl.P;
|
||||
import com.dre.dungeonsxl.game.DMob;
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class SIGNMythicMobs extends DSign {
|
||||
@ -23,6 +27,9 @@ public class SIGNMythicMobs extends DSign {
|
||||
private boolean initialized;
|
||||
private boolean active;
|
||||
private int taskId = -1;
|
||||
private Location spawnLoc;
|
||||
private LivingEntity mythicMob;
|
||||
private ArrayList<Entity> mythicMobs = new ArrayList<Entity>();
|
||||
|
||||
public SIGNMythicMobs(Sign sign, GameWorld gworld) {
|
||||
super(sign, gworld);
|
||||
@ -105,15 +112,19 @@ public class SIGNMythicMobs extends DSign {
|
||||
GameWorld gworld = GameWorld.get(world);
|
||||
|
||||
if (gworld != null) {
|
||||
Location spawnLoc = sign.sign.getLocation().add(0.5, 0, 0.5);
|
||||
spawnLoc = sign.sign.getLocation().add(0.5, 0, 0.5);
|
||||
double x = spawnLoc.getX();
|
||||
double y = spawnLoc.getY();
|
||||
double z = spawnLoc.getZ();
|
||||
|
||||
String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gworld.id + ","+ x + "," + y + "," + z;
|
||||
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
|
||||
|
||||
setMythicMobs();
|
||||
if (mythicMob != null) {
|
||||
new DMob(mythicMob, sign.gworld, null, mob);
|
||||
}
|
||||
|
||||
// Set the amount
|
||||
if (amount != -1) {
|
||||
if (amount > 1) {
|
||||
@ -142,4 +153,20 @@ public class SIGNMythicMobs extends DSign {
|
||||
public boolean isOnDungeonInit() {
|
||||
return onDungeonInit;
|
||||
}
|
||||
|
||||
private void setMythicMobs() {
|
||||
for (Entity entity : spawnLoc.getChunk().getEntities()) {
|
||||
if (entity.getLocation().getX() >= spawnLoc.getX()-1
|
||||
&& entity.getLocation().getX() <= spawnLoc.getX()+1
|
||||
&& entity.getLocation().getY() >= spawnLoc.getY()-1
|
||||
&& entity.getLocation().getY() <= spawnLoc.getY()+1
|
||||
&& entity.getLocation().getZ() >= spawnLoc.getZ()-1
|
||||
&& entity.getLocation().getZ() <= spawnLoc.getZ()+1
|
||||
&& !mythicMobs.contains(entity)) {
|
||||
mythicMob = (LivingEntity) entity;
|
||||
mythicMobs.add(entity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,15 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class OfflinePlayerUtil {
|
||||
|
||||
static Server server = Bukkit.getServer();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static UUID getUniqueIdFromName(String name) {
|
||||
OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(name);
|
||||
OfflinePlayer player = server.getOfflinePlayer(name);
|
||||
UUID uuid = player.getUniqueId();
|
||||
return uuid;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: DungeonsXL
|
||||
main: com.dre.dungeonsxl.P
|
||||
version: 0.9.6-SNAPSHOT
|
||||
version: 0.9.6
|
||||
author: Frank Baumann
|
||||
authors: [Frank Baumann, Milan Albrecht, Tobias Schmitz, Daniel Saukel]
|
||||
website: http://www.dre2n.ml
|
||||
|
Loading…
Reference in New Issue
Block a user