mirror of
https://github.com/array-in-a-matrix/brainwine.git
synced 2025-04-02 11:11:58 -04:00
Fixed block usage for blocks without metadata + public use
This commit is contained in:
parent
4a36864036
commit
a10f2d04b2
3 changed files with 28 additions and 2 deletions
|
@ -180,7 +180,11 @@ public class PlayerManager {
|
||||||
public Player getPlayer(String name) {
|
public Player getPlayer(String name) {
|
||||||
return playersByName.get(name.toLowerCase());
|
return playersByName.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player getPlayerById(String id) {
|
||||||
|
return playersById.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
public Player getPlayer(Connection connection) {
|
public Player getPlayer(Connection connection) {
|
||||||
return playersByConnection.get(connection);
|
return playersByConnection.get(connection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ public enum ItemUseType {
|
||||||
FIELDABLE,
|
FIELDABLE,
|
||||||
FLY,
|
FLY,
|
||||||
MULTI,
|
MULTI,
|
||||||
|
PROTECTED,
|
||||||
|
PUBLIC,
|
||||||
SWITCH,
|
SWITCH,
|
||||||
SWITCHED,
|
SWITCHED,
|
||||||
TELEPORT,
|
TELEPORT,
|
||||||
|
|
|
@ -48,6 +48,26 @@ public class BlockUseRequest extends PlayerRequest {
|
||||||
Item item = block.getItem(layer);
|
Item item = block.getItem(layer);
|
||||||
int mod = block.getMod(layer);
|
int mod = block.getMod(layer);
|
||||||
|
|
||||||
|
if(metaBlock != null && item.hasUse(ItemUseType.PROTECTED)) {
|
||||||
|
Player owner = GameServer.getInstance().getPlayerManager().getPlayerById(metaBlock.getOwner());
|
||||||
|
|
||||||
|
if(player != owner) {
|
||||||
|
if(item.hasUse(ItemUseType.PUBLIC)) {
|
||||||
|
String publicUse = item.getUse(ItemUseType.PUBLIC).toString();
|
||||||
|
|
||||||
|
switch(publicUse) {
|
||||||
|
case "owner":
|
||||||
|
player.alert(String.format("This %s is owned by %s.",
|
||||||
|
item.getTitle().toLowerCase(), owner == null ? "nobody.." : owner.getName()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.alert("Sorry, that belongs to somebody else.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(Entry<ItemUseType, Object> entry : item.getUses().entrySet()) {
|
for(Entry<ItemUseType, Object> entry : item.getUses().entrySet()) {
|
||||||
ItemUseType use = entry.getKey();
|
ItemUseType use = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
|
@ -55,7 +75,7 @@ public class BlockUseRequest extends PlayerRequest {
|
||||||
switch(use) {
|
switch(use) {
|
||||||
case DIALOG:
|
case DIALOG:
|
||||||
case CREATE_DIALOG:
|
case CREATE_DIALOG:
|
||||||
if(metaBlock != null && player.getDocumentId().equals(metaBlock.getOwner()) && data != null && value instanceof Map) {
|
if(data != null && value instanceof Map) {
|
||||||
Map<String, Object> config = (Map<String, Object>)value;
|
Map<String, Object> config = (Map<String, Object>)value;
|
||||||
String target = MapHelper.getString(config, "target", "none");
|
String target = MapHelper.getString(config, "target", "none");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue