Skip to content

Commit

Permalink
фиксы
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness committed Jun 3, 2023
1 parent 85c26b8 commit 14d18f5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/main/java/darkdustry/features/history/BlockEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ public class BlockEntry implements HistoryEntry {
public final short blockID;
public final int rotation;
public final boolean breaking;
public final long time;
public final long timestamp;

public BlockEntry(BlockBuildEndEvent event) {
this.uuid = event.unit.getPlayer().uuid();
this.blockID = event.tile.build instanceof ConstructBuild build ? build.current.id : event.tile.blockID();
this.rotation = event.tile.build.rotation;
this.breaking = event.breaking;
this.time = Time.millis();
this.timestamp = Time.millis();
}

public String getMessage(Player player) {
var info = netServer.admins.getInfo(uuid);
var block = content.block(blockID);

return Bundle.format(breaking ? "history.deconstruct" : block.rotate ? "history.construct.rotate" : "history.construct", player, info.lastName, Icons.icon(block), formatTime(time), sides.get(rotation));
return Bundle.format(breaking ? "history.deconstruct" : block.rotate ? "history.construct.rotate" : "history.construct", player, info.lastName, Icons.icon(block), formatTime(timestamp), sides.get(rotation));
}
}
24 changes: 12 additions & 12 deletions src/main/java/darkdustry/features/history/ConfigEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public class ConfigEntry implements HistoryEntry {
public final short blockID;
public final Object value;
public final boolean connect;
public final long time;
public final long timestamp;

public ConfigEntry(ConfigEvent event) {
this.uuid = event.player.uuid();
this.blockID = event.tile.block.id;
this.value = getValue(event);
this.connect = value instanceof Point2 point && getConnect(event, point);
this.time = Time.millis();
this.timestamp = Time.millis();
}

// Ифы сила, Дарк могила
Expand All @@ -38,41 +38,41 @@ public ConfigEntry(ConfigEvent event) {
public String getMessage(Player player) {
var info = netServer.admins.getInfo(uuid);
var block = content.block(blockID);
var date = formatTime(time);
var time = formatTime(timestamp);

if (value instanceof MappableContent content) {
return Bundle.format("history.config", player, info.lastName, Icons.icon(block), Icons.icon(content), date);
return Bundle.format("history.config", player, info.lastName, Icons.icon(block), Icons.icon(content), time);
}

if (value instanceof Boolean on) {
return on ? Bundle.format("history.config.on", player, info.lastName, Icons.icon(block), date) : Bundle.format("history.config.off", player, info.lastName, Icons.icon(block), date);
return on ? Bundle.format("history.config.on", player, info.lastName, Icons.icon(block), time) : Bundle.format("history.config.off", player, info.lastName, Icons.icon(block), time);
}

if (value instanceof String text) {
return !text.isEmpty() ? Bundle.format("history.config.text", player, info.lastName, Icons.icon(block), text, date) : Bundle.format("history.config.default", player, info.lastName, Icons.icon(block), date);
return !text.isEmpty() ? Bundle.format("history.config.text", player, info.lastName, Icons.icon(block), text, time) : Bundle.format("history.config.default", player, info.lastName, Icons.icon(block), time);
}

if (value instanceof Point2 point) {
return connect ? Bundle.format("history.config.connect", player, info.lastName, Icons.icon(block), point.x, point.y, date) : Bundle.format("history.config.disconnect", player, info.lastName, Icons.icon(block), date);
return connect ? Bundle.format("history.config.connect", player, info.lastName, Icons.icon(block), point.x, point.y, time) : Bundle.format("history.config.disconnect", player, info.lastName, Icons.icon(block), time);
}

if (value instanceof Point2[] points) {
return points.length > 0 ? Bundle.format("history.config.connects", player, info.lastName, Icons.icon(block), Arrays.toString(points), date) : Bundle.format("history.config.disconnect", player, info.lastName, Icons.icon(block), date);
return points.length > 0 ? Bundle.format("history.config.connects", player, info.lastName, Icons.icon(block), Arrays.toString(points), time) : Bundle.format("history.config.disconnect", player, info.lastName, Icons.icon(block), time);
}

if (block instanceof LightBlock) {
return Bundle.format("history.config.color", player, info.lastName, Icons.icon(block), Tmp.c1.set((int) value).toString(), date);
return Bundle.format("history.config.color", player, info.lastName, Icons.icon(block), Tmp.c1.set((int) value).toString(), time);
}

if (block instanceof LogicBlock) {
return Bundle.format("history.config.code", player, info.lastName, Icons.icon(block), date);
return Bundle.format("history.config.code", player, info.lastName, Icons.icon(block), time);
}

if (block instanceof CanvasBlock) {
return Bundle.format("history.config.image", player, info.lastName, Icons.icon(block), date);
return Bundle.format("history.config.image", player, info.lastName, Icons.icon(block), time);
}

return Bundle.format("history.config.default", player, info.lastName, Icons.icon(block), date);
return Bundle.format("history.config.default", player, info.lastName, Icons.icon(block), time);
}

public Object getValue(ConfigEvent event) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/darkdustry/features/history/DepositEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ public class DepositEntry implements HistoryEntry {
public final short blockID;
public final short itemID;
public final int amount;
public final long time;
public final long timestamp;

public DepositEntry(DepositEvent event) {
this.uuid = event.player.uuid();
this.blockID = event.tile.block.id;
this.itemID = event.item.id;
this.amount = event.amount;
this.time = Time.millis();
this.timestamp = Time.millis();
}

public String getMessage(Player player) {
var info = netServer.admins.getInfo(uuid);
return Bundle.format("history.deposit", player, info.lastName, amount, Icons.icon(content.item(itemID)), Icons.icon(content.block(blockID)), formatTime(time));
return Bundle.format("history.deposit", player, info.lastName, amount, Icons.icon(content.item(itemID)), Icons.icon(content.block(blockID)), formatTime(timestamp));
}
}
6 changes: 3 additions & 3 deletions src/main/java/darkdustry/features/history/RotateEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public class RotateEntry implements HistoryEntry {
public final String uuid;
public final short blockID;
public final int rotation;
public final long time;
public final long timestamp;

public RotateEntry(BuildRotateEvent event) {
this.uuid = event.unit.getPlayer().uuid();
this.blockID = event.build.block.id;
this.rotation = event.build.rotation;
this.time = Time.millis();
this.timestamp = Time.millis();
}

public String getMessage(Player player) {
var info = netServer.admins.getInfo(uuid);
return Bundle.format("history.rotate", player, info.lastName, Icons.icon(content.block(blockID)), sides.get(rotation), formatTime(time));
return Bundle.format("history.rotate", player, info.lastName, Icons.icon(content.block(blockID)), sides.get(rotation), formatTime(timestamp));
}
}
6 changes: 3 additions & 3 deletions src/main/java/darkdustry/features/history/WithdrawEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ public class WithdrawEntry implements HistoryEntry {
public final short blockID;
public final short itemID;
public final int amount;
public final long time;
public final long timestamp;

public WithdrawEntry(WithdrawEvent event) {
this.uuid = event.player.uuid();
this.blockID = event.tile.block.id;
this.itemID = event.item.id;
this.amount = event.amount;
this.time = Time.millis();
this.timestamp = Time.millis();
}

public String getMessage(Player player) {
var info = netServer.admins.getInfo(uuid);
return Bundle.format("history.withdraw", player, info.lastName, amount, Icons.icon(content.item(itemID)), Icons.icon(content.block(blockID)), formatTime(time));
return Bundle.format("history.withdraw", player, info.lastName, amount, Icons.icon(content.item(itemID)), Icons.icon(content.block(blockID)), formatTime(timestamp));
}
}

0 comments on commit 14d18f5

Please sign in to comment.