mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-20 02:56:44 +00:00
Password moved from vault door to settlement
This commit is contained in:
parent
201d83f8d8
commit
955d61ce99
@ -123,7 +123,7 @@ public class Settlement implements MongoSerializable {
|
|||||||
p = world.getRandomPassableTile();
|
p = world.getRandomPassableTile();
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
|
|
||||||
VaultDoor vaultDoor = new VaultDoor(0); //todo cypherId ?
|
VaultDoor vaultDoor = new VaultDoor();
|
||||||
vaultDoor.setWorld(world);
|
vaultDoor.setWorld(world);
|
||||||
|
|
||||||
int counter = 700;
|
int counter = 700;
|
||||||
@ -216,4 +216,8 @@ public class Settlement implements MongoSerializable {
|
|||||||
public List<NonPlayerCharacter> getNpcs() {
|
public List<NonPlayerCharacter> getNpcs() {
|
||||||
return npcs;
|
return npcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public char[] getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.simon987.npcplugin;
|
package net.simon987.npcplugin;
|
||||||
|
|
||||||
import net.simon987.server.GameServer;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.crypto.RandomStringGenerator;
|
|
||||||
import net.simon987.server.game.objects.*;
|
import net.simon987.server.game.objects.*;
|
||||||
import net.simon987.server.game.world.World;
|
import net.simon987.server.game.world.World;
|
||||||
import net.simon987.server.logging.LogManager;
|
import net.simon987.server.logging.LogManager;
|
||||||
@ -14,13 +13,6 @@ public class VaultDoor extends Structure implements MessageReceiver, Enterable,
|
|||||||
|
|
||||||
private static final int MAP_INFO = 0x0B00;
|
private static final int MAP_INFO = 0x0B00;
|
||||||
|
|
||||||
/**
|
|
||||||
* Password to open the vault door
|
|
||||||
*/
|
|
||||||
private char[] password;
|
|
||||||
|
|
||||||
private RandomStringGenerator randomStringGenerator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the vault door is opened
|
* Whether or not the vault door is opened
|
||||||
*/
|
*/
|
||||||
@ -37,16 +29,9 @@ public class VaultDoor extends Structure implements MessageReceiver, Enterable,
|
|||||||
private int OPEN_TIME = GameServer.INSTANCE.getConfig().getInt("vault_door_open_time");
|
private int OPEN_TIME = GameServer.INSTANCE.getConfig().getInt("vault_door_open_time");
|
||||||
|
|
||||||
private int openedTimer = 0;
|
private int openedTimer = 0;
|
||||||
private int cypherId;
|
|
||||||
|
|
||||||
public VaultDoor(int cypherId) {
|
public VaultDoor() {
|
||||||
super(1, 1);
|
super(1, 1);
|
||||||
|
|
||||||
this.cypherId = cypherId;
|
|
||||||
|
|
||||||
this.randomStringGenerator = new RandomStringGenerator();
|
|
||||||
|
|
||||||
this.password = "12345678".toCharArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VaultDoor(Document document) {
|
public VaultDoor(Document document) {
|
||||||
@ -60,8 +45,6 @@ public class VaultDoor extends Structure implements MessageReceiver, Enterable,
|
|||||||
homeX = document.getInteger("homeX");
|
homeX = document.getInteger("homeX");
|
||||||
homeY = document.getInteger("homeY");
|
homeY = document.getInteger("homeY");
|
||||||
}
|
}
|
||||||
|
|
||||||
password = document.getString("password").toCharArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,8 +52,7 @@ public class VaultDoor extends Structure implements MessageReceiver, Enterable,
|
|||||||
public void update() {
|
public void update() {
|
||||||
if (open){
|
if (open){
|
||||||
if (openedTimer <= 0) {
|
if (openedTimer <= 0) {
|
||||||
//Door was open for OPEN_TIME, close it and regen password
|
//Door was open for OPEN_TIME, close it
|
||||||
//password = GameServer.INSTANCE.getConfig().getRandomPassword();
|
|
||||||
open = false;
|
open = false;
|
||||||
openedTimer = 0;
|
openedTimer = 0;
|
||||||
LogManager.LOGGER.fine("Closed Vault door ID: " + getObjectId());
|
LogManager.LOGGER.fine("Closed Vault door ID: " + getObjectId());
|
||||||
@ -84,10 +66,12 @@ public class VaultDoor extends Structure implements MessageReceiver, Enterable,
|
|||||||
@Override
|
@Override
|
||||||
public boolean sendMessage(char[] message) {
|
public boolean sendMessage(char[] message) {
|
||||||
|
|
||||||
System.out.println("message: " + new String(message));
|
Settlement settlement = NpcPlugin.settlementMap.get(getWorld().getId());
|
||||||
System.out.println("password: " + new String(password));
|
|
||||||
|
|
||||||
if (Arrays.equals(message, password)) {
|
System.out.println("message: " + new String(message));
|
||||||
|
System.out.println("password: " + new String(settlement.getPassword()));
|
||||||
|
|
||||||
|
if (Arrays.equals(message, settlement.getPassword())) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
openVault();
|
openVault();
|
||||||
} else {
|
} else {
|
||||||
@ -144,7 +128,6 @@ public class VaultDoor extends Structure implements MessageReceiver, Enterable,
|
|||||||
|
|
||||||
dbObject.put("homeX", getHomeX());
|
dbObject.put("homeX", getHomeX());
|
||||||
dbObject.put("homeY", getHomeY());
|
dbObject.put("homeY", getHomeY());
|
||||||
dbObject.put("password", new String(password));
|
|
||||||
|
|
||||||
return dbObject;
|
return dbObject;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user