Files
Server/src/engine/objects/GuildHistory.java
T

91 lines
2.7 KiB
Java

// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.objects;
import engine.Enum.GameObjectType;
import engine.Enum.GuildHistoryType;
import engine.net.ByteBufferWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
public class GuildHistory {
private int guildID;
private String guildName;
private Instant time;
private GuildHistoryType historyType;
public GuildHistory(int guildID, String guildName,
Instant dateTime, GuildHistoryType historyType) {
super();
this.guildID = guildID;
this.guildName = guildName;
this.time = dateTime;
this.historyType = historyType;
}
public GuildHistory(ResultSet rs) throws SQLException {
java.util.Date sqlDateTime;
this.guildID = rs.getInt("guildID");
Guild guild = Guild.getGuild(this.guildID);
if (guild != null)
this.guildName = guild.getName();
else
this.guildName = "Guild Not Found";
sqlDateTime = rs.getTimestamp("historyDate");
if (sqlDateTime != null)
this.time = sqlDateTime.toInstant();
else
this.time = Instant.now().minus(1, ChronoUnit.YEARS);
this.historyType = GuildHistoryType.valueOf(rs.getString("historyType"));
}
public GuildHistoryType getHistoryType() {
return historyType;
}
public long getGuildID() {
return guildID;
}
public String getGuildName() {
return guildName;
}
public void _serialize(ByteBufferWriter writer) {
writer.putInt(this.historyType.getType());
writer.putInt(GameObjectType.Guild.ordinal());
writer.putInt(this.guildID);
writer.putString(guildName);
writer.putInt(0); //Pad
writer.putDateTime(this.time);
}
public Instant getTime() {
return time;
}
public void setTime(Instant time) {
this.time = time;
}
}